* [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume()
@ 2024-10-17 21:04 David E. Box
2024-10-17 21:04 ` [PATCH V3 2/2] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend David E. Box
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: David E. Box @ 2024-10-17 21:04 UTC (permalink / raw)
To: david.e.box, hdegoede, ilpo.jarvinen, platform-driver-x86,
linux-kernel, linux-pm, rjw, srinivas.pandruvada
Several platform resume functions currently call pmc_core_send_ltr_ignore()
and pmc_core_resume_common(), both of which are already called by
cnl_resume(). Simplify the code by having these functions call cnl_resume()
directly.
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
V3 - no change
V2 - New patch. Split from V1
drivers/platform/x86/intel/pmc/arl.c | 3 +--
drivers/platform/x86/intel/pmc/lnl.c | 3 +--
drivers/platform/x86/intel/pmc/mtl.c | 3 +--
3 files changed, 3 insertions(+), 6 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/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)
base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V3 2/2] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend
2024-10-17 21:04 [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume() David E. Box
@ 2024-10-17 21:04 ` David E. Box
2024-10-18 15:58 ` Rafael J. Wysocki
2024-10-18 15:51 ` [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume() Rafael J. Wysocki
2024-10-22 8:57 ` Ilpo Järvinen
2 siblings, 1 reply; 5+ messages in thread
From: David E. Box @ 2024-10-17 21:04 UTC (permalink / raw)
To: david.e.box, hdegoede, ilpo.jarvinen, platform-driver-x86,
linux-kernel, linux-pm, rjw, srinivas.pandruvada,
ricardo.neri-calderon
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>
---
V3 - Use s2idle wrapper function suggested by Rafael
- Use on_each_cpu() suggested by Ricardo
V2 - Remove #define DEBUG
- Move refactor of cnl_resume() to separate patch
- Use smp_call_function() to disable and restore C1_AUTO_DEMOTE
- Add comment that the MSR is per core, not per package.
- Add comment that the online cpu mask remains unchanged during
suspend due to frozen userspace.
drivers/platform/x86/intel/pmc/cnp.c | 53 ++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/drivers/platform/x86/intel/pmc/cnp.c b/drivers/platform/x86/intel/pmc/cnp.c
index 513c02670c5a..3eaad2a7ebf4 100644
--- a/drivers/platform/x86/intel/pmc/cnp.c
+++ b/drivers/platform/x86/intel/pmc/cnp.c
@@ -8,6 +8,8 @@
*
*/
+#include <linux/smp.h>
+#include <linux/suspend.h>
#include "core.h"
/* Cannon Lake: PGD PFET Enable Ack Status Register(s) bitmap */
@@ -206,8 +208,57 @@ const struct pmc_reg_map cnp_reg_map = {
.etr3_offset = ETR3_OFFSET,
};
+
+/*
+ * Disable C1 auto-demotion
+ *
+ * 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, we
+ * disable C1 auto-demotion during suspend and re-enable on resume.
+ *
+ * Note that, although MSR_PKG_CST_CONFIG_CONTROL has 'package' in its name, it
+ * is actually a per-core MSR on client platforms, affecting only a single CPU.
+ * Therefore, it must be configured on all online CPUs. The online cpu mask is
+ * unchanged during the phase of suspend/resume as user space is frozen.
+ */
+
+static DEFINE_PER_CPU(u64, pkg_cst_config);
+
+static void disable_c1_auto_demote(void *unused)
+{
+ int cpunum = smp_processor_id();
+ u64 val;
+
+ rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, val);
+ per_cpu(pkg_cst_config, cpunum) = val;
+ val &= ~NHM_C1_AUTO_DEMOTE;
+ wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, val);
+
+ pr_debug("%s: cpu:%d cst %llx\n", __func__, cpunum, val);
+}
+
+static void restore_c1_auto_demote(void *unused)
+{
+ int cpunum = smp_processor_id();
+
+ wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, per_cpu(pkg_cst_config, cpunum));
+
+ pr_debug("%s: cpu:%d cst %llx\n", __func__, cpunum,
+ per_cpu(pkg_cst_config, cpunum));
+}
+
+static void s2idle_cpu_quirk(smp_call_func_t func)
+{
+ if (pm_suspend_via_firmware())
+ return;
+
+ on_each_cpu(func, NULL, true);
+}
+
void cnl_suspend(struct pmc_dev *pmcdev)
{
+ s2idle_cpu_quirk(disable_c1_auto_demote);
+
/*
* Due to a hardware limitation, the GBE LTR blocks PC10
* when a cable is attached. To unblock PC10 during suspend,
@@ -218,6 +269,8 @@ void cnl_suspend(struct pmc_dev *pmcdev)
int cnl_resume(struct pmc_dev *pmcdev)
{
+ s2idle_cpu_quirk(restore_c1_auto_demote);
+
pmc_core_send_ltr_ignore(pmcdev, 3, 0);
return pmc_core_resume_common(pmcdev);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume()
2024-10-17 21:04 [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume() David E. Box
2024-10-17 21:04 ` [PATCH V3 2/2] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend David E. Box
@ 2024-10-18 15:51 ` Rafael J. Wysocki
2024-10-22 8:57 ` Ilpo Järvinen
2 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2024-10-18 15:51 UTC (permalink / raw)
To: David E. Box
Cc: david.e.box, hdegoede, ilpo.jarvinen, platform-driver-x86,
linux-kernel, linux-pm, rjw, srinivas.pandruvada
On Thu, Oct 17, 2024 at 11:04 PM David E. Box
<david.e.box@linux.intel.com> wrote:
>
> Several platform resume functions currently call pmc_core_send_ltr_ignore()
> and pmc_core_resume_common(), both of which are already called by
> cnl_resume(). Simplify the code by having these functions call cnl_resume()
> directly.
>
> Signed-off-by: David E. Box <david.e.box@linux.intel.com>
> ---
> V3 - no change
>
> V2 - New patch. Split from V1
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> drivers/platform/x86/intel/pmc/arl.c | 3 +--
> drivers/platform/x86/intel/pmc/lnl.c | 3 +--
> drivers/platform/x86/intel/pmc/mtl.c | 3 +--
> 3 files changed, 3 insertions(+), 6 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/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)
>
> base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V3 2/2] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend
2024-10-17 21:04 ` [PATCH V3 2/2] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend David E. Box
@ 2024-10-18 15:58 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2024-10-18 15:58 UTC (permalink / raw)
To: David E. Box
Cc: david.e.box, hdegoede, ilpo.jarvinen, platform-driver-x86,
linux-kernel, linux-pm, rjw, srinivas.pandruvada,
ricardo.neri-calderon
On Thu, Oct 17, 2024 at 11:04 PM David E. Box
<david.e.box@linux.intel.com> wrote:
>
> 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>
> ---
> V3 - Use s2idle wrapper function suggested by Rafael
> - Use on_each_cpu() suggested by Ricardo
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> V2 - Remove #define DEBUG
> - Move refactor of cnl_resume() to separate patch
> - Use smp_call_function() to disable and restore C1_AUTO_DEMOTE
> - Add comment that the MSR is per core, not per package.
> - Add comment that the online cpu mask remains unchanged during
> suspend due to frozen userspace.
>
> drivers/platform/x86/intel/pmc/cnp.c | 53 ++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/drivers/platform/x86/intel/pmc/cnp.c b/drivers/platform/x86/intel/pmc/cnp.c
> index 513c02670c5a..3eaad2a7ebf4 100644
> --- a/drivers/platform/x86/intel/pmc/cnp.c
> +++ b/drivers/platform/x86/intel/pmc/cnp.c
> @@ -8,6 +8,8 @@
> *
> */
>
> +#include <linux/smp.h>
> +#include <linux/suspend.h>
> #include "core.h"
>
> /* Cannon Lake: PGD PFET Enable Ack Status Register(s) bitmap */
> @@ -206,8 +208,57 @@ const struct pmc_reg_map cnp_reg_map = {
> .etr3_offset = ETR3_OFFSET,
> };
>
> +
> +/*
> + * Disable C1 auto-demotion
> + *
> + * 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, we
> + * disable C1 auto-demotion during suspend and re-enable on resume.
> + *
> + * Note that, although MSR_PKG_CST_CONFIG_CONTROL has 'package' in its name, it
> + * is actually a per-core MSR on client platforms, affecting only a single CPU.
> + * Therefore, it must be configured on all online CPUs. The online cpu mask is
> + * unchanged during the phase of suspend/resume as user space is frozen.
> + */
> +
> +static DEFINE_PER_CPU(u64, pkg_cst_config);
> +
> +static void disable_c1_auto_demote(void *unused)
> +{
> + int cpunum = smp_processor_id();
> + u64 val;
> +
> + rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, val);
> + per_cpu(pkg_cst_config, cpunum) = val;
> + val &= ~NHM_C1_AUTO_DEMOTE;
> + wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, val);
> +
> + pr_debug("%s: cpu:%d cst %llx\n", __func__, cpunum, val);
> +}
> +
> +static void restore_c1_auto_demote(void *unused)
> +{
> + int cpunum = smp_processor_id();
> +
> + wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, per_cpu(pkg_cst_config, cpunum));
> +
> + pr_debug("%s: cpu:%d cst %llx\n", __func__, cpunum,
> + per_cpu(pkg_cst_config, cpunum));
> +}
> +
> +static void s2idle_cpu_quirk(smp_call_func_t func)
> +{
> + if (pm_suspend_via_firmware())
> + return;
> +
> + on_each_cpu(func, NULL, true);
> +}
> +
> void cnl_suspend(struct pmc_dev *pmcdev)
> {
> + s2idle_cpu_quirk(disable_c1_auto_demote);
> +
> /*
> * Due to a hardware limitation, the GBE LTR blocks PC10
> * when a cable is attached. To unblock PC10 during suspend,
> @@ -218,6 +269,8 @@ void cnl_suspend(struct pmc_dev *pmcdev)
>
> int cnl_resume(struct pmc_dev *pmcdev)
> {
> + s2idle_cpu_quirk(restore_c1_auto_demote);
> +
> pmc_core_send_ltr_ignore(pmcdev, 3, 0);
>
> return pmc_core_resume_common(pmcdev);
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume()
2024-10-17 21:04 [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume() David E. Box
2024-10-17 21:04 ` [PATCH V3 2/2] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend David E. Box
2024-10-18 15:51 ` [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume() Rafael J. Wysocki
@ 2024-10-22 8:57 ` Ilpo Järvinen
2 siblings, 0 replies; 5+ messages in thread
From: Ilpo Järvinen @ 2024-10-22 8:57 UTC (permalink / raw)
To: david.e.box, hdegoede, platform-driver-x86, linux-kernel,
linux-pm, rjw, srinivas.pandruvada, David E. Box
On Thu, 17 Oct 2024 14:04:37 -0700, David E. Box wrote:
> Several platform resume functions currently call pmc_core_send_ltr_ignore()
> and pmc_core_resume_common(), both of which are already called by
> cnl_resume(). Simplify the code by having these functions call cnl_resume()
> directly.
>
>
Thank you for your contribution, it has been applied to my local
review-ilpo branch. Note it will show up in the public
platform-drivers-x86/review-ilpo branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume()
commit: 9fe43c8020a60b9c9ff44c4a9914e7e7df63084e
[2/2] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend
commit: 7a797cc9f80915cc5f1a5aee46d14880eb444644
--
i.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-22 8:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-17 21:04 [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume() David E. Box
2024-10-17 21:04 ` [PATCH V3 2/2] platform/x86/intel/pmc: Disable C1 auto-demotion during suspend David E. Box
2024-10-18 15:58 ` Rafael J. Wysocki
2024-10-18 15:51 ` [PATCH V3 1/2] platform/x86/intel/pmc: Refactor platform resume functions to use cnl_resume() Rafael J. Wysocki
2024-10-22 8:57 ` Ilpo Järvinen
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).