From 77ba50381cbc1b29533f2c15aa60413761bc367e Mon Sep 17 00:00:00 2001 From: Dai Xin Date: Tue, 13 Dec 2022 09:24:49 +0000 Subject: [PATCH] sw64: split out the idle loop in idle.c Sunway inclusion category: performance bugzilla: https://gitee.com/openeuler/kernel/issues/I5XTK7 -------------------------------- Signed-off-by: Dai Xin Reviewed-by: He Sheng Signed-off-by: Gu Zitao --- arch/sw_64/include/asm/idle.h | 7 +++++++ arch/sw_64/kernel/Makefile | 2 +- arch/sw_64/kernel/idle.c | 37 +++++++++++++++++++++++++++++++++++ arch/sw_64/kernel/process.c | 23 ---------------------- 4 files changed, 45 insertions(+), 24 deletions(-) create mode 100644 arch/sw_64/include/asm/idle.h create mode 100644 arch/sw_64/kernel/idle.c diff --git a/arch/sw_64/include/asm/idle.h b/arch/sw_64/include/asm/idle.h new file mode 100644 index 000000000000..7e88af18ba39 --- /dev/null +++ b/arch/sw_64/include/asm/idle.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_SW64_IDLE_H +#define _ASM_SW64_IDLE_H + +extern void arch_cpu_idle(void); + +#endif /* _ASM_SW64_IDLE_H */ diff --git a/arch/sw_64/kernel/Makefile b/arch/sw_64/kernel/Makefile index 850f6dfddd1f..3cfd7b5fdb6b 100644 --- a/arch/sw_64/kernel/Makefile +++ b/arch/sw_64/kernel/Makefile @@ -17,7 +17,7 @@ obj-y := entry.o fpu.o traps.o process.o sys_sw64.o irq.o \ irq_sw64.o signal.o setup.o ptrace.o time.o \ systbls.o dup_print.o tc.o timer.o \ insn.o early_init.o topology.o cacheinfo.o \ - vdso.o vdso/ hmcall.o stacktrace.o + vdso.o vdso/ hmcall.o stacktrace.o idle.o obj-$(CONFIG_ACPI) += acpi.o obj-$(CONFIG_SMP) += smp.o diff --git a/arch/sw_64/kernel/idle.c b/arch/sw_64/kernel/idle.c new file mode 100644 index 000000000000..729af77a2284 --- /dev/null +++ b/arch/sw_64/kernel/idle.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * sw64 idle loop support. + * + */ +#include +#include +#include +#include + +#ifdef CONFIG_HOTPLUG_CPU +void arch_cpu_idle_dead(void) +{ + play_dead(); +} +#endif + +void cpu_idle(void) +{ + int i; + + local_irq_enable(); + cpu_relax(); + + if (is_in_guest()) + hcall(HCALL_HALT, 0, 0, 0); + else { + for (i = 0; i < 16; i++) + asm("nop"); + asm("halt"); + } +} + +void arch_cpu_idle(void) +{ + cpu_idle(); +} diff --git a/arch/sw_64/kernel/process.c b/arch/sw_64/kernel/process.c index e1689d25f77d..3c5b6f032c8b 100644 --- a/arch/sw_64/kernel/process.c +++ b/arch/sw_64/kernel/process.c @@ -26,29 +26,6 @@ struct halt_info { char *restart_cmd; }; -#ifdef CONFIG_HOTPLUG_CPU -void arch_cpu_idle_dead(void) -{ - play_dead(); -} -#endif - -void arch_cpu_idle(void) -{ - int i; - - local_irq_enable(); - cpu_relax(); - - if (is_in_guest()) - hcall(HCALL_HALT, 0, 0, 0); - else { - for (i = 0; i < 16; i++) - asm("nop"); - asm("halt"); - } -} - static void common_shutdown_1(void *generic_ptr) { struct halt_info *how = (struct halt_info *)generic_ptr; -- GitLab