[PATCH RFC] powerpc/powernv: sysfs entry to force full IPL reboot

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE3520d

7 messages, 3 authors, 2016-12-23 · open the first message on its own page

[PATCH RFC] powerpc/powernv: sysfs entry to force full IPL reboot

From: Andrew Donnellan <hidden>
Date: 2016-11-22 09:23:13

skiboot now supports "fast reboot", a reboot procedure where skiboot
reinitialises hardware and loads a new kernel without re-IPLing the
machine. At present, fast reboot support is still experimental and is not
enabled by default, however it is intended that it will be enabled by
default in a near-future release.

There may be some circumstances where the user wants to force a full IPL
reboot rather than using fast reboot. Add support for the
OPAL_REBOOT_FULL_IPL reboot type, enabled by writing 1 to
/sys/firmware/opal/force_full_ipl_reboot. On versions of skiboot that
implement the OPAL_REBOOT_FULL_IPL reboot type, this will force an IPL. On
versions that do not, print an error message on reboot and proceed with a
regular reboot (which could be a full IPL or a fast reboot).

Cc: Stewart Smith <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Donnellan <redacted>

---

Corresponding skiboot patch: http://patchwork.ozlabs.org/patch/697601/

This seemed like a good idea at the time. A sysfs-based flag was the best 
option that came to mind; other suggestions are welcome. Is "full IPL" a 
reasonable term to use or should I try to think of something a bit less 
IBM-ese?

---
 arch/powerpc/include/asm/opal-api.h    |  1 +
 arch/powerpc/include/asm/opal.h        |  1 +
 arch/powerpc/platforms/powernv/opal.c  |  2 ++
 arch/powerpc/platforms/powernv/setup.c | 63 +++++++++++++++++++++++++++++++++-
 4 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
index 0e2e57b..4de1f63 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -918,6 +918,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/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index e958b70..a5e4065 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -270,6 +270,7 @@ extern void opal_platform_dump_init(void);
 extern void opal_sys_param_init(void);
 extern void opal_msglog_init(void);
 extern void opal_msglog_sysfs_init(void);
+extern void opal_reboot_sysfs_init(void);
 extern int opal_async_comp_init(void);
 extern int opal_sensor_init(void);
 extern int opal_hmi_handler_init(void);
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 6c9a65b..c619d8d 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -750,6 +750,8 @@ static int __init opal_init(void)
 		opal_sys_param_init();
 		/* Setup message log sysfs interface. */
 		opal_msglog_sysfs_init();
+		/* Setup reboot sysfs interface. */
+		opal_reboot_sysfs_init();
 	}
 
 	/* Initialize platform devices: IPMI backend, PRD & flash interface */
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index efe8b6b..d2460fc 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -28,6 +28,7 @@
 #include <linux/bug.h>
 #include <linux/pci.h>
 #include <linux/cpufreq.h>
+#include <linux/sysfs.h>
 
 #include <asm/machdep.h>
 #include <asm/firmware.h>
@@ -118,6 +119,53 @@ static void pnv_prepare_going_down(void)
 	opal_flash_term_callback();
 }
 
