Re: [PATCH v2] ASPM: Use msleep instead of cpu_relax during link retraining

Joe Perches
2009-01-06T00:53:57Z

On Mon, 2009-01-05 at 16:07 -0700, Andrew Patterson wrote:
> ASPM: Use msleep instead of cpu_relax during link retraining
> Signed-off-by: Andrew Patterson <andrew.patterson@hp.com>
> diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
> index 4d8e2c7..e67eaa2 100644
> --- a/drivers/pci/pcie/aspm.c
> +++ b/drivers/pci/pcie/aspm.c
[]
> @@ -238,16 +241,19 @@ static void pcie_aspm_configure_common_clock(struct pci_dev *pdev)
> pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
>
> /* Wait for link training end */
> - /* break out after waiting for 1 second */
> + /* break out after waiting for timeout */
> start_jiffies = jiffies;
> - while ((jiffies - start_jiffies) < HZ) {
> + for (;;) {
> pci_read_config_word(pdev, pos + PCI_EXP_LNKSTA, &reg16);
> if (!(reg16 & PCI_EXP_LNKSTA_LT))
> break;
> - cpu_relax();
> + if (time_after(start_jiffies,
> + start_jiffies + LINK_RETRAIN_TIMEOUT))
> + break;
> + msleep(1);
> }

if (time_after(jiffies, start_jiffies + LINK_RETRAIN_TIMEOUT))