From patchwork Fri Aug 13 22:36:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 12436307 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 034FFC4338F for ; Fri, 13 Aug 2021 22:36:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDC6260EB2 for ; Fri, 13 Aug 2021 22:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235144AbhHMWgp (ORCPT ); Fri, 13 Aug 2021 18:36:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235079AbhHMWgo (ORCPT ); Fri, 13 Aug 2021 18:36:44 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7091AC061756 for ; Fri, 13 Aug 2021 15:36:17 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id h13so15251547wrp.1 for ; Fri, 13 Aug 2021 15:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m3kDMwKP69zOvwkQZW9XgztPfTldaAcehTU8PH2NsKI=; b=gcyLW+eyOMitsFZun0C3KEvvR9YYt3nK+zu633vtrBb5Fb9t8Vo+4X3JQmCUctxJeu 3diLex3KReK+NmgPpFxVfrCrczrBcX8GiSVen9pMi2Ww83OgWi8hdFP4aVdV2nyIM4Gg UJD58Jz58Ue9NRMxLH3+UIiM0ffyzyjeJn/u4RDA1TM7kXQ3Lfu0X6gzJa8wDOxKSfgW HCdZgeUqTEUDGSZ2Lgne8RkmLVMu9BjEZFTlgKyXTdiKfPbaW8mi4TRmuMz9LDGNQzN7 FhCcLeiim1EFaH6XH+U4GcFnJLG6XVWZtkZcX3WJY+J0ZhouQKdIste2Yssfo+JRZpFW LxeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m3kDMwKP69zOvwkQZW9XgztPfTldaAcehTU8PH2NsKI=; b=F1TCiHf9KzEkNOqge1sVxGsW1ywaRI1uPPjup5HGRZ0jIX4Ex8fsduXxCXZThBXeyD uCiZVkGkCwTmPhkJogVr7d3oKHHnZEKVl/bQrXw5rR+hyF7UOdFr9QzdOsRVGr+NCS/V tYqVV6GYgSvF3xe7LvjT8VJ/2HbeWguPG9r7Ymor8W4Rf5vMwEt4k8dZQTc+OKDAXF6y 4AKCuA4DF4zMOOazqvCoJX9FuHB+05zEND+07kb+8eexc94lRoAfsO+Xm3IN9SZh6ag5 Yqa/v8XB4KGoqEX2tR+iBSBAkL50bJPdun932PQRhaU6Z3NOYQRTeH4cmdIEPZonWWuz T+RA== X-Gm-Message-State: AOAM532A8yeRNhZt/vjZwur5aFqupi9sU2DSR/6gREjRPwKJNMxbYpFh iX334gLOgRcrH1YBULmAndrE4oATd7MdCw== X-Google-Smtp-Source: ABdhPJwGoO40QQun2536mJDx+/SegYyRPV+jj4515P5uBdjtj4u86mu+eRiKfM6ys9qz6VdlazQ83g== X-Received: by 2002:a05:6000:18c8:: with SMTP id w8mr5402969wrq.90.1628894175830; Fri, 13 Aug 2021 15:36:15 -0700 (PDT) Received: from localhost.localdomain ([2a02:ab88:144:f570:b509:5224:f519:ca15]) by smtp.googlemail.com with ESMTPSA id 6sm2621028wmk.20.2021.08.13.15.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 15:36:15 -0700 (PDT) From: "Saheed O. Bolarinwa" To: linux-pci@vger.kernel.org Cc: "Saheed O. Bolarinwa" Subject: [RFC PATCH 1/3] PCI/ASPM: Remove struct pcie_link_state.latency_* Date: Sat, 14 Aug 2021 00:36:07 +0200 Message-Id: <20210813223610.8687-2-refactormyself@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813223610.8687-1-refactormyself@gmail.com> References: <20210813223610.8687-1-refactormyself@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Inside pcie_aspm_cap_init() the exit latencies on both upstream and downstream are calculated and cached in struct pcie_link_state.latency_* These values are only used in pcie_aspm_check_latency() where they are compared with the acceptable latencies on the link. Computing these latencies right inside pcie_aspm_check_latency() where they are only needed will remove the need for caching them. This will not make any functional change. - Calculate the exit latencies inside pcie_aspm_check_latency() - Remove struct pcie_link_state.latency_{up,dw} - Replace references with local variables of struct aspm_latency Signed-off-by: Saheed O. Bolarinwa --- drivers/pci/pcie/aspm.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 013a47f587ce..4c437b1345b2 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -66,9 +66,6 @@ struct pcie_link_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. @@ -378,7 +375,8 @@ static void encode_l12_threshold(u32 threshold_us, u32 *scale, u32 *value) static void pcie_aspm_check_latency(struct pci_dev *endpoint) { - u32 latency, l1_switch_latency = 0; + u32 latency, lnkcap_up, lnkcap_dw, l1_switch_latency = 0; + struct aspm_latency latency_up, latency_dw; struct aspm_latency *acceptable; struct pcie_link_state *link; @@ -391,14 +389,22 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) acceptable = &link->acceptable[PCI_FUNC(endpoint->devfn)]; while (link) { + /* Read direction exit latencies */ + pcie_capability_read_dword(link->pdev, PCI_EXP_LNKCAP, &lnkcap_up); + pcie_capability_read_dword(link->downstream, PCI_EXP_LNKCAP, &lnkcap_dw); + latency_up.l0s = calc_l0s_latency(lnkcap_up); + latency_up.l1 = calc_l1_latency(lnkcap_up); + latency_dw.l0s = calc_l0s_latency(lnkcap_dw); + latency_dw.l1 = calc_l1_latency(lnkcap_dw); + /* Check upstream direction L0s latency */ if ((link->aspm_capable & ASPM_STATE_L0S_UP) && - (link->latency_up.l0s > acceptable->l0s)) + (latency_up.l0s > acceptable->l0s)) link->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)) + (latency_dw.l0s > acceptable->l0s)) link->aspm_capable &= ~ASPM_STATE_L0S_DW; /* * Check L1 latency. @@ -413,7 +419,7 @@ 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, latency_up.l1, latency_dw.l1); if ((link->aspm_capable & ASPM_STATE_L1) && (latency + l1_switch_latency > acceptable->l1)) link->aspm_capable &= ~ASPM_STATE_L1; @@ -593,8 +599,6 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) link->aspm_enabled |= ASPM_STATE_L0S_UP; if (parent_lnkctl & PCI_EXP_LNKCTL_ASPM_L0S) link->aspm_enabled |= ASPM_STATE_L0S_DW; - link->latency_up.l0s = calc_l0s_latency(parent_lnkcap); - link->latency_dw.l0s = calc_l0s_latency(child_lnkcap); /* Setup L1 state */ if (parent_lnkcap & child_lnkcap & PCI_EXP_LNKCAP_ASPM_L1) @@ -602,8 +606,6 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) if (parent_lnkctl & child_lnkctl & PCI_EXP_LNKCTL_ASPM_L1) link->aspm_enabled |= ASPM_STATE_L1; - link->latency_up.l1 = calc_l1_latency(parent_lnkcap); - link->latency_dw.l1 = calc_l1_latency(child_lnkcap); /* Setup L1 substate */ pci_read_config_dword(parent, parent->l1ss + PCI_L1SS_CAP, From patchwork Fri Aug 13 22:36:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 12436309 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE018C432BE for ; Fri, 13 Aug 2021 22:36:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2A456109E for ; Fri, 13 Aug 2021 22:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235305AbhHMWgt (ORCPT ); Fri, 13 Aug 2021 18:36:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235079AbhHMWgp (ORCPT ); Fri, 13 Aug 2021 18:36:45 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55AB4C061756 for ; Fri, 13 Aug 2021 15:36:18 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id z9so15115620wrh.10 for ; Fri, 13 Aug 2021 15:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cGRy8+2gpcfbwlJlqEryHppKLbj1FR/g/l5DIPPEnkQ=; b=PHssimngDwlKLwQ8u9BVi7cVqg+qLyStl6s64yKFhto01dp5UhO6OOioGzfTikEUI2 gKmmplN+N7KDSohTuXrfhVKo21JwiAPlqiIk3n2BePRhHq1q1eZfUhKYi9/Nxi73S1QN 2iPL9dQvvdNpQ0UmxQAZVOj/zkrR36TANvGCC13w4Huylb0Ay6nRUAS2wKFBLy/LR3YM YiroFLVIsDl10EbH1fsRFCqxewf/2BuJLkZkTGtvwvI87soQBP0p9bQQQsfmvKBc9iok 2M3cgftpkozVy0MNHwAYJgJrWX9pg9tJDdBPEEaxq/gqCHlB63YDO2CroCAn5R1h+xR9 hl+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cGRy8+2gpcfbwlJlqEryHppKLbj1FR/g/l5DIPPEnkQ=; b=HOA8ipAwoD2OLwAE6H+xymy3Qx0alzjras+PnN77nMbR3eXHMLRhs1H2es5sly/Xi5 GRL1g+PCruRV6w1mjDNjH5dORnfmfQTv43kYN7fhxhf2KW968aWRLjmsXMjg05/anZHk 35Jw3d63ljPgwHoVF4rpd6IZtuqwONvS5UcTWjQltcopqRvTsFDM/GEYbDBZH7jLS/Ii KKL1g1Eq+tAMV45a8j5j9DfPB/8n3h764CBh0McRy/xa3KkziW9K4TL7QmmC1QVE9+60 Y6cPJt0Awt5p+jtR3LBhR3KC6VNHs7LIuQTFcVC7Ci0nPWwsW3GUOkF84WzdY1sPs6cF AODg== X-Gm-Message-State: AOAM533t+dsb2o2A8lBbr/o0StHCEyMLZBrPzLcRt9w91C2PWcmSBDVX NV3S/914PQ5cy4g9Mj78HReDDveeJFFldA== X-Google-Smtp-Source: ABdhPJwaqJMAqhWIgeljzFbzAqkMv0prMSDuOeLuvmC/6EHaUtHldV8oLK5RXPHCA1YIdPRDauSgrw== X-Received: by 2002:a5d:49c5:: with SMTP id t5mr71399wrs.161.1628894176719; Fri, 13 Aug 2021 15:36:16 -0700 (PDT) Received: from localhost.localdomain ([2a02:ab88:144:f570:b509:5224:f519:ca15]) by smtp.googlemail.com with ESMTPSA id 6sm2621028wmk.20.2021.08.13.15.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 15:36:16 -0700 (PDT) From: "Saheed O. Bolarinwa" To: linux-pci@vger.kernel.org Cc: "Saheed O. Bolarinwa" Subject: [RFC PATCH 2/3] PCI/ASPM: Remove struct pcie_link_state.acceptable Date: Sat, 14 Aug 2021 00:36:08 +0200 Message-Id: <20210813223610.8687-3-refactormyself@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813223610.8687-1-refactormyself@gmail.com> References: <20210813223610.8687-1-refactormyself@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Inside pcie_aspm_cap_init() the acceptable latencies for each device on the bus_list are calculated and cached in pcie_link_state->acceptable. These cached latencies are only used inside pcie_aspm_check_latency() which is called right after computing them. Computing these latencies right inside pcie_aspm_check_latency() where they are needed will remove the need for caching them without making any functional change. - Calculate the acceptable latency for each device directly inside pcie_aspm_check_latency() - Remove pcie_link_state->acceptable Signed-off-by: Saheed O. Bolarinwa --- drivers/pci/pcie/aspm.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 4c437b1345b2..b713a2c8040f 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -65,12 +65,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 */ - - /* - * 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; @@ -375,7 +369,7 @@ static void encode_l12_threshold(u32 threshold_us, u32 *scale, u32 *value) static void pcie_aspm_check_latency(struct pci_dev *endpoint) { - u32 latency, lnkcap_up, lnkcap_dw, l1_switch_latency = 0; + u32 reg32, latency, encoding, lnkcap_up, lnkcap_dw, l1_switch_latency = 0; struct aspm_latency latency_up, latency_dw; struct aspm_latency *acceptable; struct pcie_link_state *link; @@ -386,7 +380,13 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) return; link = endpoint->bus->self->link_state; - acceptable = &link->acceptable[PCI_FUNC(endpoint->devfn)]; + pcie_capability_read_dword(endpoint, PCI_EXP_DEVCAP, ®32); + /* Calculate endpoint L0s acceptable latency */ + encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; + acceptable->l0s = calc_l0s_acceptable(encoding); + /* Calculate endpoint L1 acceptable latency */ + encoding = (reg32 & PCI_EXP_DEVCAP_L1) >> 9; + acceptable->l1 = calc_l1_acceptable(encoding); while (link) { /* Read direction exit latencies */ @@ -662,22 +662,11 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) /* Get and check endpoint acceptable latencies */ list_for_each_entry(child, &linkbus->devices, bus_list) { - u32 reg32, encoding; - struct aspm_latency *acceptable = - &link->acceptable[PCI_FUNC(child->devfn)]; if (pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT && pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END) continue; - pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); - /* Calculate endpoint L0s acceptable latency */ - encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; - acceptable->l0s = calc_l0s_acceptable(encoding); - /* Calculate endpoint L1 acceptable latency */ - encoding = (reg32 & PCI_EXP_DEVCAP_L1) >> 9; - acceptable->l1 = calc_l1_acceptable(encoding); - pcie_aspm_check_latency(child); } } From patchwork Fri Aug 13 22:36:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 12436311 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C7B7C4338F for ; Fri, 13 Aug 2021 22:36:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E3C160241 for ; Fri, 13 Aug 2021 22:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235059AbhHMWgv (ORCPT ); Fri, 13 Aug 2021 18:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235213AbhHMWgu (ORCPT ); Fri, 13 Aug 2021 18:36:50 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6E1EC0617AD for ; Fri, 13 Aug 2021 15:36:19 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id f10so4660338wml.2 for ; Fri, 13 Aug 2021 15:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gQKL19PiE8Rrzwimt6iLEhRsa+5YO25zGGI/eXyJAyk=; b=O45BtnKnjLDRdA18XwPoR8usvx2VmJEJodkyD4GAot1esvb4gzhJ4ls0Jazdkar6tH 2V2eOHeSSwK3zFStjBMu4r+ePbz0mL0lssNP7rdVh1JRKxSE79P6R3gMOvsYRwWAUOW0 JISA/vP/wd9Y1id2EQkQ17zlYeL1X66S8wdVGkY8dfn7bKFOgbtV2ua8r676N9FagLTI KRG8mFomNVj2xM0AOY4Vt8EfXV40VzZ46geAUhS9HrkT1dkSX6dan5s8AuH6Sx0kHyWU 5Kz4B/IYNCX/heX5gR7AVry8QO/3z1wR/tOjgjvJIyT/47Q8ZPXlujFpxwdRsuRea7JY y7yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gQKL19PiE8Rrzwimt6iLEhRsa+5YO25zGGI/eXyJAyk=; b=CEJD1iuh8F5RY0B7fSE7P1d3RCm6ymVKk82mF+hGhZDsxD0pL8TJhN7KZyowaTbpw2 sfzsyEVfwu7BnLgf5EWEu0G92l1Sn5aENEBaxI723JQ6q2prJadq3qHvCpLBZf5JdTXh 0xzZMWWDrdCy34VudOvh8wvVw54vzy4lLl1RST9q4atLfrT0L39vfFBmHZUxwLiBGlQv B0lJLtsr9OTEW2ia0zuaRjmSrAroejOuhe7AXF2C0Z/UXsxcyMda1fbRjnFL981+tJzZ BGPoJALyieBui2Iaa1MRefOwWYgZwdsLsfjClKdl4tTCW3Ds+lOwYCiGlSbA53/Y0zNs dbWg== X-Gm-Message-State: AOAM532BR5vSS4KAYJoqLEDbHms2hfN9OcTJ/J6cPguXH+PriePbo53I CIfmoE3v2vJVrF1NIJxwUOcqX2oVd5W/Lg== X-Google-Smtp-Source: ABdhPJyaH+iYLuG7tvZ6Hmlp/Wk175qtkidjep4oXhPJffV7uFtqrvQU8tHig1RL+Lbj7gvGjsVURA== X-Received: by 2002:a1c:7503:: with SMTP id o3mr4767527wmc.129.1628894177614; Fri, 13 Aug 2021 15:36:17 -0700 (PDT) Received: from localhost.localdomain ([2a02:ab88:144:f570:b509:5224:f519:ca15]) by smtp.googlemail.com with ESMTPSA id 6sm2621028wmk.20.2021.08.13.15.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 15:36:17 -0700 (PDT) From: "Saheed O. Bolarinwa" To: linux-pci@vger.kernel.org Cc: "Saheed O. Bolarinwa" Subject: [RFC PATCH 3/3] PCI/ASPM: Remove struct aspm_latency Date: Sat, 14 Aug 2021 00:36:09 +0200 Message-Id: <20210813223610.8687-4-refactormyself@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813223610.8687-1-refactormyself@gmail.com> References: <20210813223610.8687-1-refactormyself@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The struct aspm_latency is now used only inside pcie_aspm_check_latency() Since this struct is trivial, it can be replaced with actual u32 variables within the function. This will not impact any functionality. - replace struct aspm_latency variables with u32 variables - Remove struct aspm_latency Signed-off-by: Saheed O. Bolarinwa --- drivers/pci/pcie/aspm.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index b713a2c8040f..7e5524b14127 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -41,11 +41,6 @@ #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1 | \ ASPM_STATE_L1SS) -struct aspm_latency { - u32 l0s; /* L0s latency (nsec) */ - u32 l1; /* L1 latency (nsec) */ -}; - struct pcie_link_state { struct pci_dev *pdev; /* Upstream component of the Link */ struct pci_dev *downstream; /* Downstream component, function 0 */ @@ -370,8 +365,8 @@ static void encode_l12_threshold(u32 threshold_us, u32 *scale, u32 *value) static void pcie_aspm_check_latency(struct pci_dev *endpoint) { u32 reg32, latency, encoding, lnkcap_up, lnkcap_dw, l1_switch_latency = 0; - struct aspm_latency latency_up, latency_dw; - struct aspm_latency *acceptable; + u32 latency_up_l0s, latency_up_l1, latency_dw_l0s, latency_dw_l1; + u32 acceptable_l0s, acceptable_l1; struct pcie_link_state *link; /* Device not in D0 doesn't need latency check */ @@ -383,28 +378,28 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) pcie_capability_read_dword(endpoint, PCI_EXP_DEVCAP, ®32); /* Calculate endpoint L0s acceptable latency */ encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; - acceptable->l0s = calc_l0s_acceptable(encoding); + acceptable_l0s = calc_l0s_acceptable(encoding); /* Calculate endpoint L1 acceptable latency */ encoding = (reg32 & PCI_EXP_DEVCAP_L1) >> 9; - acceptable->l1 = calc_l1_acceptable(encoding); + acceptable_l1 = calc_l1_acceptable(encoding); while (link) { /* Read direction exit latencies */ pcie_capability_read_dword(link->pdev, PCI_EXP_LNKCAP, &lnkcap_up); pcie_capability_read_dword(link->downstream, PCI_EXP_LNKCAP, &lnkcap_dw); - latency_up.l0s = calc_l0s_latency(lnkcap_up); - latency_up.l1 = calc_l1_latency(lnkcap_up); - latency_dw.l0s = calc_l0s_latency(lnkcap_dw); - latency_dw.l1 = calc_l1_latency(lnkcap_dw); + latency_up_l0s = calc_l0s_latency(lnkcap_up); + latency_up_l1 = calc_l1_latency(lnkcap_up); + latency_dw_l0s = calc_l0s_latency(lnkcap_dw); + latency_dw_l1 = calc_l1_latency(lnkcap_dw); /* Check upstream direction L0s latency */ if ((link->aspm_capable & ASPM_STATE_L0S_UP) && - (latency_up.l0s > acceptable->l0s)) + (latency_up_l0s > acceptable_l0s)) link->aspm_capable &= ~ASPM_STATE_L0S_UP; /* Check downstream direction L0s latency */ if ((link->aspm_capable & ASPM_STATE_L0S_DW) && - (latency_dw.l0s > acceptable->l0s)) + (latency_dw_l0s > acceptable_l0s)) link->aspm_capable &= ~ASPM_STATE_L0S_DW; /* * Check L1 latency. @@ -419,9 +414,9 @@ 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, latency_up.l1, latency_dw.l1); + latency = max_t(u32, latency_up_l1, latency_dw_l1); if ((link->aspm_capable & ASPM_STATE_L1) && - (latency + l1_switch_latency > acceptable->l1)) + (latency + l1_switch_latency > acceptable_l1)) link->aspm_capable &= ~ASPM_STATE_L1; l1_switch_latency += 1000; @@ -662,7 +657,6 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) /* Get and check endpoint acceptable latencies */ list_for_each_entry(child, &linkbus->devices, bus_list) { - if (pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT && pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END) continue;