RISC-V: Assorted Cleanups
Subsystems (4)
cover RISC-V: Assorted Cleanups
I finally got around to answering a very old email in my inbox that was a response to our original patch set. These are meant to cause little to no functional changes to the port, but I've given them very little testing so I wouldn't be surprised if I've managed to screw something up here.
I'll be sure to give these some testing before putting them on for-next, but I figured it'd be better to send them out now rather than later.
PATCH 1/8 RISC-V: Provide a cleaner raw_smp_processor_id()
I'm not sure how I managed to miss this the first time, but this is much better.
--- arch/riscv/include/asm/smp.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
arch/riscv/include/asm/smp.h +6 -12
@@ -14,11 +14,6 @@#ifndef _ASM_RISCV_SMP_H#define _ASM_RISCV_SMP_H -/* This both needs asm-offsets.h and is used when generating it. */ -#ifndef GENERATING_ASM_OFFSETS -#include <asm/asm-offsets.h> -#endif -#include <linux/cpumask.h> #include <linux/irqreturn.h>
@@ -33,13 +28,12 @@ void arch_send_call_function_ipi_mask(struct cpumask *mask);/* Hook for the generic smp_call_function_single() routine. */ void arch_send_call_function_single_ipi (int cpu); -/* -* This is particularly ugly: it appears we can't actually get the definition -* of task_struct here, but we need access to the CPU this task is running on. -* Instead of using C we're using asm-offsets.h to get the current processor -* ID. -*/ -#define raw_smp_processor_id () (*((int*)((char*)get_current() + TASK_TI_CPU))) +/* Obtains the hart ID of the currently executing task. This relies on +* THREAD_INFO_IN_TASK, but we define that unconditionally. */ +#ifdef CONFIG_THREAD_INFO_IN_TASK +#define get_ti () ((struct thread_info *)get_current()) +#define raw_smp_processor_id () (get_ti()->cpu) +#endif #endif /* CONFIG_SMP */
Signature · 1 line
2.16.4
Re: [PATCH 1/8] RISC-V: Provide a cleaner raw_smp_processor_id()
Quoted 2 lines · Palmer Dabbelt
+/* Obtains the hart ID of the currently executing task. This relies on
+ *THREAD_INFO_IN_TASK, but we define that unconditionally. */
Kernel comment style would be:
/*
* Obtains the hart ID of the currently executing task. This relies on
* THREAD_INFO_IN_TASK, but we define that unconditionally. */
Quoted 1 line
+#ifdef
CONFIG_THREAD_INFO_IN_TASK
THREAD_INFO_IN_TASK is always defined for riscv, so no need for this ifdef.
arch/riscv/include/asm/smp.h void arch_send_call_function_ipi_mask(struct cpumask *mask); · line 35
Quoted 2 lines
arch/riscv/include/asm/smp.h +2
-0+#define get_ti () ((struct thread_info *)get_current()) +#define raw_smp_processor_id () (get_ti()->cpu)
Please don't cast structs around. This should be something like
#define raw_smp_processor_id() \ (container_of(get_current(), struct task_struct, thread_info)->cpu)
PATCH 2/8 RISC-V: Don't set cacheinfo.{physical_line_partition,attributes}
In reply to Palmer DabbeltThese are just hard coded in the RISC-V port, which doesn't make any sense. We should probably be setting these from device tree entries when they exist, but for now I think it's saner to just leave them all as their default values.
--- arch/riscv/kernel/cacheinfo.c | 7 ------- 1 file changed, 7 deletions(-)
arch/riscv/kernel/cacheinfo.c +0 -7
@@ -22,13 +22,6 @@ static void ci_leaf_init(struct cacheinfo *this_leaf, { this_leaf->level = level; this_leaf->type = type; -/* not a sector cache */ - this_leaf->physical_line_partition =1 ; -/* TODO: Add to DTS */ - this_leaf->attributes = -CACHE_WRITE_BACK - |CACHE_READ_ALLOCATE - |CACHE_WRITE_ALLOCATE ; }static int __init_cache_level (unsigned int cpu)
Signature · 1 line
2.16.4
Re: [PATCH 2/8] RISC-V: Don't set cacheinfo.{physical_line_partition, attributes}
Quoted 6 lines · Palmer Dabbelt
These are just hard coded in the RISC-V port, which doesn't make any sense. We should probably be setting these from device tree entries when they exist, but for now I think it's saner to just leave them all as their default values.
Signed-off-by Palmer Dabbelt <[email protected]>
Looks fine:
Re: [PATCH 2/8] RISC-V: Don't set cacheinfo.{physical_line_partition,attributes}
In reply to Palmer DabbeltHi,
Quoted 4 lines · Palmer Dabbelt
These are just hard coded in the RISC-V port, which doesn't make any sense. We should probably be setting these from device tree entries when they exist, but for now I think it's saner to just leave them all as their default values.
Default value here means unset and not visible in /sys.
Which looks fine to me.
Thanks,
Quoted 25 lines
Signed-off-by Palmer Dabbelt <[email protected]>--- arch/riscv/kernel/cacheinfo.c | 7 ------- 1 file changed, 7 deletions(-)arch/riscv/kernel/cacheinfo.c +0
-7@@ -22,13 +22,6 @@ static void ci_leaf_init(struct cacheinfo *this_leaf, { this_leaf->level = level; this_leaf->type = type; -/* not a sector cache */ - this_leaf->physical_line_partition =1 ; -/* TODO: Add to DTS */ - this_leaf->attributes = -CACHE_WRITE_BACK - |CACHE_READ_ALLOCATE - |CACHE_WRITE_ALLOCATE ; }static int __init_cache_level (unsigned int cpu)
PATCH 3/8 RISC-V: Rename riscv_of_processor_hart to riscv_of_processor_hartid
In reply to Palmer DabbeltIt's a bit confusing exactly what this function does: it actually returns the hartid of an OF processor node, failing with -1 on invalid nodes. I've changed the name to _hartid() in order to make that a bit more clear, as well as adding a comment.
--- arch/riscv/include/asm/processor.h | 4 +++- arch/riscv/kernel/cpu.c | 2 +- arch/riscv/kernel/smpboot.c | 2 +- drivers/clocksource/riscv_timer.c | 2 +- drivers/irqchip/irq-sifive-plic.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-)
arch/riscv/include/asm/processor.h +3 -1
@@ -88,7 +88,9 @@ static inline void wait_for_interrupt(void) }struct device_node ; -extern int riscv_of_processor_hart (struct device_node *node); +/* Returns the hart ID of the given device tree node, or -1 if the device tree +* node isn't a RISC-V hart. */ +extern int riscv_of_processor_hartid (struct device_node *node);extern void riscv_fill_hwcap (void );
arch/riscv/kernel/cpu.c +1 -1
@@ -16,7 +16,7 @@#include <linux/of.h> /* Return -1 if not a valid hart */ -int riscv_of_processor_hart (struct device_node *node) +int riscv_of_processor_hartid (struct device_node *node) {const char *isa, *status;u32 hart;
arch/riscv/kernel/smpboot.c +1 -1
@@ -53,7 +53,7 @@ void __init setup_smp(void)int hart, im_okay_therefore_i_am =0 ;while ((dn =of_find_node_by_type (dn,"cpu" ))) { - hart =riscv_of_processor_hart (dn); + hart =riscv_of_processor_hartid (dn);if (hart >=0 ) {set_cpu_possible (hart, true);set_cpu_present (hart, true);
drivers/clocksource/riscv_timer.c +1 -1
@@ -84,7 +84,7 @@ void riscv_timer_interrupt(void)static int __init riscv_timer_init_dt (struct device_node *n) { -int cpu_id =riscv_of_processor_hart (n), error; +int cpu_id =riscv_of_processor_hartid (n), error;struct clocksource *cs;if (cpu_id !=smp_processor_id ())
drivers/irqchip/irq-sifive-plic.c +1 -1
@@ -176,7 +176,7 @@ static int plic_find_hart_id(struct device_node *node) {for (; node; node = node->parent) {if (of_device_is_compatible (node,"riscv" )) -return riscv_of_processor_hart (node); +return riscv_of_processor_hartid (node); }return -1 ;
Signature · 1 line
2.16.4
Re: [PATCH 3/8] RISC-V: Rename riscv_of_processor_hart to riscv_of_processor_hartid
Quoted 19 lines · Palmer Dabbelt
It's a bit confusing exactly what this function does: it actually returns the hartid of an OF processor node, failing with -1 on invalid nodes. I've changed the name to
_hartid()in order to make that a bit more clear, as well as adding a comment.Signed-off-by Palmer Dabbelt <[email protected]>--- arch/riscv/include/asm/processor.h | 4 +++- arch/riscv/kernel/cpu.c | 2 +- arch/riscv/kernel/smpboot.c | 2 +- drivers/clocksource/riscv_timer.c | 2 +- drivers/irqchip/irq-sifive-plic.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-)arch/riscv/include/asm/processor.h +0
-0
arch/riscv/include/asm/processor.h static inline void wait_for_interrupt(void) · line 92
Quoted 6 lines
arch/riscv/include/asm/processor.h +2
-1@@ -88,7 +88,9 @@ static inline void wait_for_interrupt(void) }struct device_node ; -extern int riscv_of_processor_hart (struct device_node *node); +/* Returns the hart ID of the given device tree node, or -1 if the device tree +* node isn't a RISC-V hart. */
I think multi-line commenting format should be:
/*
*
*/
Otherwise, Reviewed-by: Atish Patra <[email protected]>
Quoted 57 lines
arch/riscv/include/asm/processor.h +1
-0+extern int riscv_of_processor_hartid (struct device_node *node);extern void riscv_fill_hwcap (void );arch/riscv/kernel/cpu.c +1
-1@@ -16,7 +16,7 @@#include <linux/of.h> /* Return -1 if not a valid hart */ -int riscv_of_processor_hart (struct device_node *node) +int riscv_of_processor_hartid (struct device_node *node) {const char *isa, *status;u32 hart;arch/riscv/kernel/smpboot.c +1
-1@@ -53,7 +53,7 @@ void __init setup_smp(void)int hart, im_okay_therefore_i_am =0 ;while ((dn =of_find_node_by_type (dn,"cpu" ))) { - hart =riscv_of_processor_hart (dn); + hart =riscv_of_processor_hartid (dn);if (hart >=0 ) {set_cpu_possible (hart, true);set_cpu_present (hart, true);drivers/clocksource/riscv_timer.c +1
-1@@ -84,7 +84,7 @@ void riscv_timer_interrupt(void)static int __init riscv_timer_init_dt (struct device_node *n) { -int cpu_id =riscv_of_processor_hart (n), error; +int cpu_id =riscv_of_processor_hartid (n), error;struct clocksource *cs;if (cpu_id !=smp_processor_id ())drivers/irqchip/irq-sifive-plic.c +1
-1@@ -176,7 +176,7 @@ static int plic_find_hart_id(struct device_node *node) {for (; node; node = node->parent) {if (of_device_is_compatible (node,"riscv" )) -return riscv_of_processor_hart (node); +return riscv_of_processor_hartid (node); }return -1 ;
Re: [PATCH 3/8] RISC-V: Rename riscv_of_processor_hart to riscv_of_processor_hartid
In reply to Palmer DabbeltQuoted 2 lines
+/* Returns the hart ID of the given device tree node, or -1 if the device tree
+ * node isn't a RISC-V hart. */
In addition to the comment formatting: we usually keep the description near the implementation, not the header. It could also become a kerneldoc comment for added clarity.
Quoted 1 line
+extern int
riscv_of_processor_hartid(struct device_node *node);
No need to declare function prototypes in headers with the extern attribute, btw.
PATCH 4/8 RISC-V: Filter ISA and MMU values in cpuinfo
In reply to Palmer DabbeltWe shouldn't be directly passing device tree values to userspace, both because there could be mistakes in device trees and because the kernel doesn't support arbitrary ISAs.
--- arch/riscv/kernel/cpu.c | 62 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-)
arch/riscv/kernel/cpu.c +55 -7
@@ -58,6 +58,57 @@ int riscv_of_processor_hartid(struct device_node *node)#ifdef CONFIG_PROC_FS +static void print_isa (struct seq_file *f,const char *orig_isa) +{ +static const char *ext ="mafdc" ; +const char *isa = orig_isa; +const char *e; + +/* Linux doesn't support rv32e or rv128i, and we only support booting +* kernels on harts with the same ISA that the kernel is compiled for. */ +#if defined(CONFIG_32BIT ) +if (strncmp (isa,"rv32i" ,5 ) !=0 ) +return ; +#elif defined(CONFIG_64BIT ) +if (strncmp (isa,"rv64i" ,5 ) !=0 ) +return ; +#endif + +/* Print the base ISA, as we already know it's legal. */ +seq_printf (f,"isa\t: " ); +seq_write (f, isa,5 ); + isa +=5 ; + +/* Check the rest of the ISA string for valid extensions, printing those we +* find. RISC-V ISA strings define an order, so we only print the +* extension bits when they're in order. */ +for (e = ext; *e !='\0' ; ++e) { +if (isa[0 ] == e[0 ]) { +seq_write (f, isa,1 ); + isa++; + } + } + +/* If we were given an unsupported ISA in the device tree then print a bit +* of info describing what went wrong. */ +if (isa[0 ] !='\0' ) +pr_info ("unsupported ISA \"%s\" in device tree" , orig_isa); +} + +static void print_mmu (struct seq_file *f,const char *mmu_type) +{ +#if defined(CONFIG_32BIT ) +if (strcmp (mmu_type,"riscv,sv32" ) !=0 ) +return ; +#elif defined(CONFIG_64BIT ) +if ((strcmp (mmu_type,"riscv,sv39" ) !=0 ) + && (strcmp (mmu_type,"riscv,sv48" ) !=0 )) +return ; +#endif + +seq_printf (f,"mmu\t: %s\n" , mmu_type+6 ); +} +static void *c_start (struct seq_file *m,loff_t *pos) { *pos =cpumask_next (*pos -1 , cpu_online_mask);
@@ -83,13 +134,10 @@ static int c_show(struct seq_file *m, void *v)const char *compat, *isa, *mmu;seq_printf (m,"hart\t: %lu\n" , hart_id); -if (!of_property_read_string (node,"riscv,isa" , &isa) - && isa[0 ] =='r' - && isa[1 ] =='v' ) -seq_printf (m,"isa\t: %s\n" , isa); -if (!of_property_read_string (node,"mmu-type" , &mmu) - && !strncmp (mmu,"riscv," ,6 )) -seq_printf (m,"mmu\t: %s\n" , mmu+6 ); +if (!of_property_read_string (node,"riscv,isa" , &isa)) +print_isa (m, isa); +if (!of_property_read_string (node,"mmu-type" , &mmu)) +print_mmu (m, mmu);if (!of_property_read_string (node,"compatible" , &compat) &&strcmp (compat,"riscv" ))seq_printf (m,"uarch\t: %s\n" , compat);
Signature · 1 line
2.16.4
PATCH 5/8 RISC-V: Rename im_okay_therefore_i_am to found_boot_cpu
In reply to Palmer DabbeltThe old name was a bit odd.
--- arch/riscv/kernel/smpboot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/riscv/kernel/smpboot.c +4 -4
@@ -50,7 +50,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)void __init setup_smp (void ) {struct device_node *dn =NULL ; -int hart, im_okay_therefore_i_am =0 ; +int hart, found_boot_cpu =0 ;while ((dn =of_find_node_by_type (dn,"cpu" ))) { hart =riscv_of_processor_hartid (dn);
@@ -58,13 +58,13 @@ void __init setup_smp(void)set_cpu_possible (hart, true);set_cpu_present (hart, true);if (hart ==smp_processor_id ()) { -BUG_ON (im_okay_therefore_i_am); - im_okay_therefore_i_am =1 ; +BUG_ON (found_boot_cpu); + found_boot_cpu =1 ; } } } -BUG_ON (!im_okay_therefore_i_am); +BUG_ON (!found_boot_cpu); }int __cpu_up (unsigned int cpu,struct task_struct *tidle)
Signature · 1 line
2.16.4
Re: [PATCH 5/8] RISC-V: Rename im_okay_therefore_i_am to found_boot_cpu
arch/riscv/kernel/smpboot.c void __init smp_prepare_cpus(unsigned int max_cpus) · line 53
Quoted 3 lines
arch/riscv/kernel/smpboot.c +1
-1struct device_node *dn =NULL ; -int hart, im_okay_therefore_i_am =0 ; +int hart, found_boot_cpu =0 ;
If you rename this anyway please switch to use a bool.
Re: [PATCH 5/8] RISC-V: Rename im_okay_therefore_i_am to found_boot_cpu
Quoted 6 lines · Christoph Hellwig
arch/riscv/kernel/smpboot.c void __init smp_prepare_cpus(unsigned int max_cpus) · line 53
Quoted 3 lines
struct device_node *dn = NULL;arch/riscv/kernel/smpboot.c +1
-1-int hart, im_okay_therefore_i_am =0 ; +int hart, found_boot_cpu =0 ;If you rename this anyway please switch to use a bool.
I can address the comment on this patch and fold it in my series to avoid unnecessary conflict.
@Palmer: You can drop this patch.
Regards,
Atish
Re: [PATCH 5/8] RISC-V: Rename im_okay_therefore_i_am to found_boot_cpu
Quoted 8 lines · Atish Patra
Quoted 6 lines · Christoph Hellwig
arch/riscv/kernel/smpboot.c void __init smp_prepare_cpus(unsigned int max_cpus) · line 53
Quoted 3 lines
struct device_node *dn = NULL;arch/riscv/kernel/smpboot.c +1
-1-int hart, im_okay_therefore_i_am =0 ; +int hart, found_boot_cpu =0 ;If you rename this anyway please switch to use a bool.
Quoted 4 lines
I can address the comment on this patch and fold it in my series to avoid unnecessary conflict.
@Palmer: You can drop this patch.
If Palmer is ok with it how about you include a respin of his whole series? There are some overlaps I think and having a single person in charge might be helpful.
Btw, I've found your series in my linux-kernel folder, but it did not make it to linux-riscv or my personal inbox despite the CC.
Re: [PATCH 5/8] RISC-V: Rename im_okay_therefore_i_am to found_boot_cpu
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Atish Patra
Quoted 6 lines · Christoph Hellwig
arch/riscv/kernel/smpboot.c void __init smp_prepare_cpus(unsigned int max_cpus) · line 53
Quoted 3 lines
struct device_node *dn = NULL;arch/riscv/kernel/smpboot.c +1
-1-int hart, im_okay_therefore_i_am =0 ; +int hart, found_boot_cpu =0 ;If you rename this anyway please switch to use a bool.
Quoted 9 lines
Quoted 4 lines
I can address the comment on this patch and fold it in my series to avoid unnecessary conflict.
@Palmer: You can drop this patch.
If Palmer is ok with it how about you include a respin of his whole series? There are some overlaps I think and having a single person in charge might be helpful.
Sure. I am fine with it. Palmer ?
Quoted 3 lines
Btw, I've found your series in my linux-kernel folder, but it did not make it to linux-riscv or my personal inbox despite the CC.
Thanks for the review.
I checked my scripts. I couldn't figure out what went wrong. Not sure if there was some issue with infradead.org at that time.
Anyways, sorry again for the mess. I will keep a watch on this next time.
Regards,
Atish
Re: [PATCH 5/8] RISC-V: Rename im_okay_therefore_i_am to found_boot_cpu
Quoted 13 lines · atish.patra at wdc.com
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · Atish Patra
Quoted 6 lines · Christoph Hellwig
arch/riscv/kernel/smpboot.c void __init smp_prepare_cpus(unsigned int max_cpus) · line 53
Quoted 3 lines
struct device_node *dn = NULL;arch/riscv/kernel/smpboot.c +1
-1-int hart, im_okay_therefore_i_am =0 ; +int hart, found_boot_cpu =0 ;If you rename this anyway please switch to use a bool.
I can address the comment on this patch and fold it in my series to avoid unnecessary conflict.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
@Palmer: You can drop this patch.
If Palmer is ok with it how about you include a respin of his whole series? There are some overlaps I think and having a single person in charge might be helpful.
Sure. I am fine with it. Palmer ?
Ya, I have no problem with it.
Quoted 13 lines
Quoted 4 lines
Btw, I've found your series in my linux-kernel folder, but it did not make it to linux-riscv or my personal inbox despite the CC.
Thanks for the review.
I checked my scripts. I couldn't figure out what went wrong. Not sure if there was some issue with infradead.org at that time.Anyways, sorry again for the mess. I will keep a watch on this next time.
Regards,
Atish
Re: [PATCH 5/8] RISC-V: Rename im_okay_therefore_i_am to found_boot_cpu
In reply to Atish PatraQuoted 8 lines · atish.patra at wdc.com
Quoted 6 lines · Christoph Hellwig
arch/riscv/kernel/smpboot.c void __init smp_prepare_cpus(unsigned int max_cpus) · line 53
Quoted 3 lines
struct device_node *dn = NULL;arch/riscv/kernel/smpboot.c +1
-1-int hart, im_okay_therefore_i_am =0 ; +int hart, found_boot_cpu =0 ;If you rename this anyway please switch to use a bool.
Quoted 4 lines
I can address the comment on this patch and fold it in my series to avoid unnecessary conflict.
@Palmer: You can drop this patch.
Thanks!
PATCH 6/8 RISC-V: Use mmgrab()
In reply to Palmer Dabbeltf1f1007644ff ("mm: add new mmgrab() helper") added a helper that we missed out on.
--- arch/riscv/kernel/smpboot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/riscv/kernel/smpboot.c +4 -3
@@ -30,6 +30,7 @@#include <linux/irq.h> #include <linux/of.h> #include <linux/sched/task_stack.h> +#include <linux/sched/mm.h> #include <asm/irq.h> #include <asm/mmu_context.h> #include <asm/tlbflush.h>
@@ -79,8 +80,8 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)* the spinning harts that they can continue the boot process. */ smp_mb (); - __cpu_up_stack_pointer[cpu] =task_stack_page (tidle) +THREAD_SIZE ; - __cpu_up_task_pointer[cpu] = tidle; +WRITE_ONCE (__cpu_up_stack_pointer[cpu],task_stack_page (tidle) +THREAD_SIZE ); +WRITE_ONCE (__cpu_up_task_pointer[cpu], tidle);while (!cpu_online (cpu))cpu_relax ();
@@ -100,7 +101,7 @@ asmlinkage void __init smp_callin(void)struct mm_struct *mm = &init_mm;/* All kernel threads share the same mm context. */ -atomic_inc (&mm->mm_count); +mmgrab (mm); current->active_mm = mm;trap_init ();
Signature · 1 line
2.16.4
Re: [PATCH 6/8] RISC-V: Use mmgrab()
arch/riscv/kernel/smpboot.c int __cpu_up(unsigned int cpu, struct task_struct *tidle) · line 84
Quoted 12 lines
arch/riscv/kernel/smpboot.c +3
-2+#include <linux/sched/mm.h> #include <asm/irq.h> #include <asm/mmu_context.h> #include <asm/tlbflush.h> @@ -79,8 +80,8 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)* the spinning harts that they can continue the boot process. */ smp_mb (); - __cpu_up_stack_pointer[cpu] =task_stack_page (tidle) +THREAD_SIZE ; - __cpu_up_task_pointer[cpu] = tidle; +WRITE_ONCE (__cpu_up_stack_pointer[cpu],task_stack_page (tidle) +THREAD_SIZE ); +WRITE_ONCE (__cpu_up_task_pointer[cpu], tidle);
This looks unrelated.
arch/riscv/kernel/smpboot.c asmlinkage void __init smp_callin(void) · line 105
Quoted 7 lines
arch/riscv/kernel/smpboot.c +1
-1@@ -100,7 +101,7 @@ asmlinkage void __init smp_callin(void)struct mm_struct *mm = &init_mm;/* All kernel threads share the same mm context. */ -atomic_inc (&mm->mm_count); +mmgrab (mm); current->active_mm = mm;
This part looks fine to me:
PATCH 7/8 RISC-V: Comment on the TLB flush in smp_callin()
In reply to Palmer DabbeltThis isn't readily apparent from reading the code.
--- arch/riscv/kernel/smpboot.c | 2 ++ 1 file changed, 2 insertions(+)
arch/riscv/kernel/smpboot.c +2 -0
@@ -107,6 +107,8 @@ asmlinkage void __init smp_callin(void)trap_init ();notify_cpu_starting (smp_processor_id ());set_cpu_online (smp_processor_id (),1 ); +/* Remote TLB flushes are ignored while the CPU is offline, so emit a local +* TLB flush right now just in case. */ local_flush_tlb_all ();local_irq_enable ();preempt_disable ();
Signature · 1 line
2.16.4
Re: [PATCH 7/8] RISC-V: Comment on the TLB flush in smp_callin()
arch/riscv/kernel/smpboot.c asmlinkage void __init smp_callin(void) · line 111
Quoted 4 lines
arch/riscv/kernel/smpboot.c +2
-0notify_cpu_starting (smp_processor_id ());set_cpu_online (smp_processor_id (),1 ); +/* Remote TLB flushes are ignored while the CPU is offline, so emit a local +* TLB flush right now just in case. */
Please use the normal kernel comment style and break the line after 80 characters.
PATCH 8/8 RISC-V: Disable preemption before enabling interrupts when booting secondary harts
In reply to Palmer DabbeltI'm not sure, but I think this was a bug: if the scheduler fired right here then I believe it would blow up.
--- arch/riscv/kernel/smpboot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/kernel/smpboot.c +3 -1
@@ -110,7 +110,9 @@ asmlinkage void __init smp_callin(void)/* Remote TLB flushes are ignored while the CPU is offline, so emit a local * TLB flush right now just in case. */ local_flush_tlb_all (); -local_irq_enable (); +/* Disable preemption before enabling interrupts, so we don't try to +* schedule a CPU that hasn't actually started yet. */ preempt_disable (); +local_irq_enable ();cpu_startup_entry (CPUHP_AP_ONLINE_IDLE ); }
Signature · 1 line
2.16.4