linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 01/15] cpu: Add new {add,remove}_cpu() functions
       [not found] <20200223192942.18420-1-qais.yousef@arm.com>
@ 2020-02-23 19:29 ` Qais Yousef
  2020-02-23 19:29 ` [PATCH v3 02/15] smp: Create a new function to shutdown nonboot cpus Qais Yousef
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Qais Yousef @ 2020-02-23 19:29 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Juergen Gross, Mark Rutland, Lorenzo Pieralisi, linux-parisc,
	Paul E . McKenney, Michael Ellerman, Helge Deller, x86,
	linux-kernel, David S. Miller, sparclinux, xen-devel,
	linuxppc-dev, Qais Yousef, linux-arm-kernel

The new functions use device_{online,offline}() which are userspace
safe.

This is in preparation to move cpu_{up, down} kernel users to use
a safer interface that is not racy with userspace.

Suggested-by: "Paul E. McKenney" <paulmck@kernel.org>
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: "Paul E. McKenney" <paulmck@kernel.org>
CC: Helge Deller <deller@gmx.de>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: "David S. Miller" <davem@davemloft.net>
CC: Juergen Gross <jgross@suse.com>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
CC: xen-devel@lists.xenproject.org
CC: linux-parisc@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-arm-kernel@lists.infradead.org
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
---
 include/linux/cpu.h |  2 ++
 kernel/cpu.c        | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 1ca2baf817ed..cf8cf38dca43 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -89,6 +89,7 @@ extern ssize_t arch_cpu_release(const char *, size_t);
 #ifdef CONFIG_SMP
 extern bool cpuhp_tasks_frozen;
 int cpu_up(unsigned int cpu);
+int add_cpu(unsigned int cpu);
 void notify_cpu_starting(unsigned int cpu);
 extern void cpu_maps_update_begin(void);
 extern void cpu_maps_update_done(void);
@@ -118,6 +119,7 @@ extern void cpu_hotplug_disable(void);
 extern void cpu_hotplug_enable(void);
 void clear_tasks_mm_cpumask(int cpu);
 int cpu_down(unsigned int cpu);
+int remove_cpu(unsigned int cpu);
 
 #else /* CONFIG_HOTPLUG_CPU */
 
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 9c706af713fb..069802f7010f 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1057,6 +1057,18 @@ int cpu_down(unsigned int cpu)
 }
 EXPORT_SYMBOL(cpu_down);
 
+int remove_cpu(unsigned int cpu)
+{
+	int ret;
+
+	lock_device_hotplug();
+	ret = device_offline(get_cpu_device(cpu));
+	unlock_device_hotplug();
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(remove_cpu);
+
 #else
 #define takedown_cpu		NULL
 #endif /*CONFIG_HOTPLUG_CPU*/
@@ -1209,6 +1221,18 @@ int cpu_up(unsigned int cpu)
 }
 EXPORT_SYMBOL_GPL(cpu_up);
 
+int add_cpu(unsigned int cpu)
+{
+	int ret;
+
+	lock_device_hotplug();
+	ret = device_online(get_cpu_device(cpu));
+	unlock_device_hotplug();
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(add_cpu);
+
 #ifdef CONFIG_PM_SLEEP_SMP
 static cpumask_var_t frozen_cpus;
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 02/15] smp: Create a new function to shutdown nonboot cpus
       [not found] <20200223192942.18420-1-qais.yousef@arm.com>
  2020-02-23 19:29 ` [PATCH v3 01/15] cpu: Add new {add,remove}_cpu() functions Qais Yousef
@ 2020-02-23 19:29 ` Qais Yousef
  2020-02-23 19:29 ` [PATCH v3 04/15] arm: Don't use disable_nonboot_cpus() Qais Yousef
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Qais Yousef @ 2020-02-23 19:29 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Tony Luck, Fenghua Yu, linux-ia64, Rafael J. Wysocki,
	Catalin Marinas, Paul E . McKenney, Greg Kroah-Hartman,
	Peter Zijlstra (Intel),
	Jiri Kosina, Daniel Lezcano, linux-kernel, Zhenzhong Duan,
	Nicholas Piggin, Ingo Molnar, Eiichi Tsukata, Nadav Amit,
	Josh Poimboeuf, Russell King, Will Deacon, Qais Yousef,
	linux-arm-kernel

This function will be used later in machine_shutdown() for some archs.

disable_nonboot_cpus() is not safe to use when doing machine_down(),
because it relies on freeze_secondary_cpus() which in turn is
a suspend/resume related freeze and could abort if the logic detects any
pending activities that can prevent finishing the offlining process.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Josh Poimboeuf <jpoimboe@redhat.com>
CC: "Peter Zijlstra (Intel)" <peterz@infradead.org>
CC: Jiri Kosina <jkosina@suse.cz>
CC: Nicholas Piggin <npiggin@gmail.com>
CC: Daniel Lezcano <daniel.lezcano@linaro.org>
CC: Ingo Molnar <mingo@kernel.org>
CC: Eiichi Tsukata <devel@etsukata.com>
CC: Zhenzhong Duan <zhenzhong.duan@oracle.com>
CC: Nadav Amit <namit@vmware.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Russell King <linux@armlinux.org.uk>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will@kernel.org>
CC: linux-arm-kernel@lists.infradead.org
CC: linux-ia64@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 include/linux/cpu.h |  2 ++
 kernel/cpu.c        | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index cf8cf38dca43..64a246e9c8db 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -120,6 +120,7 @@ extern void cpu_hotplug_enable(void);
 void clear_tasks_mm_cpumask(int cpu);
 int cpu_down(unsigned int cpu);
 int remove_cpu(unsigned int cpu);
+extern void smp_shutdown_nonboot_cpus(unsigned int primary_cpu);
 
 #else /* CONFIG_HOTPLUG_CPU */
 
@@ -131,6 +132,7 @@ static inline int  cpus_read_trylock(void) { return true; }
 static inline void lockdep_assert_cpus_held(void) { }
 static inline void cpu_hotplug_disable(void) { }
 static inline void cpu_hotplug_enable(void) { }
+static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { }
 #endif	/* !CONFIG_HOTPLUG_CPU */
 
 /* Wrappers which go away once all code is converted */
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 069802f7010f..03c727195b65 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1069,6 +1069,48 @@ int remove_cpu(unsigned int cpu)
 }
 EXPORT_SYMBOL_GPL(remove_cpu);
 
+void smp_shutdown_nonboot_cpus(unsigned int primary_cpu)
+{
+	unsigned int cpu;
+	int error;
+
+	cpu_maps_update_begin();
+
+	/*
+	 * Make certain the cpu I'm about to reboot on is online.
+	 *
+	 * This is inline to what migrate_to_reboot_cpu() already do.
+	 */
+	if (!cpu_online(primary_cpu))
+		primary_cpu = cpumask_first(cpu_online_mask);
+
+	for_each_online_cpu(cpu) {
+		if (cpu == primary_cpu)
+			continue;
+
+		error = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
+		if (error) {
+			pr_err("Failed to offline CPU%d - error=%d",
+				cpu, error);
+			break;
+		}
+	}
+
+	/*
+	 * Ensure all but the reboot CPU are offline.
+	 */
+	BUG_ON(num_online_cpus() > 1);
+
+	/*
+	 * Make sure the CPUs won't be enabled by someone else after this
+	 * point. Kexec will reboot to a new kernel shortly resetting
+	 * everything along the way.
+	 */
+	cpu_hotplug_disabled++;
+
+	cpu_maps_update_done();
+}
+
 #else
 #define takedown_cpu		NULL
 #endif /*CONFIG_HOTPLUG_CPU*/
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 04/15] arm: Don't use disable_nonboot_cpus()
       [not found] <20200223192942.18420-1-qais.yousef@arm.com>
  2020-02-23 19:29 ` [PATCH v3 01/15] cpu: Add new {add,remove}_cpu() functions Qais Yousef
  2020-02-23 19:29 ` [PATCH v3 02/15] smp: Create a new function to shutdown nonboot cpus Qais Yousef
@ 2020-02-23 19:29 ` Qais Yousef
  2020-03-20 11:04   ` Qais Yousef
  2020-02-23 19:29 ` [PATCH v3 05/15] arm64: " Qais Yousef
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Qais Yousef @ 2020-02-23 19:29 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-arm-kernel, linux-kernel, Qais Yousef, Paul E . McKenney,
	Russell King

disable_nonboot_cpus() is not safe to use when doing machine_down(),
because it relies on freeze_secondary_cpus() which in turn is
a suspend/resume related freeze and could abort if the logic detects any
pending activities that can prevent finishing the offlining process.

Beside disable_nonboot_cpus() is dependent on CONFIG_PM_SLEEP_SMP which
is an othogonal config to rely on to ensure this function works
correctly.

Use `reboot_cpu` variable instead of hardcoding 0 as the reboot cpu.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
CC: Russell King <linux@armlinux.org.uk>
CC: linux-arm-kernel@lists.infradead.org
CC: linux-kernel@vger.kernel.org
---
 arch/arm/kernel/reboot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c
index bb18ed0539f4..0ce388f15422 100644
--- a/arch/arm/kernel/reboot.c
+++ b/arch/arm/kernel/reboot.c
@@ -88,11 +88,11 @@ void soft_restart(unsigned long addr)
  * to execute e.g. a RAM-based pin loop is not sufficient. This allows the
  * kexec'd kernel to use any and all RAM as it sees fit, without having to
  * avoid any code or data used by any SW CPU pin loop. The CPU hotplug
- * functionality embodied in disable_nonboot_cpus() to achieve this.
+ * functionality embodied in smp_shutdown_nonboot_cpus() to achieve this.
  */
 void machine_shutdown(void)
 {
-	disable_nonboot_cpus();
+	smp_shutdown_nonboot_cpus(reboot_cpu);
 }
 
 /*
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 05/15] arm64: Don't use disable_nonboot_cpus()
       [not found] <20200223192942.18420-1-qais.yousef@arm.com>
                   ` (2 preceding siblings ...)
  2020-02-23 19:29 ` [PATCH v3 04/15] arm: Don't use disable_nonboot_cpus() Qais Yousef
@ 2020-02-23 19:29 ` Qais Yousef
  2020-03-17 11:21   ` Catalin Marinas
  2020-02-23 19:29 ` [PATCH v3 06/15] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu) Qais Yousef
  2020-02-23 19:29 ` [PATCH v3 12/15] firmware: psci: Replace cpu_up/down with add/remove_cpu Qais Yousef
  5 siblings, 1 reply; 12+ messages in thread
From: Qais Yousef @ 2020-02-23 19:29 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Paul E . McKenney, Catalin Marinas, linux-kernel, Will Deacon,
	Qais Yousef, linux-arm-kernel

disable_nonboot_cpus() is not safe to use when doing machine_down(),
because it relies on freeze_secondary_cpus() which in turn is
a suspend/resume related freeze and could abort if the logic detects any
pending activities that can prevent finishing the offlining process.

Beside disable_nonboot_cpus() is dependent on CONFIG_PM_SLEEP_SMP which
is an othogonal config to rely on to ensure this function works
correctly.

Use `reboot_cpu` variable instead of hardcoding 0 as the reboot cpu.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will@kernel.org>
CC: linux-arm-kernel@lists.infradead.org
CC: linux-kernel@vger.kernel.org
---
 arch/arm64/kernel/process.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index bbb0f0c145f6..b33b415fb32e 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -141,11 +141,11 @@ void arch_cpu_idle_dead(void)
  * to execute e.g. a RAM-based pin loop is not sufficient. This allows the
  * kexec'd kernel to use any and all RAM as it sees fit, without having to
  * avoid any code or data used by any SW CPU pin loop. The CPU hotplug
- * functionality embodied in disable_nonboot_cpus() to achieve this.
+ * functionality embodied in smpt_shutdown_nonboot_cpus() to achieve this.
  */
 void machine_shutdown(void)
 {
-	disable_nonboot_cpus();
+	smp_shutdown_nonboot_cpus(reboot_cpu);
 }
 
 /*
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 06/15] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu)
       [not found] <20200223192942.18420-1-qais.yousef@arm.com>
                   ` (3 preceding siblings ...)
  2020-02-23 19:29 ` [PATCH v3 05/15] arm64: " Qais Yousef
@ 2020-02-23 19:29 ` Qais Yousef
  2020-03-17 11:21   ` Catalin Marinas
  2020-02-23 19:29 ` [PATCH v3 12/15] firmware: psci: Replace cpu_up/down with add/remove_cpu Qais Yousef
  5 siblings, 1 reply; 12+ messages in thread
From: Qais Yousef @ 2020-02-23 19:29 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Mark Rutland, linux-kernel, Paul E . McKenney, Steve Capper,
	Peter Zijlstra (Intel),
	Catalin Marinas, Daniel Lezcano, Pavankumar Kondeti,
	Zhenzhong Duan, Nicholas Piggin, Ingo Molnar, Richard Fontana,
	James Morse, Josh Poimboeuf, Jiri Kosina, Will Deacon,
	Qais Yousef, linux-arm-kernel

In preparation to make cpu_up/down private - move the user in arm64
hibernate.c to use a new generic function that provides what arm64
needs.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will@kernel.org>
CC: Steve Capper <steve.capper@arm.com>
CC: Richard Fontana <rfontana@redhat.com>
CC: James Morse <james.morse@arm.com>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Josh Poimboeuf <jpoimboe@redhat.com>
CC: Ingo Molnar <mingo@kernel.org>
CC: "Peter Zijlstra (Intel)" <peterz@infradead.org>
CC: Nicholas Piggin <npiggin@gmail.com>
CC: Daniel Lezcano <daniel.lezcano@linaro.org>
CC: Jiri Kosina <jkosina@suse.cz>
CC: Pavankumar Kondeti <pkondeti@codeaurora.org>
CC: Zhenzhong Duan <zhenzhong.duan@oracle.com>
CC: linux-arm-kernel@lists.infradead.org
CC: linux-kernel@vger.kernel.org
---
 arch/arm64/kernel/hibernate.c | 13 +++++--------
 include/linux/cpu.h           |  1 +
 kernel/cpu.c                  | 24 ++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c
index 590963c9c609..5b73e92c99e3 100644
--- a/arch/arm64/kernel/hibernate.c
+++ b/arch/arm64/kernel/hibernate.c
@@ -166,14 +166,11 @@ int arch_hibernation_header_restore(void *addr)
 		sleep_cpu = -EINVAL;
 		return -EINVAL;
 	}
-	if (!cpu_online(sleep_cpu)) {
-		pr_info("Hibernated on a CPU that is offline! Bringing CPU up.\n");
-		ret = cpu_up(sleep_cpu);
-		if (ret) {
-			pr_err("Failed to bring hibernate-CPU up!\n");
-			sleep_cpu = -EINVAL;
-			return ret;
-		}
+
+	ret = bringup_hibernate_cpu(sleep_cpu);
+	if (ret) {
+		sleep_cpu = -EINVAL;
+		return ret;
 	}
 
 	resume_hdr = *hdr;
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 64a246e9c8db..aebe8186cb07 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -93,6 +93,7 @@ int add_cpu(unsigned int cpu);
 void notify_cpu_starting(unsigned int cpu);
 extern void cpu_maps_update_begin(void);
 extern void cpu_maps_update_done(void);
+extern int bringup_hibernate_cpu(unsigned int sleep_cpu);
 
 #else	/* CONFIG_SMP */
 #define cpuhp_tasks_frozen	0
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 03c727195b65..bf39c5bfb6d9 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1275,6 +1275,30 @@ int add_cpu(unsigned int cpu)
 }
 EXPORT_SYMBOL_GPL(add_cpu);
 
+/**
+ * bringup_hibernate_cpu - Bring up the CPU that we hibernated on
+ * @sleep_cpu: The cpu we hibernated on and should be brought up.
+ *
+ * On some archs like arm64, we can hibernate on any CPU, but on wake up the
+ * CPU we hibernated on might be offline as a side effect of using maxcpus= for
+ * example.
+ */
+int bringup_hibernate_cpu(unsigned int sleep_cpu)
+{
+	int ret;
+
+	if (!cpu_online(sleep_cpu)) {
+		pr_info("Hibernated on a CPU that is offline! Bringing CPU up.\n");
+		ret = cpu_up(sleep_cpu);
+		if (ret) {
+			pr_err("Failed to bring hibernate-CPU up!\n");
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
 #ifdef CONFIG_PM_SLEEP_SMP
 static cpumask_var_t frozen_cpus;
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 12/15] firmware: psci: Replace cpu_up/down with add/remove_cpu
       [not found] <20200223192942.18420-1-qais.yousef@arm.com>
                   ` (4 preceding siblings ...)
  2020-02-23 19:29 ` [PATCH v3 06/15] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu) Qais Yousef
@ 2020-02-23 19:29 ` Qais Yousef
  5 siblings, 0 replies; 12+ messages in thread
From: Qais Yousef @ 2020-02-23 19:29 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Mark Rutland, Lorenzo Pieralisi, Paul E . McKenney, linux-kernel,
	Qais Yousef, linux-arm-kernel

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: Mark Rutland <mark.rutland@arm.com>
CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
CC: linux-arm-kernel@lists.infradead.org
CC: linux-kernel@vger.kernel.org
---
 drivers/firmware/psci/psci_checker.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/psci/psci_checker.c b/drivers/firmware/psci/psci_checker.c
index 6a445397771c..873841af8d57 100644
--- a/drivers/firmware/psci/psci_checker.c
+++ b/drivers/firmware/psci/psci_checker.c
@@ -84,7 +84,7 @@ static unsigned int down_and_up_cpus(const struct cpumask *cpus,
 
 	/* Try to power down all CPUs in the mask. */
 	for_each_cpu(cpu, cpus) {
-		int ret = cpu_down(cpu);
+		int ret = remove_cpu(cpu);
 
 		/*
 		 * cpu_down() checks the number of online CPUs before the TOS
@@ -116,7 +116,7 @@ static unsigned int down_and_up_cpus(const struct cpumask *cpus,
 
 	/* Try to power up all the CPUs that have been offlined. */
 	for_each_cpu(cpu, offlined_cpus) {
-		int ret = cpu_up(cpu);
+		int ret = add_cpu(cpu);
 
 		if (ret != 0) {
 			pr_err("Error occurred (%d) while trying "
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 05/15] arm64: Don't use disable_nonboot_cpus()
  2020-02-23 19:29 ` [PATCH v3 05/15] arm64: " Qais Yousef
@ 2020-03-17 11:21   ` Catalin Marinas
  2020-03-20 14:07     ` Qais Yousef
  0 siblings, 1 reply; 12+ messages in thread
From: Catalin Marinas @ 2020-03-17 11:21 UTC (permalink / raw)
  To: Qais Yousef
  Cc: Thomas Gleixner, Will Deacon, linux-arm-kernel,
	Paul E . McKenney, linux-kernel

On Sun, Feb 23, 2020 at 07:29:32PM +0000, Qais Yousef wrote:
> disable_nonboot_cpus() is not safe to use when doing machine_down(),
> because it relies on freeze_secondary_cpus() which in turn is
> a suspend/resume related freeze and could abort if the logic detects any
> pending activities that can prevent finishing the offlining process.
> 
> Beside disable_nonboot_cpus() is dependent on CONFIG_PM_SLEEP_SMP which
> is an othogonal config to rely on to ensure this function works
> correctly.
> 
> Use `reboot_cpu` variable instead of hardcoding 0 as the reboot cpu.
> 
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will@kernel.org>
> CC: linux-arm-kernel@lists.infradead.org
> CC: linux-kernel@vger.kernel.org

I'm not sure whether these patches have been queued already (still
unread in my inbox), so here it is:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 06/15] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu)
  2020-02-23 19:29 ` [PATCH v3 06/15] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu) Qais Yousef
@ 2020-03-17 11:21   ` Catalin Marinas
  0 siblings, 0 replies; 12+ messages in thread
From: Catalin Marinas @ 2020-03-17 11:21 UTC (permalink / raw)
  To: Qais Yousef
  Cc: Mark Rutland, Paul E . McKenney, Steve Capper,
	Peter Zijlstra (Intel),
	Jiri Kosina, Daniel Lezcano, Pavankumar Kondeti, Zhenzhong Duan,
	Nicholas Piggin, linux-kernel, Richard Fontana, James Morse,
	Josh Poimboeuf, Thomas Gleixner, Will Deacon, Ingo Molnar,
	linux-arm-kernel

On Sun, Feb 23, 2020 at 07:29:33PM +0000, Qais Yousef wrote:
> In preparation to make cpu_up/down private - move the user in arm64
> hibernate.c to use a new generic function that provides what arm64
> needs.
> 
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Will Deacon <will@kernel.org>
> CC: Steve Capper <steve.capper@arm.com>
> CC: Richard Fontana <rfontana@redhat.com>
> CC: James Morse <james.morse@arm.com>
> CC: Mark Rutland <mark.rutland@arm.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Josh Poimboeuf <jpoimboe@redhat.com>
> CC: Ingo Molnar <mingo@kernel.org>
> CC: "Peter Zijlstra (Intel)" <peterz@infradead.org>
> CC: Nicholas Piggin <npiggin@gmail.com>
> CC: Daniel Lezcano <daniel.lezcano@linaro.org>
> CC: Jiri Kosina <jkosina@suse.cz>
> CC: Pavankumar Kondeti <pkondeti@codeaurora.org>
> CC: Zhenzhong Duan <zhenzhong.duan@oracle.com>
> CC: linux-arm-kernel@lists.infradead.org
> CC: linux-kernel@vger.kernel.org

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 04/15] arm: Don't use disable_nonboot_cpus()
  2020-02-23 19:29 ` [PATCH v3 04/15] arm: Don't use disable_nonboot_cpus() Qais Yousef
@ 2020-03-20 11:04   ` Qais Yousef
  2020-03-20 13:07     ` Russell King - ARM Linux admin
  0 siblings, 1 reply; 12+ messages in thread
From: Qais Yousef @ 2020-03-20 11:04 UTC (permalink / raw)
  To: Russell King
  Cc: Thomas Gleixner, linux-arm-kernel, Paul E . McKenney, linux-kernel

On 02/23/20 19:29, Qais Yousef wrote:
> disable_nonboot_cpus() is not safe to use when doing machine_down(),
> because it relies on freeze_secondary_cpus() which in turn is
> a suspend/resume related freeze and could abort if the logic detects any
> pending activities that can prevent finishing the offlining process.
> 
> Beside disable_nonboot_cpus() is dependent on CONFIG_PM_SLEEP_SMP which
> is an othogonal config to rely on to ensure this function works
> correctly.
> 
> Use `reboot_cpu` variable instead of hardcoding 0 as the reboot cpu.
> 
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> CC: Russell King <linux@armlinux.org.uk>
> CC: linux-arm-kernel@lists.infradead.org
> CC: linux-kernel@vger.kernel.org
> ---

Hi Russel

Does the updated version look good to you now?

Thanks

--
Qais Yousef

>  arch/arm/kernel/reboot.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c
> index bb18ed0539f4..0ce388f15422 100644
> --- a/arch/arm/kernel/reboot.c
> +++ b/arch/arm/kernel/reboot.c
> @@ -88,11 +88,11 @@ void soft_restart(unsigned long addr)
>   * to execute e.g. a RAM-based pin loop is not sufficient. This allows the
>   * kexec'd kernel to use any and all RAM as it sees fit, without having to
>   * avoid any code or data used by any SW CPU pin loop. The CPU hotplug
> - * functionality embodied in disable_nonboot_cpus() to achieve this.
> + * functionality embodied in smp_shutdown_nonboot_cpus() to achieve this.
>   */
>  void machine_shutdown(void)
>  {
> -	disable_nonboot_cpus();
> +	smp_shutdown_nonboot_cpus(reboot_cpu);
>  }
>  
>  /*
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 04/15] arm: Don't use disable_nonboot_cpus()
  2020-03-20 11:04   ` Qais Yousef
@ 2020-03-20 13:07     ` Russell King - ARM Linux admin
  2020-03-20 13:41       ` Qais Yousef
  0 siblings, 1 reply; 12+ messages in thread
From: Russell King - ARM Linux admin @ 2020-03-20 13:07 UTC (permalink / raw)
  To: Qais Yousef
  Cc: Thomas Gleixner, linux-arm-kernel, Paul E . McKenney, linux-kernel

On Fri, Mar 20, 2020 at 11:04:31AM +0000, Qais Yousef wrote:
> On 02/23/20 19:29, Qais Yousef wrote:
> > disable_nonboot_cpus() is not safe to use when doing machine_down(),
> > because it relies on freeze_secondary_cpus() which in turn is
> > a suspend/resume related freeze and could abort if the logic detects any
> > pending activities that can prevent finishing the offlining process.
> > 
> > Beside disable_nonboot_cpus() is dependent on CONFIG_PM_SLEEP_SMP which
> > is an othogonal config to rely on to ensure this function works
> > correctly.
> > 
> > Use `reboot_cpu` variable instead of hardcoding 0 as the reboot cpu.

I think that should be a separate change - you have two separate
changes in this patch:

1. to switch to using the new helper.
2. to change the CPU that we potentially use for the final steps of
   shutdown

These should be two seperate changes, so if (2) causes a regression
it can be reverted independently of (1).

> > 
> > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> > CC: Russell King <linux@armlinux.org.uk>
> > CC: linux-arm-kernel@lists.infradead.org
> > CC: linux-kernel@vger.kernel.org
> > ---
> 
> Hi Russel
> 
> Does the updated version look good to you now?
> 
> Thanks
> 
> --
> Qais Yousef
> 
> >  arch/arm/kernel/reboot.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c
> > index bb18ed0539f4..0ce388f15422 100644
> > --- a/arch/arm/kernel/reboot.c
> > +++ b/arch/arm/kernel/reboot.c
> > @@ -88,11 +88,11 @@ void soft_restart(unsigned long addr)
> >   * to execute e.g. a RAM-based pin loop is not sufficient. This allows the
> >   * kexec'd kernel to use any and all RAM as it sees fit, without having to
> >   * avoid any code or data used by any SW CPU pin loop. The CPU hotplug
> > - * functionality embodied in disable_nonboot_cpus() to achieve this.
> > + * functionality embodied in smp_shutdown_nonboot_cpus() to achieve this.
> >   */
> >  void machine_shutdown(void)
> >  {
> > -	disable_nonboot_cpus();
> > +	smp_shutdown_nonboot_cpus(reboot_cpu);
> >  }
> >  
> >  /*
> > -- 
> > 2.17.1
> > 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 04/15] arm: Don't use disable_nonboot_cpus()
  2020-03-20 13:07     ` Russell King - ARM Linux admin
@ 2020-03-20 13:41       ` Qais Yousef
  0 siblings, 0 replies; 12+ messages in thread
From: Qais Yousef @ 2020-03-20 13:41 UTC (permalink / raw)
  To: Russell King - ARM Linux admin
  Cc: Thomas Gleixner, linux-arm-kernel, Paul E . McKenney, linux-kernel

On 03/20/20 13:07, Russell King - ARM Linux admin wrote:
> On Fri, Mar 20, 2020 at 11:04:31AM +0000, Qais Yousef wrote:
> > On 02/23/20 19:29, Qais Yousef wrote:
> > > disable_nonboot_cpus() is not safe to use when doing machine_down(),
> > > because it relies on freeze_secondary_cpus() which in turn is
> > > a suspend/resume related freeze and could abort if the logic detects any
> > > pending activities that can prevent finishing the offlining process.
> > > 
> > > Beside disable_nonboot_cpus() is dependent on CONFIG_PM_SLEEP_SMP which
> > > is an othogonal config to rely on to ensure this function works
> > > correctly.
> > > 
> > > Use `reboot_cpu` variable instead of hardcoding 0 as the reboot cpu.
> 
> I think that should be a separate change - you have two separate
> changes in this patch:
> 
> 1. to switch to using the new helper.
> 2. to change the CPU that we potentially use for the final steps of
>    shutdown
> 
> These should be two seperate changes, so if (2) causes a regression
> it can be reverted independently of (1).

Okay will do.

Thanks

--
Qais Yousef

> 
> > > 
> > > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> > > CC: Russell King <linux@armlinux.org.uk>
> > > CC: linux-arm-kernel@lists.infradead.org
> > > CC: linux-kernel@vger.kernel.org
> > > ---
> > 
> > Hi Russel
> > 
> > Does the updated version look good to you now?
> > 
> > Thanks
> > 
> > --
> > Qais Yousef
> > 
> > >  arch/arm/kernel/reboot.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c
> > > index bb18ed0539f4..0ce388f15422 100644
> > > --- a/arch/arm/kernel/reboot.c
> > > +++ b/arch/arm/kernel/reboot.c
> > > @@ -88,11 +88,11 @@ void soft_restart(unsigned long addr)
> > >   * to execute e.g. a RAM-based pin loop is not sufficient. This allows the
> > >   * kexec'd kernel to use any and all RAM as it sees fit, without having to
> > >   * avoid any code or data used by any SW CPU pin loop. The CPU hotplug
> > > - * functionality embodied in disable_nonboot_cpus() to achieve this.
> > > + * functionality embodied in smp_shutdown_nonboot_cpus() to achieve this.
> > >   */
> > >  void machine_shutdown(void)
> > >  {
> > > -	disable_nonboot_cpus();
> > > +	smp_shutdown_nonboot_cpus(reboot_cpu);
> > >  }
> > >  
> > >  /*
> > > -- 
> > > 2.17.1
> > > 
> > 
> 
> -- 
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 05/15] arm64: Don't use disable_nonboot_cpus()
  2020-03-17 11:21   ` Catalin Marinas
@ 2020-03-20 14:07     ` Qais Yousef
  0 siblings, 0 replies; 12+ messages in thread
From: Qais Yousef @ 2020-03-20 14:07 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Thomas Gleixner, Will Deacon, linux-arm-kernel,
	Paul E . McKenney, linux-kernel

On 03/17/20 11:21, Catalin Marinas wrote:
> On Sun, Feb 23, 2020 at 07:29:32PM +0000, Qais Yousef wrote:
> > disable_nonboot_cpus() is not safe to use when doing machine_down(),
> > because it relies on freeze_secondary_cpus() which in turn is
> > a suspend/resume related freeze and could abort if the logic detects any
> > pending activities that can prevent finishing the offlining process.
> > 
> > Beside disable_nonboot_cpus() is dependent on CONFIG_PM_SLEEP_SMP which
> > is an othogonal config to rely on to ensure this function works
> > correctly.
> > 
> > Use `reboot_cpu` variable instead of hardcoding 0 as the reboot cpu.
> > 
> > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> > CC: Catalin Marinas <catalin.marinas@arm.com>
> > CC: Will Deacon <will@kernel.org>
> > CC: linux-arm-kernel@lists.infradead.org
> > CC: linux-kernel@vger.kernel.org
> 
> I'm not sure whether these patches have been queued already (still
> unread in my inbox), so here it is:
> 
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>

Thanks Catalin!

Russel has requested to split the arm patch into 2 so that the change to
use reboot_cpu is in a separate patch. I'll do the same for arm64 to stay
consistent. I'll add your Acked-by to both patches if that's okay.

Please shout if you have any objection.

Thanks

--
Qais Yousef

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-03-20 14:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200223192942.18420-1-qais.yousef@arm.com>
2020-02-23 19:29 ` [PATCH v3 01/15] cpu: Add new {add,remove}_cpu() functions Qais Yousef
2020-02-23 19:29 ` [PATCH v3 02/15] smp: Create a new function to shutdown nonboot cpus Qais Yousef
2020-02-23 19:29 ` [PATCH v3 04/15] arm: Don't use disable_nonboot_cpus() Qais Yousef
2020-03-20 11:04   ` Qais Yousef
2020-03-20 13:07     ` Russell King - ARM Linux admin
2020-03-20 13:41       ` Qais Yousef
2020-02-23 19:29 ` [PATCH v3 05/15] arm64: " Qais Yousef
2020-03-17 11:21   ` Catalin Marinas
2020-03-20 14:07     ` Qais Yousef
2020-02-23 19:29 ` [PATCH v3 06/15] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu) Qais Yousef
2020-03-17 11:21   ` Catalin Marinas
2020-02-23 19:29 ` [PATCH v3 12/15] firmware: psci: Replace cpu_up/down with add/remove_cpu Qais Yousef

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).