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 v2 05/14] x86: Replace cpu_up/down with devcie_online/offline
Date: Mon, 25 Nov 2019 11:27:45 +0000 [thread overview]
Message-ID: <20191125112754.25223-6-qais.yousef@arm.com> (raw)
In-Reply-To: <20191125112754.25223-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-11-25 11:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191125112754.25223-1-qais.yousef@arm.com>
2019-11-25 11:27 ` [PATCH v2 01/14] smp: Create a new function to shutdown nonboot cpus Qais Yousef
2020-01-21 17:03 ` Russell King - ARM Linux admin
2020-01-21 17:47 ` Qais Yousef
2020-01-21 18:09 ` Russell King - ARM Linux admin
2020-01-22 10:32 ` Qais Yousef
2019-11-25 11:27 ` [PATCH v2 02/14] ia64: Replace cpu_down with smp_shutdown_nonboot_cpus() Qais Yousef
2019-11-25 11:27 ` [PATCH v2 03/14] arm: arm64: Don't use disable_nonboot_cpus() Qais Yousef
2020-01-21 16:50 ` Qais Yousef
2020-01-21 16:53 ` Russell King - ARM Linux admin
2020-01-21 16:58 ` Qais Yousef
2020-01-21 17:05 ` Russell King - ARM Linux admin
2019-11-25 11:27 ` [PATCH v2 04/14] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu) Qais Yousef
2019-11-25 11:27 ` Qais Yousef [this message]
2019-11-25 11:27 ` [PATCH v2 06/14] powerpc: Replace cpu_up/down with device_online/offline Qais Yousef
2019-11-25 11:27 ` [PATCH v2 07/14] sparc: " Qais Yousef
2019-11-25 11:27 ` [PATCH v2 08/14] parisc: " Qais Yousef
2019-11-25 11:27 ` [PATCH v2 09/14] driver: base: cpu: Export device_online/offline Qais Yousef
2019-11-25 11:27 ` [PATCH v2 10/14] driver: xen: Replace cpu_up/down with device_online/offline Qais Yousef
2019-12-09 6:25 ` Jürgen Groß
2019-11-25 11:27 ` [PATCH v2 11/14] firmware: psci: " Qais Yousef
2019-11-25 11:27 ` [PATCH v2 12/14] torture: " Qais Yousef
2019-11-27 21:47 ` Paul E. McKenney
2019-11-28 16:56 ` Qais Yousef
2019-11-28 17:00 ` Qais Yousef
2019-11-28 21:02 ` Paul E. McKenney
2019-11-29 9:13 ` Qais Yousef
2019-11-29 20:38 ` Paul E. McKenney
2020-02-20 15:31 ` Qais Yousef
2020-02-21 0:26 ` Paul E. McKenney
2020-02-21 9:35 ` Qais Yousef
2020-02-21 20:39 ` Paul E. McKenney
2019-11-25 11:27 ` [PATCH v2 13/14] smp: Create a new function to bringup nonboot cpus online Qais Yousef
2019-11-25 11:27 ` [PATCH v2 14/14] cpu: Hide cpu_up/down 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=20191125112754.25223-6-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®