From: "David E. Box" <david.e.box@linux.intel.com>
To: david.e.box@intel.com, hdegoede@redhat.com,
ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
rjw@rjwysocki.net
Subject: [PATCH] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend
Date: Tue, 1 Oct 2024 15:58:59 -0700 [thread overview]
Message-ID: <20241001225901.135564-1-david.e.box@linux.intel.com> (raw)
On some platforms, aggressive C1 auto-demotion may lead to failure to enter
the deepest C-state during suspend-to-idle, causing high power consumption.
To prevent this, disable C1 auto-demotion during suspend and re-enable on
resume.
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
drivers/platform/x86/intel/pmc/arl.c | 3 +--
drivers/platform/x86/intel/pmc/cnp.c | 28 +++++++++++++++++++++++++++-
drivers/platform/x86/intel/pmc/lnl.c | 3 +--
drivers/platform/x86/intel/pmc/mtl.c | 3 +--
4 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/x86/intel/pmc/arl.c b/drivers/platform/x86/intel/pmc/arl.c
index e10527c4e3e0..05dec4f5019f 100644
--- a/drivers/platform/x86/intel/pmc/arl.c
+++ b/drivers/platform/x86/intel/pmc/arl.c
@@ -687,9 +687,8 @@ static void arl_d3_fixup(void)
static int arl_resume(struct pmc_dev *pmcdev)
{
arl_d3_fixup();
- pmc_core_send_ltr_ignore(pmcdev, 3, 0);
- return pmc_core_resume_common(pmcdev);
+ return cnl_resume(pmcdev);
}
int arl_core_init(struct pmc_dev *pmcdev)
diff --git a/drivers/platform/x86/intel/pmc/cnp.c b/drivers/platform/x86/intel/pmc/cnp.c
index 513c02670c5a..5b8b3ac7f061 100644
--- a/drivers/platform/x86/intel/pmc/cnp.c
+++ b/drivers/platform/x86/intel/pmc/cnp.c
@@ -7,7 +7,8 @@
* All Rights Reserved.
*
*/
-
+#define DEBUG
+#include <linux/suspend.h>
#include "core.h"
/* Cannon Lake: PGD PFET Enable Ack Status Register(s) bitmap */
@@ -206,8 +207,24 @@ const struct pmc_reg_map cnp_reg_map = {
.etr3_offset = ETR3_OFFSET,
};
+
+static DEFINE_PER_CPU(u64, pkg_cst_config);
+
void cnl_suspend(struct pmc_dev *pmcdev)
{
+ if (!pm_suspend_via_firmware()) {
+ u64 val;
+ int cpunum;
+
+ for_each_online_cpu(cpunum) {
+ rdmsrl_on_cpu(cpunum, MSR_PKG_CST_CONFIG_CONTROL, &val);
+ per_cpu(pkg_cst_config, cpunum) = val;
+ val &= ~NHM_C1_AUTO_DEMOTE;
+ wrmsrl_on_cpu(cpunum, MSR_PKG_CST_CONFIG_CONTROL, val);
+ pr_debug("%s: cpu:%d cst %llx\n", __func__, cpunum, val);
+ }
+ }
+
/*
* Due to a hardware limitation, the GBE LTR blocks PC10
* when a cable is attached. To unblock PC10 during suspend,
@@ -220,6 +237,15 @@ int cnl_resume(struct pmc_dev *pmcdev)
{
pmc_core_send_ltr_ignore(pmcdev, 3, 0);
+ if (!pm_suspend_via_firmware()) {
+ int cpunum;
+
+ for_each_online_cpu(cpunum) {
+ pr_debug("%s: cpu:%d cst %llx\n", __func__, cpunum, per_cpu(pkg_cst_config, cpunum));
+ wrmsrl_on_cpu(cpunum, MSR_PKG_CST_CONFIG_CONTROL, per_cpu(pkg_cst_config, cpunum));
+ }
+ }
+
return pmc_core_resume_common(pmcdev);
}
diff --git a/drivers/platform/x86/intel/pmc/lnl.c b/drivers/platform/x86/intel/pmc/lnl.c
index e7a8077d1a3e..be029f12cdf4 100644
--- a/drivers/platform/x86/intel/pmc/lnl.c
+++ b/drivers/platform/x86/intel/pmc/lnl.c
@@ -546,9 +546,8 @@ static void lnl_d3_fixup(void)
static int lnl_resume(struct pmc_dev *pmcdev)
{
lnl_d3_fixup();
- pmc_core_send_ltr_ignore(pmcdev, 3, 0);
- return pmc_core_resume_common(pmcdev);
+ return cnl_resume(pmcdev);
}
int lnl_core_init(struct pmc_dev *pmcdev)
diff --git a/drivers/platform/x86/intel/pmc/mtl.c b/drivers/platform/x86/intel/pmc/mtl.c
index 91f2fa728f5c..fc6a89b8979f 100644
--- a/drivers/platform/x86/intel/pmc/mtl.c
+++ b/drivers/platform/x86/intel/pmc/mtl.c
@@ -988,9 +988,8 @@ static void mtl_d3_fixup(void)
static int mtl_resume(struct pmc_dev *pmcdev)
{
mtl_d3_fixup();
- pmc_core_send_ltr_ignore(pmcdev, 3, 0);
- return pmc_core_resume_common(pmcdev);
+ return cnl_resume(pmcdev);
}
int mtl_core_init(struct pmc_dev *pmcdev)
--
2.43.0
next reply other threads:[~2024-10-01 22:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 22:58 David E. Box [this message]
2024-10-02 3:11 ` [PATCH] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend Mario Limonciello
2024-10-02 3:51 ` David E. Box
2024-10-02 8:52 ` Ilpo Järvinen
2024-10-03 11:14 ` Ilpo Järvinen
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=20241001225901.135564-1-david.e.box@linux.intel.com \
--to=david.e.box@linux.intel.com \
--cc=david.e.box@intel.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/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