* [PATCH] PCI: Don't read config space of disconnected devices in ext cap search
@ 2026-10-19 16:51 Anthony Pighin
2026-12-05 22:46 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: Anthony Pighin @ 2026-10-19 16:51 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: Hans Zhang, linux-pci, linux-kernel, stable
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: Don't read config space of disconnected devices in ext cap search
2026-10-19 16:51 [PATCH] PCI: Don't read config space of disconnected devices in ext cap search Anthony Pighin
@ 2026-12-05 22:46 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2026-12-05 22:46 UTC (permalink / raw)
To: Anthony Pighin, Hans Zhang; +Cc: Bjorn Helgaas, linux-pci, linux-kernel, stable
[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 <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);
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-05 22:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-19 16:51 [PATCH] PCI: Don't read config space of disconnected devices in ext cap search Anthony Pighin
2026-12-05 22:46 ` Bjorn Helgaas
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®