From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Ehrhardt Date: Thu, 03 Apr 2008 08:19:12 +0000 Subject: Re: [kvm-ppc-devel] [PATCH 1 of 2] Add idle power save for ppc 4xx Message-Id: <47F49300.80302@linux.vnet.ibm.com> List-Id: References: <15675e59e019c4800a83.1206968273@thinkpadL> In-Reply-To: <15675e59e019c4800a83.1206968273@thinkpadL> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: kvm-ppc@vger.kernel.org Jerone Young wrote: > # HG changeset patch > # User Jerone Young > # Date 1207159627 18000 > # Node ID 007c135cb5f14f5eb025c103623c2ebfcc76ab11 > # Parent 1506aa38ddabb0bf73fff3ac3f3db5f9ef6458cc > Add idle power save for ppc 4xx for 2.6.25 >=20 > This patch sets the wait state MSR when power_save is called in cpu_idle = loop for ppc4xx. This is mainly to help out virtualization solutions such a= s KVM. This way the virtualization soultions are able to tell if the guest = kernel is idle. >=20 > I have tested this on hardware & KVM virtual guest. >=20 > The issue though is this is a temporary patch. As the one that will be se= nt upstream is based on linux-next (2.6.26) and is not the same as the 2.6.= 25 patch. >=20 > Signed-off-by: Jerone Young >=20 > diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile > --- a/arch/powerpc/kernel/Makefile > +++ b/arch/powerpc/kernel/Makefile > @@ -39,6 +39,7 @@ obj-$(CONFIG_GENERIC_TBSYNC) +=3D smp-tbsy > obj-$(CONFIG_GENERIC_TBSYNC) +=3D smp-tbsync.o > obj-$(CONFIG_CRASH_DUMP) +=3D crash_dump.o > obj-$(CONFIG_6xx) +=3D idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o > +obj-$(CONFIG_4xx) +=3D idle_4xx.o > obj-$(CONFIG_TAU) +=3D tau_6xx.o > obj-$(CONFIG_HIBERNATION) +=3D swsusp.o suspend.o \ > swsusp_$(CONFIG_WORD_SIZE).o > diff --git a/arch/powerpc/kernel/idle_4xx.c b/arch/powerpc/kernel/idle_4x= x.c > new file mode 100644 > --- /dev/null > +++ b/arch/powerpc/kernel/idle_4xx.c > @@ -0,0 +1,24 @@ > +/* > + * This file contains the power_save function for 4xx CPUs > + * > + * Copyright 2008 IBM Corporation. > + * added by Jerone Young > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License > + * as published by the Free Software Foundation; either version > + * 2 of the License, or (at your option) any later version. > + */ > + > +#include > +#include > + > +void ppc4xx_idle(void) > +{ > + unsigned long msr_save; > + > + /* set wait state MSR */ > + msr_save =3D mfmsr(); > + mtmsr(msr_save|MSR_WE|MSR_EE|MSR_CE|MSR_DE); > + isync(); > +} I think Jimi's comment #3 is still worth to be considered: 3) In case MSR_WE does nothing, or continues from here I'd append =20 "mstmsr(msr_save); isync();" as well And another comment that was from Arnd Bergmann into the same direction: [...] if only to make the function return with the same state that it was e= ntered. wich would then be something like > +void ppc4xx_idle(void) > +{ > + unsigned long msr_save; > + > + /* set wait state MSR */ > + msr_save =3D mfmsr(); > + mtmsr(msr_save|MSR_WE|MSR_EE|MSR_CE|MSR_DE); > + isync(); -> mtspr(msr_save); -> isync(); > +} I think it's more correct to leave as we enter. btw - Hollis was faster, but I wanted to add for the kvm kernel part I also= think placing it in emulate_instruction would save checks on every exit. > diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_3= 2.c > --- a/arch/powerpc/kernel/setup_32.c > +++ b/arch/powerpc/kernel/setup_32.c > @@ -132,6 +132,10 @@ void __init machine_init(unsigned long d > if (cpu_has_feature(CPU_FTR_CAN_DOZE) || > cpu_has_feature(CPU_FTR_CAN_NAP)) > ppc_md.power_save =3D ppc6xx_idle; > +#endif > + > +#ifdef CONFIG_4xx > + ppc_md.power_save =3D ppc4xx_idle; > #endif >=20 > if (ppc_md.progress) > diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h > --- a/include/asm-powerpc/machdep.h > +++ b/include/asm-powerpc/machdep.h > @@ -266,6 +266,7 @@ extern void power4_idle(void); > extern void power4_idle(void); > extern void power4_cpu_offline_powersave(void); > extern void ppc6xx_idle(void); > +extern void ppc4xx_idle(void); >=20 > /* > * ppc_md contains a copy of the machine description structure for the >=20 > ------------------------------------------------------------------------- > 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/marketpl= ace > _______________________________________________ > kvm-ppc-devel mailing list > kvm-ppc-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel --=20 Gr=FCsse / regards,=20 Christian Ehrhardt IBM Linux Technology Center, Open Virtualization ------------------------------------------------------------------------- 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 kvm-ppc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel