Skip to content

Commit e4aa475

Browse files
committed
Merge: platform/x86/intel/pmc: Disable C1 auto-demotion during suspend - blocks s0ix
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/126 Description: updates for platform/x86/intel/pmc: to disable C1 auto-demotion during suspend - blocks s0ix JIRA: https://issues.redhat.com/browse/RHEL-66570 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=66317330 Tested: Successful platform test results on Intel (intel-meteorlake-p-h-01) system. Signed-off-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 695b1ef + 5826dcf commit e4aa475

File tree

4 files changed

+56
-6
lines changed

4 files changed

+56
-6
lines changed

drivers/platform/x86/intel/pmc/arl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,8 @@ static void arl_d3_fixup(void)
687687
static int arl_resume(struct pmc_dev *pmcdev)
688688
{
689689
arl_d3_fixup();
690-
pmc_core_send_ltr_ignore(pmcdev, 3, 0);
691690

692-
return pmc_core_resume_common(pmcdev);
691+
return cnl_resume(pmcdev);
693692
}
694693

695694
int arl_core_init(struct pmc_dev *pmcdev)

drivers/platform/x86/intel/pmc/cnp.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
*
99
*/
1010

11+
#include <linux/smp.h>
12+
#include <linux/suspend.h>
1113
#include "core.h"
1214

1315
/* Cannon Lake: PGD PFET Enable Ack Status Register(s) bitmap */
@@ -204,8 +206,57 @@ const struct pmc_reg_map cnp_reg_map = {
204206
.etr3_offset = ETR3_OFFSET,
205207
};
206208

209+
210+
/*
211+
* Disable C1 auto-demotion
212+
*
213+
* Aggressive C1 auto-demotion may lead to failure to enter the deepest C-state
214+
* during suspend-to-idle, causing high power consumption. To prevent this, we
215+
* disable C1 auto-demotion during suspend and re-enable on resume.
216+
*
217+
* Note that, although MSR_PKG_CST_CONFIG_CONTROL has 'package' in its name, it
218+
* is actually a per-core MSR on client platforms, affecting only a single CPU.
219+
* Therefore, it must be configured on all online CPUs. The online cpu mask is
220+
* unchanged during the phase of suspend/resume as user space is frozen.
221+
*/
222+
223+
static DEFINE_PER_CPU(u64, pkg_cst_config);
224+
225+
static void disable_c1_auto_demote(void *unused)
226+
{
227+
int cpunum = smp_processor_id();
228+
u64 val;
229+
230+
rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, val);
231+
per_cpu(pkg_cst_config, cpunum) = val;
232+
val &= ~NHM_C1_AUTO_DEMOTE;
233+
wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, val);
234+
235+
pr_debug("%s: cpu:%d cst %llx\n", __func__, cpunum, val);
236+
}
237+
238+
static void restore_c1_auto_demote(void *unused)
239+
{
240+
int cpunum = smp_processor_id();
241+
242+
wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, per_cpu(pkg_cst_config, cpunum));
243+
244+
pr_debug("%s: cpu:%d cst %llx\n", __func__, cpunum,
245+
per_cpu(pkg_cst_config, cpunum));
246+
}
247+
248+
static void s2idle_cpu_quirk(smp_call_func_t func)
249+
{
250+
if (pm_suspend_via_firmware())
251+
return;
252+
253+
on_each_cpu(func, NULL, true);
254+
}
255+
207256
void cnl_suspend(struct pmc_dev *pmcdev)
208257
{
258+
s2idle_cpu_quirk(disable_c1_auto_demote);
259+
209260
/*
210261
* Due to a hardware limitation, the GBE LTR blocks PC10
211262
* when a cable is attached. To unblock PC10 during suspend,
@@ -216,6 +267,8 @@ void cnl_suspend(struct pmc_dev *pmcdev)
216267

217268
int cnl_resume(struct pmc_dev *pmcdev)
218269
{
270+
s2idle_cpu_quirk(restore_c1_auto_demote);
271+
219272
pmc_core_send_ltr_ignore(pmcdev, 3, 0);
220273

221274
return pmc_core_resume_common(pmcdev);

drivers/platform/x86/intel/pmc/lnl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,8 @@ static void lnl_d3_fixup(void)
546546
static int lnl_resume(struct pmc_dev *pmcdev)
547547
{
548548
lnl_d3_fixup();
549-
pmc_core_send_ltr_ignore(pmcdev, 3, 0);
550549

551-
return pmc_core_resume_common(pmcdev);
550+
return cnl_resume(pmcdev);
552551
}
553552

554553
int lnl_core_init(struct pmc_dev *pmcdev)

drivers/platform/x86/intel/pmc/mtl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,9 +986,8 @@ static void mtl_d3_fixup(void)
986986
static int mtl_resume(struct pmc_dev *pmcdev)
987987
{
988988
mtl_d3_fixup();
989-
pmc_core_send_ltr_ignore(pmcdev, 3, 0);
990989

991-
return pmc_core_resume_common(pmcdev);
990+
return cnl_resume(pmcdev);
992991
}
993992

994993
int mtl_core_init(struct pmc_dev *pmcdev)

0 commit comments

Comments
 (0)