Skip to contentSkip to conversation

sparc64: shut down to OBP correctly

PATCH In review Larry Bassel 3 participants 4 messages Jan 5, 2017 – Mar 16, 2017 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 sparc64: shut down to OBP correctly

The command "shutdown -h -H now" should shut the system down to the OBP, however the machine was being powered off in the LDOM case.

In the LDOM case, the "reboot-command" variable must be set to the string "noop" and then ldom_reboot() must be called. This will make the OBP ignore the setting of "auto-boot?" after it completes the reset. This causes the system to stop at the ok prompt.

---
 arch/sparc/include/asm/ldc.h |    2 +-
 arch/sparc/kernel/ds.c       |    6 +++---
 arch/sparc/prom/misc_64.c    |   12 ++++++++++--
 3 files changed, 14 insertions(+), 6 deletions(-)
arch/sparc/include/asm/ldc.h +1 -1
index 6e9004a..a96a849 100644
@@ -5,7 +5,7 @@
 
 extern int ldom_domaining_enabled;
 void ldom_set_var(const char *var, const char *value);
-void ldom_reboot(const char *boot_command);
+extern void ldom_reboot(const char *boot_command, bool prepend_boot);
 void ldom_power_off(void);
 
 /* The event handler will be evoked when link state changes
arch/sparc/kernel/ds.c +3 -3
index f87a55d..723167a 100644
@@ -841,7 +841,7 @@ void ldom_set_var(const char *var, const char *value)
 static char full_boot_str[256] __attribute__((aligned(32)));
 static int reboot_data_supported;
 
-void ldom_reboot(const char *boot_command)
+void ldom_reboot(const char *boot_command, bool prepend_boot)
 {
 	/* Don't bother with any of this if the boot_command
 	 * is empty.
@@ -849,8 +849,8 @@ void ldom_reboot(const char *boot_command)
 	if (boot_command && strlen(boot_command)) {
 		unsigned long len;
 
-		snprintf(full_boot_str, sizeof(full_boot_str), "boot %s",
-			 boot_command);
+		snprintf(full_boot_str, sizeof(full_boot_str), "%s%s",
+			 prepend_boot ? "boot " : "", boot_command);
 		len = strlen(full_boot_str);
 
 		if (reboot_data_supported) {
arch/sparc/prom/misc_64.c +10 -2
index 53a696d..7efe361 100644
@@ -54,7 +54,7 @@ void prom_reboot(const char *bcommand)
 
 #ifdef CONFIG_SUN_LDOMS
 	if (ldom_domaining_enabled)
-		ldom_reboot(bcommand);
+		ldom_reboot(bcommand, true);
 #endif
 	args[0] = (unsigned long) "boot";
 	args[1] = 1;
@@ -116,8 +116,16 @@ void notrace prom_halt(void)
 	unsigned long args[3];
 
 #ifdef CONFIG_SUN_LDOMS
+	/*
+	* By storing a no-op command
+	* in the 'reboot-command' variable we cause OBP
+	* to ignore the setting of 'auto-boot?' after
+	* it completes the reset.  This causes the system
+	* to stop at the ok prompt.
+	*/
+
 	if (ldom_domaining_enabled)
-		ldom_power_off();
+		ldom_reboot("noop", false);
 #endif
 again:
 	args[0] = (unsigned long) "exit";
Signature · 1 line
1.7.1
maintainer
#1 lore raw

From: Larry Bassel <[email protected]>
Date: Thu, 5 Jan 2017 09:23:33 -0800

Quoted 9 lines

The command "shutdown -h -H now" should shut the system down to the OBP, however the machine was being powered off in the LDOM case.

In the LDOM case, the "reboot-command" variable must be set to the string "noop" and then ldom_reboot() must be called. This will make the OBP ignore the setting of "auto-boot?" after it completes the reset. This causes the system to stop at the ok prompt.

This really doesn't make any sense.

The purpose of shutting down to the "OK" prompt is to inspect the system state using OBP commands from the context of the currently running kernel boot.

