From: Qais Yousef <qais.yousef@arm.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Qais Yousef <qais.yousef@arm.com>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 02/12] x86: Replace cpu_up/down with devcie_online/offline
Date: Wed, 30 Oct 2019 15:38:27 +0000 [thread overview]
Message-ID: <20191030153837.18107-3-qais.yousef@arm.com> (raw)
In-Reply-To: <20191030153837.18107-1-qais.yousef@arm.com>
The core device API performs extra housekeeping bits that are missing
from directly calling cpu_up/down.
See commit a6717c01ddc2 ("powerpc/rtas: use device model APIs and
serialization during LPM") for an example description of what might go
wrong.
This also prepares to make cpu_up/down a private interface for anything
but the cpu subsystem.
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: Borislav Petkov <bp@alien8.de>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
---
arch/x86/kernel/topology.c | 4 ++--
arch/x86/mm/mmio-mod.c | 8 ++++++--
arch/x86/xen/smp.c | 4 +++-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c
index be5bc2e47c71..3b253088615e 100644
--- a/arch/x86/kernel/topology.c
+++ b/arch/x86/kernel/topology.c
@@ -69,7 +69,7 @@ int _debug_hotplug_cpu(int cpu, int action)
switch (action) {
case 0:
- ret = cpu_down(cpu);
+ ret = device_offline(get_cpu_device(cpu));
if (!ret) {
pr_info("DEBUG_HOTPLUG_CPU0: CPU %u is now offline\n", cpu);
dev->offline = true;
@@ -78,7 +78,7 @@ int _debug_hotplug_cpu(int cpu, int action)
pr_debug("Can't offline CPU%d.\n", cpu);
break;
case 1:
- ret = cpu_up(cpu);
+ ret = device_online(get_cpu_device(cpu));
if (!ret) {
dev->offline = false;
kobject_uevent(&dev->kobj, KOBJ_ONLINE);
diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
index b8ef8557d4b3..7ec7d05335ce 100644
--- a/arch/x86/mm/mmio-mod.c
+++ b/arch/x86/mm/mmio-mod.c
@@ -385,13 +385,15 @@ static void enter_uniprocessor(void)
pr_notice("Disabling non-boot CPUs...\n");
put_online_cpus();
+ lock_device_hotplug();
for_each_cpu(cpu, downed_cpus) {
- err = cpu_down(cpu);
+ err = device_offline(get_cpu_device(cpu));
if (!err)
pr_info("CPU%d is down.\n", cpu);
else
pr_err("Error taking CPU%d down: %d\n", cpu, err);
}
+ unlock_device_hotplug();
out:
if (num_online_cpus() > 1)
pr_warning("multiple CPUs still online, may miss events.\n");
@@ -405,13 +407,15 @@ static void leave_uniprocessor(void)
if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
return;
pr_notice("Re-enabling CPUs...\n");
+ lock_device_hotplug();
for_each_cpu(cpu, downed_cpus) {
- err = cpu_up(cpu);
+ err = device_online(get_cpu_device(cpu));
if (!err)
pr_info("enabled CPU%d.\n", cpu);
else
pr_err("cannot re-enable CPU%d: %d\n", cpu, err);
}
+ unlock_device_hotplug();
}
#else /* !CONFIG_HOTPLUG_CPU */
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 7a43b2ae19f1..aaa31100a31e 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -128,11 +128,12 @@ void __init xen_smp_cpus_done(unsigned int max_cpus)
if (xen_have_vcpu_info_placement)
return;
+ lock_device_hotplug();
for_each_online_cpu(cpu) {
if (xen_vcpu_nr(cpu) < MAX_VIRT_CPUS)
continue;
- rc = cpu_down(cpu);
+ rc = device_offline(get_cpu_device(cpu));
if (rc == 0) {
/*
@@ -145,6 +146,7 @@ void __init xen_smp_cpus_done(unsigned int max_cpus)
__func__, cpu, rc);
}
}
+ unlock_device_hotplug();
WARN(count, "%s: brought %d CPUs offline\n", __func__, count);
}
--
2.17.1
next prev parent reply other threads:[~2019-10-30 15:42 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191030153837.18107-1-qais.yousef@arm.com>
2019-10-30 15:38 ` [PATCH 01/12] arm64: hibernate.c: create a new function to handle cpu_up(sleep_cpu) Qais Yousef
2019-11-19 22:31 ` Thomas Gleixner
2019-11-19 22:51 ` Qais Yousef
2019-11-19 23:01 ` Thomas Gleixner
2019-11-19 23:21 ` Qais Yousef
2019-10-30 15:38 ` Qais Yousef [this message]
2019-10-30 15:38 ` [PATCH 03/12] powerpc: Replace cpu_up/down with device_online/offline Qais Yousef
2019-11-19 1:19 ` Michael Ellerman
2019-11-19 9:47 ` Qais Yousef
2019-10-30 15:38 ` [PATCH 04/12] ia64: Replace cpu_down with freeze_secondary_cpus Qais Yousef
2019-11-02 4:59 ` kbuild test robot
2019-11-19 22:21 ` Thomas Gleixner
2019-11-19 22:32 ` Qais Yousef
2019-11-19 22:59 ` Thomas Gleixner
2019-11-19 23:19 ` Qais Yousef
2019-11-20 8:46 ` Thomas Gleixner
2019-11-20 10:49 ` Qais Yousef
2019-10-30 15:38 ` [PATCH 05/12] sparc: Replace cpu_up/down with device_online/offline Qais Yousef
2019-10-30 19:33 ` David Miller
2019-10-30 15:38 ` [PATCH 06/12] parisc: " Qais Yousef
2019-11-20 11:09 ` Qais Yousef
2019-11-22 19:51 ` Helge Deller
2019-11-24 10:20 ` Qais Yousef
2019-10-30 15:38 ` [PATCH 07/12] driver: base: cpu: export device_online/offline Qais Yousef
2019-11-02 17:17 ` Greg Kroah-Hartman
2019-10-30 15:38 ` [PATCH 08/12] driver: xen: Replace cpu_up/down with device_online/offline Qais Yousef
2019-10-30 15:38 ` [PATCH 09/12] firmware: psci: " Qais Yousef
2019-10-30 15:38 ` [PATCH 10/12] torture: " Qais Yousef
2019-10-30 15:38 ` [PATCH 11/12] smp: Create a new function to bringup nonboot cpus online Qais Yousef
2019-11-19 22:42 ` Thomas Gleixner
2019-10-30 15:38 ` [PATCH 12/12] cpu: Hide cpu_up/down Qais Yousef
2019-11-19 22:25 ` Thomas Gleixner
2019-11-19 22:36 ` Qais Yousef
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=20191030153837.18107-3-qais.yousef@arm.com \
--to=qais.yousef@arm.com \
--cc=bp@alien8.de \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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®