powerpc/powernv: Make possible for user to force a full ipl cec reboot
authorVaibhav Jain <vaibhav@linux.ibm.com>
Fri, 7 Sep 2018 07:34:48 +0000 (13:04 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 3 Oct 2018 05:39:45 +0000 (15:39 +1000)
Ever since fast reboot is enabled by default in opal,
opal_cec_reboot() will use fast-reset instead of full IPL to perform
system reboot. This leaves the user with no direct way to force a full
IPL reboot except changing an nvram setting that persistently disables
fast-reset for all subsequent reboots.

This patch provides a more direct way for the user to force a one-shot
full IPL reboot by passing the command line argument 'full' to the
reboot command. So the user will be able to tweak the reboot behavior
via:

  $ sudo reboot full # Force a full ipl reboot skipping fast-reset

  or
  $ sudo reboot   # default reboot path (usually fast-reset)

The reboot command passes the un-parsed command argument to the kernel
via the 'Reboot' syscall which is then passed on to the arch function
pnv_restart(). The patch updates pnv_restart() to handle this cmd-arg
and issues opal_cec_reboot2 with OPAL_REBOOT_FULL_IPL to force a full
IPL reset.

Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/opal-api.h
arch/powerpc/platforms/powernv/setup.c

index 8365353330b43e79f89fa9b55a00bc2a58ae5b06..870fb7b239ea420b0f4d5b8d5c4ba3e356f5542c 100644 (file)
@@ -1050,6 +1050,7 @@ enum OpalSysCooling {
 enum {
        OPAL_REBOOT_NORMAL              = 0,
        OPAL_REBOOT_PLATFORM_ERROR      = 1,
+       OPAL_REBOOT_FULL_IPL            = 2,
 };
 
 /* Argument to OPAL_PCI_TCE_KILL */
index c9cbd11a442e767e92c170083c24e9a14b5f6171..14befee4b3f1eae867947e9282c7b064cc1974a8 100644 (file)
@@ -219,17 +219,41 @@ static void pnv_prepare_going_down(void)
 
 static void  __noreturn pnv_restart(char *cmd)
 {
-       long rc = OPAL_BUSY;
+       long rc;
 
        pnv_prepare_going_down();
 
-       while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
-               rc = opal_cec_reboot();
-               if (rc == OPAL_BUSY_EVENT)
-                       opal_poll_events(NULL);
+       do {
+               if (!cmd)
+                       rc = opal_cec_reboot();
+               else if (strcmp(cmd, "full") == 0)
+                       rc = opal_cec_reboot2(OPAL_REBOOT_FULL_IPL, NULL);
                else
+                       rc = OPAL_UNSUPPORTED;
+
+               if (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
+                       /* Opal is busy wait for some time and retry */
+                       opal_poll_events(NULL);
                        mdelay(10);
-       }
+
+               } else  if (cmd && rc) {
+                       /* Unknown error while issuing reboot */
+                       if (rc == OPAL_UNSUPPORTED)
+                               pr_err("Unsupported '%s' reboot.\n", cmd);
+                       else
+                               pr_err("Unable to issue '%s' reboot. Err=%ld\n",
+                                      cmd, rc);
+                       pr_info("Forcing a cec-reboot\n");
+                       cmd = NULL;
+                       rc = OPAL_BUSY;
+
+               } else if (rc != OPAL_SUCCESS) {
+                       /* Unknown error while issuing cec-reboot */
+                       pr_err("Unable to reboot. Err=%ld\n", rc);
+               }
+
+       } while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT);
+
        for (;;)
                opal_poll_events(NULL);
 }