linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: bhelgaas@google.com
Cc: hkallweit1@gmail.com, anthony.wong@canonical.com,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Kai-Heng Feng" <kai.heng.feng@canonical.com>,
	"Logan Gunthorpe" <logang@deltatee.com>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Vidya Sagar" <vidyas@nvidia.com>
Subject: [PATCH v2 2/3] PCI/ASPM: Use capability to override ASPM via sysfs
Date: Thu, 21 Oct 2021 11:51:58 +0800	[thread overview]
Message-ID: <20211021035159.1117456-3-kai.heng.feng@canonical.com> (raw)
In-Reply-To: <20211021035159.1117456-1-kai.heng.feng@canonical.com>

If we are to use sysfs to change ASPM settings, we may want to override
the default ASPM policy.

So use ASPM capability, instead of default policy, to be able to use all
possible ASPM states.

Upon power management change, pcie_aspm_pm_state_change() always
re-apply the state from global ASPM policy, so also introduce a new flag
to make the sysfs change persistent.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v2:
 - Add flag to make ASPM change persistent

 drivers/pci/pcie/aspm.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 30b1bc899026..1560859ab056 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -60,6 +60,8 @@ struct pcie_link_state {
 	u32 aspm_default:7;		/* Default ASPM state by BIOS */
 	u32 aspm_disable:7;		/* Disabled ASPM state */
 
+	bool aspm_ignore_policy;	/* Ignore ASPM policy after sysfs overwrite */
+
 	/* Clock PM state */
 	u32 clkpm_capable:1;		/* Clock PM capable? */
 	u32 clkpm_enabled:1;		/* Current Clock PM state */
@@ -796,7 +798,8 @@ static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state)
 static void pcie_config_aspm_path(struct pcie_link_state *link)
 {
 	while (link) {
-		pcie_config_aspm_link(link, policy_to_aspm_state(link));
+		pcie_config_aspm_link(link, link->aspm_ignore_policy ?
+				      link->aspm_capable : policy_to_aspm_state(link));
 		link = link->parent;
 	}
 }
@@ -1238,8 +1241,8 @@ static ssize_t aspm_attr_store_common(struct device *dev,
 
 		link->aspm_disable |= state;
 	}
-
-	pcie_config_aspm_link(link, policy_to_aspm_state(link));
+	pcie_config_aspm_link(link, link->aspm_capable);
+	link->aspm_ignore_policy = true;
 
 	mutex_unlock(&aspm_lock);
 	up_read(&pci_bus_sem);
-- 
2.32.0


  parent reply	other threads:[~2021-10-21  3:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21  3:51 [PATCH v2 0/3] Let user enable ASPM and LTR via sysfs Kai-Heng Feng
2021-10-21  3:51 ` [PATCH v2 1/3] PCI/ASPM: Store disabled ASPM states Kai-Heng Feng
2021-10-21  3:51 ` Kai-Heng Feng [this message]
2021-10-21  3:51 ` [PATCH v2 3/3] PCI/ASPM: Add LTR sysfs attributes Kai-Heng Feng
2021-10-21 15:09   ` Bjorn Helgaas
2021-10-25 10:33     ` Kai-Heng Feng
2021-10-25 17:31       ` Bjorn Helgaas
2021-10-26  2:28         ` Kai-Heng Feng
2021-10-26 16:53           ` Bjorn Helgaas
2021-10-28  5:16             ` Kai-Heng Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211021035159.1117456-3-kai.heng.feng@canonical.com \
    --to=kai.heng.feng@canonical.com \
    --cc=anthony.wong@canonical.com \
    --cc=bhelgaas@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=vidyas@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).