From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH for-4.22 v2 2/8] x86/mwait-idle: clean up BYT/CHT auto demotion disable
Date: Tue, 12 May 2026 17:36:06 +0200 [thread overview]
Message-ID: <aa14f45e-44fa-4cfc-8c51-d48548d55f3a@suse.com> (raw)
In-Reply-To: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com>
Bay Trail (BYT) and Cherry Trail (CHT) platforms have a very specific way
of disabling auto-demotion via specific MSR bits. Clean up the code so that
BYT/CHT-specifics do not show up in the common 'struct idle_cpu' data
structure.
Remove the 'byt_auto_demotion_disable_flag' flag from 'struct idle_cpu',
because a better coding pattern is to avoid very case-specific fields like
'bool byt_auto_demotion_disable_flag' in a common data structure, which is
used for all platforms, not only BYT/CHT. The code is just more readable
when common data structures contain only commonly used fields.
Instead, match BYT/CHT in the 'intel_idle_init_cstates_icpu()' function,
and introduce a small helper to take care of BYT/CHT auto-demotion. This
is consistent with how platform-specific things are done for other
platforms.
No intended functional changes.
Inspired by (and description largely taken from) Linux'es c93d13b661a6
("intel_idle: clean up BYT/CHT auto demotion disable").
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Init "first" to "true" in mwait_idle_cpu_init().
--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -103,7 +103,6 @@ struct idle_cpu {
* Indicate which enable bits to clear here.
*/
unsigned long auto_demotion_disable_flags;
- bool byt_auto_demotion_disable_flag;
enum c1e_promotion c1e_promotion;
};
@@ -1144,7 +1143,7 @@ static void cf_check auto_demotion_disab
wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits);
}
-static void cf_check byt_auto_demotion_disable(void *dummy)
+static void byt_cht_auto_demotion_disable(void)
{
wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0);
wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0);
@@ -1195,13 +1194,11 @@ static const struct idle_cpu idle_cpu_sn
static const struct idle_cpu idle_cpu_byt = {
.state_table = byt_cstates,
.c1e_promotion = C1E_PROMOTION_DISABLE,
- .byt_auto_demotion_disable_flag = true,
};
static const struct idle_cpu idle_cpu_cht = {
.state_table = cht_cstates,
.c1e_promotion = C1E_PROMOTION_DISABLE,
- .byt_auto_demotion_disable_flag = true,
};
static const struct idle_cpu idle_cpu_ivb = {
@@ -1677,14 +1674,11 @@ static int __init mwait_idle_probe(void)
return 0;
}
-static void mwait_idle_cpu_tweak(unsigned int cpu)
+static void mwait_idle_cpu_tweak(unsigned int cpu, bool bsp)
{
if (icpu->auto_demotion_disable_flags)
on_selected_cpus(cpumask_of(cpu), auto_demotion_disable, NULL, 1);
- if (icpu->byt_auto_demotion_disable_flag)
- on_selected_cpus(cpumask_of(cpu), byt_auto_demotion_disable, NULL, 1);
-
switch (icpu->c1e_promotion) {
case C1E_PROMOTION_DISABLE:
on_selected_cpus(cpumask_of(cpu), c1e_promotion_disable, NULL, 1);
@@ -1697,12 +1691,24 @@ static void mwait_idle_cpu_tweak(unsigne
case C1E_PROMOTION_PRESERVE:
break;
}
+
+ /* Pkg-scope MSRs on 1-socket-only systems need writing only once. */
+ if (!bsp)
+ return;
+
+ switch (boot_cpu_data.vfm) {
+ case INTEL_ATOM_SILVERMONT:
+ case INTEL_ATOM_AIRMONT:
+ byt_cht_auto_demotion_disable();
+ break;
+ }
}
static int cf_check mwait_idle_cpu_init(
struct notifier_block *nfb, unsigned long action, void *hcpu)
{
unsigned int cpu = (unsigned long)hcpu, cstate;
+ static bool first = true;
struct acpi_processor_power *dev = processor_powers[cpu];
switch (action) {
@@ -1781,7 +1787,8 @@ static int cf_check mwait_idle_cpu_init(
dev->count++;
}
- mwait_idle_cpu_tweak(cpu);
+ mwait_idle_cpu_tweak(cpu, first);
+ first = false;
return NOTIFY_DONE;
}
@@ -1818,7 +1825,7 @@ void mwait_idle_resume(void)
if (!icpu)
return;
- mwait_idle_cpu_tweak(smp_processor_id());
+ mwait_idle_cpu_tweak(smp_processor_id(), true);
}
/* Helper function for HPET. */
next prev parent reply other threads:[~2026-05-12 15:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 15:34 [PATCH for-4.22 v2 0/8] x86/mwait-idle: sync up with Linux 7.0-rc Jan Beulich
2026-05-12 15:35 ` [PATCH for-4.22 v2 1/8] x86/mwait-idle: arrange for BSP MSR adjustments during S3 resume Jan Beulich
2026-05-14 13:06 ` Roger Pau Monné
2026-05-12 15:36 ` Jan Beulich [this message]
2026-05-14 14:10 ` [PATCH for-4.22 v2 2/8] x86/mwait-idle: clean up BYT/CHT auto demotion disable Roger Pau Monné
2026-05-12 15:36 ` [PATCH for-4.22 v2 3/8] x86/mwait-idle: latch struct idle_cpu contents Jan Beulich
2026-05-12 15:36 ` [PATCH for-4.22 v2 4/8] x86/mwait-idle: move pre-initialized struct idle_cpu instances Jan Beulich
2026-05-12 15:37 ` [PATCH for-4.22 v2 5/8] x86/mwait-idle: Remove the 'preferred_cstates' parameter Jan Beulich
2026-05-12 15:37 ` [PATCH for-4.22 v2 6/8] x86/mwait-idle: drop const from struct cpuidle_state arrays Jan Beulich
2026-05-12 15:38 ` [PATCH for-4.22 v2 7/8] x86/mwait-idle: Add cmdline option to adjust C-states table Jan Beulich
2026-05-14 15:18 ` Roger Pau Monné
2026-05-15 6:57 ` Jan Beulich
2026-05-15 7:59 ` Roger Pau Monné
2026-05-12 15:38 ` [PATCH for-4.22 v2 8/8] x86/mwait-idle: Add C-states validation Jan Beulich
2026-05-14 15:30 ` Roger Pau Monné
2026-05-15 7:01 ` Jan Beulich
2026-05-12 15:39 ` [PATCH for-4.22 v2 0/8] x86/mwait-idle: sync up with Linux 7.0-rc Jan Beulich
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=aa14f45e-44fa-4cfc-8c51-d48548d55f3a@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.