Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp913813lqp; Thu, 21 Mar 2024 22:26:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVoZURgmQzrpHYmRCMY3oHWrz2TKsodz/qhtSRQkvoIWEkHIUsg2F6s2cEN4OYK0Ve7lUsXVSL+N3FkJEv6C0Ktds2UGLUMpL5qHHk5vA== X-Google-Smtp-Source: AGHT+IE+pJB12p1Er0IKRIb0bz1ixCjW4eSbTZrNCoizcec5jcaby0QYsgpYhGd/GkMmCFj1G4nj X-Received: by 2002:a2e:a266:0:b0:2d4:d78:b05a with SMTP id k6-20020a2ea266000000b002d40d78b05amr856506ljm.19.1711085203706; Thu, 21 Mar 2024 22:26:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711085203; cv=pass; d=google.com; s=arc-20160816; b=FZq9boG7l17ssCMcSc3hr5uvk8viabs2BApMXfyw74ZDAYT7xeOQdW//XEwq7ID7Em abSHv0eGv8B2CWY4DaKrsCV8rgAHnsl+5XW6Wr7xFP9By0y2no062u2Ze+ojQxzwsFNQ wOxqRtw5SEpWlSVnFXB1CwjHPOc98u/5C2Rws3q1sx+7yMIeoSQlofkkbh82ua5QFwDO 20urmeuuKUNeDIW8xENXIyqUGzwj98FEkGHSjUYJtetmxu3pY/H7PEZGwMYXiffZR9W7 9U0fuiUYSjacEGrUdqc8rbynwUNGEl1UzgASfVEqjurAN+JnzVm1i2P4zxoHYR7c2OSx kmYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bOCJC5GNDO94zeTpEtIfrONDeLxqcqkeNnlp28cLLms=; fh=E3NcVccCiv0bc53Qqh3qjNuQDBIr+ApAimx3GLnuAkM=; b=TYiKB9E5N3ybgwxdm5KmhqEmCmOQoSNlCRVCKWvYFMRcYFHpR4sL/QgliCutlqzmPB UupW7/i5n3zmK1Ft9wO6C7XrryT8dtQ9TNT2Sfl6hgLQLX/tZe3+YlHHLqF2MmThFH7P Dmj+goSypLv8NbE4pBgWi67/ziFdlbYvTAQReb8OROEEIbUjtTp4+DVekzcW91ELPtDe IQHpTQUoCmHajyEtIPFyJxL3VwaE6auqh9jn36Cl+0PZw59JqDCsDi2CM9/tc7iO+BnV TcZvSXShIIqNCFlAnehyXZQEkULzhn/t1bKudTPLmC/0/dPxvlLJQtPGSRgGpkX7DbOR 6UDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TIEp4OC4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-110937-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ck6-20020a0564021c0600b0056ae8e49adcsi590169edb.319.2024.03.21.22.26.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 22:26:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110937-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TIEp4OC4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-110937-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6EA561F249FA for ; Fri, 22 Mar 2024 05:26:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 487C1B660; Fri, 22 Mar 2024 05:26:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TIEp4OC4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6764D8BE8; Fri, 22 Mar 2024 05:26:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711085195; cv=none; b=YN3FZABNsdMEy2DVYn2Py28wwgkxkeef/CHpYvkPW2ETksDF4/VKMMorXBXmpUkOmvhLPuqCrPIb8syPujNzV50HKpea9uLLozRyxGqDEes6HCUkCzlas6aFPvofg6apruoLfUqOkkD59GQ04xxxm0LnZoNT/fB/lr5uz5OVOf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711085195; c=relaxed/simple; bh=XgCtEPtvhPQa/3nth0Qxvy5Epa05Z8v2RBpaIRqoZG8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IDlOdoLb6GnN8EYrIOqbiurWxv7hwN6rQGJ5gUK+wAECzluOZdOKuEK8oTu+tIdma9NkgwUwox9oysqNW7sVxdFkp8CPQk9oksvAzmusXdI5sOm1+AXv0vXt6JjWLjkUJbFFhKos8XWugJW3P4tJn8Kkq26zbENUXFpQ+QSf3Rc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TIEp4OC4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34359C433C7; Fri, 22 Mar 2024 05:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711085194; bh=XgCtEPtvhPQa/3nth0Qxvy5Epa05Z8v2RBpaIRqoZG8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TIEp4OC4M5z6mpOgUpGNDFoS4Mbvk9BN481N0dArh6BKJmd7vlxuXBx5Q6Q8IyJGs lDPEtOFoffPaqHZxFeEwVpJrt36jbDNwTe/23chI9C0zXZEW7wp6fRhEOrXEqiniAS N8NxYQTfsiQJ20/sX7z4RJX0TfY+iE2T4fCglfRYVG2iwi7nfR5YBzxG7w/2cU6ymK /oXrFjczaZSAhR1+i4X7gABGsBUnRiGJRO4YAZpeLGid5Z2zeE8O1jIYmY30FiEANX 5oVNASbOrFuRZKyEKpmLoYfuWUi7GntlZNYMYCzRD2mgrYW9a3qqe8DoJMtViUbIq9 YSk+Xhs5xtSng== Date: Fri, 22 Mar 2024 10:56:23 +0530 From: Manivannan Sadhasivam To: Bjorn Helgaas Cc: Manivannan Sadhasivam , Frank Li , niklas.cassel@wdc.com, bhelgaas@google.com, gustavo.pimentel@synopsys.com, imx@lists.linux.dev, jdmason@kudzu.us, jingoohan1@gmail.com, kw@linux.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, robh@kernel.org Subject: Re: [PATCH v2 1/1] PCI: dwc: Fix index 0 incorrectly being interpreted as a free ATU slot Message-ID: <20240322052623.GA4092@thinkpad> References: <20240321171345.GA2385@thinkpad> <20240321180732.GA1329092@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240321180732.GA1329092@bhelgaas> On Thu, Mar 21, 2024 at 01:07:32PM -0500, Bjorn Helgaas wrote: > On Thu, Mar 21, 2024 at 10:43:45PM +0530, Manivannan Sadhasivam wrote: > > On Mon, Mar 04, 2024 at 05:46:16PM -0500, Frank Li wrote: > > > dw_pcie_ep_inbound_atu() > > > { > > > ... > > > if (!ep->bar_to_atu[bar]) > > > free_win = find_first_zero_bit(ep->ib_window_map, pci->num_ib_windows); > > > else > > > free_win = ep->bar_to_atu[bar]; > > > ... > > > } > > > > > > The atu index 0 is valid case for atu number. The find_first_zero_bit() > > > will return 6 when second time call into this function if atu is 0. Suppose > > > it should use branch 'free_win = ep->bar_to_atu[bar]'. > > > > > > Change 'bar_to_atu' to free_win + 1. Initialize bar_to_atu as 0 to indicate > > > it have not allocate atu to the bar. > > > > I'd rewrite the commit message as below: > > > > "The mapping between PCI BAR and iATU inbound window are maintained in the > > dw_pcie_ep::bar_to_atu[] array. While allocating a new inbound iATU map for a > > BAR, dw_pcie_ep_inbound_atu() API will first check for the availability of the > > existing mapping in the array and if it is not found (i.e., value in the array > > indexed by the BAR is found to be 0), then it will allocate a new map value > > using find_first_zero_bit(). > > > > The issue here is, the existing logic failed to consider the fact that the map > > value '0' is a valid value for BAR0. Because, find_first_zero_bit() will return > > '0' as the map value for BAR0 (note that it returns the first zero bit > > position). > > > > Due to this, when PERST# assert + deassert happens on the PERST# supported > > platforms, the inbound window allocation restarts from BAR0 and the existing > > logic to find the BAR mapping will return '6' for BAR0 instead of '0' due to the > > fact that it considers '0' as an invalid map value. > > > > So fix this issue by always incrementing the map value before assigning to > > bar_to_atu[] array and then decrementing it while fetching. This will make sure > > that the map value '0' always represents the invalid mapping." > > This translates C code to English in great detail, but still doesn't > tell me what's broken from a user's point of view, how urgent the fix > is, or how it should be handled. > > DMA doesn't work because ATU setup is wrong? Driver MMIO access to > the device doesn't work? OS crashes? How? Incorrectly routed access > causes UR response? Happens on every boot? Only after a reboot or > controller reset? What platforms are affected? "PERST# supported > platforms" is not actionable without a lot of research or pre-existing > knowledge. Should this be backported to -stable? > Severity is less for the bug fixed by this patch. We have 8 inbound iATU windows on almost all of the platforms and after PERST# assert + deassert, BAR0 uses map '6' instead of '0'. This has no user visibility since the mapping will go fine and we have only 6 BARs. So I'd not mark this as as critical fix that needs special attention. Frank: Please ammend the commit message with the bug impact. - Mani -- மணிவண்ணன் சதாசிவம்