Message ID | 20220325143833.402631-11-deller@gmx.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [01/12] parisc: Switch from GENERIC_CPU_DEVICES to GENERIC_ARCH_TOPOLOGY | expand |
Am Freitag, 25. März 2022, 15:38:32 CET schrieb Helge Deller: > Let the PDC firmware put the CPU into firmware idle loop with > pdc_cpu_rendezvous() function. > > Signed-off-by: Helge Deller <deller@gmx.de> > --- > arch/parisc/kernel/process.c | 33 ++++++++++++++++++++++++++++++--- > 1 file changed, 30 insertions(+), 3 deletions(-) > > diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c > index ea3d83b6fb62..44fa89fbb280 100644 > --- a/arch/parisc/kernel/process.c > +++ b/arch/parisc/kernel/process.c > @@ -38,6 +38,7 @@ > #include <linux/rcupdate.h> > #include <linux/random.h> > #include <linux/nmi.h> > +#include <linux/sched/hotplug.h> > > #include <asm/io.h> > #include <asm/asm-offsets.h> > @@ -46,6 +47,7 @@ > #include <asm/pdc_chassis.h> > #include <asm/unwind.h> > #include <asm/sections.h> > +#include <asm/cacheflush.h> > > #define COMMAND_GLOBAL F_EXTEND(0xfffe0030) > #define CMD_RESET 5 /* reset any module */ > @@ -158,10 +160,35 @@ void release_thread(struct task_struct *dead_task) > int running_on_qemu __ro_after_init; > EXPORT_SYMBOL(running_on_qemu); > > -void __cpuidle arch_cpu_idle_dead(void) > +/* > + * Called from the idle thread for the CPU which has been shutdown. > + */ > +void arch_cpu_idle_dead(void) > { > - /* nop on real hardware, qemu will offline CPU. */ > - asm volatile("or %%r31,%%r31,%%r31\n":::); > +#ifdef CONFIG_HOTPLUG_CPU > + idle_task_exit(); > + > + local_irq_disable(); > + > + /* > + * Tell __cpu_die() that this CPU is now safe to dispose of. > + */ > + (void)cpu_report_death(); > + > + /* > + * Ensure that the cache lines are written out. > + */ > + flush_cache_all_local(); > + flush_tlb_all_local(NULL); > + > + /* > + * Let PDC firmware put CPU into firmware idle loop. > + */ > + __pdc_cpu_rendezvous(); That could all be one-line comments for a higher code/line ratio ;)
On 3/25/22 17:56, Rolf Eike Beer wrote: > Am Freitag, 25. März 2022, 15:38:32 CET schrieb Helge Deller: >> Let the PDC firmware put the CPU into firmware idle loop with >> pdc_cpu_rendezvous() function. >> >> Signed-off-by: Helge Deller <deller@gmx.de> >> --- >> arch/parisc/kernel/process.c | 33 ++++++++++++++++++++++++++++++--- >> 1 file changed, 30 insertions(+), 3 deletions(-) >> >> diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c >> index ea3d83b6fb62..44fa89fbb280 100644 >> --- a/arch/parisc/kernel/process.c >> +++ b/arch/parisc/kernel/process.c >> @@ -38,6 +38,7 @@ >> #include <linux/rcupdate.h> >> #include <linux/random.h> >> #include <linux/nmi.h> >> +#include <linux/sched/hotplug.h> >> >> #include <asm/io.h> >> #include <asm/asm-offsets.h> >> @@ -46,6 +47,7 @@ >> #include <asm/pdc_chassis.h> >> #include <asm/unwind.h> >> #include <asm/sections.h> >> +#include <asm/cacheflush.h> >> >> #define COMMAND_GLOBAL F_EXTEND(0xfffe0030) >> #define CMD_RESET 5 /* reset any module */ >> @@ -158,10 +160,35 @@ void release_thread(struct task_struct *dead_task) >> int running_on_qemu __ro_after_init; >> EXPORT_SYMBOL(running_on_qemu); >> >> -void __cpuidle arch_cpu_idle_dead(void) >> +/* >> + * Called from the idle thread for the CPU which has been shutdown. >> + */ >> +void arch_cpu_idle_dead(void) >> { >> - /* nop on real hardware, qemu will offline CPU. */ >> - asm volatile("or %%r31,%%r31,%%r31\n":::); >> +#ifdef CONFIG_HOTPLUG_CPU >> + idle_task_exit(); >> + >> + local_irq_disable(); >> + >> + /* >> + * Tell __cpu_die() that this CPU is now safe to dispose of. >> + */ >> + (void)cpu_report_death(); >> + >> + /* >> + * Ensure that the cache lines are written out. >> + */ >> + flush_cache_all_local(); >> + flush_tlb_all_local(NULL); >> + >> + /* >> + * Let PDC firmware put CPU into firmware idle loop. >> + */ >> + __pdc_cpu_rendezvous(); > > That could all be one-line comments for a higher code/line ratio ;) Yes. The syntax is mostly copied from other arches, where it's like this. Helge
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index ea3d83b6fb62..44fa89fbb280 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -38,6 +38,7 @@ #include <linux/rcupdate.h> #include <linux/random.h> #include <linux/nmi.h> +#include <linux/sched/hotplug.h> #include <asm/io.h> #include <asm/asm-offsets.h> @@ -46,6 +47,7 @@ #include <asm/pdc_chassis.h> #include <asm/unwind.h> #include <asm/sections.h> +#include <asm/cacheflush.h> #define COMMAND_GLOBAL F_EXTEND(0xfffe0030) #define CMD_RESET 5 /* reset any module */ @@ -158,10 +160,35 @@ void release_thread(struct task_struct *dead_task) int running_on_qemu __ro_after_init; EXPORT_SYMBOL(running_on_qemu); -void __cpuidle arch_cpu_idle_dead(void) +/* + * Called from the idle thread for the CPU which has been shutdown. + */ +void arch_cpu_idle_dead(void) { - /* nop on real hardware, qemu will offline CPU. */ - asm volatile("or %%r31,%%r31,%%r31\n":::); +#ifdef CONFIG_HOTPLUG_CPU + idle_task_exit(); + + local_irq_disable(); + + /* + * Tell __cpu_die() that this CPU is now safe to dispose of. + */ + (void)cpu_report_death(); + + /* + * Ensure that the cache lines are written out. + */ + flush_cache_all_local(); + flush_tlb_all_local(NULL); + + /* + * Let PDC firmware put CPU into firmware idle loop. + */ + __pdc_cpu_rendezvous(); + + pr_warn("PDC does not provide rendezvous function.\n"); +#endif + while (1); } void __cpuidle arch_cpu_idle(void)
Let the PDC firmware put the CPU into firmware idle loop with pdc_cpu_rendezvous() function. Signed-off-by: Helge Deller <deller@gmx.de> --- arch/parisc/kernel/process.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) -- 2.35.1