Skip to contentSkip to conversation

powerpc/powernv: Return secondary CPUs to firmware on kexec

PATCH Superseded Benjamin Herrenschmidt 2 participants 3 messages Aug 16, 2013 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/powernv: Return secondary CPUs to firmware on kexec

With OPAL v3 we can return secondary CPUs to firmware on kexec. This allows firmware to do various cleanups making things generally more reliable, and will enable the "new" kernel to call OPAL to perform some reconfiguration tasks early on that can only be done while all the CPUs are in firmware.

arch/powerpc/platforms/powernv/setup.c +11 -0
index d4459bf..b59a1da 100644
@@ -31,6 +31,7 @@
 #include <asm/xics.h>
 #include <asm/rtas.h>
 #include <asm/opal.h>
+#include <asm/kexec.h>
 
 #include "powernv.h"
 
@@ -143,6 +144,16 @@ static void pnv_shutdown(void)
 static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
 {
 	xics_kexec_teardown_cpu(secondary);
+
+	/* Return secondary CPUs to firmware on OPAL v3 */
+	if (firmware_has_feature(FW_FEATURE_OPALv3) && secondary) {
+		mb();
+		get_paca()->kexec_state = KEXEC_STATE_REAL_MODE;
+		mb();
+
+		/* Return the CPU to OPAL */
+		opal_return_cpu();
+	}
 }
 #endif /* CONFIG_KEXEC */
 
#1 lore raw
Quoted 5 lines

With OPAL v3 we can return secondary CPUs to firmware on kexec. This allows firmware to do various cleanups making things generally more reliable, and will enable the "new" kernel to call OPAL to perform some reconfiguration tasks early on that can only be done while all the CPUs are in firmware.

Dumb question, but isn't the point of kexec to avoid fw interactions like this?

Mikey

Review

Quoted 3 lines
(quoted diff) +0 -0

b/arch/powerpc/platforms/powernv/setup.c

Quoted 35 lines

index d4459bf..b59a1da 100644

arch/powerpc/platforms/powernv/setup.c +11 -0
@@ -31,6 +31,7 @@
 #include <asm/xics.h>
 #include <asm/rtas.h>
 #include <asm/opal.h>
+#include <asm/kexec.h>
 
 #include "powernv.h"
 
@@ -143,6 +144,16 @@ static void pnv_shutdown(void)
 static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
 {
        xics_kexec_teardown_cpu(secondary);
+
+       /* Return secondary CPUs to firmware on OPAL v3 */
+       if (firmware_has_feature(FW_FEATURE_OPALv3) && secondary) {
+               mb();
+               get_paca()->kexec_state = KEXEC_STATE_REAL_MODE;
+               mb();
+
+               /* Return the CPU to OPAL */
+               opal_return_cpu();
+       }
 }
 #endif /* CONFIG_KEXEC */
 

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#2 lore raw
Quoted 9 lines · Michael Neuling
Quoted 6 lines

With OPAL v3 we can return secondary CPUs to firmware on kexec. This allows firmware to do various cleanups making things generally more reliable, and will enable the "new" kernel to call OPAL to perform some reconfiguration tasks early on that can only be done while all the CPUs are in firmware.

Dumb question, but isn't the point of kexec to avoid fw interactions like this?

The point of kexec is to avoid rebooting :-)

Sending secondaries back to the OPAL internal spin loop doesn't take a noticeable amount of time.

We could avoid doing it and solve the problem of needing all CPUs in firmware for "reconfig" differently however. We could have the "target" kernel code take them out of kexec into a special path that goes back into the fw ... I chose the kexec solution because it was simpler and less code :-)

Cheers,
Ben.

Quoted 44 lines

Mikey

Review

Quoted 3 lines
(quoted diff) +0 -0

b/arch/powerpc/platforms/powernv/setup.c

Quoted 35 lines

index d4459bf..b59a1da 100644

arch/powerpc/platforms/powernv/setup.c +11 -0
@@ -31,6 +31,7 @@
 #include <asm/xics.h>
 #include <asm/rtas.h>
 #include <asm/opal.h>
+#include <asm/kexec.h>
 
 #include "powernv.h"
 
@@ -143,6 +144,16 @@ static void pnv_shutdown(void)
 static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
 {
        xics_kexec_teardown_cpu(secondary);
+
+       /* Return secondary CPUs to firmware on OPAL v3 */
+       if (firmware_has_feature(FW_FEATURE_OPALv3) && secondary) {
+               mb();
+               get_paca()->kexec_state = KEXEC_STATE_REAL_MODE;
+               mb();
+
+               /* Return the CPU to OPAL */
+               opal_return_cpu();
+       }
 }
 #endif /* CONFIG_KEXEC */
 

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev