linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] openrisc: use device tree to determine present cpus
@ 2021-01-29 18:29 Jan Henrik Weinstock
  2021-01-29 22:16 ` Stafford Horne
  2021-01-30 10:37 ` [PATCH] " Geert Uytterhoeven
  0 siblings, 2 replies; 14+ messages in thread
From: Jan Henrik Weinstock @ 2021-01-29 18:29 UTC (permalink / raw)
  To: jonas, stefan.kristiansson, shorne, openrisc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1467 bytes --]

This patch proposes to use the device tree to determine the present cpus 
instead of assuming all CONFIG_NRCPUS are actually present in the system.

Signed-off-by: Jan Henrik Weinstock <jan.weinstock@rwth-aachen.de>
---
  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


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5316 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-02-08 12:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 18:29 [PATCH] openrisc: use device tree to determine present cpus Jan Henrik Weinstock
2021-01-29 22:16 ` Stafford Horne
2021-01-30 11:00   ` Jan Henrik Weinstock
2021-01-30 23:03     ` Stafford Horne
2021-01-30 23:11       ` Stafford Horne
2021-01-31  8:22       ` Jan Henrik Weinstock
2021-01-31 21:27         ` Stafford Horne
2021-02-01 11:49           ` [PATCH v2] " Jan Henrik Weinstock
2021-02-05 14:43             ` Stafford Horne
2021-02-05 16:07               ` Geert Uytterhoeven
2021-02-05 22:36                 ` Stafford Horne
2021-02-06  9:33                   ` Geert Uytterhoeven
     [not found]                     ` <20210208121648.GN2002709@lianli.shorne-pla.net>
2021-02-08 12:22                       ` Geert Uytterhoeven
2021-01-30 10:37 ` [PATCH] " Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).