[RFC] pci: Don't enable aspm before drivers have had a chance to veto it

From: Matthew Garrett
Date: Wed Jun 09 2010 - 10:10:42 EST


The aspm code will currently set the configured aspm policy before drivers
have had an opportunity to indicate that their hardware doesn't support it.
Unfortunately, putting some hardware in L0 or L1 can result in the hardware
no longer responding to any requests, even after aspm is disabled. It makes
more sense to leave aspm policy at the BIOS defaults at initial setup time,
reconfiguring it after pci_enable_device() is called. This allows the
driver to blacklist individual devices beforehand.

Signed-off-by: Matthew Garrett <mjg@xxxxxxxxxx>
---
drivers/pci/pcie/aspm.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index be53d98..223b39e 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -562,6 +562,7 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
{
struct pcie_link_state *link;
int blacklist = !!pcie_aspm_sanity_check(pdev);
+ int orig_policy = aspm_policy;

if (aspm_disabled || !pci_is_pcie(pdev) || pdev->link_state)
return;
@@ -588,11 +589,23 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
* update through pcie_aspm_cap_init().
*/
pcie_aspm_cap_init(link, blacklist);
+
+ /*
+ * At this stage drivers haven't had an opportunity to change the
+ * link policy setting. Enabling ASPM on broken hardware can cripple
+ * it even before the driver has had a chance to disable ASPM, so
+ * default to a safe level right now. The real policy will be enabled
+ * once pci_enable_device is called.
+ */
+ if (aspm_policy == POLICY_POWERSAVE)
+ aspm_policy = POLICY_DEFAULT;
pcie_config_aspm_path(link);

/* Setup initial Clock PM state */
pcie_clkpm_cap_init(link, blacklist);
pcie_set_clkpm(link, policy_to_clkpm_state(link));
+ aspm_policy = orig_policy;
+
unlock:
mutex_unlock(&aspm_lock);
out:
--
1.7.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/