Skip to content

Commit 310d827

Browse files
committed
parisc: qemu idle sleep support
Add qemu idle sleep support when running under qemu with SeaBIOS PDC firmware. Like the power architecture we use the "or" assembler instructions, which translate to nops on real hardware, to indicate that qemu shall idle sleep. Signed-off-by: Helge Deller <deller@gmx.de> Cc: Richard Henderson <rth@twiddle.net> CC: stable@vger.kernel.org # v4.9+
1 parent 88776c0 commit 310d827

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

arch/parisc/kernel/process.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <linux/kernel.h>
4040
#include <linux/mm.h>
4141
#include <linux/fs.h>
42+
#include <linux/cpu.h>
4243
#include <linux/module.h>
4344
#include <linux/personality.h>
4445
#include <linux/ptrace.h>
@@ -183,6 +184,44 @@ int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r)
183184
return 1;
184185
}
185186

187+
/*
188+
* Idle thread support
189+
*
190+
* Detect when running on QEMU with SeaBIOS PDC Firmware and let
191+
* QEMU idle the host too.
192+
*/
193+
194+
int running_on_qemu __read_mostly;
195+
196+
void __cpuidle arch_cpu_idle_dead(void)
197+
{
198+
/* nop on real hardware, qemu will offline CPU. */
199+
asm volatile("or %%r31,%%r31,%%r31\n":::);
200+
}
201+
202+
void __cpuidle arch_cpu_idle(void)
203+
{
204+
local_irq_enable();
205+
206+
/* nop on real hardware, qemu will idle sleep. */
207+
asm volatile("or %%r10,%%r10,%%r10\n":::);
208+
}
209+
210+
static int __init parisc_idle_init(void)
211+
{
212+
const char *marker;
213+
214+
/* check QEMU/SeaBIOS marker in PAGE0 */
215+
marker = (char *) &PAGE0->pad0;
216+
running_on_qemu = (memcmp(marker, "SeaBIOS", 8) == 0);
217+
218+
if (!running_on_qemu)
219+
cpu_idle_poll_ctrl(1);
220+
221+
return 0;
222+
}
223+
arch_initcall(parisc_idle_init);
224+
186225
/*
187226
* Copy architecture-specific thread state
188227
*/

0 commit comments

Comments
 (0)