mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
To: linux-snps-arc@lists.infradead.org
Cc: linux-kernel@vger.kernel.org,
	Vineet Gupta <Vineet.Gupta1@synopsys.com>,
	Alexey Brodkin <Alexey.Brodkin@synopsys.com>,
	Rob Herring <robh+dt@kernel.org>,
	Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Subject: [RFC] ARC: setup cpu possible mask according to status field in dts
Date: Fri, 22 Dec 2017 22:08:28 +0300	[thread overview]
Message-ID: <20171222190828.29162-1-Eugeniy.Paltsev@synopsys.com> (raw)

As we have option in u-boot to set CPU mask for running linux,
we want to pass information to kernel about CPU cores should
be brought up.

So we patch kernel dtb in u-boot to set CPUs status.

On linux boot we setup cpu possible mask according to status
field in each cpu node. It is generic method according to ePAPR:
  status - a standard property describing the state of a CPU.
  This property shall be present for nodes representing CPUs in a
  symmetric multiprocessing (SMP) configuration. For a CPU node
  the meaning of the "okay" and "disabled" values are as follows:
  "okay" - The CPU is running; "disabled" - The CPU is in a
  quiescent state."

Also we setup MCIP debug mask according cpu possible mask.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
---
 arch/arc/kernel/mcip.c | 10 ++++++++--
 arch/arc/kernel/smp.c  | 30 ++++++++++++++++++++++++++----
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/arch/arc/kernel/mcip.c b/arch/arc/kernel/mcip.c
index f61a52b..246481d 100644
--- a/arch/arc/kernel/mcip.c
+++ b/arch/arc/kernel/mcip.c
@@ -89,6 +89,8 @@ static void mcip_ipi_clear(int irq)
 static void mcip_probe_n_setup(void)
 {
 	struct mcip_bcr mp;
+	u32 mcip_mask = 0;
+	int i;
 
 	READ_BCR(ARC_REG_MCIP_BCR, mp);
 
@@ -102,9 +104,13 @@ static void mcip_probe_n_setup(void)
 
 	cpuinfo_arc700[0].extn.gfrc = mp.gfrc;
 
+	for (i = 0; i < NR_CPUS; i++)
+		if (cpu_possible(i))
+			mcip_mask |= BIT(i);
+
 	if (mp.dbg) {
-		__mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, 0xf);
-		__mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, 0xf);
+		__mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, mcip_mask);
+		__mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, mcip_mask);
 	}
 }
 
diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
index efe8b42..ee8b20a 100644
--- a/arch/arc/kernel/smp.c
+++ b/arch/arc/kernel/smp.c
@@ -24,6 +24,8 @@
 #include <linux/reboot.h>
 #include <linux/irqdomain.h>
 #include <linux/export.h>
+#include <linux/of_fdt.h>
+#include <linux/libfdt.h>
 
 #include <asm/processor.h>
 #include <asm/setup.h>
@@ -47,6 +49,29 @@ void __init smp_prepare_boot_cpu(void)
 {
 }
 
+/* Mark cpu as possible if cpu status is "okay" or status absents */
+void __init smp_init_cpumask(void)
+{
+	const struct fdt_property *prop;
+	char fdt_cpu_path[25];
+	unsigned int i, oft;
+
+	for (i = 0; i < NR_CPUS; i++) {
+		sprintf(fdt_cpu_path, "/cpus/cpu@%u", i);
+		oft = fdt_path_offset(initial_boot_params, fdt_cpu_path);
+		prop = fdt_get_property(initial_boot_params, oft, "status", NULL);
+
+		/* No status property == status OK */
+		if (!prop) {
+			set_cpu_possible(i, true);
+			continue;
+		}
+
+		if (!strcmp("okay", prop->data))
+			set_cpu_possible(i, true);
+	}
+}
+
 /*
  * Called from setup_arch() before calling setup_processor()
  *
@@ -58,10 +83,7 @@ void __init smp_prepare_boot_cpu(void)
  */
 void __init smp_init_cpus(void)
 {
-	unsigned int i;
-
-	for (i = 0; i < NR_CPUS; i++)
-		set_cpu_possible(i, true);
+	smp_init_cpumask();
 
 	if (plat_smp_ops.init_early_smp)
 		plat_smp_ops.init_early_smp();
-- 
2.9.3

             reply	other threads:[~2017-12-22 19:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-22 19:08 Eugeniy Paltsev [this message]
2018-01-05 20:37 ` Vineet Gupta

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=20171222190828.29162-1-Eugeniy.Paltsev@synopsys.com \
    --to=eugeniy.paltsev@synopsys.com \
    --cc=Alexey.Brodkin@synopsys.com \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=robh+dt@kernel.org \
    /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

all inboxes | Powered by JetHome®