From 4d1a8352984bca548aac83506f84b8fdadcfd079 Mon Sep 17 00:00:00 2001 From: leoliu-oc Date: Thu, 30 Oct 2025 19:12:34 +0800 Subject: [PATCH] PCI: Fix PCIe unplug Enumeration Long Blocking Issue zhaoxin inclusion category: feature ------------------- When a USB4 device is inserted, a PCIe tunnel will be established. Then, the PCIe hierarchy within the USB4 device will be enumerated. If the device is suddenly unplugged during the enumeration process, it is possible that the function pci_find_next_ext_capability called when the PCI driver scans the PCIe extended capability may take a very long time, perhaps more than 20 seconds. Signed-off-by: leoliu-oc --- drivers/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 309b458e862a..762c44981ffd 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -591,6 +591,9 @@ u16 pci_find_next_ext_capability(struct pci_dev *dev, u16 start, int cap) return 0; while (ttl-- > 0) { + if (header == 0xffffffff) + return 0; + if (PCI_EXT_CAP_ID(header) == cap && pos != start) return pos; -- Gitee