diff options
Diffstat (limited to 'drivers/pci/pcie')
-rw-r--r-- | drivers/pci/pcie/aspm.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 4d8e2c7b2ad1..586b6f75910d 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/jiffies.h> | 19 | #include <linux/jiffies.h> |
20 | #include <linux/delay.h> | ||
20 | #include <linux/pci-aspm.h> | 21 | #include <linux/pci-aspm.h> |
21 | #include "../pci.h" | 22 | #include "../pci.h" |
22 | 23 | ||
@@ -75,6 +76,8 @@ static const char *policy_str[] = { | |||
75 | [POLICY_POWERSAVE] = "powersave" | 76 | [POLICY_POWERSAVE] = "powersave" |
76 | }; | 77 | }; |
77 | 78 | ||
79 | #define LINK_RETRAIN_TIMEOUT HZ | ||
80 | |||
78 | static int policy_to_aspm_state(struct pci_dev *pdev) | 81 | static int policy_to_aspm_state(struct pci_dev *pdev) |
79 | { | 82 | { |
80 | struct pcie_link_state *link_state = pdev->link_state; | 83 | struct pcie_link_state *link_state = pdev->link_state; |
@@ -238,16 +241,18 @@ static void pcie_aspm_configure_common_clock(struct pci_dev *pdev) | |||
238 | pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); | 241 | pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); |
239 | 242 | ||
240 | /* Wait for link training end */ | 243 | /* Wait for link training end */ |
241 | /* break out after waiting for 1 second */ | 244 | /* break out after waiting for timeout */ |
242 | start_jiffies = jiffies; | 245 | start_jiffies = jiffies; |
243 | while ((jiffies - start_jiffies) < HZ) { | 246 | for (;;) { |
244 | pci_read_config_word(pdev, pos + PCI_EXP_LNKSTA, ®16); | 247 | pci_read_config_word(pdev, pos + PCI_EXP_LNKSTA, ®16); |
245 | if (!(reg16 & PCI_EXP_LNKSTA_LT)) | 248 | if (!(reg16 & PCI_EXP_LNKSTA_LT)) |
246 | break; | 249 | break; |
247 | cpu_relax(); | 250 | if (time_after(jiffies, start_jiffies + LINK_RETRAIN_TIMEOUT)) |
251 | break; | ||
252 | msleep(1); | ||
248 | } | 253 | } |
249 | /* training failed -> recover */ | 254 | /* training failed -> recover */ |
250 | if ((jiffies - start_jiffies) >= HZ) { | 255 | if (reg16 & PCI_EXP_LNKSTA_LT) { |
251 | dev_printk (KERN_ERR, &pdev->dev, "ASPM: Could not configure" | 256 | dev_printk (KERN_ERR, &pdev->dev, "ASPM: Could not configure" |
252 | " common clock\n"); | 257 | " common clock\n"); |
253 | i = 0; | 258 | i = 0; |