From: Lukas Wunner <lukas@wunner.de>
To: "Yury M." <yurypm@arista.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org,
James Sewart <jamessewart@arista.com>
Subject: Re: [PATCH] PCI: Stop waiting for link status after config read failure
Date: Sat, 5 Sep 2026 12:06:39 +0200 [thread overview]
Message-ID: <apvpr5Q6gu_3MODj@wunner.de> (raw)
In-Reply-To: <6f916404-63b5-40a3-a429-befe42a08629@arista.com>
On Fri, Sep 04, 2026 at 04:36:12PM +0100, Yury M. wrote:
> 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.
>
> 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;
It's repetitive because pcie_capability_read_word() already checks
internally for pci_dev_is_disconnected():
pcie_capability_read_word()
pci_read_config_word()
pci_dev_is_disconnected()
I just thought that since you specifically want to bail out in the
hot-removal case, it might be clearer to check pci_dev_is_disconnected()
in pcie_wait_for_link_status() before performing the config space read.
But I don't feel strongly either way and checking the return value of
pcie_capability_read_word() is a viable approach as well.
Thanks,
Lukas
prev parent reply other threads:[~2026-09-05 10:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 11:13 [PATCH] PCI: Stop waiting for link status after config read failure Yury Murashka
2026-09-04 11:28 ` sashiko-bot
2026-09-04 11:59 ` Ilpo Järvinen
2026-09-04 12:20 ` Lukas Wunner
2026-09-04 15:36 ` Yury M.
2026-09-04 20:20 ` Ilpo Järvinen
2026-09-05 10:06 ` Lukas Wunner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=apvpr5Q6gu_3MODj@wunner.de \
--to=lukas@wunner.de \
--cc=bhelgaas@google.com \
--cc=jamessewart@arista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=yurypm@arista.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox