git: 41e26e8288f1 - main - powerpc: better handling of shutdown flags

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 23 Nov 2023 16:07:59 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=41e26e8288f1743c8584e5f9c461d36dce1cccc6

commit 41e26e8288f1743c8584e5f9c461d36dce1cccc6
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-11-23 15:25:05 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-11-23 16:07:42 +0000

    powerpc: better handling of shutdown flags
    
    RB_HALT does not mean poweroff, RB_POWEROFF does.
    
    Reviewed by:    jhibbits
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D42339
---
 sys/powerpc/powermac/cuda.c    | 8 +++++++-
 sys/powerpc/powermac/pmu.c     | 6 ++++--
 sys/powerpc/powermac/smu.c     | 6 ++++--
 sys/powerpc/powernv/opal_dev.c | 6 ++++--
 sys/powerpc/pseries/rtas_dev.c | 4 ++--
 5 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/sys/powerpc/powermac/cuda.c b/sys/powerpc/powermac/cuda.c
index 974ad585b543..97f60f269559 100644
--- a/sys/powerpc/powermac/cuda.c
+++ b/sys/powerpc/powermac/cuda.c
@@ -748,7 +748,13 @@ cuda_shutdown(void *xsc, int howto)
 	struct cuda_softc *sc = xsc;
 	uint8_t cmd[] = {CUDA_PSEUDO, 0};
 
-	cmd[1] = (howto & RB_HALT) ? CMD_POWEROFF : CMD_RESET;
+	if ((howto & RB_POWEROFF) != 0)
+		cmd[1] = CMD_POWEROFF;
+	else if ((howto & RB_HALT) == 0)
+		cmd[1] = CMD_RESET;
+	else
+		return;
+
 	cuda_poll(sc->sc_dev);
 	cuda_send(sc, 1, 2, cmd);
 
diff --git a/sys/powerpc/powermac/pmu.c b/sys/powerpc/powermac/pmu.c
index 67ef57bf6be8..f9d9d4d40c72 100644
--- a/sys/powerpc/powermac/pmu.c
+++ b/sys/powerpc/powermac/pmu.c
@@ -812,10 +812,12 @@ pmu_shutdown(void *xsc, int howto)
 	struct pmu_softc *sc = xsc;
 	uint8_t cmd[] = {'M', 'A', 'T', 'T'};
 
-	if (howto & RB_HALT)
+	if ((howto & RB_POWEROFF) != 0)
 		pmu_send(sc, PMU_POWER_OFF, 4, cmd, 0, NULL);
-	else
+	else if ((howto & RB_HALT) == 0)
 		pmu_send(sc, PMU_RESET_CPU, 0, NULL, 0, NULL);
+	else
+		return;
 
 	for (;;);
 }
diff --git a/sys/powerpc/powermac/smu.c b/sys/powerpc/powermac/smu.c
index 5aed7b87d3c2..af00599e6b54 100644
--- a/sys/powerpc/powermac/smu.c
+++ b/sys/powerpc/powermac/smu.c
@@ -1317,10 +1317,12 @@ smu_shutdown(void *xdev, int howto)
 	struct smu_cmd cmd;
 
 	cmd.cmd = SMU_POWER;
-	if (howto & RB_HALT)
+	if ((howto & RB_POWEROFF) != 0)
 		strcpy(cmd.data, "SHUTDOWN");
-	else
+	else if ((howto & RB_HALT) == 0)
 		strcpy(cmd.data, "RESTART");
+	else
+		return;
 
 	cmd.len = strlen(cmd.data);
 
diff --git a/sys/powerpc/powernv/opal_dev.c b/sys/powerpc/powernv/opal_dev.c
index edb8f6d435ad..ab1a1fbb731c 100644
--- a/sys/powerpc/powernv/opal_dev.c
+++ b/sys/powerpc/powernv/opal_dev.c
@@ -344,10 +344,12 @@ static void
 opal_shutdown(void *arg, int howto)
 {
 
-	if (howto & RB_HALT)
+	if ((howto & RB_POWEROFF) != 0)
 		opal_call(OPAL_CEC_POWER_DOWN, 0 /* Normal power off */);
-	else
+	else if ((howto & RB_HALT) == 0)
 		opal_call(OPAL_CEC_REBOOT);
+	else
+		return;
 
 	opal_call(OPAL_RETURN_CPU);
 }
diff --git a/sys/powerpc/pseries/rtas_dev.c b/sys/powerpc/pseries/rtas_dev.c
index ef9522f5495d..f8198ef27417 100644
--- a/sys/powerpc/pseries/rtas_dev.c
+++ b/sys/powerpc/pseries/rtas_dev.c
@@ -155,13 +155,13 @@ rtas_shutdown(void *arg, int howto)
 {
 	cell_t token, status;
 
-	if (howto & RB_HALT) {
+	if ((howto & RB_POWEROFF) != 0) {
 		token = rtas_token_lookup("power-off");
 		if (token == -1)
 			return;
 
 		rtas_call_method(token, 2, 1, 0, 0, &status);
-	} else {
+	} else if ((howto & RB_HALT) == 0) {
 		token = rtas_token_lookup("system-reboot");
 		if (token == -1)
 			return;