Re: [PATCH] PCI: Stop waiting for link status after config read failure
From: Ilpo Järvinen
Date: Fri Sep 04 2026 - 16:20:26 EST
On Fri, 4 Sep 2026, Yury M. wrote:
> 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;
Apparently you're ignoring my feedback. :-(
--
i.
> 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.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
>
>