Skip to contentSkip to conversation

mach-tango updates for v4.8

PATCH Superseded Marc Gonzalez 5 participants 13 messages Jun 28, 2016 – Jul 7, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover mach-tango updates for v4.8

Hello arm-soc maintainers,

Could you please merge the following patches?

(Ideally, the MAINTAINERS update would be merged as a fix into the next 4.7 release candidate.)

Marc Gonzalez (2):
ARM: tango: add HOTPLUG_CPU support
Update ARM/TANGO section

 MAINTAINERS                   |  3 +--
 arch/arm/mach-tango/platsmp.c | 30 ++++++++++++++++++++++++++++++
 arch/arm/mach-tango/smc.h     |  4 +++-
 3 files changed, 34 insertions(+), 3 deletions(-)

Regards.

#1 lore raw

PATCH v3 1/2 ARM: tango: add HOTPLUG_CPU support

cpu_die() and cpu_kill() are implemented in firmware.

---
 arch/arm/mach-tango/platsmp.c | 30 ++++++++++++++++++++++++++++++
 arch/arm/mach-tango/smc.h     |  4 +++-
 2 files changed, 33 insertions(+), 1 deletion(-)
arch/arm/mach-tango/platsmp.c +30 -0
index a21f55e000d2..a24b9b1d0b1a 100644
@@ -1,3 +1,4 @@
+#include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/smp.h>
 #include "smc.h"
@@ -9,8 +10,37 @@ static int tango_boot_secondary(unsigned int cpu, struct task_struct *idle)
 	return 0;
 }
 
+#ifdef CONFIG_HOTPLUG_CPU
+/*
+ * cpu_kill() and cpu_die() run concurrently on different cores.
+ * Firmware will only "kill" a core once it has properly "died".
+ * Keep trying to kill a core until the operation succeeds, but
+ * sleep between tries to give the core time to die.
+ */
+static int tango_cpu_kill(unsigned int cpu)
+{
+	do {
+		msleep(10);
+	} while (tango_aux_core_kill(cpu) != 0);
+
+	return 1;
+}
+
+static void tango_cpu_die(unsigned int cpu)
+{
+	do {
+		cpu_relax();
+	} while (tango_aux_core_die(cpu) != 0);
+}
+#else
+#define tango_cpu_kill	NULL
+#define tango_cpu_die	NULL
+#endif
+
 static const struct smp_operations tango_smp_ops __initconst = {
 	.smp_boot_secondary	= tango_boot_secondary,
+	.cpu_kill		= tango_cpu_kill,
+	.cpu_die		= tango_cpu_die,
 };
 
 CPU_METHOD_OF_DECLARE(tango4_smp, "sigma,tango4-smp", &tango_smp_ops);
arch/arm/mach-tango/smc.h +3 -1
index 7a4af35cc390..3d31f984f44c 100644
@@ -2,4 +2,6 @@ extern int tango_smc(unsigned int val, unsigned int service);
 
 #define tango_set_l2_control(val)	tango_smc(val, 0x102)
 #define tango_start_aux_core(val)	tango_smc(val, 0x104)
-#define tango_set_aux_boot_addr(val)	tango_smc((unsigned int)val, 0x105)
+#define tango_set_aux_boot_addr(val)	tango_smc(val, 0x105)
+#define tango_aux_core_die(val)		tango_smc(val, 0x121)
+#define tango_aux_core_kill(val)	tango_smc(val, 0x122)
Signature · 1 line
2.9.0
#2 lore raw

PATCH v3 1/2 ARM: tango: add HOTPLUG_CPU support

Quoted 23 lines · Marc Gonzalez

cpu_die() and cpu_kill() are implemented in firmware.

---
 arch/arm/mach-tango/platsmp.c | 30 ++++++++++++++++++++++++++++++
 arch/arm/mach-tango/smc.h     |  4 +++-
 2 files changed, 33 insertions(+), 1 deletion(-)
arch/arm/mach-tango/platsmp.c +3 -0
index a21f55e000d2..a24b9b1d0b1a 100644
@@ -1,3 +1,4 @@
+#include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/smp.h>
 #include "smc.h"
@@ -9,8 +10,37 @@ static int tango_boot_secondary(unsigned int cpu, struct task_struct *idle)
 	return 0;
 }
 
+#ifdef CONFIG_HOTPLUG_CPU
+/*

arch/arm/mach-tango/platsmp.c static int tango_boot_secondary(unsigned int cpu, struct task_struct *idle) · line 24

Quoted 10 lines
arch/arm/mach-tango/platsmp.c +10 -0
+ * cpu_kill() and cpu_die() run concurrently on different cores.
+ * Firmware will only "kill" a core once it has properly "died".
+ * Keep trying to kill a core until the operation succeeds, but
+ * sleep between tries to give the core time to die.
+ */
+static int tango_cpu_kill(unsigned int cpu)
+{
+	do {
+		msleep(10);
+	} while (tango_aux_core_kill(cpu) != 0);

Does the firmware guarantee that this will succeed (or at least report success) in finite time, regardless of how messed up the system might be? I'd imagine this should probably have either a timeout or a comment clarifying why it doesn't need a timeout.

Robin.

Quoted 35 lines
arch/arm/mach-tango/platsmp.c +17 -0
+
+	return 1;
+}
+
+static void tango_cpu_die(unsigned int cpu)
+{
+	do {
+		cpu_relax();
+	} while (tango_aux_core_die(cpu) != 0);
+}
+#else
+#define tango_cpu_kill	NULL
+#define tango_cpu_die	NULL
+#endif
+
 static const struct smp_operations tango_smp_ops __initconst = {
 	.smp_boot_secondary	= tango_boot_secondary,
+	.cpu_kill		= tango_cpu_kill,
+	.cpu_die		= tango_cpu_die,
 };
 
 CPU_METHOD_OF_DECLARE(tango4_smp, "sigma,tango4-smp", &tango_smp_ops);
arch/arm/mach-tango/smc.h +3 -1
index 7a4af35cc390..3d31f984f44c 100644
@@ -2,4 +2,6 @@ extern int tango_smc(unsigned int val, unsigned int service);
 
 #define tango_set_l2_control(val)	tango_smc(val, 0x102)
 #define tango_start_aux_core(val)	tango_smc(val, 0x104)
-#define tango_set_aux_boot_addr(val)	tango_smc((unsigned int)val, 0x105)
+#define tango_set_aux_boot_addr(val)	tango_smc(val, 0x105)
+#define tango_aux_core_die(val)		tango_smc(val, 0x121)
+#define tango_aux_core_kill(val)	tango_smc(val, 0x122)
#3 lore raw

PATCH v3 1/2 ARM: tango: add HOTPLUG_CPU support

