Re: [PATCH] PCI: Stop waiting for link status after config read failure
From: Yury M.
Date: Fri Sep 04 2026 - 12:05:03 EST
what to you think about this check:
if ((pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta) || PCI_POSSIBLE_ERROR(lnksta)) && pci_dev_is_disconnected(pdev))
return -ENODEV;
On 9/4/26 13:20, Lukas Wunner wrote:
On Fri, Sep 04, 2026 at 11:13:18AM +0000, Yury Murashka wrote:
With a nested PCIe topology with multiple layers of hotplug, a link can go[...]
down near the bottom of the topology shortly before a link above it goes
down. In that case, pcie_wait_for_link_status() can wait for the full
timeout while every read of the link status register fails because the
device has disappeared.
Return immediately when reading the link status fails so event processing
can continue.
+++ b/drivers/pci/pci.cIt might be clearer if you check for pci_dev_is_disconnected() directly
@@ -4580,7 +4581,8 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev,
end_jiffies = jiffies + msecs_to_jiffies(PCIE_LINK_RETRAIN_TIMEOUT_MS);
do {
- pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta);
+ if (pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta))
+ return -ENODEV;
if ((lnksta & lnksta_mask) == lnksta_match)
return 0;
msleep(1);
instead of relying on a PCIBIOS_DEVICE_NOT_FOUND return value which is
generated as a side effect of the device being gone.
Thanks,
Lukas