+static bool force_full_ipl_reboot = false;
+
+static ssize_t force_full_ipl_reboot_show(struct kobject *k,
+					  struct kobj_attribute *attr,
+					  char *buf)
+{
+	return sprintf(buf, "%d\n", (int) force_full_ipl_reboot);
+}
+
+static ssize_t force_full_ipl_reboot_store(struct kobject *k,
+					   struct kobj_attribute *attr,
+					   const char *buf,
+					   size_t count)
+{
+	if (count != 2)  /* including trailing NUL */
+		return -EINVAL;
+
+	switch (buf[0]) {
+	case '0':
+		force_full_ipl_reboot = false;
+		return count;
+	case '1':
+		force_full_ipl_reboot = true;
+		return count;
+	default:
+		return -EINVAL;
+	}
+}
+
+static struct kobj_attribute opal_force_full_ipl_reboot_attr =
+	__ATTR(force_full_ipl_reboot, 0644, force_full_ipl_reboot_show,
+	       force_full_ipl_reboot_store);
+
+void opal_reboot_sysfs_init(void) {
+	int rc = 0;
+
+	if (!opal_kobj) {
+		pr_warn("setup: opal kobject is not available");
+		return;
+	}
+
+	rc = sysfs_create_file(opal_kobj, &opal_force_full_ipl_reboot_attr.attr);
+	if (rc)
+		pr_err("setup: unable to create sysfs file "
+		       "force_full_ipl_reboot (%d)", rc);
+}
+
 static void  __noreturn pnv_restart(char *cmd)
 {
 	long rc = OPAL_BUSY;
@@ -125,7 +173,20 @@ static void  __noreturn pnv_restart(char *cmd)
 	pnv_prepare_going_down();
 
 	while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
-		rc = opal_cec_reboot();
+		if (force_full_ipl_reboot && opal_check_token(OPAL_CEC_REBOOT2)) {
+			rc = opal_cec_reboot2(OPAL_REBOOT_FULL_IPL,
+					      "Full IPL reboot requested");
+
+			if (rc == OPAL_UNSUPPORTED) {
+				pr_err("Firmware doesn't support forcing full "
+				       "IPL reboot");
+				force_full_ipl_reboot = false;
+				rc = opal_cec_reboot();
+			}
+		} else {
+			rc = opal_cec_reboot();
+		}
+
 		if (rc == OPAL_BUSY_EVENT)
 			opal_poll_events(NULL);
 		else
-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

Re: [PATCH RFC] powerpc/powernv: sysfs entry to force full IPL reboot

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2016-11-22 10:27:50

Andrew Donnellan [off-list ref] writes:
skiboot now supports "fast reboot", a reboot procedure where skiboot
reinitialises hardware and loads a new kernel without re-IPLing the
machine. At present, fast reboot support is still experimental and is not
enabled by default, however it is intended that it will be enabled by
default in a near-future release.

There may be some circumstances where the user wants to force a full IPL
reboot rather than using fast reboot. Add support for the
OPAL_REBOOT_FULL_IPL reboot type, enabled by writing 1 to
/sys/firmware/opal/force_full_ipl_reboot. On versions of skiboot that
implement the OPAL_REBOOT_FULL_IPL reboot type, this will force an IPL. On
versions that do not, print an error message on reboot and proceed with a
regular reboot (which could be a full IPL or a fast reboot).
Hi Andrew,

Can I suggest:
 - Fix OPAL
 - Fix OPAL
 - Fix OPAL

...

Oh OK, it's firmware :D

There's existing logic in kernel/reboot.c to handle a reboot= command
line parameter, which can set the reboot_mode, so my preference would be
that we use that.

Currently we completely ignore the reboot_mode, so there's no backward
compatibility issue.

It looks like the default is REBOOT_COLD, whatever that means. So I
think we could define that on powernv REBOOT_HARD means "do a full IPL".

Or we could use "force", which already exists, though I can't quite see
what that actually means on x86.

cheers

Re: [PATCH RFC] powerpc/powernv: sysfs entry to force full IPL reboot

From: Andrew Donnellan <hidden>
Date: 2016-11-23 01:37:46

On 22/11/16 21:27, Michael Ellerman wrote:
Can I suggest:
 - Fix OPAL
 - Fix OPAL
 - Fix OPAL

...

Oh OK, it's firmware :D
Yep :D
There's existing logic in kernel/reboot.c to handle a reboot= command
line parameter, which can set the reboot_mode, so my preference would be
that we use that.

Currently we completely ignore the reboot_mode, so there's no backward
compatibility issue.

It looks like the default is REBOOT_COLD, whatever that means. So I
think we could define that on powernv REBOOT_HARD means "do a full IPL".
Sounds good.
Or we could use "force", which already exists, though I can't quite see
what that actually means on x86.
Hmm.

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

Re: [PATCH RFC] powerpc/powernv: sysfs entry to force full IPL reboot

From: Andrew Donnellan <hidden>
Date: 2016-11-23 02:33:27

On 23/11/16 12:37, Andrew Donnellan wrote:
quoted
There's existing logic in kernel/reboot.c to handle a reboot= command
line parameter, which can set the reboot_mode, so my preference would be
that we use that.

Currently we completely ignore the reboot_mode, so there's no backward
compatibility issue.

It looks like the default is REBOOT_COLD, whatever that means. So I
think we could define that on powernv REBOOT_HARD means "do a full IPL".
Sounds good.
Thinking about this more - you can't change that at runtime. :(
quoted
Or we could use "force", which already exists, though I can't quite see
what that actually means on x86.
Hmm.
It looks like that on x86, if reboot_force = 1, we don't call 
machine_shutdown() and go straight to __machine_emergency_restart()?

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

Re: [PATCH RFC] powerpc/powernv: sysfs entry to force full IPL reboot

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2016-11-23 03:19:17

Andrew Donnellan [off-list ref] writes:
On 23/11/16 12:37, Andrew Donnellan wrote:
quoted
quoted
There's existing logic in kernel/reboot.c to handle a reboot= command
line parameter, which can set the reboot_mode, so my preference would be
that we use that.

Currently we completely ignore the reboot_mode, so there's no backward
compatibility issue.

It looks like the default is REBOOT_COLD, whatever that means. So I
think we could define that on powernv REBOOT_HARD means "do a full IPL".
Sounds good.
Thinking about this more - you can't change that at runtime. :(
Yeah. Is that a problem? From my POV this is basically a "my firmware is
broken" workaround, so you're going to want to set it permanently until
you update your firmware.
quoted
quoted
Or we could use "force", which already exists, though I can't quite see
what that actually means on x86.
Hmm.
It looks like that on x86, if reboot_force = 1, we don't call 
machine_shutdown() and go straight to __machine_emergency_restart()?
I think so. But I don't know what that actually means from a user's
point of view.

cheers

Re: [PATCH RFC] powerpc/powernv: sysfs entry to force full IPL reboot

From: Stewart Smith <hidden>
Date: 2016-12-23 04:19:17

Michael Ellerman [off-list ref] writes:
Andrew Donnellan [off-list ref] writes:
quoted
On 23/11/16 12:37, Andrew Donnellan wrote:
quoted
quoted
There's existing logic in kernel/reboot.c to handle a reboot= command
line parameter, which can set the reboot_mode, so my preference would be
that we use that.

Currently we completely ignore the reboot_mode, so there's no backward
compatibility issue.

It looks like the default is REBOOT_COLD, whatever that means. So I
think we could define that on powernv REBOOT_HARD means "do a full IPL".
Sounds good.
Thinking about this more - you can't change that at runtime. :(
Yeah. Is that a problem? From my POV this is basically a "my firmware is
broken" workaround, so you're going to want to set it permanently until
you update your firmware.
The only real world application I can see wanting to do that is perhaps
HTX - where it chooses what kind of bootme run it wants. So, well, for
certain definitions of "real world".

-- 
Stewart Smith
OPAL Architect, IBM.

Re: [PATCH RFC] powerpc/powernv: sysfs entry to force full IPL reboot

From: Stewart Smith <hidden>
Date: 2016-12-23 04:20:52

Andrew Donnellan [off-list ref] writes:
skiboot now supports "fast reboot", a reboot procedure where skiboot
reinitialises hardware and loads a new kernel without re-IPLing the
machine. At present, fast reboot support is still experimental and is not
enabled by default, however it is intended that it will be enabled by
default in a near-future release.

There may be some circumstances where the user wants to force a full IPL
reboot rather than using fast reboot. Add support for the
OPAL_REBOOT_FULL_IPL reboot type, enabled by writing 1 to
/sys/firmware/opal/force_full_ipl_reboot. On versions of skiboot that
implement the OPAL_REBOOT_FULL_IPL reboot type, this will force an IPL. On
versions that do not, print an error message on reboot and proceed with a
regular reboot (which could be a full IPL or a fast reboot).

Cc: Stewart Smith <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Donnellan <redacted>

---

Corresponding skiboot patch: http://patchwork.ozlabs.org/patch/697601/
FWIW I've just merged the skiboot patch.

-- 
Stewart Smith
OPAL Architect, IBM.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help