Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp146103pxb; Tue, 28 Sep 2021 17:48:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5ZvOqtYhja/UzZqqih+p2cGNJkzMajMIfiU00RjWSVvhU4oUDZp271oKFL5DaLPsRqJAa X-Received: by 2002:a17:906:d1d1:: with SMTP id bs17mr10036004ejb.198.1632876515356; Tue, 28 Sep 2021 17:48:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632876515; cv=none; d=google.com; s=arc-20160816; b=zJCxtDbrIMbz4hTT3tSypQgrLe/wt66N34lwdOSC8xLjJdW+GGkU97y/5yuhcnK9aU McxFllKXht9F1bW0spQti7GzMGyb1sfNSBBpkKFihYQE/FtXvBBa5uelFdXd0KsJ2AdR cLBv+HvLXoHEB6DH/srk5mYlyml2MI6WR0oYbS+rGrfOIfQZbxCj2w2r022dcITnBZtK Y5GjtSfGXOcSR9FeA7XWypPALSiQcwH+mQURUh+eVY2kG1I7AE9HHxdHnHi5vLLpAkTP dY7OkDYcu6hCmVIkNLZXC/hTlOwgaoSQ1rn0j+B5AaAgvlWXcSfxwFACZd8WD/hzuKks 163A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l2b36K0VOEbskUSIYtzJAJSfMxT71VREguqbCSTPpWU=; b=izF9wE1lXkpG237LjO7cGqUDuxTrQVBdKpFgSS20Ol57iEe92gmtMZUG5Cl4Jw8x19 L/+qYKAV7cuOBtnYGALq+cIxVHCKdMwZ+y1nngJdsy2mhT9BcrZAJkNj8d7NqcQJ2iRL +kWiI7m0zrB2IMK8/Ab9J4AvQ2qMRxNgAKWBONzdlcjg80LrBx6dAMP6XvCFQth3Zvsk k9jW/qzxTKR4sQkIjDYhVMjTfkYrMinK2eekLPQx+ML/Mpzc0zjllJcHh4z2J/iEK6Fk kCUP9w+0lTgSbovWz7potgE3g0nG/WDGdnrGD93GDui7v9hij8qG+5FT+lavnU4lfA2Z dnEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KMfsKV9f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dg13si657117edb.604.2021.09.28.17.48.11; Tue, 28 Sep 2021 17:48:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KMfsKV9f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243584AbhI2Apy (ORCPT + 99 others); Tue, 28 Sep 2021 20:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243507AbhI2Apr (ORCPT ); Tue, 28 Sep 2021 20:45:47 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD6A4C061745; Tue, 28 Sep 2021 17:44:06 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id bd28so1894083edb.9; Tue, 28 Sep 2021 17:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l2b36K0VOEbskUSIYtzJAJSfMxT71VREguqbCSTPpWU=; b=KMfsKV9f+1N9bMaDc82Uc+u0pvOBjnmkVVkF6+KIujtFNDEowLMAgIJghV7+twAJxJ gkPokOGez6K09iirfblMhnu9qfdiEpEL2qdWDz0PWPsoA1EKNJGpMePf0MV3UMPaOFvz cBWhJKEBi4CcG4GraxAIN/KA6ZLh9jJTONYCrHLwsHEI7yTAZG1gQZD+I22HQCVd/uVt if2JQvxjPKYnbCxglwgaABxq/tfMeh+J5pGdIwRW0RYFyktw/EolDRrpSFT2w2DGvuoN OxDeUA9KXh362WWzkeKnRvoNYSncU5VT+W9K6FEePDLOyd26dRdMhzRasylrc/0RPasr YYqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l2b36K0VOEbskUSIYtzJAJSfMxT71VREguqbCSTPpWU=; b=o0dzRkpg9plHb8FjyR/MT2ilQsfGBdHUkqBvd8GmznrEk6PdeBHv6UZccYeIfXmhSD mjsd6wu+i4jWaAM/KsAlhZFkQ9qfq1Y3KVVyv1matptXQJZfPf5QRadlNZDWcmzLaZlO tzKD3F+AIK2ifwpqigUg9I1TlQ2F2tLtWG30c8gGuJRV0ngBx0PZttUPRQV53/UQRy8p 2iqqLMDdxdzgrWUyR8WXHxGntEL7doZq78+/9AMnGMYnel5JYsECo58hpKx40M8EG3SB A8sOKk/NV+h2xhxhU4gwHljbLbNkrpggJb0BN8DYaSybjJf/eZ05qzYtns/7ZK+n5I+E pvNg== X-Gm-Message-State: AOAM531FTwfmn2HZtqD7zWFLhOAN3yn9FXhu8HnAptk4YOtDzGTfRSxQ SvEauTY+155MSGkB7J4ETQoR4Cy5yII= X-Received: by 2002:a50:d90b:: with SMTP id t11mr11789788edj.32.1632876245475; Tue, 28 Sep 2021 17:44:05 -0700 (PDT) Received: from localhost.localdomain ([2a02:ab88:10f:c9f0:35c7:3af0:a197:61d0]) by smtp.googlemail.com with ESMTPSA id r19sm383578edt.54.2021.09.28.17.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 17:44:05 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org Cc: "Bolarinwa O. Saheed" , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 1/4] [PCI/ASPM:] Remove struct pcie_link_state.clkpm_default Date: Wed, 29 Sep 2021 02:43:57 +0200 Message-Id: <20210929004400.25717-2-refactormyself@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210929004400.25717-1-refactormyself@gmail.com> References: <20210929004400.25717-1-refactormyself@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Bolarinwa O. Saheed" The clkpm_default member of the struct pcie_link_state stores the value of the default clkpm state as it is in the BIOS. This patch: - Removes clkpm_default from struct pcie_link_state - Creates pcie_get_clkpm_state() which return the clkpm state obtained the BIOS - Replaces references to clkpm_default with call to pcie_get_clkpm_state() Signed-off-by: Bolarinwa O. Saheed --- drivers/pci/pcie/aspm.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 013a47f587ce..c23da9a4e2fb 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -63,7 +63,6 @@ struct pcie_link_state { /* Clock PM state */ u32 clkpm_capable:1; /* Clock PM capable? */ 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 */ @@ -123,6 +122,30 @@ static int policy_to_aspm_state(struct pcie_link_state *link) return 0; } +static int pcie_get_clkpm_state(struct pci_dev *pdev) +{ + int enabled = 1; + u32 reg32; + u16 reg16; + struct pci_dev *child; + struct pci_bus *linkbus = pdev->subordinate; + + /* All functions should have the same clkpm state, take the worst */ + list_for_each_entry(child, &linkbus->devices, bus_list) { + pcie_capability_read_dword(child, PCI_EXP_LNKCAP, ®32); + if (!(reg32 & PCI_EXP_LNKCAP_CLKPM)) { + enabled = 0; + break; + } + + pcie_capability_read_word(child, PCI_EXP_LNKCTL, ®16); + if (!(reg16 & PCI_EXP_LNKCTL_CLKREQ_EN)) + enabled = 0; + } + + return enabled; +} + static int policy_to_clkpm_state(struct pcie_link_state *link) { switch (aspm_policy) { @@ -134,7 +157,7 @@ static int policy_to_clkpm_state(struct pcie_link_state *link) /* Enable Clock PM */ return 1; case POLICY_DEFAULT: - return link->clkpm_default; + return pcie_get_clkpm_state(link->pdev); } return 0; } @@ -168,9 +191,8 @@ static void pcie_set_clkpm(struct pcie_link_state *link, int enable) static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) { - int capable = 1, enabled = 1; + int capable = 1; u32 reg32; - u16 reg16; struct pci_dev *child; struct pci_bus *linkbus = link->pdev->subordinate; @@ -179,15 +201,10 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) pcie_capability_read_dword(child, PCI_EXP_LNKCAP, ®32); if (!(reg32 & PCI_EXP_LNKCAP_CLKPM)) { capable = 0; - enabled = 0; break; } - pcie_capability_read_word(child, PCI_EXP_LNKCTL, ®16); - if (!(reg16 & PCI_EXP_LNKCTL_CLKREQ_EN)) - enabled = 0; } - link->clkpm_enabled = enabled; - link->clkpm_default = enabled; + link->clkpm_enabled = pcie_get_clkpm_state(link->pdev); link->clkpm_capable = capable; link->clkpm_disable = blacklist ? 1 : 0; } -- 2.20.1