lkml.org 
[lkml]   [2008]   [Dec]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] ASPM: Use msleep instead of cpu_relax during link retraining
On Mon 2008-12-22 15:11:57, Andrew Patterson wrote:
> ASPM: Use msleep instead of cpu_relax during link retraining
>
> The cpu_relax() function can be a noop on certain architectures
> like IA-64 when CPU threads are disabled, so use msleep instead
> during link retraining busy/wait loop.

Author clearly wanted to do a busy loop... why do you think 10msec
delay here is acceptable?


> Introduce define LINK_RETRAIN_TIMEOUT instead of hard-coding
> timeout in pcie_aspm_configure_common_clock.
>
> Signed-off-by: Andrew Patterson <andrew.patterson@hp.com>
> @@ -70,6 +71,8 @@ static const char *policy_str[] = {
> [POLICY_POWERSAVE] = "powersave"
> };
>
> +#define LINK_RETRAIN_TIMEOUT HZ
> +
> static int policy_to_aspm_state(struct pci_dev *pdev)
> {
> struct pcie_link_state *link_state = pdev->link_state;
> @@ -217,16 +220,18 @@ 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 ((jiffies - start_jiffies) >= LINK_RETRAIN_TIMEOUT)
> + break;
> + msleep(1);

Is this safe w.r.t. jiffie wraparounds?

> }
> /* training failed -> recover */
> - if ((jiffies - start_jiffies) >= HZ) {
> + if ((jiffies - start_jiffies) >= LINK_RETRAIN_TIMEOUT) {
> dev_printk (KERN_ERR, &pdev->dev, "ASPM: Could not configure"
> " common clock\n");
> i = 0;

AFAICT this can trigger false positives. !reg16 test succeeds and then
jiffies tick.

...it could happen before but you make it way more probable...
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


\
 
 \ /
  Last update: 2008-12-25 20:05    [W:0.062 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site