Quoted 11 lines · Robin Murphy
Quoted 9 lines · Marc Gonzalez
arch/arm/mach-tango/platsmp.c +9 -0
+#ifdef CONFIG_HOTPLUG_CPU
+/*
+ * cpu_kill() and cpu_die() run concurrently on different cores.
+ * Firmware will only "kill" a core once it has properly "died".
+ * Keep trying to kill a core until the operation succeeds, but
+ * sleep between tries to give the core time to die.
+ */
+static int tango_cpu_kill(unsigned int cpu)
+{
Quoted 8 lines

arch/arm/mach-tango/platsmp.c static int tango_boot_secondary(unsigned int cpu, struct task_struct *idle) · line 24

Quoted 3 lines
arch/arm/mach-tango/platsmp.c +3 -0
+	do {
+		msleep(10);
+	} while (tango_aux_core_kill(cpu) != 0);

Does the firmware guarantee that this will succeed (or at least report success) in finite time, regardless of how messed up the system might be? I'd imagine this should probably have either a timeout or a comment clarifying why it doesn't need a timeout.

Good point.

The FW allows only one thread at a time. If a thread is wedged inside the FW, no other thread can use the FW. In that situation, cpu0 would remain stuck inside tango_cpu_kill().

Note, that if tango_cpu_kill() starts failing, then secondary cores will remain "zombies". So the system is mostly hosed anyway... Only cpu0 will be available.

Regards.

#4 lore raw

PATCH v3 1/2 ARM: tango: add HOTPLUG_CPU support

Quoted 24 lines · Marc Gonzalez
Quoted 11 lines · Robin Murphy
Quoted 9 lines · Marc Gonzalez
arch/arm/mach-tango/platsmp.c +9 -0
+#ifdef CONFIG_HOTPLUG_CPU
+/*
+ * cpu_kill() and cpu_die() run concurrently on different cores.
+ * Firmware will only "kill" a core once it has properly "died".
+ * Keep trying to kill a core until the operation succeeds, but
+ * sleep between tries to give the core time to die.
+ */
+static int tango_cpu_kill(unsigned int cpu)
+{
Quoted 8 lines

arch/arm/mach-tango/platsmp.c static int tango_boot_secondary(unsigned int cpu, struct task_struct *idle) · line 24

Quoted 3 lines
arch/arm/mach-tango/platsmp.c +3 -0
+	do {
+		msleep(10);
+	} while (tango_aux_core_kill(cpu) != 0);

Does the firmware guarantee that this will succeed (or at least report success) in finite time, regardless of how messed up the system might be? I'd imagine this should probably have either a timeout or a comment clarifying why it doesn't need a timeout.

Good point.

Quoted 7 lines

The FW allows only one thread at a time. If a thread is wedged inside the FW, no other thread can use the FW. In that situation, cpu0 would remain stuck inside tango_cpu_kill().

Note, that if tango_cpu_kill() starts failing, then secondary cores will remain "zombies". So the system is mostly hosed anyway... Only cpu0 will be available.

Indeed; my thought was that if CPU1 somehow ends up wedged such that tango_aux_core_die() never completes, then CPU0 eventually timing out and being able to limp through a clean(ish) reboot is probably preferable to spinning in cpu_kill() forever.

Robin.

Quoted 9 lines

Regards.

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

#5 lore raw

PATCH v3 1/2 ARM: tango: add HOTPLUG_CPU support

Quoted 15 lines · Robin Murphy
Quoted 13 lines · Marc Gonzalez
Quoted 4 lines · Robin Murphy

Does the firmware guarantee that this will succeed (or at least report success) in finite time, regardless of how messed up the system might be? I'd imagine this should probably have either a timeout or a comment clarifying why it doesn't need a timeout.

Good point.

The FW allows only one thread at a time. If a thread is wedged inside the FW, no other thread can use the FW. In that situation, cpu0 would remain stuck inside tango_cpu_kill().

Quoted 8 lines
Quoted 3 lines

Note, that if tango_cpu_kill() starts failing, then secondary cores will remain "zombies". So the system is mostly hosed anyway... Only cpu0 will be available.

Indeed; my thought was that if CPU1 somehow ends up wedged such that tango_aux_core_die() never completes, then CPU0 eventually timing out and being able to limp through a clean(ish) reboot is probably preferable to spinning in cpu_kill() forever.

I have sent an updated patch addressing your comment. Thanks for flagging the issue.

Regards.

#6 lore raw

PATCH v4 1/2 ARM: tango: add HOTPLUG_CPU support

In reply to Marc Gonzalez

cpu_die() and cpu_kill() are implemented in firmware.

---
New in v4:
o panic() if tango_cpu_die() returns unexpectedly
o timeout after 10 tries in tango_cpu_kill()

---
 arch/arm/mach-tango/platsmp.c | 36 ++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tango/smc.h     |  4 +++-
 2 files changed, 39 insertions(+), 1 deletion(-)
arch/arm/mach-tango/platsmp.c +36 -0
index a21f55e000d2..8380699d4fa3 100644
@@ -1,3 +1,4 @@
+#include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/smp.h>
 #include "smc.h"
@@ -9,8 +10,43 @@ static int tango_boot_secondary(unsigned int cpu, struct task_struct *idle)
 	return 0;
 }
 
+#ifdef CONFIG_HOTPLUG_CPU
+/*
+ * cpu_kill() and cpu_die() run concurrently on different cores.
+ * Firmware will only "kill" a core once it has properly "died".
+ * Try a few times to kill a core before giving up, and sleep
+ * between tries to give that core enough time to die.
+ */
+static int tango_cpu_kill(unsigned int cpu)
+{
+	int i, err;
+
+	for (i = 0; i < 10; ++i) {
+		msleep(10);
+		err = tango_aux_core_kill(cpu);
+		if (!err)
+			return true;
+	}
+
+	return false;
+}
+
+static void tango_cpu_die(unsigned int cpu)
+{
+	while (tango_aux_core_die(cpu) < 0)
+		cpu_relax();
+
+	panic("cpu %d failed to die\n", cpu);
+}
+#else
+#define tango_cpu_kill	NULL
+#define tango_cpu_die	NULL
+#endif
+
 static const struct smp_operations tango_smp_ops __initconst = {
 	.smp_boot_secondary	= tango_boot_secondary,
+	.cpu_kill		= tango_cpu_kill,
+	.cpu_die		= tango_cpu_die,
 };
 
 CPU_METHOD_OF_DECLARE(tango4_smp, "sigma,tango4-smp", &tango_smp_ops);
arch/arm/mach-tango/smc.h +3 -1
index 7a4af35cc390..3d31f984f44c 100644
@@ -2,4 +2,6 @@ extern int tango_smc(unsigned int val, unsigned int service);
 
 #define tango_set_l2_control(val)	tango_smc(val, 0x102)
 #define tango_start_aux_core(val)	tango_smc(val, 0x104)
-#define tango_set_aux_boot_addr(val)	tango_smc((unsigned int)val, 0x105)
+#define tango_set_aux_boot_addr(val)	tango_smc(val, 0x105)
+#define tango_aux_core_die(val)		tango_smc(val, 0x121)
+#define tango_aux_core_kill(val)	tango_smc(val, 0x122)
Signature · 1 line
2.9.0
#7 lore raw

PATCH v3 2/2 Update ARM/TANGO section

In reply to Marc Gonzalez

Use regex pattern to match tango-specific files.

---
 MAINTAINERS | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
MAINTAINERS +1 -2
index e1b090f86e0d..b8140a3f5764 100644
@@ -1734,8 +1734,7 @@ ARM/TANGO ARCHITECTURE
 M:	Marc Gonzalez <[email protected]>
 L:	linux-arm-kernel at lists.infradead.org
 S:	Maintained
-F:	arch/arm/mach-tango/
-F:	arch/arm/boot/dts/tango*
+N:	tango
 
 ARM/TECHNOLOGIC SYSTEMS TS7250 MACHINE SUPPORT
 M:	Lennert Buytenhek <[email protected]>
Signature · 1 line
2.9.0
#8 lore raw

v3 cover mach-tango updates for v4.8

In reply to Marc Gonzalez
Quoted 7 lines · Marc Gonzalez

Hello arm-soc maintainers,

Could you please merge the following patches?

Marc Gonzalez (2):
ARM: tango: add HOTPLUG_CPU support
Update ARM/TANGO section

Hello Olof,

I see you've just merged a large number of patches in the for-next branch.
https://git.kernel.org/cgit/linux/kernel/git/arm/arm-soc.git/log/?h=for-next

I think you overlooked the two patches in this thread:

[PATCH v4 1/2] ARM: tango: add HOTPLUG_CPU support [PATCH v3 2/2] Update ARM/TANGO section

Could you merge these patches as well?

Regards.

#9 lore raw

v3 cover mach-tango updates for v4.8

Quoted 15 lines · Mason
Quoted 7 lines · Marc Gonzalez

Hello arm-soc maintainers,

Could you please merge the following patches?

Marc Gonzalez (2):
ARM: tango: add HOTPLUG_CPU support
Update ARM/TANGO section

Hello Olof,

I see you've just merged a large number of patches in the for-next branch.
https://git.kernel.org/cgit/linux/kernel/git/arm/arm-soc.git/log/?h=for-next

Quoted 6 lines

I think you overlooked the two patches in this thread:

[PATCH v4 1/2] ARM: tango: add HOTPLUG_CPU support [PATCH v3 2/2] Update ARM/TANGO section

Could you merge these patches as well?

Yes, applied now. Thanks!

-Olof

#10 lore raw

v3 cover mach-tango updates for v4.8

Quoted 16 lines · CEST Olof Johansson
Quoted 15 lines · Mason
Quoted 7 lines · Marc Gonzalez

Hello arm-soc maintainers,

Could you please merge the following patches?

Marc Gonzalez (2):
ARM: tango: add HOTPLUG_CPU support
Update ARM/TANGO section

Hello Olof,

I see you've just merged a large number of patches in the for-next branch.
https://git.kernel.org/cgit/linux/kernel/git/arm/arm-soc.git/log/?h=for-next

Quoted 8 lines
Quoted 6 lines

I think you overlooked the two patches in this thread:

[PATCH v4 1/2] ARM: tango: add HOTPLUG_CPU support [PATCH v3 2/2] Update ARM/TANGO section

Could you merge these patches as well?

Yes, applied now. Thanks!

I ran into a build regression during randconfig testing, I think we should apply the patch below on top of next/soc:

Arnd

Quoted 1 line

From 3ea8aba06a2a99e40e145b90865e0635a56209c8 Mon Sep 17 00:00:00 2001

From: Arnd Bergmann <[email protected]>
Date: Wed, 6 Jul 2016 21:59:55 +0200
Subject: [PATCH] ARM: tango: fix CONFIG_HOTPLUG_CPU=n build

Building with CONFIG_HOTPLUG_CPU disabled fails for mach-tango:

include/linux/stddef.h:7:14: error: excess elements in struct initializer [-Werror]
#define NULL ((void *)0)
arch/arm/mach-tango/platsmp.c:48:15: note: in expansion of macro 'tango_cpu_kill'
.cpu_kill = tango_cpu_kill,

the problem as that the .cpu_kill and .cpu_die struct members are unavailable and we must not try to assign them in this configuration.

Hiding the two (as all other platforms do too) lets us get rid of the #else clause as well.

arch/arm/mach-tango/platsmp.c +2 -3
index 8380699..98c62a4 100644
@@ -38,15 +38,14 @@ static void tango_cpu_die(unsigned int cpu)
 
 	panic("cpu %d failed to die\n", cpu);
 }
-#else
-#define tango_cpu_kill	NULL
-#define tango_cpu_die	NULL
 #endif
 
 static const struct smp_operations tango_smp_ops __initconst = {
 	.smp_boot_secondary	= tango_boot_secondary,
+#ifdef CONFIG_HOTPLUG_CPU
 	.cpu_kill		= tango_cpu_kill,
 	.cpu_die		= tango_cpu_die,
+#endif
 };
 
 CPU_METHOD_OF_DECLARE(tango4_smp, "sigma,tango4-smp", &tango_smp_ops);
#11 lore raw

v3 cover mach-tango updates for v4.8

Quoted 22 lines · Arnd Bergmann
Quoted 21 lines · CEST Olof Johansson
Quoted 20 lines · Mason
Quoted 7 lines · Marc Gonzalez

Hello arm-soc maintainers,

Could you please merge the following patches?

Marc Gonzalez (2):
ARM: tango: add HOTPLUG_CPU support
Update ARM/TANGO section

Hello Olof,

I see you've just merged a large number of patches in the for-next branch.
https://git.kernel.org/cgit/linux/kernel/git/arm/arm-soc.git/log/?h=for-next

I think you overlooked the two patches in this thread:

[PATCH v4 1/2] ARM: tango: add HOTPLUG_CPU support [PATCH v3 2/2] Update ARM/TANGO section

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Could you merge these patches as well?

Yes, applied now. Thanks!

I ran into a build regression during randconfig testing, I think we should apply the patch below on top of next/soc:

Yep, applied.

-Olof

#12 lore raw

v3 cover mach-tango updates for v4.8

Quoted 6 lines · Olof Johansson
Quoted 2 lines · Arnd Bergmann

I ran into a build regression during randconfig testing, I think we should apply the patch below on top of next/soc:

Yep, applied.

Thanks to both of you.

Regards.