linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] powerpc/powernv: Make possible for user to force a full ipl cec reboot
@ 2018-09-07  7:34 Vaibhav Jain
  2018-09-07  8:20 ` Andrew Donnellan
  2018-10-04  6:14 ` [v3] " Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Vaibhav Jain @ 2018-09-07  7:34 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Michael Ellerman, Stewart Smith
  Cc: Vaibhav Jain, linuxppc-dev, Andrew Donnellan, Vasant Hegde,
	Michael Neuling, Nicholas Piggin, Oliver O'Halloran

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>
---
Change-log:

v3	-> Re-factored the code to make it more readable [Andrew]
	   Handle return of OPAL_SUCCESS from cec_reboot variants
	   [Vasant]

v2	-> Updated the code to handle case when opal_cec_reboot2() is
	   not supported by opal. [Andrew]

	-> Force a call to opal_cec_reboot() is opal_cec_reboot2()
           fails or the action verb 'cmd' is not recognized.
---
 arch/powerpc/include/asm/opal-api.h    |  1 +
 arch/powerpc/platforms/powernv/setup.c | 36 +++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
index 8365353330b4..870fb7b239ea 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -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 */
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index adddde023622..79fd839faa2d 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -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);
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] powerpc/powernv: Make possible for user to force a full ipl cec reboot
  2018-09-07  7:34 [PATCH v3] powerpc/powernv: Make possible for user to force a full ipl cec reboot Vaibhav Jain
@ 2018-09-07  8:20 ` Andrew Donnellan
  2018-10-04  6:14 ` [v3] " Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Donnellan @ 2018-09-07  8:20 UTC (permalink / raw)
  To: Vaibhav Jain, Benjamin Herrenschmidt, Michael Ellerman,
	Stewart Smith
  Cc: linuxppc-dev, Vasant Hegde, Michael Neuling, Nicholas Piggin,
	Oliver O'Halloran

On 07/09/18 17:34, Vaibhav Jain wrote:
> 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>

This looks better!

Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

> ---
> Change-log:
> 
> v3	-> Re-factored the code to make it more readable [Andrew]
> 	   Handle return of OPAL_SUCCESS from cec_reboot variants
> 	   [Vasant]
> 
> v2	-> Updated the code to handle case when opal_cec_reboot2() is
> 	   not supported by opal. [Andrew]
> 
> 	-> Force a call to opal_cec_reboot() is opal_cec_reboot2()
>             fails or the action verb 'cmd' is not recognized.
> ---
>   arch/powerpc/include/asm/opal-api.h    |  1 +
>   arch/powerpc/platforms/powernv/setup.c | 36 +++++++++++++++++++++-----
>   2 files changed, 31 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
> index 8365353330b4..870fb7b239ea 100644
> --- a/arch/powerpc/include/asm/opal-api.h
> +++ b/arch/powerpc/include/asm/opal-api.h
> @@ -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 */
> diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
> index adddde023622..79fd839faa2d 100644
> --- a/arch/powerpc/platforms/powernv/setup.c
> +++ b/arch/powerpc/platforms/powernv/setup.c
> @@ -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);
>   }
> 

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [v3] powerpc/powernv: Make possible for user to force a full ipl cec reboot
  2018-09-07  7:34 [PATCH v3] powerpc/powernv: Make possible for user to force a full ipl cec reboot Vaibhav Jain
  2018-09-07  8:20 ` Andrew Donnellan
@ 2018-10-04  6:14 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-10-04  6:14 UTC (permalink / raw)
  To: Vaibhav Jain, Benjamin Herrenschmidt, Stewart Smith
  Cc: Michael Neuling, Nicholas Piggin, Vasant Hegde,
	Oliver O'Halloran, Andrew Donnellan, Vaibhav Jain,
	linuxppc-dev

On Fri, 2018-09-07 at 07:34:48 UTC, Vaibhav Jain wrote:
> 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>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/8139046a5a34787849df81f4a5875c

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-04  6:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-07  7:34 [PATCH v3] powerpc/powernv: Make possible for user to force a full ipl cec reboot Vaibhav Jain
2018-09-07  8:20 ` Andrew Donnellan
2018-10-04  6:14 ` [v3] " Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).