From: guoren@kernel.org
To: anup.patel@wdc.com, atish.patra@wdc.com,
palmerdabbelt@google.com, tglx@linutronix.de, maz@kernel.org,
guoren@kernel.org
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Guo Ren <guoren@linux.alibaba.com>
Subject: [PATCH 2/2] riscv: Improve status in cpu sections of device-tree for cpuhotplug usage
Date: Tue, 3 Aug 2021 09:12:03 +0800 [thread overview]
Message-ID: <1627953123-24248-2-git-send-email-guoren@kernel.org> (raw)
In-Reply-To: <1627953123-24248-1-git-send-email-guoren@kernel.org>
From: Guo Ren <guoren@linux.alibaba.com>
If we define cpu sections with first okay & second fail:
cpus {
#address-cells = <1>;
#size-cells = <0>;
timebase-frequency = <3000000>;
cpu@0 {
device_type = "cpu";
reg = <0>;
status = "okay";
...
};
cpu@1 {
device_type = "cpu";
reg = <1>;
status = "fail";
...
};
};
Currently, we only get cpu0 without cpu1 in the shell:
$ ls /sys/bus/cpu/devices/
cpu0
But it should be cpu0 online and cpu1 offline, then we could let
cpu1 online later by shell. This patch fixup the problem and let
us could make cpu1 online in the shell later after system boot:
$ ls /sys/bus/cpu/devices/
cpu0 cpu1
$ cat /sys/bus/cpu/devices/cpu0/online
1
$ cat /sys/bus/cpu/devices/cpu1/online
0
$ echo 224 > /sys/bus/cpu/devices/cpu1/hotplug/target
(cat /sys/devices/system/cpu/hotplug/states "224: online")
$ cat /sys/bus/cpu/devices/cpu1/online
1
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Anup Patel <anup.patel@wdc.com>
Cc: Atish Patra <atish.patra@wdc.com>
Cc: Palmer Dabbelt <palmerdabbelt@google.com>
---
arch/riscv/kernel/cpu.c | 5 -----
arch/riscv/kernel/smpboot.c | 11 +++++++++++
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
index 6d59e69..14f63fd 100644
--- a/arch/riscv/kernel/cpu.c
+++ b/arch/riscv/kernel/cpu.c
@@ -27,11 +27,6 @@ int riscv_of_processor_hartid(struct device_node *node)
return -ENODEV;
}
- if (!of_device_is_available(node)) {
- pr_info("CPU with hartid=%d is not available\n", hart);
- 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;
diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index bd82375..c3b620b 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -37,6 +37,7 @@
#include "head.h"
static DECLARE_COMPLETION(cpu_running);
+static struct cpumask cpu_delay_available_mask = { CPU_BITS_NONE };
void __init smp_prepare_boot_cpu(void)
{
@@ -99,6 +100,11 @@ void __init setup_smp(void)
break;
}
+ if (!of_device_is_available(dn))
+ pr_info("CPU with hartid=%d is not available\n", hart);
+ else
+ cpumask_set_cpu(cpuid, &cpu_delay_available_mask);
+
cpuid_to_hartid_map(cpuid) = hart;
early_map_cpu_to_node(cpuid, of_node_to_nid(dn));
cpuid++;
@@ -131,6 +137,11 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
int ret = 0;
tidle->thread_info.cpu = cpu;
+ if (!cpumask_test_cpu(cpu, &cpu_delay_available_mask)) {
+ cpumask_set_cpu(cpu, &cpu_delay_available_mask);
+ return -EIO;
+ }
+
ret = start_secondary_cpu(cpu, tidle);
if (!ret) {
wait_for_completion_timeout(&cpu_running,
--
2.7.4
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2021-08-03 1:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 1:12 [PATCH 1/2] irqchip/sifive-plic: Fix PLIC crash on touching offline CPU context guoren
2021-08-03 1:12 ` guoren [this message]
2021-08-03 5:13 ` Anup Patel
2021-08-10 2:43 ` Guo Ren
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=1627953123-24248-2-git-send-email-guoren@kernel.org \
--to=guoren@kernel.org \
--cc=anup.patel@wdc.com \
--cc=atish.patra@wdc.com \
--cc=guoren@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=maz@kernel.org \
--cc=palmerdabbelt@google.com \
--cc=tglx@linutronix.de \
/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