From: Michael Neuling on
This is not going to work without:
f8b67691828321f5c85bb853283aa101ae673130

It'll get a build failure.

Mikey

In message <20100701172856.882121276(a)clark.site> you wrote:
> 2.6.27-stable review patch. If anyone has any objections, please let us know
..
>
> ------------------
>
> From: Michael Neuling <mikey(a)neuling.org>
>
> commit aef40e87d866355ffd279ab21021de733242d0d5 upstream.
>
> Currently we always call start-cpu irrespective of if the CPU is
> stopped or not. Unfortunatley on POWER7, firmware seems to not like
> start-cpu being called when a cpu already been started. This was not
> the case on POWER6 and earlier.
>
> This patch checks to see if the CPU is stopped or not via an
> query-cpu-stopped-state call, and only calls start-cpu on CPUs which
> are stopped.
>
> This fixes a bug with kexec on POWER7 on PHYP where only the primary
> thread would make it to the second kernel.
>
> Reported-by: Ankita Garg <ankita(a)linux.vnet.ibm.com>
> Signed-off-by: Michael Neuling <mikey(a)neuling.org>
> Signed-off-by: Benjamin Herrenschmidt <benh(a)kernel.crashing.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh(a)suse.de>
>
> ---
> arch/powerpc/platforms/pseries/smp.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> --- a/arch/powerpc/platforms/pseries/smp.c
> +++ b/arch/powerpc/platforms/pseries/smp.c
> @@ -84,6 +84,12 @@ static inline int __devinit smp_startup_
>
> pcpu = get_hard_smp_processor_id(lcpu);
>
> + /* Check to see if the CPU out of FW already for kexec */
> + if (smp_query_cpu_stopped(pcpu) == QCSS_NOT_STOPPED){
> + cpu_set(lcpu, of_spin_map);
> + return 1;
> + }
> +
> /* Fixup atomic count: it exited inside IRQ handler. */
> task_thread_info(paca[lcpu].__current)->preempt_count = 0;
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Michael Neuling on
> > This is not going to work without:
> > f8b67691828321f5c85bb853283aa101ae673130
> >
> > It'll get a build failure.
>
> That is because that patch does not apply to the .32 series. If it is
> needed, can you please send me a backported version to apply?

Sure... Compile and boot tested only.

Thanks,
Mikey


From: Michael Neuling <mikey(a)neuling.org>

powerpc/pseries: Make query_cpu_stopped callable outside hotplug cpu

This moves query_cpu_stopped() out of the hotplug cpu code and into
smp.c so it can called in other places and renames it to
smp_query_cpu_stopped().

It also cleans up the return values by adding some #defines

Cc: <stable(a)kernel.org>
Signed-off-by: Michael Neuling <mikey(a)neuling.org>
Signed-off-by: Benjamin Herrenschmidt <benh(a)kernel.crashing.org>

Index: clone1/arch/powerpc/platforms/pseries/hotplug-cpu.c
===================================================================
--- clone1.orig/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ clone1/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -66,30 +66,6 @@ static void pseries_mach_cpu_die(void)
for(;;);
}

-static int qcss_tok; /* query-cpu-stopped-state token */
-
-/* Get state of physical CPU.
- * Return codes:
- * 0 - The processor is in the RTAS stopped state
- * 1 - stop-self is in progress
- * 2 - The processor is not in the RTAS stopped state
- * -1 - Hardware Error
- * -2 - Hardware Busy, Try again later.
- */
-static int query_cpu_stopped(unsigned int pcpu)
-{
- int cpu_status, status;
-
- status = rtas_call(qcss_tok, 1, 2, &cpu_status, pcpu);
- if (status != 0) {
- printk(KERN_ERR
- "RTAS query-cpu-stopped-state failed: %i\n", status);
- return status;
- }
-
- return cpu_status;
-}
-
static int pseries_cpu_disable(void)
{
int cpu = smp_processor_id();
@@ -113,8 +89,9 @@ static void pseries_cpu_die(unsigned int
unsigned int pcpu = get_hard_smp_processor_id(cpu);

for (tries = 0; tries < 25; tries++) {
- cpu_status = query_cpu_stopped(pcpu);
- if (cpu_status == 0 || cpu_status == -1)
+ cpu_status = smp_query_cpu_stopped(pcpu);
+ if (cpu_status == QCSS_STOPPED ||
+ cpu_status == QCSS_HARDWARE_ERROR)
break;
cpu_relax();
}
@@ -256,6 +233,7 @@ static int __init pseries_cpu_hotplug_in
{
struct device_node *np;
const char *typep;
+ int qcss_tok;

for_each_node_by_name(np, "interrupt-controller") {
typep = of_get_property(np, "compatible", NULL);
Index: clone1/arch/powerpc/platforms/pseries/plpar_wrappers.h
===================================================================
--- clone1.orig/arch/powerpc/platforms/pseries/plpar_wrappers.h
+++ clone1/arch/powerpc/platforms/pseries/plpar_wrappers.h
@@ -4,6 +4,14 @@
#include <asm/hvcall.h>
#include <asm/page.h>

+/* Get state of physical CPU from query_cpu_stopped */
+int smp_query_cpu_stopped(unsigned int pcpu);
+#define QCSS_STOPPED 0
+#define QCSS_STOPPING 1
+#define QCSS_NOT_STOPPED 2
+#define QCSS_HARDWARE_ERROR -1
+#define QCSS_HARDWARE_BUSY -2
+
static inline long poll_pending(void)
{
return plpar_hcall_norets(H_POLL_PENDING);
Index: clone1/arch/powerpc/platforms/pseries/smp.c
===================================================================
--- clone1.orig/arch/powerpc/platforms/pseries/smp.c
+++ clone1/arch/powerpc/platforms/pseries/smp.c
@@ -56,6 +56,28 @@
*/
static cpumask_t of_spin_map;

+/* Query where a cpu is now. Return codes #defined in plpar_wrappers.h */
+int smp_query_cpu_stopped(unsigned int pcpu)
+{
+ int cpu_status, status;
+ int qcss_tok = rtas_token("query-cpu-stopped-state");
+
+ if (qcss_tok == RTAS_UNKNOWN_SERVICE) {
+ printk(KERN_INFO "Firmware doesn't support "
+ "query-cpu-stopped-state\n");
+ return QCSS_HARDWARE_ERROR;
+ }
+
+ status = rtas_call(qcss_tok, 1, 2, &cpu_status, pcpu);
+ if (status != 0) {
+ printk(KERN_ERR
+ "RTAS query-cpu-stopped-state failed: %i\n", status);
+ return status;
+ }
+
+ return cpu_status;
+}
+
/**
* smp_startup_cpu() - start the given cpu
*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Michael Neuling on
In message <20100703015627.GB16229(a)suse.de> you wrote:
> On Fri, Jul 02, 2010 at 10:02:48AM +1000, Michael Neuling wrote:
> > This is not going to work without:
> > f8b67691828321f5c85bb853283aa101ae673130
> >
> > It'll get a build failure.
>
> But that patch does not apply on the .27 series, care to provide a
> backported version of it?

Sure... Compile and boot tested only.

Thanks,
Mikey

From: Michael Neuling <mikey(a)neuling.org>

powerpc/pseries: Make query_cpu_stopped callable outside hotplug cpu

This moves query_cpu_stopped() out of the hotplug cpu code and into
smp.c so it can called in other places and renames it to
smp_query_cpu_stopped().

It also cleans up the return values by adding some #defines

Signed-off-by: Michael Neuling <mikey(a)neuling.org>
Signed-off-by: Benjamin Herrenschmidt <benh(a)kernel.crashing.org>

Index: clone3/arch/powerpc/platforms/pseries/hotplug-cpu.c
===================================================================
--- clone3.orig/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ clone3/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -66,30 +66,6 @@ static void pseries_mach_cpu_die(void)
for(;;);
}

-static int qcss_tok; /* query-cpu-stopped-state token */
-
-/* Get state of physical CPU.
- * Return codes:
- * 0 - The processor is in the RTAS stopped state
- * 1 - stop-self is in progress
- * 2 - The processor is not in the RTAS stopped state
- * -1 - Hardware Error
- * -2 - Hardware Busy, Try again later.
- */
-static int query_cpu_stopped(unsigned int pcpu)
-{
- int cpu_status, status;
-
- status = rtas_call(qcss_tok, 1, 2, &cpu_status, pcpu);
- if (status != 0) {
- printk(KERN_ERR
- "RTAS query-cpu-stopped-state failed: %i\n", status);
- return status;
- }
-
- return cpu_status;
-}
-
static int pseries_cpu_disable(void)
{
int cpu = smp_processor_id();
@@ -113,8 +89,9 @@ static void pseries_cpu_die(unsigned int
unsigned int pcpu = get_hard_smp_processor_id(cpu);

for (tries = 0; tries < 25; tries++) {
- cpu_status = query_cpu_stopped(pcpu);
- if (cpu_status == 0 || cpu_status == -1)
+ cpu_status = smp_query_cpu_stopped(pcpu);
+ if (cpu_status == QCSS_STOPPED ||
+ cpu_status == QCSS_HARDWARE_ERROR)
break;
msleep(200);
}
@@ -256,6 +233,7 @@ static int __init pseries_cpu_hotplug_in
{
struct device_node *np;
const char *typep;
+ int qcss_tok;

for_each_node_by_name(np, "interrupt-controller") {
typep = of_get_property(np, "compatible", NULL);
Index: clone3/arch/powerpc/platforms/pseries/plpar_wrappers.h
===================================================================
--- clone3.orig/arch/powerpc/platforms/pseries/plpar_wrappers.h
+++ clone3/arch/powerpc/platforms/pseries/plpar_wrappers.h
@@ -4,6 +4,14 @@
#include <asm/hvcall.h>
#include <asm/page.h>

+/* Get state of physical CPU from query_cpu_stopped */
+int smp_query_cpu_stopped(unsigned int pcpu);
+#define QCSS_STOPPED 0
+#define QCSS_STOPPING 1
+#define QCSS_NOT_STOPPED 2
+#define QCSS_HARDWARE_ERROR -1
+#define QCSS_HARDWARE_BUSY -2
+
static inline long poll_pending(void)
{
return plpar_hcall_norets(H_POLL_PENDING);
Index: clone3/arch/powerpc/platforms/pseries/smp.c
===================================================================
--- clone3.orig/arch/powerpc/platforms/pseries/smp.c
+++ clone3/arch/powerpc/platforms/pseries/smp.c
@@ -59,6 +59,28 @@ static cpumask_t of_spin_map;

extern void generic_secondary_smp_init(unsigned long);

+/* Query where a cpu is now. Return codes #defined in plpar_wrappers.h */
+int smp_query_cpu_stopped(unsigned int pcpu)
+{
+ int cpu_status, status;
+ int qcss_tok = rtas_token("query-cpu-stopped-state");
+
+ if (qcss_tok == RTAS_UNKNOWN_SERVICE) {
+ printk(KERN_INFO "Firmware doesn't support "
+ "query-cpu-stopped-state\n");
+ return QCSS_HARDWARE_ERROR;
+ }
+
+ status = rtas_call(qcss_tok, 1, 2, &cpu_status, pcpu);
+ if (status != 0) {
+ printk(KERN_ERR
+ "RTAS query-cpu-stopped-state failed: %i\n", status);
+ return status;
+ }
+
+ return cpu_status;
+}
+
/**
* smp_startup_cpu() - start the given cpu
*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/