From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Yury Murashka <yurypm@arista.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
James Sewart <jamessewart@arista.com>
Subject: Re: [PATCH] PCI: Stop waiting for link status after config read failure
Date: Fri, 4 Sep 2026 14:59:21 +0300 (EEST) [thread overview]
Message-ID: <6e10813b-3c79-7f61-2bf8-85a6d09674ed@linux.intel.com> (raw)
In-Reply-To: <20260904111318.1063858-1-yurypm@arista.com>
On Fri, 4 Sep 2026, 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.
>
> Signed-off-by: Yury Murashka <yurypm@arista.com>
> Co-authored-by: James Sewart <jamessewart@arista.com>
> ---
> drivers/pci/pci.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index b2879a6be..a568d5ac1 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4565,8 +4565,9 @@ static int pci_pm_reset(struct pci_dev *dev, bool probe)
> * @use_lt: Use the LT bit if TRUE, or the DLLLA bit if FALSE.
> * @active: Waiting for active or inactive?
> *
> - * Return 0 if successful, or -ETIMEDOUT if status has not changed within
> - * PCIE_LINK_RETRAIN_TIMEOUT_MS milliseconds.
> + * Return 0 if successful, -ENODEV if the link status cannot be read, or
> + * -ETIMEDOUT if status has not changed within PCIE_LINK_RETRAIN_TIMEOUT_MS
> + * milliseconds.
> */
> static int pcie_wait_for_link_status(struct pci_dev *pdev,
> bool use_lt, bool active)
> @@ -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;
Wouldn't it be better to base such checks on PCI_POSSIBLE_ERROR()?
If you keep the check for the case where pcie_capability_read_word()
returns error, its return value should be converted with
pcibios_err_to_errno(), not just return -ENODEV.
> if ((lnksta & lnksta_mask) == lnksta_match)
> return 0;
> msleep(1);
> @@ -4603,8 +4605,9 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev,
> * according to @use_lt. It is not verified whether the use of the DLLLA
> * bit is valid.
> *
> - * Return 0 if successful, or -ETIMEDOUT if training has not completed
> - * within PCIE_LINK_RETRAIN_TIMEOUT_MS milliseconds.
> + * Return 0 if successful, -ENODEV if the link status cannot be read, or
Kerneldoc wants this formatting:
Return:
> + * -ETIMEDOUT if training has not completed within
> + * PCIE_LINK_RETRAIN_TIMEOUT_MS milliseconds.
> */
> int pcie_retrain_link(struct pci_dev *pdev, bool use_lt)
> {
>
> base-commit: a500db7819c50db59e55f1b4fa1c3baa5a2616f3
>
--
i.
next prev parent reply other threads:[~2026-09-04 11:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 11:13 Yury Murashka
2026-09-04 11:59 ` Ilpo Järvinen [this message]
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
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=6e10813b-3c79-7f61-2bf8-85a6d09674ed@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--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
all inboxes | Powered by JetHome®