From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796510785; b=fHe197kqqj4V9YWDe8uXbmlovI7ouGJWrNNxQ1dGwC7V4+E6wx+0CjSzF6Wi7DRETuwC wnzf9A/Lk9LxgfJr3yqwig9QuTj/9JpFuGw2WVPvmohzvS1ewUIQg0ZbmxUab8tNrbqT1 hZC8iADSrmhMTN53ezItwyAedGEWONi6PMUK9Y9Wi1nl3Qz1l9uE9orfOi+u5+F9NxLGy 7MM4OH3loCzYkkBoc+YT4vTs0CG5P/Bq7mxTfxKjg1LCwqos1gwumV0QgamPIZXIPaE8D VRWTutZdl+d1I37MaZiRQaau3sXUoRG87qEotIOrUjjCvLIAGMIuLB8eBEoGu95N/MQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796510785; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=Ym/qWJYU2IWoicpzjkDSGVKmuf1Smyw+lcieoAtGs90=; b=uyomVIyQW25T+4xTt5Q0ordvpsllFaDU/s7k18I+KKxfD1UgYD1kyjR0viwfVzgHWPxY cGgcjW8Mb5EjVt2KpkH/xphRCYp7wgoqKsyvhs+d2fzIzceCCd+rYlVXJ+k7rRGl196/C sJC5jQYHxzZYWvnvqbn2yf5dBhdYJrLSo745cz4ZBj+owdeh0hE5pxLIZ46XgA2LQd6Xw eSj8JryiPSzaGjntTR5qU6054Fyb6IIsrNmgv7jtLV8Jex9C8ISc3brQortMwp3cpZnkX 656ZrM94WjcpLRolYOwqtAZ23D1NXnMbUX/s1JUbZ4qCc7rqOXVrblbw2OyaQ5n58hA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ejo53vQP; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D92A9606A31F; Sat, 5 Dec 2026 22:46:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ejo53vQP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77B131F0092B; Sat, 5 Dec 2026 22:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796510785; bh=Ym/qWJYU2IWoicpzjkDSGVKmuf1Smyw+lcieoAtGs90=; h=Date:From:To:Cc:Subject:In-Reply-To; b=Ejo53vQP2zMRVtf4bLBs1G6BaKwWxhzrSgrx0MrXc2NuNmncwPnXRac8upGNhVhS8 jMJ6ibMlCvodQ7vLxfke9OhvGHBIYNqQfWEZvJJ+V6O/lHHDq4Cx/ujqgTCiSEuzML k31Ylb39xm/ReARH2cA/p5u25FLlAdz9XAtGdVU7d5RypJ6utu2cVUFfqp0qKSriBY ZcA+Z1d3xj2Q0jKn8xYd40hpSWVYZmhwYO8tjed/39njMBAUC9Vu5qHWs+waypEXAj RZCD6TfKzXfzA8Dtbjs9UjpwAOdj9W5vGK4XfOvZSEuTPhZZWPhQM4KiO6GmAjQXlA vrO9D6H+b6esg== Date: Sat, 5 Dec 2026 16:46:24 -0600 From: Bjorn Helgaas To: Anthony Pighin , Hans Zhang <18255117159@163.com> Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] PCI: Don't read config space of disconnected devices in ext cap search Message-ID: <20261205224624.GA1135745@bhelgaas> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261019165159.1268120-1-anthony.pighin@nokia.com> [cc->to: Hans] On Mon, Oct 19, 2026 at 12:51:59PM -0400, Anthony Pighin wrote: > Commit 4d909bf1a53e ("PCI: Refactor extended capability search into > PCI_FIND_NEXT_EXT_CAP()") moved the extended capability search from the > device config accessor to the bus config accessor. The bus accessor > skips the disconnected device check, so walking the extended capability > list of a device already marked disconnected (surprise removal, AER/DPC > recovery) now issues real config reads to it. A dead device returns all > ones for the first extended capability header. That decodes as a next > pointer to the last dword of config space, so the walk keeps re-reading > that dword until its TTL expires, roughly 480 config reads per call. > > Restore the device accessor so the walk stops without touching hardware > once the device is disconnected. Thanks, Anthony, sorry I missed this before. > Fixes: 4d909bf1a53e ("PCI: Refactor extended capability search into PCI_FIND_NEXT_EXT_CAP()") > Cc: stable@vger.kernel.org > Signed-off-by: Anthony Pighin > --- > drivers/pci/pci.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index d79d2ee4ac69..908d2273466b 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -519,8 +519,7 @@ u16 pci_find_next_ext_capability(struct pci_dev *dev, u16 start, int cap) > if (dev->cfg_size <= PCI_CFG_SPACE_SIZE) > return 0; > > - return PCI_FIND_NEXT_EXT_CAP(pci_bus_read_config, start, cap, > - NULL, dev->bus, dev->devfn); > + return PCI_FIND_NEXT_EXT_CAP(pci_read_config, start, cap, NULL, dev); This seems right. I try to avoid relying on pci_dev_is_disconnected() because it's always racy. We could also consider checking for PCI_POSSIBLE_ERROR() in PCI_FIND_NEXT_EXT_CAP() to cover the race and also avoid more failures if called for devices in DPC containment or in D3cold. I put this on pci/enumeration for v7.5, thanks! > } > EXPORT_SYMBOL_GPL(pci_find_next_ext_capability); > > -- > 2.43.0 >