Commit 44f6cc31 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6:
  PCIe: ASPM: Break out of endless loop waiting for PCI config bits to switch
  PCI: stop leaking 'slot_name' in pci_create_slot
parents 061afe9f 2a42d9db
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/pci-aspm.h> #include <linux/pci-aspm.h>
#include "../pci.h" #include "../pci.h"
...@@ -161,11 +162,12 @@ static void pcie_check_clock_pm(struct pci_dev *pdev) ...@@ -161,11 +162,12 @@ static void pcie_check_clock_pm(struct pci_dev *pdev)
*/ */
static void pcie_aspm_configure_common_clock(struct pci_dev *pdev) static void pcie_aspm_configure_common_clock(struct pci_dev *pdev)
{ {
int pos, child_pos; int pos, child_pos, i = 0;
u16 reg16 = 0; u16 reg16 = 0;
struct pci_dev *child_dev; struct pci_dev *child_dev;
int same_clock = 1; int same_clock = 1;
unsigned long start_jiffies;
u16 child_regs[8], parent_reg;
/* /*
* all functions of a slot should have the same Slot Clock * all functions of a slot should have the same Slot Clock
* Configuration, so just check one function * Configuration, so just check one function
...@@ -191,16 +193,19 @@ static void pcie_aspm_configure_common_clock(struct pci_dev *pdev) ...@@ -191,16 +193,19 @@ static void pcie_aspm_configure_common_clock(struct pci_dev *pdev)
child_pos = pci_find_capability(child_dev, PCI_CAP_ID_EXP); child_pos = pci_find_capability(child_dev, PCI_CAP_ID_EXP);
pci_read_config_word(child_dev, child_pos + PCI_EXP_LNKCTL, pci_read_config_word(child_dev, child_pos + PCI_EXP_LNKCTL,
&reg16); &reg16);
child_regs[i] = reg16;
if (same_clock) if (same_clock)
reg16 |= PCI_EXP_LNKCTL_CCC; reg16 |= PCI_EXP_LNKCTL_CCC;
else else
reg16 &= ~PCI_EXP_LNKCTL_CCC; reg16 &= ~PCI_EXP_LNKCTL_CCC;
pci_write_config_word(child_dev, child_pos + PCI_EXP_LNKCTL, pci_write_config_word(child_dev, child_pos + PCI_EXP_LNKCTL,
reg16); reg16);
i++;
} }
/* Configure upstream component */ /* Configure upstream component */
pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16); pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
parent_reg = reg16;
if (same_clock) if (same_clock)
reg16 |= PCI_EXP_LNKCTL_CCC; reg16 |= PCI_EXP_LNKCTL_CCC;
else else
...@@ -212,12 +217,30 @@ static void pcie_aspm_configure_common_clock(struct pci_dev *pdev) ...@@ -212,12 +217,30 @@ static void pcie_aspm_configure_common_clock(struct pci_dev *pdev)
pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
/* Wait for link training end */ /* Wait for link training end */
while (1) { /* break out after waiting for 1 second */
start_jiffies = jiffies;
while ((jiffies - start_jiffies) < HZ) {
pci_read_config_word(pdev, pos + PCI_EXP_LNKSTA, &reg16); pci_read_config_word(pdev, pos + PCI_EXP_LNKSTA, &reg16);
if (!(reg16 & PCI_EXP_LNKSTA_LT)) if (!(reg16 & PCI_EXP_LNKSTA_LT))
break; break;
cpu_relax(); cpu_relax();
} }
/* training failed -> recover */
if ((jiffies - start_jiffies) >= HZ) {
dev_printk (KERN_ERR, &pdev->dev, "ASPM: Could not configure"
" common clock\n");
i = 0;
list_for_each_entry(child_dev, &pdev->subordinate->devices,
bus_list) {
child_pos = pci_find_capability(child_dev,
PCI_CAP_ID_EXP);
pci_write_config_word(child_dev,
child_pos + PCI_EXP_LNKCTL,
child_regs[i]);
i++;
}
pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, parent_reg);
}
} }
/* /*
......
...@@ -253,6 +253,7 @@ placeholder: ...@@ -253,6 +253,7 @@ placeholder:
__func__, pci_domain_nr(parent), parent->number, slot_nr); __func__, pci_domain_nr(parent), parent->number, slot_nr);
out: out:
kfree(slot_name);
up_write(&pci_bus_sem); up_write(&pci_bus_sem);
return slot; return slot;
err: err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment