public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH v1] PCI: replace msleep to save waiting time
@ 2026-02-23  6:19 Hongyu Xie
  2026-02-23 12:05 ` Ilpo Järvinen
  2026-02-25 18:10 ` Bjorn Helgaas
  0 siblings, 2 replies; 3+ messages in thread
From: Hongyu Xie @ 2026-02-23  6:19 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-kernel, Hongyu Xie

In pcie_wait_for_link_status, using msleep(1) to wait for link status
change.
But msleep(1) can sleep for nearly 5ms.

ftrace shows:
 0)               |                pcie_wait_for_link_status() {
 0)   0.500 us    |                  pcie_capability_read_word();
 0)   0.580 us    |                  pcie_capability_read_word();
 0) * 10292.26 us |                }

 after changing to usleep_range.
 ftrace shows:

 0)               |                pcie_wait_for_link_status() {
 0)   0.320 us    |                  pcie_capability_read_word();
 0)   0.480 us    |                  pcie_capability_read_word();
 0) # 2483.980 us |                }

 So fix this by using usleep_range.

Signed-off-by: Hongyu Xie <xiehongyu1@kylinos.cn>
---
 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index f3244630bfd0..68532e248e51 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4519,7 +4519,7 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev,
 		pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta);
 		if ((lnksta & lnksta_mask) == lnksta_match)
 			return 0;
-		msleep(1);
+		usleep_range(1000, 1100);
 	} while (time_before(jiffies, end_jiffies));
 
 	return -ETIMEDOUT;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH v1] PCI: replace msleep to save waiting time
  2026-02-23  6:19 [RESEND PATCH v1] PCI: replace msleep to save waiting time Hongyu Xie
@ 2026-02-23 12:05 ` Ilpo Järvinen
  2026-02-25 18:10 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2026-02-23 12:05 UTC (permalink / raw)
  To: Hongyu Xie; +Cc: bhelgaas, linux-pci, LKML

On Mon, 23 Feb 2026, Hongyu Xie wrote:

> In pcie_wait_for_link_status, using msleep(1) to wait for link status

Add () after any function name in the commit message.

> change.
> But msleep(1) can sleep for nearly 5ms.

Why does the extra delay matter/is a problem? It would be good to include 
such a justification into this change description.

> ftrace shows:
>  0)               |                pcie_wait_for_link_status() {
>  0)   0.500 us    |                  pcie_capability_read_word();
>  0)   0.580 us    |                  pcie_capability_read_word();
>  0) * 10292.26 us |                }
> 
>  after changing to usleep_range.

+ ()

>  ftrace shows:
> 
>  0)               |                pcie_wait_for_link_status() {
>  0)   0.320 us    |                  pcie_capability_read_word();
>  0)   0.480 us    |                  pcie_capability_read_word();
>  0) # 2483.980 us |                }
> 
>  So fix this by using usleep_range.

Ditto.

> Signed-off-by: Hongyu Xie <xiehongyu1@kylinos.cn>
> ---
>  drivers/pci/pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index f3244630bfd0..68532e248e51 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4519,7 +4519,7 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev,
>  		pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta);
>  		if ((lnksta & lnksta_mask) == lnksta_match)
>  			return 0;
> -		msleep(1);
> +		usleep_range(1000, 1100);
>  	} while (time_before(jiffies, end_jiffies));
>  
>  	return -ETIMEDOUT;
> 

-- 
 i.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH v1] PCI: replace msleep to save waiting time
  2026-02-23  6:19 [RESEND PATCH v1] PCI: replace msleep to save waiting time Hongyu Xie
  2026-02-23 12:05 ` Ilpo Järvinen
@ 2026-02-25 18:10 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2026-02-25 18:10 UTC (permalink / raw)
  To: Hongyu Xie; +Cc: bhelgaas, linux-pci, linux-kernel

On Mon, Feb 23, 2026 at 02:19:19PM +0800, Hongyu Xie wrote:
> In pcie_wait_for_link_status, using msleep(1) to wait for link status
> change.
> But msleep(1) can sleep for nearly 5ms.
> 
> ftrace shows:
>  0)               |                pcie_wait_for_link_status() {
>  0)   0.500 us    |                  pcie_capability_read_word();
>  0)   0.580 us    |                  pcie_capability_read_word();
>  0) * 10292.26 us |                }
> 
>  after changing to usleep_range.
>  ftrace shows:
> 
>  0)               |                pcie_wait_for_link_status() {
>  0)   0.320 us    |                  pcie_capability_read_word();
>  0)   0.480 us    |                  pcie_capability_read_word();
>  0) # 2483.980 us |                }
> 
>  So fix this by using usleep_range.
> 
> Signed-off-by: Hongyu Xie <xiehongyu1@kylinos.cn>
> ---
>  drivers/pci/pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index f3244630bfd0..68532e248e51 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4519,7 +4519,7 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev,
>  		pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta);
>  		if ((lnksta & lnksta_mask) == lnksta_match)
>  			return 0;
> -		msleep(1);
> +		usleep_range(1000, 1100);

Perhaps consider fsleep(), since it's a little more generic and I
don't think there's anything magic about the 100 us range value.

>  	} while (time_before(jiffies, end_jiffies));
>  
>  	return -ETIMEDOUT;
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-25 18:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23  6:19 [RESEND PATCH v1] PCI: replace msleep to save waiting time Hongyu Xie
2026-02-23 12:05 ` Ilpo Järvinen
2026-02-25 18:10 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox