Skip to contentSkip to conversation

Add MSR Wait state to cpu_idle loop

PATCH In review Jerone Young 2 participants 2 messages Mar 28, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add MSR Wait state to cpu_idle loop

# HG changeset patch
# User Jerone Young <[email protected]>
# Date 1206720510 18000
# Node ID e48cf2ad6c85c457ff64c04b83960fc305420842 # Parent 1506aa38ddabb0bf73fff3ac3f3db5f9ef6458cc Add MSR Wait state to cpu_idle loop

This patch sets the wait state MSR when in the cpu_idle loop. This is mainly to help out virtualization solutions such as KVM. This way the virtualization soultion is able to tell if the guest kernel is idle.

arch/powerpc/kernel/idle.c +6 -0
@@ -32,6 +32,8 @@
 #include <asm/time.h>
 #include <asm/machdep.h>
 #include <asm/smp.h>
+
+static unsigned long msr_save;
 
 #ifdef CONFIG_HOTPLUG_CPU
 /* this is used for software suspend, and that shuts down
@@ -88,6 +90,10 @@ void cpu_idle(void)
 				HMT_low();
 				HMT_very_low();
 			}
+
+			/* set wait state MSR */
+			msr_save = mfmsr();
+			mtmsr(msr_save|MSR_WE);
 		}
 
 		HMT_medium();

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
kvm-ppc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

#1 lore raw

Re: [kvm-ppc-devel] [PATCH 1 of 2] Add MSR Wait state to cpu_idle

Quoted 13 lines · Jerone Young
Quoted 12 lines · Hollis Blanchard
Quoted 12 lines

#ifdef CONFIG_HOTPLUG_CPU
/* this is used for software suspend, and that shuts down

arch/powerpc/kernel/idle.c +4 -0
@@ -88,6 +90,10 @@ void cpu_idle(void)
 				HMT_low();
 				HMT_very_low();
 			}
+
+			/* set wait state MSR */
+			msr_save = mfmsr();
+			mtmsr(msr_save|MSR_WE);
 		}
 
Quoted 8 lines
Quoted 5 lines

arch/powerpc/kernel/idle.c void cpu_idle(void) · line 99

Quoted 1 line
arch/powerpc/kernel/idle.c +0 -0
 		HMT_medium();

The code you are modifying is common to all PowerPC kernels. Why didn't you use the power_save() hook provided to you?

power_save() is called with interrupts disabled. So we would never wake up.

MSR_WE/POW is implementation-dependent and modifying it in generic code is not okay.

You can re-enable interrupts in your power_save implementation before setting MSR_WE (in fact power4_idle does this).

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
kvm-ppc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel