Subject: [PATCH] powerpc/pseries: tell phyp to auto-restart

From: [email-masked] (Linas Vepstas)
Date: Tue, 20 Nov 2007 20:09:22 -0600

The pseries hypervisor attempts to detect and prevent an 
infinite loop of kernel crashes and auto-reboots. It does 
so by refusing to auto-reboot unless we indicate that the
current boot was sucessful.  So, indicate success late in
the boot sequence.

Signed-off-by: Linas Vepstas <[email-masked]>

----
Sigh. This is a side-effect of the patch I sent yesterday.
Its supposed to simplify the management large numbers of 
partitions. 

 arch/powerpc/platforms/pseries/setup.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Index: linux-2.6.24-rc3-git1/arch/powerpc/platforms/pseries/setup.c
===================================================================
--- linux-2.6.24-rc3-git1.orig/arch/powerpc/platforms/pseries/setup.c	2007-11-20 18:37:14.000000000 -0600
+++ linux-2.6.24-rc3-git1/arch/powerpc/platforms/pseries/setup.c	2007-11-20 19:08:12.000000000 -0600
@@ -491,6 +491,37 @@ void pSeries_power_off(void)
 	for (;;);
 }
 
+/**
+ * pSeries_auto_restart - tell hypervisor that boot succeeded.
+ *
+ * The pseries hypervisor attempts to detect and prevent an
+ * infinite loop of kernel crashes and auto-reboots. It does
+ * so by refusing to auto-reboot unless we indicate that the
+ * current boot was sucessful.  So, indicate success late in
+ * the boot sequence.
+ */
+static int __init pSeries_auto_restart(void)
+{
+	static char buff[3]; /* static so that its in RMO region */
+	int rc;
+	int token = rtas_token("ibm,set-system-parameter");
+	if (!token)
+		return 0;
+
+	/* partition_auto_restart is 21; set to to 1 to auto-restart the OS. */
+	buff[0] = 0;
+	buff[1] = 1; /* length */
+	buff[2] = 1; /* value */
+	do {
+		rc = rtas_call (token, 2, 1, NULL, 21, buff);
+	} while (rtas_busy_delay(rc));
+	if (rc)
+		printk(KERN_INFO "pSeries_auto_restart(): "
+		       "unable to setup autorestart, rc=%d\n", rc);
+	return 0;
+}
+late_initcall(pSeries_auto_restart);
+
 #ifndef CONFIG_PCI
 void pSeries_final_fixup(void) { }
 #endif