[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/mwait-idle: arrange for BSP MSR adjustments during S3 resume



commit c6627327af2a5438adc74f77aafea6ffd16e74ac
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon May 18 08:54:36 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon May 18 08:54:36 2026 +0200

    x86/mwait-idle: arrange for BSP MSR adjustments during S3 resume
    
    mwait_idle_cpu_init() is only called for APs, yet MSR writes will
    typically need re-doing post-S3 even for the BSP. When multiple cores /
    threads are present (and to come back online) in a package, for package
    scope MSRs this may be covered by APs doing the writes, but we can't rely
    on that.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
---
 xen/arch/x86/acpi/power.c        |  2 ++
 xen/arch/x86/cpu/mwait-idle.c    | 49 +++++++++++++++++++++++++---------------
 xen/arch/x86/include/asm/mwait.h |  3 +++
 3 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c
index 27d672ad5d..3452650a61 100644
--- a/xen/arch/x86/acpi/power.c
+++ b/xen/arch/x86/acpi/power.c
@@ -28,6 +28,7 @@
 #include <asm/io_apic.h>
 #include <asm/irq.h>
 #include <asm/microcode.h>
+#include <asm/mwait.h>
 #include <asm/prot-key.h>
 #include <asm/spec_ctrl.h>
 #include <asm/tboot.h>
@@ -299,6 +300,7 @@ static int enter_state(u32 state)
     acpi_sleep_post(state);
     if ( hvm_cpu_up() )
         BUG();
+    mwait_idle_resume();
     cpufreq_add_cpu(0);
 
  enable_cpu:
diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c
index c0d5767f87..d575a256a4 100644
--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -1677,6 +1677,28 @@ static int __init mwait_idle_probe(void)
        return 0;
 }
 
+static void mwait_idle_cpu_tweak(unsigned int cpu)
+{
+       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);
+               break;
+
+       case C1E_PROMOTION_ENABLE:
+               on_selected_cpus(cpumask_of(cpu), c1e_promotion_enable, NULL, 
1);
+               break;
+
+       case C1E_PROMOTION_PRESERVE:
+               break;
+       }
+}
+
 static int cf_check mwait_idle_cpu_init(
     struct notifier_block *nfb, unsigned long action, void *hcpu)
 {
@@ -1759,24 +1781,7 @@ static int cf_check mwait_idle_cpu_init(
                dev->count++;
        }
 
-       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);
-               break;
-
-       case C1E_PROMOTION_ENABLE:
-               on_selected_cpus(cpumask_of(cpu), c1e_promotion_enable, NULL, 
1);
-               break;
-
-       case C1E_PROMOTION_PRESERVE:
-               break;
-       }
+       mwait_idle_cpu_tweak(cpu);
 
        return NOTIFY_DONE;
 }
@@ -1808,6 +1813,14 @@ int __init mwait_idle_init(struct notifier_block *nfb)
        return err;
 }
 
+void mwait_idle_resume(void)
+{
+       if (!icpu)
+               return;
+
+       mwait_idle_cpu_tweak(smp_processor_id());
+}
+
 /* Helper function for HPET. */
 bool __init mwait_pc10_supported(void)
 {
diff --git a/xen/arch/x86/include/asm/mwait.h b/xen/arch/x86/include/asm/mwait.h
index 000a692f6d..8f547d330d 100644
--- a/xen/arch/x86/include/asm/mwait.h
+++ b/xen/arch/x86/include/asm/mwait.h
@@ -14,9 +14,12 @@
 #define MWAIT_ECX_INTERRUPT_BREAK      0x1
 
 void mwait_idle_with_hints(unsigned int eax, unsigned int ecx);
+
 #ifdef CONFIG_INTEL
+void mwait_idle_resume(void);
 bool mwait_pc10_supported(void);
 #else
+static inline void mwait_idle_resume(void) {}
 static inline bool mwait_pc10_supported(void)
 {
     return false;
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.