mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anthony Pighin <anthony.pighin@nokia.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Hans Zhang <18255117159@163.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] PCI: Don't read config space of disconnected devices in ext cap search
Date: Mon, 19 Oct 2026 12:51:59 -0400	[thread overview]
Message-ID: <20261019165159.1268120-1-anthony.pighin@nokia.com> (raw)

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.

Fixes: 4d909bf1a53e ("PCI: Refactor extended capability search into PCI_FIND_NEXT_EXT_CAP()")
Cc: stable@vger.kernel.org
Signed-off-by: Anthony Pighin <anthony.pighin@nokia.com>
---
 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);
 }
 EXPORT_SYMBOL_GPL(pci_find_next_ext_capability);
 
-- 
2.43.0


             reply	other threads:[~2026-10-19 16:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 16:51 Anthony Pighin [this message]
2026-12-05 22:46 ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019165159.1268120-1-anthony.pighin@nokia.com \
    --to=anthony.pighin@nokia.com \
    --cc=18255117159@163.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®