[Linux-kernel-mentees] [RFC PATCH v5 04/23] PCI: Compute aspm_register_info.support directly

Saheed O. Bolarinwa refactormyself at gmail.com
Sat Aug 22 20:03:39 UTC 2020


Replace all references to aspm_register_info.support with its
computation.

Signed-off-by: Saheed O. Bolarinwa <refactormyself at gmail.com>
---
 drivers/pci/pcie/aspm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 629737125b36..64224be52435 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -565,7 +565,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
 	 * If ASPM not supported, don't mess with the clocks and link,
 	 * bail out now.
 	 */
-	if (!(upreg.support & dwreg.support))
+	if (!(((parent->lnkcap & PCI_EXP_LNKCAP_ASPMS) >> 10) &
+		((child->lnkcap & PCI_EXP_LNKCAP_ASPMS) >> 10)))
 		return;
 
 	/* Configure common clock before checking latencies */
@@ -585,8 +586,11 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
 	 * given link unless components on both sides of the link each
 	 * support L0s.
 	 */
-	if (dwreg.support & upreg.support & PCIE_LINK_STATE_L0S)
+	if (((parent->lnkcap & PCI_EXP_LNKCAP_ASPMS) >> 10) &
+			((child->lnkcap & PCI_EXP_LNKCAP_ASPMS) >> 10) &
+			PCIE_LINK_STATE_L0S)
 		link->aspm_support |= ASPM_STATE_L0S;
+
 	if (dwreg.enabled & PCIE_LINK_STATE_L0S)
 		link->aspm_enabled |= ASPM_STATE_L0S_UP;
 	if (upreg.enabled & PCIE_LINK_STATE_L0S)
@@ -595,7 +599,9 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
 	link->latency_dw.l0s = calc_l0s_latency(child);
 
 	/* Setup L1 state */
-	if (upreg.support & dwreg.support & PCIE_LINK_STATE_L1)
+	if (((parent->lnkcap & PCI_EXP_LNKCAP_ASPMS) >> 10) &
+			((child->lnkcap & PCI_EXP_LNKCAP_ASPMS) >> 10) &
+			PCIE_LINK_STATE_L1)
 		link->aspm_support |= ASPM_STATE_L1;
 	if (upreg.enabled & dwreg.enabled & PCIE_LINK_STATE_L1)
 		link->aspm_enabled |= ASPM_STATE_L1;
-- 
2.18.4



More information about the Linux-kernel-mentees mailing list