All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8
@ 2016-06-28 11:55 Marc Gonzalez
  2016-06-28 11:59   ` Marc Gonzalez
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-28 11:55 UTC (permalink / raw)
  To: linux-arm-kernel

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.

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

* [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
  2016-06-28 11:55 [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8 Marc Gonzalez
@ 2016-06-28 11:59   ` Marc Gonzalez
  2016-06-28 12:01 ` [PATCH v3 2/2] Update ARM/TANGO section Marc Gonzalez
  2016-07-05 12:32 ` [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8 Mason
  2 siblings, 0 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-28 11:59 UTC (permalink / raw)
  To: arm-soc
  Cc: Mark Rutland, Sebastian Frias, Mason, Thibaud Cornic, linux-pm,
	Linux ARM

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

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---
 arch/arm/mach-tango/platsmp.c | 30 ++++++++++++++++++++++++++++++
 arch/arm/mach-tango/smc.h     |  4 +++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-tango/platsmp.c b/arch/arm/mach-tango/platsmp.c
index a21f55e000d2..a24b9b1d0b1a 100644
--- a/arch/arm/mach-tango/platsmp.c
+++ b/arch/arm/mach-tango/platsmp.c
@@ -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);
diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
index 7a4af35cc390..3d31f984f44c 100644
--- a/arch/arm/mach-tango/smc.h
+++ b/arch/arm/mach-tango/smc.h
@@ -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)
-- 
2.9.0

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

* [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
@ 2016-06-28 11:59   ` Marc Gonzalez
  0 siblings, 0 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-28 11:59 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---
 arch/arm/mach-tango/platsmp.c | 30 ++++++++++++++++++++++++++++++
 arch/arm/mach-tango/smc.h     |  4 +++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-tango/platsmp.c b/arch/arm/mach-tango/platsmp.c
index a21f55e000d2..a24b9b1d0b1a 100644
--- a/arch/arm/mach-tango/platsmp.c
+++ b/arch/arm/mach-tango/platsmp.c
@@ -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);
diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
index 7a4af35cc390..3d31f984f44c 100644
--- a/arch/arm/mach-tango/smc.h
+++ b/arch/arm/mach-tango/smc.h
@@ -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)
-- 
2.9.0

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

* [PATCH v3 2/2] Update ARM/TANGO section
  2016-06-28 11:55 [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8 Marc Gonzalez
  2016-06-28 11:59   ` Marc Gonzalez
@ 2016-06-28 12:01 ` Marc Gonzalez
  2016-07-05 12:32 ` [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8 Mason
  2 siblings, 0 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-28 12:01 UTC (permalink / raw)
  To: linux-arm-kernel

Use regex pattern to match tango-specific files.

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---
 MAINTAINERS | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index e1b090f86e0d..b8140a3f5764 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1734,8 +1734,7 @@ ARM/TANGO ARCHITECTURE
 M:	Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
 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 <kernel@wantstofly.org>
-- 
2.9.0

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

* Re: [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
  2016-06-28 11:59   ` Marc Gonzalez
@ 2016-06-28 12:30     ` Robin Murphy
  -1 siblings, 0 replies; 19+ messages in thread
From: Robin Murphy @ 2016-06-28 12:30 UTC (permalink / raw)
  To: Marc Gonzalez, arm-soc
  Cc: Mark Rutland, Sebastian Frias, Mason, Thibaud Cornic, linux-pm,
	Linux ARM

On 28/06/16 12:59, Marc Gonzalez wrote:
> cpu_die() and cpu_kill() are implemented in firmware.
> 
> Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
> ---
>  arch/arm/mach-tango/platsmp.c | 30 ++++++++++++++++++++++++++++++
>  arch/arm/mach-tango/smc.h     |  4 +++-
>  2 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-tango/platsmp.c b/arch/arm/mach-tango/platsmp.c
> index a21f55e000d2..a24b9b1d0b1a 100644
> --- a/arch/arm/mach-tango/platsmp.c
> +++ b/arch/arm/mach-tango/platsmp.c
> @@ -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);

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.

> +
> +	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);
> diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
> index 7a4af35cc390..3d31f984f44c 100644
> --- a/arch/arm/mach-tango/smc.h
> +++ b/arch/arm/mach-tango/smc.h
> @@ -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)
> 


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

* [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
@ 2016-06-28 12:30     ` Robin Murphy
  0 siblings, 0 replies; 19+ messages in thread
From: Robin Murphy @ 2016-06-28 12:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 28/06/16 12:59, Marc Gonzalez wrote:
> cpu_die() and cpu_kill() are implemented in firmware.
> 
> Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
> ---
>  arch/arm/mach-tango/platsmp.c | 30 ++++++++++++++++++++++++++++++
>  arch/arm/mach-tango/smc.h     |  4 +++-
>  2 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-tango/platsmp.c b/arch/arm/mach-tango/platsmp.c
> index a21f55e000d2..a24b9b1d0b1a 100644
> --- a/arch/arm/mach-tango/platsmp.c
> +++ b/arch/arm/mach-tango/platsmp.c
> @@ -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);

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.

> +
> +	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);
> diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
> index 7a4af35cc390..3d31f984f44c 100644
> --- a/arch/arm/mach-tango/smc.h
> +++ b/arch/arm/mach-tango/smc.h
> @@ -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)
> 

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

* Re: [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
  2016-06-28 12:30     ` Robin Murphy
@ 2016-06-28 15:04       ` Marc Gonzalez
  -1 siblings, 0 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-28 15:04 UTC (permalink / raw)
  To: Robin Murphy
  Cc: arm-soc, Mark Rutland, Sebastian Frias, Mason, Thibaud Cornic,
	linux-pm, Linux ARM

On 28/06/2016 14:30, Robin Murphy wrote:

> On 28/06/16 12:59, Marc Gonzalez wrote:
>
>> +#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);
> 
> 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.


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

* [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
@ 2016-06-28 15:04       ` Marc Gonzalez
  0 siblings, 0 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-28 15:04 UTC (permalink / raw)
  To: linux-arm-kernel

On 28/06/2016 14:30, Robin Murphy wrote:

> On 28/06/16 12:59, Marc Gonzalez wrote:
>
>> +#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);
> 
> 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.

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

* Re: [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
  2016-06-28 15:04       ` Marc Gonzalez
@ 2016-06-28 15:16         ` Robin Murphy
  -1 siblings, 0 replies; 19+ messages in thread
From: Robin Murphy @ 2016-06-28 15:16 UTC (permalink / raw)
  To: Marc Gonzalez
  Cc: Mark Rutland, Sebastian Frias, linux-pm, Thibaud Cornic, Mason,
	arm-soc, Linux ARM

On 28/06/16 16:04, Marc Gonzalez wrote:
> On 28/06/2016 14:30, Robin Murphy wrote:
> 
>> On 28/06/16 12:59, Marc Gonzalez wrote:
>>
>>> +#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);
>>
>> 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.

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.

> 
> Regards.
> 
> 
> _______________________________________________
> 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] 19+ messages in thread

* [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
@ 2016-06-28 15:16         ` Robin Murphy
  0 siblings, 0 replies; 19+ messages in thread
From: Robin Murphy @ 2016-06-28 15:16 UTC (permalink / raw)
  To: linux-arm-kernel

On 28/06/16 16:04, Marc Gonzalez wrote:
> On 28/06/2016 14:30, Robin Murphy wrote:
> 
>> On 28/06/16 12:59, Marc Gonzalez wrote:
>>
>>> +#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);
>>
>> 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.

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.

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

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

* [PATCH v4 1/2] ARM: tango: add HOTPLUG_CPU support
  2016-06-28 11:59   ` Marc Gonzalez
@ 2016-06-29 12:21     ` Marc Gonzalez
  -1 siblings, 0 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-29 12:21 UTC (permalink / raw)
  To: arm-soc
  Cc: Mark Rutland, Sebastian Frias, linux-pm, Thibaud Cornic, Mason,
	Robin Murphy, Linux ARM

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

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---
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(-)

diff --git a/arch/arm/mach-tango/platsmp.c b/arch/arm/mach-tango/platsmp.c
index a21f55e000d2..8380699d4fa3 100644
--- a/arch/arm/mach-tango/platsmp.c
+++ b/arch/arm/mach-tango/platsmp.c
@@ -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);
diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
index 7a4af35cc390..3d31f984f44c 100644
--- a/arch/arm/mach-tango/smc.h
+++ b/arch/arm/mach-tango/smc.h
@@ -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)
-- 
2.9.0

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

* [PATCH v4 1/2] ARM: tango: add HOTPLUG_CPU support
@ 2016-06-29 12:21     ` Marc Gonzalez
  0 siblings, 0 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-29 12:21 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---
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(-)

diff --git a/arch/arm/mach-tango/platsmp.c b/arch/arm/mach-tango/platsmp.c
index a21f55e000d2..8380699d4fa3 100644
--- a/arch/arm/mach-tango/platsmp.c
+++ b/arch/arm/mach-tango/platsmp.c
@@ -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);
diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
index 7a4af35cc390..3d31f984f44c 100644
--- a/arch/arm/mach-tango/smc.h
+++ b/arch/arm/mach-tango/smc.h
@@ -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)
-- 
2.9.0

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

* Re: [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
  2016-06-28 15:16         ` Robin Murphy
@ 2016-06-29 12:28           ` Marc Gonzalez
  -1 siblings, 0 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-29 12:28 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Mark Rutland, Sebastian Frias, linux-pm, Thibaud Cornic, Mason,
	arm-soc, Linux ARM

On 28/06/2016 17:16, Robin Murphy wrote:

> On 28/06/16 16:04, Marc Gonzalez wrote:
>
>> On 28/06/2016 14:30, Robin Murphy wrote:
>>
>>> 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.
> 
> 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.


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

* [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support
@ 2016-06-29 12:28           ` Marc Gonzalez
  0 siblings, 0 replies; 19+ messages in thread
From: Marc Gonzalez @ 2016-06-29 12:28 UTC (permalink / raw)
  To: linux-arm-kernel

On 28/06/2016 17:16, Robin Murphy wrote:

> On 28/06/16 16:04, Marc Gonzalez wrote:
>
>> On 28/06/2016 14:30, Robin Murphy wrote:
>>
>>> 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.
> 
> 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.

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

* [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8
  2016-06-28 11:55 [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8 Marc Gonzalez
  2016-06-28 11:59   ` Marc Gonzalez
  2016-06-28 12:01 ` [PATCH v3 2/2] Update ARM/TANGO section Marc Gonzalez
@ 2016-07-05 12:32 ` Mason
  2016-07-06  3:57   ` Olof Johansson
  2 siblings, 1 reply; 19+ messages in thread
From: Mason @ 2016-07-05 12:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 28/06/2016 13:55, Marc Gonzalez wrote:

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

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

* [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8
  2016-07-05 12:32 ` [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8 Mason
@ 2016-07-06  3:57   ` Olof Johansson
  2016-07-06 20:04     ` Arnd Bergmann
  0 siblings, 1 reply; 19+ messages in thread
From: Olof Johansson @ 2016-07-06  3:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 05, 2016 at 02:32:31PM +0200, Mason wrote:
> On 28/06/2016 13:55, Marc Gonzalez wrote:
> 
> > 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?

Yes, applied now. Thanks!


-Olof

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

* [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8
  2016-07-06  3:57   ` Olof Johansson
@ 2016-07-06 20:04     ` Arnd Bergmann
  2016-07-07  4:45       ` Olof Johansson
  0 siblings, 1 reply; 19+ messages in thread
From: Arnd Bergmann @ 2016-07-06 20:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday, July 5, 2016 8:57:30 PM CEST Olof Johansson wrote:
> On Tue, Jul 05, 2016 at 02:32:31PM +0200, Mason wrote:
> > On 28/06/2016 13:55, Marc Gonzalez wrote:
> > 
> > > 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?
> 
> 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

>From 3ea8aba06a2a99e40e145b90865e0635a56209c8 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@arndb.de>
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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/arch/arm/mach-tango/platsmp.c b/arch/arm/mach-tango/platsmp.c
index 8380699..98c62a4 100644
--- a/arch/arm/mach-tango/platsmp.c
+++ b/arch/arm/mach-tango/platsmp.c
@@ -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);

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

* [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8
  2016-07-06 20:04     ` Arnd Bergmann
@ 2016-07-07  4:45       ` Olof Johansson
  2016-07-07  8:50         ` Mason
  0 siblings, 1 reply; 19+ messages in thread
From: Olof Johansson @ 2016-07-07  4:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 06, 2016 at 10:04:42PM +0200, Arnd Bergmann wrote:
> On Tuesday, July 5, 2016 8:57:30 PM CEST Olof Johansson wrote:
> > On Tue, Jul 05, 2016 at 02:32:31PM +0200, Mason wrote:
> > > On 28/06/2016 13:55, Marc Gonzalez wrote:
> > > 
> > > > 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?
> > 
> > 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

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

* [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8
  2016-07-07  4:45       ` Olof Johansson
@ 2016-07-07  8:50         ` Mason
  0 siblings, 0 replies; 19+ messages in thread
From: Mason @ 2016-07-07  8:50 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/07/2016 06:45, Olof Johansson wrote:

> On Wed, Jul 06, 2016 at 10:04:42PM +0200, Arnd Bergmann wrote:
> 
>> 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.

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

end of thread, other threads:[~2016-07-07  8:50 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-28 11:55 [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8 Marc Gonzalez
2016-06-28 11:59 ` [PATCH v3 1/2] ARM: tango: add HOTPLUG_CPU support Marc Gonzalez
2016-06-28 11:59   ` Marc Gonzalez
2016-06-28 12:30   ` Robin Murphy
2016-06-28 12:30     ` Robin Murphy
2016-06-28 15:04     ` Marc Gonzalez
2016-06-28 15:04       ` Marc Gonzalez
2016-06-28 15:16       ` Robin Murphy
2016-06-28 15:16         ` Robin Murphy
2016-06-29 12:28         ` Marc Gonzalez
2016-06-29 12:28           ` Marc Gonzalez
2016-06-29 12:21   ` [PATCH v4 " Marc Gonzalez
2016-06-29 12:21     ` Marc Gonzalez
2016-06-28 12:01 ` [PATCH v3 2/2] Update ARM/TANGO section Marc Gonzalez
2016-07-05 12:32 ` [PATCH v3 0/2] [for arm-soc] mach-tango updates for v4.8 Mason
2016-07-06  3:57   ` Olof Johansson
2016-07-06 20:04     ` Arnd Bergmann
2016-07-07  4:45       ` Olof Johansson
2016-07-07  8:50         ` Mason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.