aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/pci.c6
-rw-r--r--drivers/pci/pcie/aspm.c22
-rw-r--r--include/linux/pci-aspm.h4
3 files changed, 32 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b714d787bddd..2472e7177b4b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -740,6 +740,12 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
740 740
741 if (!__pci_complete_power_transition(dev, state)) 741 if (!__pci_complete_power_transition(dev, state))
742 error = 0; 742 error = 0;
743 /*
744 * When aspm_policy is "powersave" this call ensures
745 * that ASPM is configured.
746 */
747 if (!error && dev->bus->self)
748 pcie_aspm_powersave_config_link(dev->bus->self);
743 749
744 return error; 750 return error;
745} 751}
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index bbdb4fd85b9c..e61b82e611c2 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -708,6 +708,28 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev)
708 up_read(&pci_bus_sem); 708 up_read(&pci_bus_sem);
709} 709}
710 710
711void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
712{
713 struct pcie_link_state *link = pdev->link_state;
714
715 if (aspm_disabled || !pci_is_pcie(pdev) || !link)
716 return;
717
718 if (aspm_policy != POLICY_POWERSAVE)
719 return;
720
721 if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
722 (pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
723 return;
724
725 down_read(&pci_bus_sem);
726 mutex_lock(&aspm_lock);
727 pcie_config_aspm_path(link);
728 pcie_set_clkpm(link, policy_to_clkpm_state(link));
729 mutex_unlock(&aspm_lock);
730 up_read(&pci_bus_sem);
731}
732
711/* 733/*
712 * pci_disable_link_state - disable pci device's link state, so the link will 734 * pci_disable_link_state - disable pci device's link state, so the link will
713 * never enter specific states 735 * never enter specific states
diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h
index ce6810512c66..67cb3ae38016 100644
--- a/include/linux/pci-aspm.h
+++ b/include/linux/pci-aspm.h
@@ -26,6 +26,7 @@
26extern void pcie_aspm_init_link_state(struct pci_dev *pdev); 26extern void pcie_aspm_init_link_state(struct pci_dev *pdev);
27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev); 27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev);
28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev); 28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev);
29extern void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
29extern void pci_disable_link_state(struct pci_dev *pdev, int state); 30extern void pci_disable_link_state(struct pci_dev *pdev, int state);
30extern void pcie_clear_aspm(void); 31extern void pcie_clear_aspm(void);
31extern void pcie_no_aspm(void); 32extern void pcie_no_aspm(void);
@@ -39,6 +40,9 @@ static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev)
39static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) 40static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev)
40{ 41{
41} 42}
43static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
44{
45}
42static inline void pci_disable_link_state(struct pci_dev *pdev, int state) 46static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
43{ 47{
44} 48}