PCIE ASPM support
RFC 1/1 PCIE ASPM support
PCI Express ASPM defines a protocol for PCI Express components in the D0 state to reduce Link power by placing their Links into a low power state and instructing the other end of the Link to do likewise. This capability allows hardware-autonomous, dynamic Link power reduction beyond what is achievable by software-only controlled power management. However, The device should be configured by software appropriately. Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for ASPM, a sysfs file /sys/module/pcie_aspm/parameters/policy can control it. The interface can be used as a boot option too. Currently we have below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM state
and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.
In my test, power difference between powersave mode and performance mode is about 1.3w in a system with 3 PCIE links.
please review, any comments will be appreciated.
--- drivers/pci/pci-acpi.c | 9 drivers/pci/pci.c | 4 drivers/pci/pcie/Kconfig | 13 drivers/pci/pcie/Makefile | 3 drivers/pci/pcie/aspm.c | 673 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/probe.c | 5 drivers/pci/remove.c | 4 include/linux/aspm.h | 33 ++ include/linux/pci.h | 4 include/linux/pci_regs.h | 8 10 files changed, 756 insertions(+)
drivers/pci/pcie/Makefile +3 -0
@@ -2,6 +2,9 @@ # Makefile for PCI-Express PORT Driver # +# Build PCI Express ASPM if needed +obj-$(CONFIG_PCIEASPM) += aspm.o + pcieportdrv-y := portdrv_core.o portdrv_pci.o portdrv_bus.o obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o
drivers/pci/pcie/aspm.c new file +673 -0
673 lines not on this page · raw message
include/linux/aspm.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* aspm.h +* +* PCI Express ASPM defines and function prototypes +* +* Copyright (C) 2007 Intel Corp. +* Zhang Yanmin ([email protected]) +* Shaohua Li ([email protected]) +* +* For more information, please consult the following manuals (look at +* http://www.pcisig.com/ for how to get them): +* +* PCI Express Specification +*/ + +#ifndef LINUX_ASPM_H +#define LINUX_ASPM_H + +#include <linux/pci.h> + +#ifdef CONFIG_PCIEASPM +extern void pcie_aspm_init_link_state (struct pci_dev *pdev); +extern void pcie_aspm_exit_link_state (struct pci_dev *pdev); +extern void pcie_aspm_pm_state_change (struct pci_dev *pdev); +extern int pcie_aspm_init (void ); +#else +#define pcie_aspm_init_link_state (pdev) do {} while (0) +#define pcie_aspm_exit_link_state (pdev) do {} while (0) +#define pcie_aspm_pm_state_change (pdev) do {} while (0) +#define pcie_aspm_init () do {} while (0) +#endif + +#endif /* LINUX_ASPM_H */
drivers/pci/pcie/Kconfig +13 -0
@@ -26,3 +26,16 @@ config HOTPLUG_PCI_PCIE When in doubt, say N. source "drivers/pci/pcie/aer/Kconfig" + +# +# PCI Express ASPM +# +config PCIEASPM + bool "PCI Express ASPM support(Experimental)" + depends on PCI && EXPERIMENTAL + default y + help + This enables PCI Express ASPM (Active State Power Management) and + Clock Power Management. ASPM supports state L0/L0s/L1. + + When in doubt, say N.
include/linux/pci.h +4 -0
@@ -164,6 +164,10 @@ struct pci_dev {this is D0-D3, D0 being fully functional, and D3 being off. */ +#ifdef CONFIG_PCIEASPM +void *link_state;/* ASPM link state. */ +#endif +pci_channel_state_t error_state;/* current connectivity state */ struct device dev;/* Generic device interface */
include/linux/pci_regs.h +8 -0
@@ -395,9 +395,17 @@#define PCI_EXP_DEVSTA_AUXPD 0x10/* AUX Power Detected */ #define PCI_EXP_DEVSTA_TRPND 0x20/* Transactions Pending */ #define PCI_EXP_LNKCAP 12/* Link Capabilities */ +#define PCI_EXP_LNKCAP_ASPMS 0xc00/* ASPM Support */ +#define PCI_EXP_LNKCAP_L0SEL 0x7000/* L0s Exit Latency */ +#define PCI_EXP_LNKCAP_L1EL 0x38000/* L1 Exit Latency */ +#define PCI_EXP_LNKCAP_CLKPM 0x40000/* L1 Clock Power Management */ #define PCI_EXP_LNKCTL 16/* Link Control */ +#define PCI_EXP_LNKCTL_RL 0x20/* Retrain Link */ +#define PCI_EXP_LNKCTL_CCC 0x40/* Common Clock COnfiguration */ #define PCI_EXP_LNKCTL_CLKREQ_EN 0x100/* Enable clkreq */ #define PCI_EXP_LNKSTA 18/* Link Status */ +#define PCI_EXP_LNKSTA_LT 0x800/* Link Training */ +#define PCI_EXP_LNKSTA_SLC 0x1000/* Slot Clock Configuration */ #define PCI_EXP_SLTCAP 20/* Slot Capabilities */ #define PCI_EXP_SLTCTL 24/* Slot Control */ #define PCI_EXP_SLTSTA 26/* Slot Status */
drivers/pci/probe.c +5 -0
@@ -9,6 +9,7 @@#include <linux/slab.h> #include <linux/module.h> #include <linux/cpumask.h> +#include <linux/aspm.h> #include "pci.h" #define CARDBUS_LATENCY_TIMER 176/* secondary latency timer */
@@ -1011,6 +1012,10 @@ int pci_scan_slot(struct pci_bus *bus, ibreak ; } } + +if (bus->self) +pcie_aspm_init_link_state (bus->self); +return nr; }
drivers/pci/pci-acpi.c +9 -0
@@ -15,6 +15,7 @@#include <acpi/acnamesp.h> #include <acpi/acresrc.h> #include <acpi/acpi_bus.h> +#include <linux/aspm.h> #include <linux/pci-acpi.h> #include "pci.h"
@@ -349,3 +350,11 @@ static int __init acpi_pci_init(void)return 0 ; }arch_initcall (acpi_pci_init); + +/* Called after ACPI is enabled */ +static int __init acpi_pcie_support_init (void ) +{ +pcie_aspm_init (); +return 0 ; +} +fs_initcall (acpi_pcie_support_init);
drivers/pci/remove.c +4 -0
@@ -1,5 +1,6 @@#include <linux/pci.h> #include <linux/module.h> +#include <linux/aspm.h> #include "pci.h" static void pci_free_resources (struct pci_dev *dev)
@@ -30,6 +31,9 @@ static void pci_stop_dev(struct pci_dev dev->global_list.next = dev->global_list.prev =NULL ;up_write (&pci_bus_sem); } + +if (dev->bus->self) +pcie_aspm_exit_link_state (dev); }static void pci_destroy_dev (struct pci_dev *dev)
drivers/pci/pci.c +4 -0
@@ -18,6 +18,7 @@#include <linux/spinlock.h> #include <linux/string.h> #include <linux/log2.h> +#include <linux/aspm.h> #include <asm/dma.h> /* isa_dma_bridge_buggy */ #include "pci.h"
@@ -501,6 +502,9 @@ pci_set_power_state(struct pci_dev *dev,if (need_restore)pci_restore_bars (dev); +if (dev->bus->self) +pcie_aspm_pm_state_change (dev->bus->self); +return 0 ; }
Quoted 19 lines · Shaohua Li
PCI Express ASPM defines a protocol for PCI Express components in the D0 state to reduce Link power by placing their Links into a low power state and instructing the other end of the Link to do likewise. This capability allows hardware-autonomous, dynamic Link power reduction beyond what is achievable by software-only controlled power management. However, The device should be configured by software appropriately. Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for ASPM, a sysfs file
/sys/module/pcie_aspm/parameters/policycan control it. The interface can be used as a boot option too. Currently we have below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM state
and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.
Quoted 4 lines
In my test, power difference between powersave mode and performance mode is about 1.3w in a system with 3 PCIE links.
please review, any comments will be appreciated.
quickly glanced this over since I recently disabled l1 ASPM for the e1000/e1000e driven 82573 device which has issues with l1 ASPM. that immediately gives me the
question: how can I continue to disable 1l aspm by default for this device using this infrastructure?
I do like the fact that there is a generic way to re-enable it for the users who want to use it. Can this change be done when the device is already active? Can you change this parameter per device/module?
drivers/pci/pcie/aspm.c line 50
Quoted 4 lines
drivers/pci/pcie/aspm.c new file +4
-0+/* Clock PM state*/ + unsigned int clk_pm_capable:1; + unsigned int clk_pm_enabled:1; + unsigned int bios_clk_state:1;
might want to get rid of these bitfields?
Cheers,
Auke
Quoted 23 lines · Auke
Quoted 22 lines · Shaohua Li
PCI Express ASPM defines a protocol for PCI Express components in the D0 state to reduce Link power by placing their Links into a low power state and instructing the other end of the Link to do likewise. This capability allows hardware-autonomous, dynamic Link power reduction beyond what is achievable by software-only controlled power management. However, The device should be configured by software appropriately. Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for ASPM, a sysfs file
/sys/module/pcie_aspm/parameters/policycan control it. The interface can be used as a boot option too. Currently we have below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM state
and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.In my test, power difference between powersave mode and performance mode is about 1.3w in a system with 3 PCIE links.
Quoted 7 lines
Quoted 1 line
please review, any comments will be appreciated.
quickly glanced this over since I recently disabled l1 ASPM for the e1000/e1000e driven 82573 device which has issues with l1 ASPM. that immediately gives me the
question: how can I continue to disable 1l aspm by default for this device using this infrastructure?
I used to have a per-device interface, but thought the interface might be hard to use for users. If we really need the per-device interface, I can re-add it.
Quoted 2 lines
I do like the fact that there is a generic way to re-enable it for the users who want to use it. Can this change be done when the device is already active?
Yes, at least in my test.
Quoted 2 lines
Can you
change this parameter per device/module?
Another way is to provide a helper for driver, and driver disables specific ASPM states. It sounds better to let driver do the disabling, as users haven't the knowledge?
Thanks,
Shaohua
Quoted 36 lines · Shaohua Li
Quoted 23 lines · Auke
Quoted 22 lines · Shaohua Li
PCI Express ASPM defines a protocol for PCI Express components in the D0 state to reduce Link power by placing their Links into a low power state and instructing the other end of the Link to do likewise. This capability allows hardware-autonomous, dynamic Link power reduction beyond what is achievable by software-only controlled power management. However, The device should be configured by software appropriately. Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for ASPM, a sysfs file
/sys/module/pcie_aspm/parameters/policycan control it. The interface can be used as a boot option too. Currently we have below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM state
and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.In my test, power difference between powersave mode and performance mode is about 1.3w in a system with 3 PCIE links.
Quoted 6 lines
Quoted 1 line
please review, any comments will be appreciated.
quickly glanced this over since I recently disabled l1 ASPM for the e1000/e1000e driven 82573 device which has issues with l1 ASPM. that immediately gives me the
question: how can I continue to disable 1l aspm by default for this device using this infrastructure?I used to have a per-device interface, but thought the interface might be hard to use for users. If we really need the per-device interface, I can re-add it.
Quoted 2 lines
I do like the fact that there is a generic way to re-enable it for the users who want to use it. Can this change be done when the device is already active?
Quoted 7 lines
Yes, at least in my test.
Quoted 2 lines
Can you
change this parameter per device/module?Another way is to provide a helper for driver, and driver disables specific ASPM states. It sounds better to let driver do the disabling, as users haven't the knowledge?
agreed, however this could still be usefull in debugging equipment for the experienced user. In any case an easy handle for the driver to dis/enable ASPM would certainly help our case, and possibly others.
Auke
Quoted 41 lines · Auke
Quoted 40 lines · Shaohua Li
Quoted 23 lines · Auke
Quoted 22 lines · Shaohua Li
PCI Express ASPM defines a protocol for PCI Express components in the D0 state to reduce Link power by placing their Links into a low power state and instructing the other end of the Link to do likewise. This capability allows hardware-autonomous, dynamic Link power reduction beyond what is achievable by software-only controlled power management. However, The device should be configured by software appropriately. Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for ASPM, a sysfs file
/sys/module/pcie_aspm/parameters/policycan control it. The interface can be used as a boot option too. Currently we have below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM state
and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.In my test, power difference between powersave mode and performance mode is about 1.3w in a system with 3 PCIE links.
Quoted 6 lines
Quoted 1 line
please review, any comments will be appreciated.
quickly glanced this over since I recently disabled l1 ASPM for the e1000/e1000e driven 82573 device which has issues with l1 ASPM. that immediately gives me the
question: how can I continue to disable 1l aspm by default for this device using this infrastructure?I used to have a per-device interface, but thought the interface might be hard to use for users. If we really need the per-device interface, I can re-add it.
Quoted 2 lines
I do like the fact that there is a generic way to re-enable it for the users who want to use it. Can this change be done when the device is already active?
Yes, at least in my test.
Quoted 2 lines
Can you
change this parameter per device/module?
Quoted 7 lines
Quoted 3 lines
Another way is to provide a helper for driver, and driver disables specific ASPM states. It sounds better to let driver do the disabling, as users haven't the knowledge?
agreed, however this could still be usefull in debugging equipment for the experienced user. In any case an easy handle for the driver to dis/enable ASPM would certainly help our case, and possibly others.
Then I'll add a config option, and enable the per-device interface with config enabled.
Thanks,
Shaohua
Quoted 19 lines · Shaohua Li
PCI Express ASPM defines a protocol for PCI Express components in the D0 state to reduce Link power by placing their Links into a low power state and instructing the other end of the Link to do likewise. This capability allows hardware-autonomous, dynamic Link power reduction beyond what is achievable by software-only controlled power management. However, The device should be configured by software appropriately. Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for ASPM, a sysfs file
/sys/module/pcie_aspm/parameters/policycan control it. The interface can be used as a boot option too. Currently we have below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM state
and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.
Quoted 6 lines
In my test, power difference between powersave mode and performance mode is about 1.3w in a system with 3 PCIE links.
please review, any comments will be appreciated.
Signed-off-by Shaohua Li <[email protected]>
Minor nit, but you do a lot of these:
+ return ((struct link_state *)pdev->link_state)->bios_aspm_state;
+ return ((struct link_state *)pdev->link_state)->bios_clk_state;
+ ((struct link_state*)pdev->link_state)->clk_pm_enabled = !!enable;
+ ((struct link_state*)pdev->link_state)->clk_pm_capable = capable;
+ ((struct link_state*)pdev->link_state)->clk_pm_enabled = enabled;
+ ((struct link_state*)pdev->link_state)->bios_clk_state = enabled;
+ ((struct link_state *)pdev->link_state)->enabled_state = state;
+ if (((struct link_state *)pdev->link_state)->support_state == 0)
+ if (((struct link_state *)pdev->link_state)->enabled_state == state)
+ ((struct link_state *)pdev->link_state)->enabled_state);
Which is a little hard on the eye.
cheers
Signature · 8 lines
Michael Ellerman OzLabs, IBM Australia Development Lab wwweb: http://michael.ellerman.id.au phone: +61 2 6212 1183 (tie line 70 21183) We do not inherit the earth from our ancestors, we borrow it from our children. - S.M.A.R.T Person
Quoted 29 lines · Michael Ellerman
Quoted 19 lines · Shaohua Li
PCI Express ASPM defines a protocol for PCI Express components in the D0 state to reduce Link power by placing their Links into a low power state and instructing the other end of the Link to do likewise. This capability allows hardware-autonomous, dynamic Link power reduction beyond what is achievable by software-only controlled power management. However, The device should be configured by software appropriately. Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for ASPM, a sysfs file
/sys/module/pcie_aspm/parameters/policycan control it. The interface can be used as a boot option too. Currently we have below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM state
and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.Quoted 6 lines
In my test, power difference between powersave mode and performance mode is about 1.3w in a system with 3 PCIE links.
please review, any comments will be appreciated.
Signed-off-by Shaohua Li <[email protected]>Minor nit, but you do a lot of these:
drivers/pci/pcie/aspm.c
Quoted 10 lines
drivers/pci/pcie/aspm.c new file +10
-0+return ((struct link_state *)pdev->link_state)->bios_aspm_state; +return ((struct link_state *)pdev->link_state)->bios_clk_state; + ((struct link_state *)pdev->link_state)->clk_pm_enabled = !!enable; + ((struct link_state *)pdev->link_state)->clk_pm_capable = capable; + ((struct link_state *)pdev->link_state)->clk_pm_enabled = enabled; + ((struct link_state *)pdev->link_state)->bios_clk_state = enabled; + ((struct link_state *)pdev->link_state)->enabled_state = state; +if (((struct link_state *)pdev->link_state)->support_state ==0 ) +if (((struct link_state *)pdev->link_state)->enabled_state == state) + ((struct link_state *)pdev->link_state)->enabled_state);
Thanks for your time. I'll fix in next release.
Thanks,
Shaohua