lkml.org 
[lkml]   [2021]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH] Use devicetree to determine present cpus
Date
Signed-off-by: Jan Henrik Weinstock <jan.weinstock@rwth-aachen.de>
---

Re-send patch with git sendmail

arch/openrisc/kernel/smp.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c
index 29c82ef2e..75be7e34f 100644
--- a/arch/openrisc/kernel/smp.c
+++ b/arch/openrisc/kernel/smp.c
@@ -16,6 +16,7 @@
#include <linux/sched.h>
#include <linux/sched/mm.h>
#include <linux/irq.h>
+#include <linux/of.h>
#include <asm/cpuinfo.h>
#include <asm/mmu_context.h>
#include <asm/tlbflush.h>
@@ -68,14 +69,25 @@ void __init smp_init_cpus(void)

void __init smp_prepare_cpus(unsigned int max_cpus)
{
- int i;
+ u32 cpu_id;
+ struct device_node *cpu, *cpus;

/*
* Initialise the present map, which describes the set of CPUs
* actually populated at the present time.
*/
- for (i = 0; i < max_cpus; i++)
- set_cpu_present(i, true);
+ cpus = of_find_node_by_path("/cpus");
+ for_each_child_of_node(cpus, cpu) {
+ if (of_property_read_u32(cpu, "reg", &cpu_id)) {
+ pr_warn("%s missing reg property", cpu->full_name);
+ continue;
+ }
+
+ if (cpu_id >= max_cpus)
+ continue;
+
+ set_cpu_present(cpu_id, true);
+ }
}

void __init smp_cpus_done(unsigned int max_cpus)
--
2.17.1
\
 
 \ /
  Last update: 2021-02-08 15:46    [W:0.027 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site