PCI/ASPM: reconfigure ASPM following hotplug for POLICY_DEFAULT
Subsystems (2)
PATCH v2 1/1 PCI/ASPM: reconfigure ASPM following hotplug for POLICY_DEFAULT
When the operating system is booted with the default ASPM policy (POLICY_DEFAULT), the current code is determining the ASPM policy set up by the BIOS by querying the enable/disable states from ASPM registers.
In the case of hotplug removal, the ASPM registers get cleared by calling the pcie_aspm_exit_link_state() function.
An insertion following hotplug removal reads incorrect policy as ASPM disabled even though ASPM was enabled during boot.
Adding a flag to the struct pci_dev and saving the power up policy in the bridge to be reused during hotplug insertion. Bridge's enable counter is used as a switch to determine when to use saved value.
--- drivers/pci/pcie/aspm.c | 21 +++++++++++++++++---- include/linux/pci.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/pci/pcie/aspm.c +17 -4
@@ -338,8 +338,9 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) } } -static void pcie_aspm_cap_init (struct pcie_link_state *link,int blacklist) +static void pcie_aspm_cap_init (struct pci_dev *pdev,int blacklist) { +struct pcie_link_state *link = pdev->link_state;struct pci_dev *child, *parent = link->pdev;struct pci_bus *linkbus = parent->subordinate;struct aspm_register_info upreg, dwreg;
@@ -397,8 +398,20 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) link->latency_up.l1 =calc_l1_latency (upreg.latency_encoding_l1); link->latency_dw.l1 =calc_l1_latency (dwreg.latency_encoding_l1); -/* Save default state */ - link->aspm_default = link->aspm_enabled; +/* +* Save default state from FW when enabling ASPM for the first time +* during boot by looking at the calculated link->aspm_enabled bits +* above and enable_cnt will be zero. +* +* If this path is getting called for the second/third time +* (enable_cnt will be non-zero). Assume that the current state of the +* ASPM registers may not necessarily match what FW asked us to do as +* in the case of hotplug insertion/removal. +*/ +if (!atomic_read (&pdev->enable_cnt)) + pdev->aspm_default = link->aspm_default = link->aspm_enabled; +else + link->aspm_default = pdev->aspm_default;/* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support;
@@ -599,7 +612,7 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)* upstream links also because capable state of them can be * update through pcie_aspm_cap_init(). */ -pcie_aspm_cap_init (link, blacklist); +pcie_aspm_cap_init (pdev, blacklist);/* Setup initial Clock PM state */ pcie_clkpm_cap_init (link, blacklist);
include/linux/pci.h +1 -0
@@ -321,6 +321,7 @@ struct pci_dev {#ifdef CONFIG_PCIEASPM struct pcie_link_state *link_state;/* ASPM link state */ +unsigned int aspm_default;/* ASPM policy set by BIOS */ #endif pci_channel_state_t error_state;/* current connectivity state */
Signature · 1 line
1.9.1
Quoted 9 lines
When the operating system is booted with the default ASPM policy (
POLICY_DEFAULT), the current code is determining the ASPM policy set up by the BIOS by querying the enable/disable states from ASPM registers.In the case of hotplug removal, the ASPM registers get cleared by calling the
pcie_aspm_exit_link_state()function.
I see the same problem. So cherry-picked your change to resolve the problem on top of Linus mainline.
Quoted 29 lines
An insertion following hotplug removal reads incorrect policy as ASPM disabled even though ASPM was enabled during boot.
Adding a flag to the struct
pci_devand saving the power up policy in the bridge to be reused during hotplug insertion. Bridge's enable counter is used as a switch to determine when to use saved value.Signed-off-by Sinan Kaya <[email protected]>---
drivers/pci/pcie/aspm.c| 21 +++++++++++++++++----include/linux/pci.h| 1 +2 files changed, 18 insertions(+), 4 deletions(-)drivers/pci/pcie/aspm.c +2
-1@@ -338,8 +338,9 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) } } -static void pcie_aspm_cap_init (struct pcie_link_state *link,int blacklist) +static void pcie_aspm_cap_init (struct pci_dev *pdev,int blacklist) { +struct pcie_link_state *link = pdev->link_state;struct pci_dev *child, *parent = link->pdev;struct pci_bus *linkbus = parent->subordinate;struct aspm_register_info upreg, dwreg;
drivers/pci/pcie/aspm.c static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) · line 401
Quoted 5 lines
drivers/pci/pcie/aspm.c +0
-2@@ -397,8 +398,20 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) link->latency_up.l1 =calc_l1_latency (upreg.latency_encoding_l1); link->latency_dw.l1 =calc_l1_latency (dwreg.latency_encoding_l1); -/* Save default state */ - link->aspm_default = link->aspm_enabled;
But, I am finding a problem with this change, if Policy is set to default, BIOS enables ASPM L1, but pcie_config_aspm_link() disables ASPM L1 due to link->aspm_enabled is different than link->aspm_default while called from pcie_aspm_init_link_state() during hotplug insertion.
Quoted 41 lines
drivers/pci/pcie/aspm.c +15
-1+/* +* Save default state from FW when enabling ASPM for the first time +* during boot by looking at the calculated link->aspm_enabled bits +* above and enable_cnt will be zero. +* +* If this path is getting called for the second/third time +* (enable_cnt will be non-zero). Assume that the current state of the +* ASPM registers may not necessarily match what FW asked us to do as +* in the case of hotplug insertion/removal. +*/ +if (!atomic_read (&pdev->enable_cnt)) + pdev->aspm_default = link->aspm_default = link->aspm_enabled; +else + link->aspm_default = pdev->aspm_default;/* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support;@@ -599,7 +612,7 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)* upstream links also because capable state of them can be * update through pcie_aspm_cap_init(). */ -pcie_aspm_cap_init (link, blacklist); +pcie_aspm_cap_init (pdev, blacklist);/* Setup initial Clock PM state */ pcie_clkpm_cap_init (link, blacklist);include/linux/pci.h +1
-1@@ -321,6 +321,7 @@ struct pci_dev {#ifdef CONFIG_PCIEASPM struct pcie_link_state *link_state;/* ASPM link state */ +unsigned int aspm_default;/* ASPM policy set by BIOS */ #endif pci_channel_state_t error_state;/* current connectivity state */ --1.9.1
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Quoted 7 lines · Mayurkumar
drivers/pci/pcie/aspm.c static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) · line 401
Quoted 2 lines
drivers/pci/pcie/aspm.c +0
-2-/* Save default state */ - link->aspm_default = link->aspm_enabled;But, I am finding a problem with this change, if Policy is set to default, BIOS enables ASPM L1, but
pcie_config_aspm_link()disables ASPM L1 due tolink->aspm_enabledis different thanlink->aspm_defaultwhile called frompcie_aspm_init_link_state()during hotplug insertion.
Thanks for testing. I think it means the enable count logic I put below is not working.
I was trying to figure out when to use saved values vs. the values in registers by looking at the enable_cnt.
enable_cnt is 0 during boot on my system.
The enable_cnt should have been non-zero following an insertion following remove and default and enabled values should have been identical.
Can you print out the values of pdev->aspm_default, link->aspm_default, and link->aspm_enabled in this function along with atomic_read(&pdev->enable_cnt)?
Quoted 15 lines
Quoted 15 lines
drivers/pci/pcie/aspm.c +14
-0+/* +* Save default state from FW when enabling ASPM for the first time +* during boot by looking at the calculated link->aspm_enabled bits +* above and enable_cnt will be zero. +* +* If this path is getting called for the second/third time +* (enable_cnt will be non-zero). Assume that the current state of the +* ASPM registers may not necessarily match what FW asked us to do as +* in the case of hotplug insertion/removal. +*/ +if (!atomic_read (&pdev->enable_cnt)) + pdev->aspm_default = link->aspm_default = link->aspm_enabled; +else + link->aspm_default = pdev->aspm_default;
Signature · 3 lines
Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 10 lines · Mayurkumar
Quoted 7 lines
drivers/pci/pcie/aspm.c static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) · line 401
Quoted 2 lines
drivers/pci/pcie/aspm.c +0
-2-/* Save default state */ - link->aspm_default = link->aspm_enabled;But, I am finding a problem with this change, if Policy is set to default, BIOS enables ASPM L1, but
pcie_config_aspm_link()disables ASPM L1 due tolink->aspm_enabledis different thanlink->aspm_defaultwhile called frompcie_aspm_init_link_state()during hotplug insertion.
Quoted 2 lines
Thanks for testing. I think it means the enable count logic I put below is not working.
Yes I believe so.
Quoted 5 lines
I was trying to figure out when to use saved values vs. the values in registers by looking at the
enable_cnt.
enable_cntis 0 during boot on my system.
enable_cnt for the root port on my system is set to 1 for "root port" already without saving any ASPM related settings.
Quoted 4 lines
The
enable_cntshould have been non-zero following an insertion following remove and default and enabled values should have been identical.
pcie_aspm_init_link_state() is called on the "root port" from hotplug routine when I plug in PCIE Endpoint. And in my case root port "enable_cnt" is already set to 1 because of root port driver probed already. So link->aspm_default by default always sets to pdev->aspm_default which is 0 as it was never set to BIOS values before. I will continue dig in further to see how the "root port" probe gets triggered and why it does not call pcie_aspm_init_link_state() to store aspm policy before "enable_cnt" becomes 1 for it.
Quoted 4 lines
Can you print out the values of
pdev->aspm_default,link->aspm_default, andlink->aspm_enabledin this function along withatomic_read(&pdev->enable_cnt)?Quoted 1 line
Yes. Also printed link control register(lnkctl) set by BIOS for upstream port and downstream port Which gets disabled afterwards due to the link->aspm_default is 0. The prints are in pcie_aspm_cap_init() Function.
[ 199.287732] pci 0000:03:00.0: reg 0x10: [mem 0x00000000-0x00000fff 64bit] [ 199.287748] pci 0000:03:00.0: reg 0x18: [mem 0x00000000-0x000000ff 64bit] [ 199.287864] pci 0000:03:00.0: PME# supported from D0 D3hot D3cold [ 199.288000] pci 0000:03:00.0: System wakeup disabled by ACPI [ 199.299868] upreg lnkcap 00000003 lnkctl=00000042 [ 199.299996] dwreg lnkcap 00000002 lnkctl=00000142 [ 199.300076] pdev_aspm_default: 0x00000000 link_aspm_default: 0x00000000 aspm_enabled: 0x00000004 enable_cnt: 0x00000001 [ 199.300402] pci 0000:03:00.0: BAR 0: assigned [mem 0xaa000000-0xaa000fff 64bit] [ 199.300413] pci 0000:03:00.0: BAR 2: assigned [mem 0xaa001000-0xaa0010ff 64bit]
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/pci/pcie/aspm.c +12
-0+/* +* Save default state from FW when enabling ASPM for the first time +* during boot by looking at the calculated link->aspm_enabled bits +* above and enable_cnt will be zero. +* +* If this path is getting called for the second/third time +* (enable_cnt will be non-zero). Assume that the current state of the +* ASPM registers may not necessarily match what FW asked us to do as +* in the case of hotplug insertion/removal. +*/ +if (!atomic_read (&pdev->enable_cnt)) + pdev->aspm_default = link->aspm_default = link->aspm_enabled;
Quoted 8 lines
Quoted 2 lines
drivers/pci/pcie/aspm.c static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) · line 414
Quoted 2 lines
drivers/pci/pcie/aspm.c +2
-0+else + link->aspm_default = pdev->aspm_default;--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Hi Bjorn,
Quoted 7 lines · Mayurkumar
Quoted 3 lines
I was trying to figure out when to use saved values vs. the values in registers by looking at the
enable_cnt.enable_cntis 0 during boot on my system.
enable_cntfor the root port on my system is set to 1 for "root port" already without saving any ASPM related settings.
What would be the best way to figure out when to save power-on values from the registers?
Signature · 3 lines
Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 7 lines
Hi Bjorn,
Quoted 3 lines · Mayurkumar
Quoted 3 lines
I was trying to figure out when to use saved values vs. the values in registers by looking at the
enable_cnt.enable_cntis 0 during boot on my system.
Quoted 8 lines
Quoted 4 lines
enable_cntfor the root port on my system is set to 1 for "root port" already without saving any ASPM related settings.What would be the best way to figure out when to save power-on values from the registers?
So in my case, pci_enable_device() for root port is called from pcie_port_device_register() at the boot time which Is called from pcie_portdrv_probe() function which does not call pcie_aspm_init_link_state() but Increment's enable_cnt field. When the Endpoint get plugged in, pcie_aspm_init_link_state() is called from hotplug routine on "Root port" but due to enable_cnt is already incremented we do not set right policy and aspm gets disabled by aspm driver.
Shall we introduce new atomic variable along with aspm_default in struct pci_dev and increment it in when called first time pcie_aspm_init_link_state() to save power-on values ( I have tested it locally, if you think could be good approach I can upload the diffs) because enable_cnt in pci_enable_device() can be triggered
from multiple places at boot time so it might not be safe to use it?
or adding pcie_aspm_init_link_state() in pcie_port_device_register() for ports before calling pci_enable_device() although I am not sure whether it's the right approach and that would work for all the devices!
@Kaya/Bjorn: Do you have any other suggestions or Could you also please help by comment what would make sense?
Quoted 4 lines
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Hi Mayurkumar
Quoted 12 lines · Mayurkumar
Quoted 12 lines
Hi Bjorn,
Quoted 7 lines · Mayurkumar
Quoted 3 lines
I was trying to figure out when to use saved values vs. the values in registers by looking at the
enable_cnt.enable_cntis 0 during boot on my system.
enable_cntfor the root port on my system is set to 1 for "root port" already without saving any ASPM related settings.
Quoted 6 lines
Quoted 3 lines
What would be the best way to figure out when to save power-on values from the registers?
I can upload the diffs) because
enable_cntinpci_enable_device()can be triggered from multiple places at boot time so it might not be safe to use it?
Go ahead and share your diff. It doesn't hurt to look at other alternatives.
Quoted 17 lines
@Kaya/Bjorn: Do you have any other suggestions or Could you also please help by comment what would make sense?
Quoted 4 lines
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Signature · 3 lines
Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi Kaya
Quoted 16 lines
Hi Mayurkumar
Quoted 12 lines · Mayurkumar
Quoted 12 lines
Hi Bjorn,
Quoted 7 lines · Mayurkumar
Quoted 3 lines
I was trying to figure out when to use saved values vs. the values in registers by looking at the
enable_cnt.enable_cntis 0 during boot on my system.
enable_cntfor the root port on my system is set to 1 for "root port" already without saving any ASPM related settings.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
What would be the best way to figure out when to save power-on values from the registers?
I can upload the diffs) because
enable_cntinpci_enable_device()can be triggered from multiple places at boot time so it might not be safe to use it?Go ahead and share your diff. It doesn't hurt to look at other alternatives.
So basically, I introduced a new atomic variable to save the aspm_policy for the first time. Below is my diff.
drivers/pci/pcie/aspm.c +18 -4
@@ -338,8 +338,9 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) } } -static void pcie_aspm_cap_init (struct pcie_link_state *link,int blacklist) +static void pcie_aspm_cap_init (struct pci_dev *pdev,int blacklist) { +struct pcie_link_state *link = pdev->link_state;struct pci_dev *child, *parent = link->pdev;struct pci_bus *linkbus = parent->subordinate;struct aspm_register_info upreg, dwreg;
@@ -397,8 +398,21 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) link->latency_up.l1 =calc_l1_latency (upreg.latency_encoding_l1); link->latency_dw.l1 =calc_l1_latency (dwreg.latency_encoding_l1); -/* Save default state */ - link->aspm_default = link->aspm_enabled; +/* +* Save default state from FW when enabling ASPM for the first time +* during boot by looking at the calculated link->aspm_enabled bits +* above and aspm_enable_cnt will be zero. +* +* If this path is getting called for the second/third time +* (aspm_enable_cnt will be non-zero). Assume that the current state +* of the ASPM registers may not necessarily match what FW asked us to +* do as in the case of hotplug insertion/removal. +*/ +if (atomic_inc_return (&pdev->aspm_enable_cnt) ==1 ) + pdev->aspm_default = link->aspm_default = link->aspm_enabled; +else + link->aspm_default = pdev->aspm_default; +/* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support;
@@ -606,7 +620,7 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)* upstream links also because capable state of them can be * update through pcie_aspm_cap_init(). */ -pcie_aspm_cap_init (link, blacklist); +pcie_aspm_cap_init (pdev, blacklist);/* Setup initial Clock PM state */ pcie_clkpm_cap_init (link, blacklist);
include/linux/pci.h +2 -0
@@ -321,6 +321,8 @@ struct pci_dev {#ifdef CONFIG_PCIEASPM struct pcie_link_state *link_state;/* ASPM link state */ +unsigned int aspm_default;/* ASPM policy set by BIOS */ +atomic_t aspm_enable_cnt;/* ASPM policy initialization */ #endif pci_channel_state_t error_state;/* current connectivity state */
Quoted 19 lines
Quoted 8 lines
@Kaya/Bjorn: Do you have any other suggestions or Could you also please help by comment what would make sense?
Quoted 4 lines
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.Quoted 9 lines
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Quoted 4 lines
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Quoted 29 lines · Mayurkumar
Hi Kaya
Quoted 27 lines
Hi Mayurkumar
Quoted 22 lines · Mayurkumar
Quoted 14 lines
Hi Bjorn,
Quoted 9 lines · Mayurkumar
Quoted 4 lines
I was trying to figure out when to use saved values vs. the values in
registers by looking at theenable_cnt.enable_cntis 0 during boot on my system.
enable_cntfor the root port on my system is set to 1 for "root port" already without saving
any ASPM related settings.Quoted 4 lines
What would be the best way to figure out when to save power-on values from
the registers?I can upload the diffs) because
enable_cntinpci_enable_device()can be triggered
from multiple places at boot time so it might not be safe to use it?
Quoted 7 lines
Quoted 3 lines
Go ahead and share your diff. It doesn't hurt to look at other alternatives.
So basically, I introduced a new atomic variable to save the
aspm_policyfor the first time.
Below is my diff.
Thanks.
Ok, i will incorporate your change and add your signoff, then repost the next version after testing next week. I am OoO until next week.
Quoted 72 lines
drivers/pci/pcie/aspm.c +2
-1@@ -338,8 +338,9 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) } } -static void pcie_aspm_cap_init (struct pcie_link_state *link,int blacklist) +static void pcie_aspm_cap_init(struct pci_dev *pdev, int blacklist) { +struct pcie_link_state *link = pdev->link_state;struct pci_dev *child, *parent = link->pdev;struct pci_bus *linkbus = parent->subordinate; struct aspm_register_info upreg, dwreg;drivers/pci/pcie/aspm.c +2
-2@@ -397,8 +398,21 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) link->latency_up.l1 =calc_l1_latency (upreg.latency_encoding_l1); link->latency_dw.l1 =calc_l1_latency (dwreg.latency_encoding_l1); -/* Save default state */ - link->aspm_default = link->aspm_enabled; +/* +* Save default state from FW when enabling ASPM for the first time
+ * during boot by looking at the calculatedlink->aspm_enabled
bitsdrivers/pci/pcie/aspm.c +4
-0+* above and aspm_enable_cnt will be zero. +* +* If this path is getting called for the second/third time +* (aspm_enable_cnt will be non-zero). Assume that the current state
+ * of the ASPM registers may not necessarily match what FW
asked us todrivers/pci/pcie/aspm.c +4
-0+* do as in the case of hotplug insertion/removal. +*/ +if (atomic_inc_return (&pdev->aspm_enable_cnt) ==1 ) + pdev->aspm_default = link->aspm_default =
link->aspm_enabled;drivers/pci/pcie/aspm.c +4
-1+else + link->aspm_default = pdev->aspm_default; +/* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support;@@ -606,7 +620,7 @@ void pcie_aspm_init_link_state(struct pci_dev*pdev) * upstream links also because capable state of them can be * update through pcie_aspm_cap_init(). */ -pcie_aspm_cap_init (link, blacklist); +pcie_aspm_cap_init (pdev, blacklist);/* Setup initial Clock PM state */ pcie_clkpm_cap_init(link, blacklist);include/linux/pci.h +1
-0@@ -321,6 +321,8 @@ struct pci_dev {#ifdef CONFIG_PCIEASPM struct pcie_link_state *link_state;/* ASPM link state */ +unsigned int aspm_default;/* ASPM policy set by BIOS */
+atomic_taspm_enable_cnt; /* ASPM policy
initialization */