If you allow the software reset to happen and then force a stop at the "OK" prompt, the intention of the facility has been completely compromised so this is pointless.

User's who want the behavior you mention can get it by setting the reboot-command variable from userspace using the 'eeprom' or similar commands, and then simply reboot.

I am not applying this patch, sorry.

#2 lore raw
In reply to Larry Bassel
Quoted 23 lines · David Miller

From: Larry Bassel <[email protected]>
Date: Thu, 5 Jan 2017 09:23:33 -0800

Quoted 9 lines

The command "shutdown -h -H now" should shut the system down to the OBP, however the machine was being powered off in the LDOM case.

In the LDOM case, the "reboot-command" variable must be set to the string "noop" and then ldom_reboot() must be called. This will make the OBP ignore the setting of "auto-boot?" after it completes the reset. This causes the system to stop at the ok prompt.

This really doesn't make any sense.

The purpose of shutting down to the "OK" prompt is to inspect the system state using OBP commands from the context of the currently running kernel boot.

If you allow the software reset to happen and then force a stop at the "OK" prompt, the intention of the facility has been completely compromised so this is pointless.

Quoted 5 lines

User's who want the behavior you mention can get it by setting the reboot-command variable from userspace using the 'eeprom' or similar commands, and then simply reboot.

I am not applying this patch, sorry.

My apologies for the delayed response.

I've gotten feedback from several Oracle people (copied on this email) that my explanation for why this patch is useful is incomplete:

1. The variable "reboot-command" isn't one of the usual nvram variables, it's magic and expected to be used for purposes like this (as Solaris already does). It's not like "boot-device" which sets a permanent default. It's cleared when it's used by OpenBoot.

2. It's how you can reboot to an alternate kernel once or reboot from an alternate boot device once, without changing the permanent default.

I'd appreciate it if you'd reconsider accepting this patch.

Thanks.

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Larry

#3 lore raw
In reply to Larry Bassel
Quoted 40 lines · Larry Bassel
Quoted 23 lines · David Miller

From: Larry Bassel <[email protected]>
Date: Thu, 5 Jan 2017 09:23:33 -0800

Quoted 9 lines

The command "shutdown -h -H now" should shut the system down to the OBP, however the machine was being powered off in the LDOM case.

In the LDOM case, the "reboot-command" variable must be set to the string "noop" and then ldom_reboot() must be called. This will make the OBP ignore the setting of "auto-boot?" after it completes the reset. This causes the system to stop at the ok prompt.

This really doesn't make any sense.

The purpose of shutting down to the "OK" prompt is to inspect the system state using OBP commands from the context of the currently running kernel boot.

If you allow the software reset to happen and then force a stop at the "OK" prompt, the intention of the facility has been completely compromised so this is pointless.

Quoted 5 lines

User's who want the behavior you mention can get it by setting the reboot-command variable from userspace using the 'eeprom' or similar commands, and then simply reboot.

I am not applying this patch, sorry.

My apologies for the delayed response.

I've gotten feedback from several Oracle people (copied on this email) that my explanation for why this patch is useful is incomplete:

1. The variable "reboot-command" isn't one of the usual nvram variables, it's magic and expected to be used for purposes like this (as Solaris already does). It's not like "boot-device" which sets a permanent default. It's cleared when it's used by OpenBoot.

Quoted 5 lines

2. It's how you can reboot to an alternate kernel once or reboot from an alternate boot device once, without changing the permanent default.

I'd appreciate it if you'd reconsider accepting this patch.

Another important point is that you shouldn't re-enter the OBP after the OS was booted.

After the OS is booted, the configuration of a domain can be dynamically changed by adding/removing resources (in particular cpu/memory). However, the OBP won't be aware of any of these changes. So if you return to the OBP, the OBP might have an inaccurate knowledge of the configuration, and you can have unpredictable behavior.

That's precisely why Solaris actually removes the OBP right after Solaris takes control, and effectively prevents returning to the OBP.

So it makes sense to reset the domain before returning to the OBP.

Rgds,

alex.