[Linux-kernel-mentees] [RFC PATCH v5 16/23] PCI: Remove Exit latencies from struct pcie_link_state

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


 - Initialise pci_dev.acceptable instead of pcie_link_state.acceptable
 - Replace all access to pcie_link_state.(acceptable && latency_*)
   with the versions in struct pci_dev
 - Remove pcie_link_state.(acceptable && latency_*)

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

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 9ca06f00e98d..56fdf2e7c98a 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -59,15 +59,6 @@ struct pcie_link_state {
 	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 */
-	struct aspm_latency latency_dw;	/* Downstream direction exit latency */
-	/*
-	 * Endpoint acceptable latencies. A pcie downstream port only
-	 * has one slot under it, so at most there are 8 functions.
-	 */
-	struct aspm_latency acceptable[8];
 };
 
 static int aspm_disabled, aspm_force;
@@ -389,19 +380,19 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint)
 
 	link = endpoint->bus->self->link_state;
 	pdev = endpoint->bus->self;
-	acceptable = &link->acceptable[PCI_FUNC(endpoint->devfn)];
+	acceptable = &link->pdev->acceptable[PCI_FUNC(endpoint->devfn)];
 
 	while (link) {
 		/* Check upstream direction L0s latency */
 		if ((link->aspm_capable & ASPM_STATE_L0S_UP) &&
-		    (link->latency_up.l0s > acceptable->l0s)) {
+		    (link->pdev->latency_up.l0s > acceptable->l0s)) {
 			link->aspm_capable &= ~ASPM_STATE_L0S_UP;
 			pdev->aspm_capable &= ~ASPM_STATE_L0S_UP;
 		}
 
 		/* Check downstream direction L0s latency */
 		if ((link->aspm_capable & ASPM_STATE_L0S_DW) &&
-		    (link->latency_dw.l0s > acceptable->l0s)) {
+		    (link->pdev->latency_dw.l0s > acceptable->l0s)) {
 			link->aspm_capable &= ~ASPM_STATE_L0S_DW;
 			pdev->aspm_capable &= ~ASPM_STATE_L0S_DW;
 		}
@@ -419,7 +410,8 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint)
 		 * L1 exit latencies advertised by a device include L1
 		 * substate latencies (and hence do not do any check).
 		 */
-		latency = max_t(u32, link->latency_up.l1, link->latency_dw.l1);
+		latency = max_t(u32, link->pdev->latency_up.l1,
+						link->pdev->latency_dw.l1);
 		if ((link->aspm_capable & ASPM_STATE_L1) &&
 		    (latency + l1_switch_latency > acceptable->l1)) {
 			link->aspm_capable &= ~ASPM_STATE_L1;
@@ -559,8 +551,6 @@ static void pcie_aspm_cap_init(struct pci_dev *pdev, int blacklist)
 		parent->aspm_enabled |= ASPM_STATE_L0S_DW;
 	}
 
-	link->latency_up.l0s = calc_l0s_latency(parent);
-	link->latency_dw.l0s = calc_l0s_latency(child);
 	parent->latency_up.l0s = calc_l0s_latency(parent);
 	parent->latency_dw.l0s = calc_l0s_latency(child);
 
@@ -578,8 +568,6 @@ static void pcie_aspm_cap_init(struct pci_dev *pdev, int blacklist)
 		parent->aspm_enabled |= ASPM_STATE_L1;
 	}
 
-	link->latency_up.l1 = calc_l1_latency(parent);
-	link->latency_dw.l1 = calc_l1_latency(child);
 	parent->latency_up.l1 = calc_l1_latency(parent);
 	parent->latency_dw.l1 = calc_l1_latency(child);
 
@@ -630,7 +618,7 @@ static void pcie_aspm_cap_init(struct pci_dev *pdev, int blacklist)
 	list_for_each_entry(child, &linkbus->devices, bus_list) {
 		u32 reg32, encoding;
 		struct aspm_latency *acceptable =
-			&link->acceptable[PCI_FUNC(child->devfn)];
+			&parent->acceptable[PCI_FUNC(child->devfn)];
 
 		if (pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT &&
 		    pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END)
-- 
2.18.4



More information about the Linux-kernel-mentees mailing list