riscv: minor fixes and cleanups
PATCH 2/5 riscv: use pr_info and friends
In reply to Johan HovoldUse the pr_info and pr_err macros instead of printk with explicit log levels.
--- arch/riscv/kernel/setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/riscv/kernel/setup.c +3 -3
@@ -76,11 +76,11 @@ static void __init setup_initrd(void)unsigned long size;if (initrd_start >= initrd_end) { -printk (KERN_INFO "initrd not found or empty" ); +pr_info ("initrd not found or empty" ); goto disable; }if (__pa (initrd_end) >PFN_PHYS (max_low_pfn)) { -printk (KERN_ERR "initrd extends beyond end of memory" ); +pr_err ("initrd extends beyond end of memory" ); goto disable; }
@@ -88,7 +88,7 @@ static void __init setup_initrd(void)memblock_reserve (__pa (initrd_start), size); initrd_below_start_ok =1 ; -printk (KERN_INFO "Initial ramdisk at: 0x%p (%lu bytes)\n" , +pr_info ("Initial ramdisk at: 0x%p (%lu bytes)\n" , (void *)(initrd_start), size);return ; disable:
Signature · 1 line
2.20.1
PATCH 1/5 riscv: add missing newlines to printk messages
In reply to Johan HovoldAdd missing newline characters to printk messages.
Also replace two pr_warning with the shorter pr_warn, and fix up the tense of one error message while at it.
--- arch/riscv/kernel/cpu.c | 2 +- arch/riscv/kernel/cpufeature.c | 8 ++++---- arch/riscv/kernel/ftrace.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
arch/riscv/kernel/cpu.c +1 -1
@@ -106,7 +106,7 @@ static void print_isa(struct seq_file *f, const char *orig_isa)* a bit of info describing what went wrong. */ if (isa[0 ] !='\0' ) -pr_info ("unsupported ISA \"%s\" in device tree" , orig_isa); +pr_info ("unsupported ISA \"%s\" in device tree\n" , orig_isa); }static void print_mmu (struct seq_file *f,const char *mmu_type)
arch/riscv/kernel/cpufeature.c +4 -4
@@ -50,12 +50,12 @@ void riscv_fill_hwcap(void)if (riscv_of_processor_hartid (node) >=0 )break ;if (!node) { -pr_warning ("Unable to find \"cpu\" devicetree entry" ); +pr_warn ("Unable to find \"cpu\" devicetree entry\n" );return ; }if (of_property_read_string (node,"riscv,isa" , &isa)) { -pr_warning ("Unable to find \"riscv,isa\" devicetree entry" ); +pr_warn ("Unable to find \"riscv,isa\" devicetree entry\n" );of_node_put (node);return ; }
@@ -67,11 +67,11 @@ void riscv_fill_hwcap(void)/* We don't support systems with F but without D, so mask those out * here. */ if ((elf_hwcap &COMPAT_HWCAP_ISA_F ) && !(elf_hwcap &COMPAT_HWCAP_ISA_D )) { -pr_info ("This kernel does not support systems with F but not D" ); +pr_info ("This kernel does not support systems with F but not D\n" ); elf_hwcap &= ~COMPAT_HWCAP_ISA_F ; } -pr_info ("elf_hwcap is 0x%lx" , elf_hwcap); +pr_info ("elf_hwcap is 0x%lx\n" , elf_hwcap);#ifdef CONFIG_FPU if (elf_hwcap & (COMPAT_HWCAP_ISA_F |COMPAT_HWCAP_ISA_D ))
arch/riscv/kernel/ftrace.c +1 -1
@@ -32,7 +32,7 @@ static int ftrace_check_current_call(unsigned long hook_pos,* return must be -EINVAL on failed comparison */ if (memcmp (expected, replaced,sizeof (replaced))) { -pr_err ("%p: expected (%08x %08x) but get (%08x %08x)" , +pr_err ("%p: expected (%08x %08x) but got (%08x %08x)\n" , (void *)hook_pos, expected[0 ], expected[1 ], replaced[0 ], replaced[1 ]);return -EINVAL ;
Signature · 1 line
2.20.1
PATCH 5/5 riscv: use for_each_of_cpu_node iterator
In reply to Johan HovoldUse the new for_each_of_cpu_node() helper to iterate over cpu nodes instead of open coding. Note that this will allow matching also on the node name instead of the (for FDT) deprecated device_type property.
--- arch/riscv/kernel/cpufeature.c | 5 +++-- arch/riscv/kernel/smpboot.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-)
arch/riscv/kernel/cpufeature.c +3 -2
@@ -28,7 +28,7 @@ bool has_fpu __read_mostly;void riscv_fill_hwcap (void ) { -struct device_node *node =NULL ; +struct device_node *node;const char *isa;size_t i;static unsigned long isa2hwcap[256 ] = {0 };
@@ -46,9 +46,10 @@ void riscv_fill_hwcap(void)* We don't support running Linux on hertergenous ISA systems. For * now, we just check the ISA of the first "okay" processor. */ -while ((node =of_find_node_by_type (node,"cpu" ))) +for_each_of_cpu_node (node) {if (riscv_of_processor_hartid (node) >=0 )break ; + }if (!node) {pr_warn ("Unable to find \"cpu\" devicetree entry\n" );return ;
arch/riscv/kernel/smpboot.c +2 -2
@@ -50,12 +50,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus)void __init setup_smp (void ) { -struct device_node *dn =NULL ; +struct device_node *dn;int hart;bool found_boot_cpu = false;int cpuid =1 ; -while ((dn =of_find_node_by_type (dn,"cpu" ))) { +for_each_of_cpu_node (dn) { hart =riscv_of_processor_hartid (dn);if (hart <0 )continue ;
Signature · 1 line
2.20.1
cover riscv: minor fixes and cleanups
This series fix up some minor issues found through inspection.
Note that the fourth patch changes which cpu (hart) devicetree nodes are enabled by following the Linux convention of considering nodes without a status property as enabled.
These patches are against the riscv-next (and fixes) branch with Andreas node-reference fix applied:
https://lore.kernel.org/lkml/[email protected]/
and have been tested using QEMU.
Johan
Johan Hovold (5):
riscv: add missing newlines to printk messages
riscv: use pr_info and friends
riscv: fix riscv_of_processor_hartid() comment
riscv: treat cpu devicetree nodes without status as enabled
riscv: use for_each_of_cpu_node iterator
arch/riscv/kernel/cpu.c | 28 ++++++++++++---------------- arch/riscv/kernel/cpufeature.c | 13 +++++++------ arch/riscv/kernel/ftrace.c | 2 +- arch/riscv/kernel/setup.c | 6 +++--- arch/riscv/kernel/smpboot.c | 4 ++-- 5 files changed, 25 insertions(+), 28 deletions(-)
Signature · 7 lines
2.20.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH 3/5 riscv: fix riscv_of_processor_hartid() comment
The riscv_of_processor_hartid() helper returns -ENODEV when the specified node isn't an enabled and valid RISC-V hart node.
Also drop the unnecessary parenthesis around errno defines.
--- arch/riscv/kernel/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/riscv/kernel/cpu.c +9 -9
@@ -17,8 +17,8 @@#include <asm/smp.h> /* -* Returns the hart ID of the given device tree node, or -1 if the device tree -* node isn't a RISC-V hart. +* Returns the hart ID of the given device tree node, or -ENODEV if the node +* isn't an enabled and valid RISC-V hart node. */ int riscv_of_processor_hartid (struct device_node *node) {
@@ -27,34 +27,34 @@ int riscv_of_processor_hartid(struct device_node *node)if (!of_device_is_compatible (node,"riscv" )) {pr_warn ("Found incompatible CPU\n" ); -return -(ENODEV ); +return -ENODEV ; }if (of_property_read_u32 (node,"reg" , &hart)) {pr_warn ("Found CPU without hart ID\n" ); -return -(ENODEV ); +return -ENODEV ; }if (hart >=NR_CPUS ) {pr_info ("Found hart ID %d, which is above NR_CPUs. Disabling this hart\n" , hart); -return -(ENODEV ); +return -ENODEV ; }if (of_property_read_string (node,"status" , &status)) {pr_warn ("CPU with hartid=%d has no \"status\" property\n" , hart); -return -(ENODEV ); +return -ENODEV ; }if (strcmp (status,"okay" )) {pr_info ("CPU with hartid=%d has a non-okay status of \"%s\"\n" , hart, status); -return -(ENODEV ); +return -ENODEV ; }if (of_property_read_string (node,"riscv,isa" , &isa)) {pr_warn ("CPU with hartid=%d has no \"riscv,isa\" property\n" , hart); -return -(ENODEV ); +return -ENODEV ; }if (isa[0 ] !='r' || isa[1 ] !='v' ) {pr_warn ("CPU with hartid=%d has an invalid ISA of \"%s\"\n" , hart, isa); -return -(ENODEV ); +return -ENODEV ; }return hart;
Signature · 1 line
2.20.1
PATCH 4/5 riscv: treat cpu devicetree nodes without status as enabled
In reply to Johan HovoldFollow the Linux convention and treat devicetree nodes without a status property as enabled rather than disabled, while also allowing "ok" as a shorthand for "okay".
--- arch/riscv/kernel/cpu.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
arch/riscv/kernel/cpu.c +3 -7
@@ -22,7 +22,7 @@*/ int riscv_of_processor_hartid (struct device_node *node) { -const char *isa, *status; +const char *isa;u32 hart;if (!of_device_is_compatible (node,"riscv" )) {
@@ -39,12 +39,8 @@ int riscv_of_processor_hartid(struct device_node *node)return -ENODEV ; } -if (of_property_read_string (node,"status" , &status)) { -pr_warn ("CPU with hartid=%d has no \"status\" property\n" , hart); -return -ENODEV ; - } -if (strcmp (status,"okay" )) { -pr_info ("CPU with hartid=%d has a non-okay status of \"%s\"\n" , hart, status); +if (!of_device_is_available (node)) { +pr_info ("CPU with hartid=%d is not available\n" , hart);return -ENODEV ; }
Signature · 7 lines
2.20.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH 2/5] riscv: use pr_info and friends
In reply to Johan HovoldQuoted 4 lines · Johan Hovold
Use the
pr_infoandpr_errmacros instead of printk with explicit log levels.Signed-off-by Johan Hovold <[email protected]>
- Paul
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH 3/5] riscv: fix riscv_of_processor_hartid() comment
In reply to Johan HovoldQuoted 6 lines · Johan Hovold
The
riscv_of_processor_hartid()helper returns-ENODEVwhen the specified node isn't an enabled and valid RISC-V hart node.Also drop the unnecessary parenthesis around errno defines.
Signed-off-by Johan Hovold <[email protected]>
- Paul
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH 4/5] riscv: treat cpu devicetree nodes without status as enabled
In reply to Johan HovoldQuoted 5 lines · Johan Hovold
Follow the Linux convention and treat devicetree nodes without a status property as enabled rather than disabled, while also allowing "ok" as a shorthand for "okay".
Signed-off-by Johan Hovold <[email protected]>
... although I probably would have phrased the commit message slightly differently - something like "Use of_device_is_available() in riscv_of_processor_hartid(), in place of an open-coded test." That frames the change as one that removes custom code in place of an existing standard function for the same purpose.
- Paul
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH 4/5] riscv: treat cpu devicetree nodes without status as enabled
Quoted 8 lines · Paul Walmsley
Quoted 5 lines · Johan Hovold
Follow the Linux convention and treat devicetree nodes without a status property as enabled rather than disabled, while also allowing "ok" as a shorthand for "okay".
Signed-off-by Johan Hovold <[email protected]>
Quoted 7 lines
Reviewed-by Paul Walmsley <[email protected]>... although I probably would have phrased the commit message slightly differently - something like "Use
of_device_is_available()inriscv_of_processor_hartid(), in place of an open-coded test." That frames the change as one that removes custom code in place of an existing standard function for the same purpose.
You're right, and that was my motivation too. In the end I decided to highlight the side effect in case someone was perhaps unknowingly relying on the current behaviour.
Thanks for the review!
Johan
Quoted 11 lines · Johan Hovold
This series fix up some minor issues found through inspection.
Note that the fourth patch changes which cpu (hart) devicetree nodes are enabled by following the Linux convention of considering nodes without a status property as enabled.
These patches are against the riscv-next (and fixes) branch with Andreas node-reference fix applied:
Quoted 8 lines
and have been tested using QEMU.
Johan Hovold (5):
riscv: add missing newlines to printk messages
riscv: usepr_infoand friends
riscv: fixriscv_of_processor_hartid()comment
riscv: treat cpu devicetree nodes without status as enabled
riscv: usefor_each_of_cpu_nodeiterator
Are these still in your queue, Palmer?
Note that the node-reference dependency mentioned above is now in Linus's tree.
Johan
Quoted 21 lines · On Mon, 11 Feb 2019 01:34:06 PST (-0800), [email protected] wrote:
Quoted 11 lines · Johan Hovold
This series fix up some minor issues found through inspection.
Note that the fourth patch changes which cpu (hart) devicetree nodes are enabled by following the Linux convention of considering nodes without a status property as enabled.
These patches are against the riscv-next (and fixes) branch with Andreas node-reference fix applied:
Quoted 8 lines
and have been tested using QEMU.
Johan Hovold (5):
riscv: add missing newlines to printk messages
riscv: usepr_infoand friends
riscv: fixriscv_of_processor_hartid()comment
riscv: treat cpu devicetree nodes without status as enabled
riscv: usefor_each_of_cpu_nodeiterator
Quoted 4 lines
Are these still in your queue, Palmer?
Note that the node-reference dependency mentioned above is now in Linus's tree.
They're still in my queue. With any luck I'll have time tonight to go through by Linux patch review backlog.
Re: [PATCH 1/5] riscv: add missing newlines to printk messages
In reply to Johan HovoldQuoted 6 lines · Johan Hovold
Add missing newline characters to printk messages.
Also replace two
pr_warningwith the shorterpr_warn, and fix up the tense of one error message while at it.Signed-off-by Johan Hovold <[email protected]>
Looks good,
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH 2/5] riscv: use pr_info and friends
In reply to Johan HovoldQuoted 4 lines · Johan Hovold
Use the
pr_infoandpr_errmacros instead of printk with explicit log levels.Signed-off-by Johan Hovold <[email protected]>
Looks good,
Re: [PATCH 3/5] riscv: fix riscv_of_processor_hartid() comment
In reply to Johan HovoldQuoted 6 lines · Johan Hovold
The
riscv_of_processor_hartid()helper returns-ENODEVwhen the specified node isn't an enabled and valid RISC-V hart node.Also drop the unnecessary parenthesis around errno defines.
Signed-off-by Johan Hovold <[email protected]>
Looks good,
Re: [PATCH 4/5] riscv: treat cpu devicetree nodes without status as enabled
In reply to Johan HovoldQuoted 5 lines · Johan Hovold
Follow the Linux convention and treat devicetree nodes without a status property as enabled rather than disabled, while also allowing "ok" as a shorthand for "okay".
Signed-off-by Johan Hovold <[email protected]>
Looks good:
Re: [PATCH 5/5] riscv: use for_each_of_cpu_node iterator
In reply to Johan HovoldQuoted 5 lines · Johan Hovold
Use the new
for_each_of_cpu_node()helper to iterate over cpu nodes instead of open coding. Note that this will allow matching also on the node name instead of the (for FDT) deprecateddevice_typeproperty.Signed-off-by Johan Hovold <[email protected]>
I think this is going to conflict with the ELF caps changes from Atish. Maybe the riscv_fill_hwcap hunk should be included in his patch?
Otherwise looks good:
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH 5/5] riscv: use for_each_of_cpu_node iterator
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Johan Hovold
Use the new
for_each_of_cpu_node()helper to iterate over cpu nodes instead of open coding. Note that this will allow matching also on the node name instead of the (for FDT) deprecateddevice_typeproperty.Signed-off-by Johan Hovold <[email protected]>I think this is going to conflict with the ELF caps changes from Atish. Maybe the
riscv_fill_hwcaphunk should be included in his patch?
Since that patch had some issues (e.g. the node reference underflow) it may be better to rebase it on top of this series. The changes are otherwise distinct after all.
Quoted 3 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Thanks for reviewing!
Johan
Re: [PATCH 5/5] riscv: use for_each_of_cpu_node iterator
Quoted 8 lines · Johan Hovold
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Johan Hovold
Use the new
for_each_of_cpu_node()helper to iterate over cpu nodes instead of open coding. Note that this will allow matching also on the node name instead of the (for FDT) deprecateddevice_typeproperty.Signed-off-by Johan Hovold <[email protected]>
Quoted 8 lines
Quoted 3 lines
I think this is going to conflict with the ELF caps changes from Atish. Maybe the
riscv_fill_hwcaphunk should be included in his patch?Since that patch had some issues (e.g. the node reference underflow) it may be better to rebase it on top of this series. The changes are otherwise distinct after all.
I have fixed the node reference underflow issue and made some more changes based on comments.
Some other patches(1,3,4,5) in this series may conflict with my series as well. I can rebase my series on top of yours and send it as one series if that's okay with you and Palmer.
Regards,
Atish
Quoted 8 lines
Quoted 3 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>Thanks for reviewing!
Johan
Re: [PATCH 5/5] riscv: use for_each_of_cpu_node iterator
Quoted 18 lines · Atish Patra
Quoted 8 lines · Johan Hovold
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Johan Hovold
Use the new
for_each_of_cpu_node()helper to iterate over cpu nodes instead of open coding. Note that this will allow matching also on the node name instead of the (for FDT) deprecateddevice_typeproperty.Signed-off-by Johan Hovold <[email protected]>Quoted 8 lines
Quoted 3 lines
I think this is going to conflict with the ELF caps changes from Atish. Maybe the
riscv_fill_hwcaphunk should be included in his patch?Since that patch had some issues (e.g. the node reference underflow) it may be better to rebase it on top of this series. The changes are otherwise distinct after all.
Quoted 6 lines
I have fixed the node reference underflow issue and made some more changes based on comments.
Some other
patches(1,3,4,5)in this series may conflict with my series as well. I can rebase my series on top of yours and send it as one series if that's okay with you and Palmer.
No need for you to resend these patches as they are reviewed any ready to be merged. Just rebase your series and mention the dependency in the cover letter as I did with Andreas's patch which this series depended on.
Thanks,
Johan
Re: [PATCH 5/5] riscv: use for_each_of_cpu_node iterator
Quoted 22 lines · Johan Hovold
Quoted 21 lines · Atish Patra
Quoted 8 lines · Johan Hovold
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Johan Hovold
Use the new
for_each_of_cpu_node()helper to iterate over cpu nodes instead of open coding. Note that this will allow matching also on the node name instead of the (for FDT) deprecateddevice_typeproperty.Signed-off-by Johan Hovold <[email protected]>Quoted 8 lines
Quoted 3 lines
I think this is going to conflict with the ELF caps changes from Atish. Maybe the
riscv_fill_hwcaphunk should be included in his patch?Since that patch had some issues (e.g. the node reference underflow) it may be better to rebase it on top of this series. The changes are otherwise distinct after all.
I have fixed the node reference underflow issue and made some more changes based on comments.
Quoted 9 lines
Quoted 3 lines
Some other
patches(1,3,4,5)in this series may conflict with my series as well. I can rebase my series on top of yours and send it as one series if that's okay with you and Palmer.No need for you to resend these patches as they are reviewed any ready to be merged. Just rebase your series and mention the dependency in the cover letter as I did with Andreas's patch which this series depended on.
Sure. I will do that.
Regards,
Atish
Quoted 3 lines
Thanks,
Johan