Skip to contentSkip to conversation

powerpc/powernv: Treat an empty reboot string as default

PATCH In review Oliver O'Halloran 5 participants 8 messages Feb 17, 2020 – Mar 6, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 powerpc/powernv: Treat an empty reboot string as default

Treat an empty reboot cmd string the same as a NULL string. This squashes a spurious unsupported reboot message that sometimes gets out when using xmon.

---
 arch/powerpc/platforms/powernv/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/powernv/setup.c +1 -1
index 11fdae8..a8fe630 100644
@@ -229,7 +229,7 @@ static void  __noreturn pnv_restart(char *cmd)
 	pnv_prepare_going_down();
 
 	do {
-		if (!cmd)
+		if (!cmd || !strlen(cmd))
 			rc = opal_cec_reboot();
 		else if (strcmp(cmd, "full") == 0)
 			rc = opal_cec_reboot2(OPAL_REBOOT_FULL_IPL, NULL);
Signature · 1 line
2.9.5
#1 lore raw

PATCH 2/2 powerpc/powernv: Add explicit fast-reboot support

Add a way to manually invoke a fast-reboot rather than setting the NVRAM flag. The idea is to allow userspace to invoke a fast-reboot using the optional string argument to the reboot() system call, or using the xmon zr command so we don't need to leave around a persistent changes on a system to use the feature.

---
Companion skiboot patch:
http://lists.ozlabs.org/pipermail/skiboot/2020-February/016420.html

---
 arch/powerpc/include/asm/opal-api.h    | 1 +
 arch/powerpc/platforms/powernv/setup.c | 2 ++
 2 files changed, 3 insertions(+)
arch/powerpc/include/asm/opal-api.h +1 -0
index c1f25a7..1dffa3c 100644
@@ -1067,6 +1067,7 @@ enum {
 	OPAL_REBOOT_PLATFORM_ERROR	= 1,
 	OPAL_REBOOT_FULL_IPL		= 2,
 	OPAL_REBOOT_MPIPL		= 3,
+	OPAL_REBOOT_FAST		= 4,
 };
 
 /* Argument to OPAL_PCI_TCE_KILL */
arch/powerpc/platforms/powernv/setup.c +2 -0
index a8fe630..3bc188d 100644
@@ -237,6 +237,8 @@ static void  __noreturn pnv_restart(char *cmd)
 			rc = opal_cec_reboot2(OPAL_REBOOT_MPIPL, NULL);
 		else if (strcmp(cmd, "error") == 0)
 			rc = opal_cec_reboot2(OPAL_REBOOT_PLATFORM_ERROR, NULL);
+		else if (strcmp(cmd, "fast") == 0)
+			rc = opal_cec_reboot2(OPAL_REBOOT_FAST, NULL);
 		else
 			rc = OPAL_UNSUPPORTED;
 
Signature · 1 line
2.9.5
#3 lore raw
In reply to Oliver O'Halloran
Quoted 14 lines · Oliver O'Halloran

Treat an empty reboot cmd string the same as a NULL string. This squashes a spurious unsupported reboot message that sometimes gets out when using xmon.

---
 arch/powerpc/platforms/powernv/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/powernv/setup.c +0 -0
index 11fdae8..a8fe630 100644

arch/powerpc/platforms/powernv/setup.c static void __noreturn pnv_restart(char *cmd) · line 232

Quoted 5 lines
arch/powerpc/platforms/powernv/setup.c +1 -1
@@ -229,7 +229,7 @@ static void  __noreturn pnv_restart(char *cmd)
 	pnv_prepare_going_down();
 
 	do {
-		if (!cmd)
+		if (!cmd || !strlen(cmd))

nit: this does not matter here in practice but

if (!cmd || cmd[0] == '\0')

is faster (you do not care about the length anyway) and safer (@cmd can potentially be endless) ;)

Quoted 4 lines
arch/powerpc/platforms/powernv/setup.c +0 -0
 			rc = opal_cec_reboot();
 		else if (strcmp(cmd, "full") == 0)
 			rc = opal_cec_reboot2(OPAL_REBOOT_FULL_IPL, NULL);
Signature · 1 line
Alexey
Reviewed-by on v1 1/2
#6 lore raw
In reply to Oliver O'Halloran
Quoted 5 lines · Oliver O'Halloran

Treat an empty reboot cmd string the same as a NULL string. This squashes a spurious unsupported reboot message that sometimes gets out when using xmon.

Pretty sure I've seen that spurious reboot message a few times and never thought to check why... this makes sense.

Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]             IBM Australia Limited
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] powerpc/powernv: Add explicit fast-reboot support

In reply to Oliver O'Halloran
Quoted 7 lines · Oliver O'Halloran

Add a way to manually invoke a fast-reboot rather than setting the NVRAM flag. The idea is to allow userspace to invoke a fast-reboot using the optional string argument to the reboot() system call, or using the xmon zr command so we don't need to leave around a persistent changes on a system to use the feature.

Both this and the previous patch have passed snowpatch with no warnings, and don't seem to have any obvious issues.

Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]             IBM Australia Limited
#4 lore raw
In reply to Alexey Kardashevskiy
Quoted 10 lines · Alexey Kardashevskiy

arch/powerpc/platforms/powernv/setup.c static void __noreturn pnv_restart(char *cmd) · line 232

Quoted 6 lines · Oliver O'Halloran

Treat an empty reboot cmd string the same as a NULL string. This squashes a spurious unsupported reboot message that sometimes gets out when using xmon.

arch/powerpc/platforms/powernv/setup.c +1 -1
-		if (!cmd)
+		if (!cmd || !strlen(cmd))

nit: this does not matter here in practice but

Quoted 4 lines

if (!cmd || cmd[0] == '\0')

is faster (you do not care about the length anyway) and safer (@cmd can potentially be endless) ;)

No it isn't, this compiles to identical machine code. (I tested with GCC 9, and going back until 4.6 -- the generated code becomes progressively worse (unrelated to this code, fwiw), but identical for both cases all the time).

Segher

#5 lore raw
Quoted 13 lines · Segher Boessenkool
Quoted 12 lines · Alexey Kardashevskiy

arch/powerpc/platforms/powernv/setup.c static void __noreturn pnv_restart(char *cmd) · line 232

Quoted 6 lines · Oliver O'Halloran

Treat an empty reboot cmd string the same as a NULL string. This squashes a spurious unsupported reboot message that sometimes gets out when using xmon.

arch/powerpc/platforms/powernv/setup.c +1 -1
-		if (!cmd)
+		if (!cmd || !strlen(cmd))

nit: this does not matter here in practice but

if (!cmd || cmd[0] == '\0')

Quoted 7 lines
Quoted 2 lines

is faster (you do not care about the length anyway) and safer (@cmd can potentially be endless) ;)

No it isn't, this compiles to identical machine code. (I tested with GCC 9, and going back until 4.6 -- the generated code becomes progressively worse (unrelated to this code, fwiw), but identical for both cases all the time).

oh cool, I did not think gcc is that smart.

Signature · 1 line
Alexey