* [PATCH] PCI: fix link retrain status in pcie_wait_for_link_delay()
@ 2024-03-13 9:49 Simon Guinot
2024-03-13 12:00 ` Ilpo Järvinen
0 siblings, 1 reply; 3+ messages in thread
From: Simon Guinot @ 2024-03-13 9:49 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Maciej W . Rozycki, linux-pci, linux-kernel, Simon Guinot, stable
The current code in pcie_wait_for_link_delay() handles the value
returned by pcie_failed_link_retrain() as an integer, expecting 0
when the link has been successfully retrained. The issue is that
pcie_failed_link_retrain() returns a boolean: "true" if the link
has been successfully retrained and "false" otherwise. This leads
pcie_wait_for_link_delay() to return an incorrect "active link"
status when pcie_failed_link_retrain() is called.
This patch fixes the check of the value returned by
pcie_failed_link_retrain() in pcie_wait_for_link_delay().
Note that this bug induces abnormal timeout delays when a PCI device
is unplugged (around 60 seconds per bridge / secondary bus removed).
Cc: stable@vger.kernel.org
Fixes: 1abb47390350 ("Merge branch 'pci/enumeration'")
Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
---
drivers/pci/pci.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ccee56615f78..7ec91b4c5d03 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5101,9 +5101,7 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,
msleep(20);
rc = pcie_wait_for_link_status(pdev, false, active);
if (active) {
- if (rc)
- rc = pcie_failed_link_retrain(pdev);
- if (rc)
+ if (rc && !pcie_failed_link_retrain(pdev))
return false;
msleep(delay);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] PCI: fix link retrain status in pcie_wait_for_link_delay()
2024-03-13 9:49 [PATCH] PCI: fix link retrain status in pcie_wait_for_link_delay() Simon Guinot
@ 2024-03-13 12:00 ` Ilpo Järvinen
2024-03-13 13:55 ` simon.guinot
0 siblings, 1 reply; 3+ messages in thread
From: Ilpo Järvinen @ 2024-03-13 12:00 UTC (permalink / raw)
To: Simon Guinot, Bjorn Helgaas; +Cc: Maciej W . Rozycki, linux-pci, LKML, stable
On Wed, 13 Mar 2024, Simon Guinot wrote:
> The current code in pcie_wait_for_link_delay() handles the value
> returned by pcie_failed_link_retrain() as an integer, expecting 0
> when the link has been successfully retrained. The issue is that
> pcie_failed_link_retrain() returns a boolean: "true" if the link
> has been successfully retrained and "false" otherwise. This leads
> pcie_wait_for_link_delay() to return an incorrect "active link"
> status when pcie_failed_link_retrain() is called.
>
> This patch fixes the check of the value returned by
> pcie_failed_link_retrain() in pcie_wait_for_link_delay().
>
> Note that this bug induces abnormal timeout delays when a PCI device
> is unplugged (around 60 seconds per bridge / secondary bus removed).
>
> Cc: stable@vger.kernel.org
> Fixes: 1abb47390350 ("Merge branch 'pci/enumeration'")
> Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
Hi Simon,
Thanks for your patch. There's, however, already a better series to fix
this and other related issues. Bjorn just hasn't gotten into applying them
yet:
https://patchwork.kernel.org/project/linux-pci/list/?series=824858
(I proposed a patch very similar to yours month ago, but Maciej came up
a better way to fix all the issues.)
--
i.
> ---
> drivers/pci/pci.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index ccee56615f78..7ec91b4c5d03 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -5101,9 +5101,7 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,
> msleep(20);
> rc = pcie_wait_for_link_status(pdev, false, active);
> if (active) {
> - if (rc)
> - rc = pcie_failed_link_retrain(pdev);
> - if (rc)
> + if (rc && !pcie_failed_link_retrain(pdev))
> return false;
>
> msleep(delay);
>
--
i.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] PCI: fix link retrain status in pcie_wait_for_link_delay()
2024-03-13 12:00 ` Ilpo Järvinen
@ 2024-03-13 13:55 ` simon.guinot
0 siblings, 0 replies; 3+ messages in thread
From: simon.guinot @ 2024-03-13 13:55 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Simon Guinot, Bjorn Helgaas, Maciej W . Rozycki, linux-pci, LKML,
stable
[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]
On Wed, Mar 13, 2024 at 02:00:21PM +0200, Ilpo Järvinen wrote:
> On Wed, 13 Mar 2024, Simon Guinot wrote:
>
> > The current code in pcie_wait_for_link_delay() handles the value
> > returned by pcie_failed_link_retrain() as an integer, expecting 0
> > when the link has been successfully retrained. The issue is that
> > pcie_failed_link_retrain() returns a boolean: "true" if the link
> > has been successfully retrained and "false" otherwise. This leads
> > pcie_wait_for_link_delay() to return an incorrect "active link"
> > status when pcie_failed_link_retrain() is called.
> >
> > This patch fixes the check of the value returned by
> > pcie_failed_link_retrain() in pcie_wait_for_link_delay().
> >
> > Note that this bug induces abnormal timeout delays when a PCI device
> > is unplugged (around 60 seconds per bridge / secondary bus removed).
> >
> > Cc: stable@vger.kernel.org
> > Fixes: 1abb47390350 ("Merge branch 'pci/enumeration'")
> > Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
>
> Hi Simon,
>
> Thanks for your patch. There's, however, already a better series to fix
> this and other related issues. Bjorn just hasn't gotten into applying them
> yet:
>
> https://patchwork.kernel.org/project/linux-pci/list/?series=824858
>
> (I proposed a patch very similar to yours month ago, but Maciej came up
> a better way to fix all the issues.)
Hi Ilpo,
Thanks for pointing this patch series. This indeed fixes the timeout delay
issue I observed.
Simon
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-13 13:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-13 9:49 [PATCH] PCI: fix link retrain status in pcie_wait_for_link_delay() Simon Guinot
2024-03-13 12:00 ` Ilpo Järvinen
2024-03-13 13:55 ` simon.guinot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox