]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
powerpc/powernv: Make possible for user to force a full ipl cec reboot
authorVaibhav Jain <vaibhav@linux.ibm.com>
Thu, 14 Mar 2019 17:56:44 +0000 (14:56 -0300)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 1 Apr 2019 12:37:29 +0000 (14:37 +0200)
BugLink: https://bugs.launchpad.net/bugs/1819989
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>
(cherry picked from commit 8139046a5a34787849df81f4a5875cf4b404a7a1)
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.ibm.com>
Acked-by: Kamal Mostafa <kamal@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/include/asm/opal-api.h
arch/powerpc/platforms/powernv/setup.c

index 402f2cd80f9e45c0367b35d9a53bfc8d3131e995..e2515843b37eb89a06e555bd16ce6e64e85da4c2 100644 (file)
@@ -1047,6 +1047,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 34e36f91a38e11ea2e3d4cb1e371f34e17b05376..be7eac602402102309f9103186a2a75eb8e4676f 100644 (file)
@@ -217,17 +217,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);
 }