linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Henrik Weinstock <jan.weinstock@rwth-aachen.de>
To: Stafford Horne <shorne@gmail.com>, <geert@linux-m68k.org>
Cc: <jonas@southpole.se>, <stefan.kristiansson@saunalahti.fi>,
	<openrisc@lists.librecores.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v2] openrisc: use device tree to determine present cpus
Date: Mon, 1 Feb 2021 12:49:31 +0100	[thread overview]
Message-ID: <6dbc27f8-5261-59c5-acba-70f6c6a74ba1@rwth-aachen.de> (raw)
In-Reply-To: <20210131212752.GG2002709@lianli.shorne-pla.net>

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

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>
---
Changes since v1:
  1. use for_each_of_cpu_node
  2. possible_cpus is now what is in the devicetree, up to NR_CPUS
  3. present_cpus is now all possible cpus, up to max_cpus

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

diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c
index 75be7e34f..83cbf43d4 100644
--- a/arch/openrisc/kernel/smp.c
+++ b/arch/openrisc/kernel/smp.c
@@ -61,32 +61,31 @@ void __init smp_prepare_boot_cpu(void)

  void __init smp_init_cpus(void)
  {
-	int i;
+	struct device_node* cpu;
+	u32 cpu_id;
+
+	for_each_of_cpu_node(cpu) {
+		if (of_property_read_u32(cpu, "reg", &cpu_id)) {
+			pr_warn("%s missing reg property", cpu->full_name);
+			continue;
+		}

-	for (i = 0; i < NR_CPUS; i++)
-		set_cpu_possible(i, true);
+		if (cpu_id < NR_CPUS)
+			set_cpu_possible(cpu_id, true);
+	}
  }

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

  	/*
  	 * Initialise the present map, which describes the set of CPUs
  	 * actually populated at the present time.
  	 */
-	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);
+	for_each_possible_cpu(cpu) {
+		if (cpu < max_cpus)
+			set_cpu_present(cpu, true);
  	}
  }

-- 
2.17.1


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

  reply	other threads:[~2021-02-01 11:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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           ` Jan Henrik Weinstock [this message]
2021-02-05 14:43             ` [PATCH v2] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6dbc27f8-5261-59c5-acba-70f6c6a74ba1@rwth-aachen.de \
    --to=jan.weinstock@rwth-aachen.de \
    --cc=geert@linux-m68k.org \
    --cc=jonas@southpole.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openrisc@lists.librecores.org \
    --cc=shorne@gmail.com \
    --cc=stefan.kristiansson@saunalahti.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).