PCI/ASPM: add sysfs attributes for controlling ASPM
v4 cover PCI/ASPM: add sysfs attributes for controlling ASPM
Background of this extension is a problem with the r8169 network driver. Several combinations of board chipsets and network chip versions have problems if ASPM is enabled, therefore we have to disable ASPM per default. However especially on notebooks ASPM can provide significant power-saving, therefore we want to give users the option to enable ASPM. With the new sysfs attributes users can control which ASPM link-states are disabled.
v2:
- use a dedicated sysfs attribute per link state
- allow separate control of ASPM and PCI PM L1 sub-states
v3:
- patch 3: statically allocate the attribute group
- patch 3: replace snprintf with printf
- add patch 4
v4:
- patch 3: add call to sysfs_update_group because is_visible callback returns false always at file creation time
- patch 3: simplify code a little
Heiner Kallweit (4):
PCI/ASPM: add L1 sub-state support to pci_disable_link_state PCI/ASPM: allow to re-enable Clock PM
PCI/ASPM: add sysfs attributes for controlling ASPM link states PCI/ASPM: remove Kconfig option PCIEASPM_DEBUG and related code
Documentation/ABI/testing/sysfs-bus-pci | 13 ++ drivers/pci/pci-sysfs.c | 10 +- drivers/pci/pci.h | 12 +- drivers/pci/pcie/Kconfig | 7 - drivers/pci/pcie/aspm.c | 236 ++++++++++++++++-------- include/linux/pci-aspm.h | 10 +- 6 files changed, 195 insertions(+), 93 deletions(-)
Signature · 1 line
2.23.0
PATCH v4 1/4 PCI/ASPM: add L1 sub-state support to pci_disable_link_state
Add support for disabling states L1.1 and L1.2 topci_disable_link_state. Allow separate control of
ASPM and PCI PM L1 sub-states.
---
v2:
- allow separate control of ASPM and PCI PM L1 sub-states
--- drivers/pci/pcie/aspm.c | 11 ++++++++++- include/linux/pci-aspm.h | 10 +++++++--- 2 files changed, 17 insertions(+), 4 deletions(-)
drivers/pci/pcie/aspm.c +10 -1
@@ -1095,7 +1095,16 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)if (state &PCIE_LINK_STATE_L0S ) link->aspm_disable |=ASPM_STATE_L0S ;if (state &PCIE_LINK_STATE_L1 ) - link->aspm_disable |=ASPM_STATE_L1 ; +/* sub-states require L1 */ + link->aspm_disable |=ASPM_STATE_L1 |ASPM_STATE_L1SS ; +if (state &PCIE_LINK_STATE_L1_1 ) + link->aspm_disable |=ASPM_STATE_L1_1 ; +if (state &PCIE_LINK_STATE_L1_2 ) + link->aspm_disable |=ASPM_STATE_L1_2 ; +if (state &PCIE_LINK_STATE_L1_1_PCIPM ) + link->aspm_disable |=ASPM_STATE_L1_1_PCIPM ; +if (state &PCIE_LINK_STATE_L1_2_PCIPM ) + link->aspm_disable |=ASPM_STATE_L1_2_PCIPM ;pcie_config_aspm_link (link,policy_to_aspm_state (link));if (state &PCIE_LINK_STATE_CLKPM ) {
include/linux/pci-aspm.h +7 -3
@@ -19,9 +19,13 @@#include <linux/pci.h> -#define PCIE_LINK_STATE_L0S 1 -#define PCIE_LINK_STATE_L1 2 -#define PCIE_LINK_STATE_CLKPM 4 +#define PCIE_LINK_STATE_L0S BIT(0) +#define PCIE_LINK_STATE_L1 BIT(1) +#define PCIE_LINK_STATE_CLKPM BIT(2) +#define PCIE_LINK_STATE_L1_1 BIT(3) +#define PCIE_LINK_STATE_L1_2 BIT(4) +#define PCIE_LINK_STATE_L1_1_PCIPM BIT(5) +#define PCIE_LINK_STATE_L1_2_PCIPM BIT(6)#ifdef CONFIG_PCIEASPM int pci_disable_link_state (struct pci_dev *pdev,int state);
Signature · 1 line
2.23.0
PATCH v4 2/4 PCI/ASPM: allow to re-enable Clock PM
In reply to Heiner KallweitSo far Clock PM can't be re-enabled once it has been disabled with a call to pci_disable_link_state(). Reason is that clkpm_capable is reset. Change this by adding a clkpm_disable field similar to aspm_disable.
--- drivers/pci/pcie/aspm.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/pci/pcie/aspm.c +11 -7
@@ -65,6 +65,7 @@ struct pcie_link_state { u32 clkpm_capable:1; /* Clock PM capable? */ u32 clkpm_enabled:1; /* Current Clock PM state */ u32 clkpm_default:1; /* Default Clock PM state by BIOS */ + u32 clkpm_disable:1; /* Clock PM disabled *//* Exit latencies */ struct aspm_latency latency_up;/* Upstream direction exit latency */
@@ -162,8 +163,11 @@ static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable)static void pcie_set_clkpm (struct pcie_link_state *link,int enable) { -/* Don't enable Clock PM if the link is not Clock PM capable */ -if (!link->clkpm_capable) +/* +* Don't enable Clock PM if the link is not Clock PM capable +* or Clock PM is disabled +*/ +if (!link->clkpm_capable || link->clkpm_disable) enable =0 ;/* Need nothing if the specified equals to current state */ if (link->clkpm_enabled == enable)
@@ -193,7 +197,8 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) } link->clkpm_enabled = enabled; link->clkpm_default = enabled; - link->clkpm_capable = (blacklist) ?0 : capable; + link->clkpm_capable = capable; + link->clkpm_disable = blacklist ?1 :0 ; }static bool pcie_retrain_link (struct pcie_link_state *link)
@@ -1107,10 +1112,9 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) link->aspm_disable |=ASPM_STATE_L1_2_PCIPM ;pcie_config_aspm_link (link,policy_to_aspm_state (link)); -if (state &PCIE_LINK_STATE_CLKPM ) { - link->clkpm_capable =0 ; -pcie_set_clkpm (link,0 ); - } +if (state &PCIE_LINK_STATE_CLKPM ) + link->clkpm_disable =1 ; +pcie_set_clkpm (link,policy_to_clkpm_state (link));mutex_unlock (&aspm_lock);if (sem)up_read (&pci_bus_sem);
Signature · 1 line
2.23.0
PATCH v4 3/4 PCI/ASPM: add sysfs attributes for controlling ASPM link states
In reply to Heiner KallweitBackground of this extension is a problem with the r8169 network driver. Several combinations of board chipsets and network chip versions have problems if ASPM is enabled, therefore we have to disable ASPM per default. However especially on notebooks ASPM can provide significant power-saving, therefore we want to give users the option to enable ASPM. With the new sysfs attributes users can control which ASPM link-states are enabled/disabled.
---
v2:
- use a dedicated sysfs attribute per link state
- allow separate control of ASPM and PCI PM L1 sub-states
v3:
- statically allocate the attribute group
- replace snprintf with printf
- base on top of "PCI: Make pcie_downstream_port() available outside of access.c" v4:
- add call to sysfs_update_group because is_visible callback returns false always at file creation time
- simplify code a little
--- Documentation/ABI/testing/sysfs-bus-pci | 13 ++ drivers/pci/pci-sysfs.c | 7 + drivers/pci/pci.h | 4 + drivers/pci/pcie/aspm.c | 184 ++++++++++++++++++++++++ 4 files changed, 208 insertions(+)
Documentation/ABI/testing/sysfs-bus-pci +13 -0
@@ -347,3 +347,16 @@ Description: If the device has any Peer-to-Peer memory registered, this file contains a '1' if the memory has been published for use outside the driver that owns the device. + +What /sys/bus/pci/devices/.../aspm/aspm_l0s +What /sys/bus/pci/devices/.../aspm/aspm_l1 +What /sys/bus/pci/devices/.../aspm/aspm_l1_1 +What /sys/bus/pci/devices/.../aspm/aspm_l1_2 +What /sys/bus/pci/devices/.../aspm/aspm_l1_1_pcipm +What /sys/bus/pci/devices/.../aspm/aspm_l1_2_pcipm +What /sys/bus/pci/devices/.../aspm/aspm_clkpm +date: August 2019 +Contact: Heiner Kallweit <[email protected]> +Description: If ASPM is supported for an endpoint, then these files + can be used to disable or enable the individual + power management states.
drivers/pci/pci-sysfs.c +7 -0
@@ -1331,6 +1331,10 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev)pcie_vpd_create_sysfs_dev_files (dev);pcie_aspm_create_sysfs_dev_files (dev); +#ifdef CONFIG_PCIEASPM +/* update visibility of attributes in this group */ +sysfs_update_group (&dev->dev.kobj, &aspm_ctrl_attr_group); +#endif if (dev->reset_fn) { retval =device_create_file (&dev->dev, &dev_attr_reset);
@@ -1587,6 +1591,9 @@ static const struct attribute_group *pci_dev_attr_groups[] = { &pcie_dev_attr_group,#ifdef CONFIG_PCIEAER &aer_stats_attr_group, +#endif +#ifdef CONFIG_PCIEASPM + &aspm_ctrl_attr_group, #endif NULL, };
drivers/pci/pci.h +4 -0
@@ -649,4 +649,8 @@ static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { }static inline void pci_aer_clear_device_status (struct pci_dev *dev) { }#endif +#ifdef CONFIG_PCIEASPM +extern const struct attribute_group aspm_ctrl_attr_group; +#endif +#endif /* DRIVERS_PCI_H */
drivers/pci/pcie/aspm.c +184 -0
190 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH v4 4/4 PCI/ASPM: remove Kconfig option PCIEASPM_DEBUG and related code
In reply to Heiner KallweitNow that we have sysfs attributes for enabling/disabling the individual ASPM link states, this debug code isn't needed any longer.
--- drivers/pci/pci-sysfs.c | 3 -- drivers/pci/pci.h | 8 --- drivers/pci/pcie/Kconfig | 7 --- drivers/pci/pcie/aspm.c | 105 --------------------------------------- 4 files changed, 123 deletions(-)
drivers/pci/pci-sysfs.c +0 -3
@@ -1330,7 +1330,6 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev)int retval;pcie_vpd_create_sysfs_dev_files (dev); -pcie_aspm_create_sysfs_dev_files (dev);#ifdef CONFIG_PCIEASPM /* update visibility of attributes in this group */ sysfs_update_group (&dev->dev.kobj, &aspm_ctrl_attr_group);
@@ -1344,7 +1343,6 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev)return 0 ; error: -pcie_aspm_remove_sysfs_dev_files (dev);pcie_vpd_remove_sysfs_dev_files (dev);return retval; }
@@ -1420,7 +1418,6 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)static void pci_remove_capabilities_sysfs (struct pci_dev *dev) {pcie_vpd_remove_sysfs_dev_files (dev); -pcie_aspm_remove_sysfs_dev_files (dev);if (dev->reset_fn) {device_remove_file (&dev->dev, &dev_attr_reset); dev->reset_fn =0 ;
drivers/pci/pci.h +0 -8
@@ -532,14 +532,6 @@ static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) { }static inline void pcie_aspm_powersave_config_link (struct pci_dev *pdev) { }#endif -#ifdef CONFIG_PCIEASPM_DEBUG -void pcie_aspm_create_sysfs_dev_files (struct pci_dev *pdev); -void pcie_aspm_remove_sysfs_dev_files (struct pci_dev *pdev); -#else -static inline void pcie_aspm_create_sysfs_dev_files (struct pci_dev *pdev) { } -static inline void pcie_aspm_remove_sysfs_dev_files (struct pci_dev *pdev) { } -#endif -#ifdef CONFIG_PCIE_ECRC void pcie_set_ecrc_checking (struct pci_dev *dev);void pcie_ecrc_get_policy (char *str);
drivers/pci/pcie/Kconfig +0 -7
@@ -79,13 +79,6 @@ config PCIEASPM When in doubt, say Y. -config PCIEASPM_DEBUG - bool "Debug PCI Express ASPM" - depends on PCIEASPM - help - This enables PCI Express ASPM debug support. It will add per-device - interface to control ASPM. - choice prompt "Default ASPM policy" default PCIEASPM_DEFAULT
drivers/pci/pcie/aspm.c +0 -105
111 lines not on this page · raw message
Signature · 1 line
2.23.0
Quoted 28 lines · Heiner Kallweit
Background of this extension is a problem with the r8169 network driver. Several combinations of board chipsets and network chip versions have problems if ASPM is enabled, therefore we have to disable ASPM per default. However especially on notebooks ASPM can provide significant power-saving, therefore we want to give users the option to enable ASPM. With the new sysfs attributes users can control which ASPM link-states are disabled.
v2:
- use a dedicated sysfs attribute per link state
- allow separate control of ASPM and PCI PM L1 sub-statesv3:
- patch 3: statically allocate the attribute group
- patch 3: replace snprintf with printf
- add patch 4v4:
- patch 3: add call tosysfs_update_groupbecauseis_visiblecallback returns false always at file creation time
- patch 3: simplify code a littleHeiner Kallweit (4):
PCI/ASPM: add L1 sub-state support topci_disable_link_statePCI/ASPM: allow to re-enable Clock PM
PCI/ASPM: add sysfs attributes for controlling ASPM link states PCI/ASPM: removeKconfigoptionPCIEASPM_DEBUGand related code
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-pci | 13 ++ drivers/pci/pci-sysfs.c | 10 +- drivers/pci/pci.h | 12 +- drivers/pci/pcie/Kconfig | 7 - drivers/pci/pcie/aspm.c | 236 ++++++++++++++++-------- include/linux/pci-aspm.h | 10 +- 6 files changed, 195 insertions(+), 93 deletions(-)
I can fix this if you don't get to it, but this doesn't apply cleanly to either my "master" branch (v5.3-rc1) or my "next" branch. I always prefer series based on my "master" branch when possible.
Bjorn
Quoted 37 lines · Bjorn Helgaas
Quoted 28 lines · Heiner Kallweit
Background of this extension is a problem with the r8169 network driver. Several combinations of board chipsets and network chip versions have problems if ASPM is enabled, therefore we have to disable ASPM per default. However especially on notebooks ASPM can provide significant power-saving, therefore we want to give users the option to enable ASPM. With the new sysfs attributes users can control which ASPM link-states are disabled.
v2:
- use a dedicated sysfs attribute per link state
- allow separate control of ASPM and PCI PM L1 sub-statesv3:
- patch 3: statically allocate the attribute group
- patch 3: replace snprintf with printf
- add patch 4v4:
- patch 3: add call tosysfs_update_groupbecauseis_visiblecallback returns false always at file creation time
- patch 3: simplify code a littleHeiner Kallweit (4):
PCI/ASPM: add L1 sub-state support topci_disable_link_statePCI/ASPM: allow to re-enable Clock PM
PCI/ASPM: add sysfs attributes for controlling ASPM link states PCI/ASPM: removeKconfigoptionPCIEASPM_DEBUGand related codeQuoted 7 lines
Documentation/ABI/testing/sysfs-bus-pci | 13 ++ drivers/pci/pci-sysfs.c | 10 +- drivers/pci/pci.h | 12 +- drivers/pci/pcie/Kconfig | 7 - drivers/pci/pcie/aspm.c | 236 ++++++++++++++++-------- include/linux/pci-aspm.h | 10 +- 6 files changed, 195 insertions(+), 93 deletions(-)
Quoted 6 lines
I can fix this if you don't get to it, but this doesn't apply cleanly to either my "master" branch (v5.3-rc1) or my "next" branch. I always prefer series based on my "master" branch when possible.
Bjorn
I based it on top of linux-next, can rebase it to your master branch.
Heiner
Quoted 42 lines · Heiner Kallweit
Quoted 41 lines · Bjorn Helgaas
Quoted 28 lines · Heiner Kallweit
Background of this extension is a problem with the r8169 network driver. Several combinations of board chipsets and network chip versions have problems if ASPM is enabled, therefore we have to disable ASPM per default. However especially on notebooks ASPM can provide significant power-saving, therefore we want to give users the option to enable ASPM. With the new sysfs attributes users can control which ASPM link-states are disabled.
v2:
- use a dedicated sysfs attribute per link state
- allow separate control of ASPM and PCI PM L1 sub-statesv3:
- patch 3: statically allocate the attribute group
- patch 3: replace snprintf with printf
- add patch 4v4:
- patch 3: add call tosysfs_update_groupbecauseis_visiblecallback returns false always at file creation time
- patch 3: simplify code a littleHeiner Kallweit (4):
PCI/ASPM: add L1 sub-state support topci_disable_link_statePCI/ASPM: allow to re-enable Clock PM
PCI/ASPM: add sysfs attributes for controlling ASPM link states PCI/ASPM: removeKconfigoptionPCIEASPM_DEBUGand related codeQuoted 7 lines
Documentation/ABI/testing/sysfs-bus-pci | 13 ++ drivers/pci/pci-sysfs.c | 10 +- drivers/pci/pci.h | 12 +- drivers/pci/pcie/Kconfig | 7 - drivers/pci/pcie/aspm.c | 236 ++++++++++++++++-------- include/linux/pci-aspm.h | 10 +- 6 files changed, 195 insertions(+), 93 deletions(-)I can fix this if you don't get to it, but this doesn't apply cleanly to either my "master" branch (v5.3-rc1) or my "next" branch. I always prefer series based on my "master" branch when possible.
Quoted 6 lines
Quoted 2 lines
Bjorn
I based it on top of linux-next, can rebase it to your master branch.
Heiner
Ah, one more point:
This series has a dependency on Mika Westerberg's
"PCI: Make pcie_downstream_port() available outside of access.c" that is sitting in your inbox. How do you want to deal with this?
Heiner
Quoted 39 lines · Heiner Kallweit
Quoted 38 lines · Heiner Kallweit
Quoted 37 lines · Bjorn Helgaas
Quoted 35 lines · Heiner Kallweit
Background of this extension is a problem with the r8169 network driver. Several combinations of board chipsets and network chip versions have problems if ASPM is enabled, therefore we have to disable ASPM per default. However especially on notebooks ASPM can provide significant power-saving, therefore we want to give users the option to enable ASPM. With the new sysfs attributes users can control which ASPM link-states are disabled.
v2:
- use a dedicated sysfs attribute per link state
- allow separate control of ASPM and PCI PM L1 sub-statesv3:
- patch 3: statically allocate the attribute group
- patch 3: replace snprintf with printf
- add patch 4v4:
- patch 3: add call tosysfs_update_groupbecauseis_visiblecallback returns false always at file creation time
- patch 3: simplify code a littleHeiner Kallweit (4):
PCI/ASPM: add L1 sub-state support topci_disable_link_statePCI/ASPM: allow to re-enable Clock PM
PCI/ASPM: add sysfs attributes for controlling ASPM link states PCI/ASPM: removeKconfigoptionPCIEASPM_DEBUGand related codeDocumentation/ABI/testing/sysfs-bus-pci | 13 ++ drivers/pci/pci-sysfs.c | 10 +- drivers/pci/pci.h | 12 +- drivers/pci/pcie/Kconfig | 7 - drivers/pci/pcie/aspm.c | 236 ++++++++++++++++-------- include/linux/pci-aspm.h | 10 +- 6 files changed, 195 insertions(+), 93 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
I can fix this if you don't get to it, but this doesn't apply cleanly to either my "master" branch (v5.3-rc1) or my "next" branch. I always prefer series based on my "master" branch when possible.
I based it on top of linux-next, can rebase it to your master branch.
That'd be great. linux-next is a moving target, so I never apply patches based directly on that.
Quoted 4 lines
Ah, one more point:
This series has a dependency on Mika Westerberg's
"PCI: Makepcie_downstream_port()available outside ofaccess.c" that is sitting in your inbox. How do you want to deal with this?
Just mention the dependency in the cover letter and I'll take care of it.
Thanks!
Re: [PATCH v4 3/4] PCI/ASPM: add sysfs attributes for controlling ASPM link states
In reply to Heiner KallweitQuoted 8 lines · Heiner Kallweit
Background of this extension is a problem with the r8169 network driver. Several combinations of board chipsets and network chip versions have problems if ASPM is enabled, therefore we have to disable ASPM per default. However especially on notebooks ASPM can provide significant power-saving, therefore we want to give users the option to enable ASPM. With the new sysfs attributes users can control which ASPM link-states are enabled/disabled.
Signed-off-by Heiner Kallweit <[email protected]>