parisc: QEMU host idle sleep support
Helge Deller
maintainerPATCH 1/1 parisc: QEMU host idle sleep support
Add QEMU host idle sleep support when running under QEMU with SeaBIOS PDC Firmware.
Like ppc64 we use "or" assembler instructions (which translate to nops on real hardware) to indicate that qemu shall idle sleep.
Signed-off-by Helge Deller <[email protected]>
Cc Richard Henderson <[email protected]>
CC [email protected] # v4.9+
arch/parisc/kernel/process.c +39 -0
@@ -39,6 +39,7 @@#include <linux/kernel.h> #include <linux/mm.h> #include <linux/fs.h> +#include <linux/cpu.h> #include <linux/module.h> #include <linux/personality.h> #include <linux/ptrace.h>
@@ -184,6 +185,44 @@ int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r) }/* +* Idle thread support +* +* Detect when running on QEMU with SeaBIOS PDC Firmware and let +* QEMU idle the host too. +*/ + +int running_on_qemu__read_mostly ; + +void __cpuidle arch_cpu_idle_dead(void) +{ +/* nop on real hardware, qemu will offline CPU. */ + asmvolatile ("or %%r31,%%r31,%%r31\n" :::); +} + +void __cpuidle arch_cpu_idle(void) +{ +local_irq_enable (); + +/* nop on real hardware, qemu will idle sleep. */ + asmvolatile ("or %%r10,%%r10,%%r10\n" :::); +} + +static int __init parisc_idle_init (void ) +{ +const char *marker; + +/* check QEMU/SeaBIOS marker in PAGE0 */ + marker = (char *) &PAGE0 ->pad0; + running_on_qemu = (memcmp (marker,"SeaBIOS" ,8 ) ==0 ); + +if (!running_on_qemu) +cpu_idle_poll_ctrl (1 ); + +return 0 ; +} +arch_initcall (parisc_idle_init); + +/* * Copy architecture-specific thread state */ int