From: Hollis Blanchard Date: Thu, 03 Apr 2008 23:13:59 +0000 Subject: Re: [kvm-ppc-devel] [PATCH] Add idle wait support for 44x platforms Message-Id: <200804031813.59297.hollisb@us.ibm.com> List-Id: References: <7226bef216680748a503.1207262582@thinkpadL> In-Reply-To: <7226bef216680748a503.1207262582@thinkpadL> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Jerone Young Cc: kvm-ppc-devel@lists.sourceforge.net, linuxppc-dev@ozlabs.org, Stuart Yoder On Thursday 03 April 2008 17:43:02 Jerone Young wrote: > # HG changeset patch > # User Jerone Young > # Date 1207262487 18000 > # Node ID 7226bef216680748a50327900572c2fbc3e762b0 > # Parent a5b2aebbc6ebd2439c655f1c047ed7e3c1991ec1 > Add idle wait support for 44x platforms > > This patch adds the ability for the CPU to go into wait state while in > cpu_idle loop. This helps virtulization solutions know when the guest Linux > kernel is in an idle state. There are two ways to do it. > > 1) Command line > idle=spin <-- CPU will spin (this is the default) > idle=wait <-- set CPU into wait state when idle > > 2) The device tree will be checked for the "/hypervisor" node > If this node is seen it will use "wait" for idle, so that > the hypervisor can know when guest Linux kernel it is in > an idle state. > > This patch, unlike the last, isolates the code to 44x platforms. > > Signed-off-by: Jerone Young Very nice. > +static void ppc44x_idle(void) > +{ > + unsigned long msr_save; > + > + msr_save = mfmsr(); > + /* set wait state MSR */ > + mtmsr(msr_save|MSR_WE|MSR_EE|MSR_CE); > + /* return to initial state */ > + mtmsr(msr_save); > +} > + > +int __init ppc44x_idle_init(void) > +{ > + if(of_find_node_by_path("/hypervisor") != NULL) { > + /* if we find /hypervisor node is in device tree, > + set idle mode to wait */ > + current_mode = 1; /* wait mode */ > + } > + > + ppc_md.power_save = modes[current_mode].entry; > + return 0; > +} By the way, watch that space in "if(". Also, you need to call of_node_put(). The one thing I don't like is the hardcoded assumption that 1 means "wait". Instead, you could do something like this (not even compile-tested): int __init ppc44x_idle_init(void) { void *func = modes[current_mode].entry; struct device_node *node; node = of_find_node_by_path("/hypervisor") if (node) { /* if we find /hypervisor node is in device tree, * set idle mode to wait */ func = &ppc44x_idle; of_node_put(node); } ppc_md.power_save = func; return 0; } Stuart, we're getting into ePAPR territory. Do you think we need to worry about a hypervisor not handling mtmsr(MSR_WE)? In that case, we'd need to be more specific than just testing for "/hypervisor". IMHO every hypervisor should implement it... but maybe /hypervisor/idle = "wait" would be more explicit and therefore better? -- Hollis Blanchard IBM Linux Technology Center ------------------------------------------------------------------------- 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