Re: [PATCH] PCI: Stop waiting for link status after config read failure
From: Lukas Wunner
Date: Fri Sep 04 2026 - 09:00:53 EST
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.c
> @@ -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);
It might be clearer if you check for pci_dev_is_disconnected() directly
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