ppc/shutdown: Implement machine_{halt,restart}()
cover ppc/shutdown: Implement machine_{halt,restart}()
I got bored testing fixes to the gitlab containers.
Oleksii: There's almost certainly a related change suitable for RISC-V.
Andrew Cooper (2):
xen/shutdown: Fix build issue with shutdown.h on PPC ppc/shutdown: Implement machine_{halt,restart}()
xen/arch/ppc/Makefile | 1 + xen/arch/ppc/ppc64/opal-calls.S | 4 +++ xen/arch/ppc/setup.c | 8 +++--- xen/arch/ppc/shutdown.c | 43 +++++++++++++++++++++++++++++++++ xen/arch/ppc/stubs.c | 12 --------- xen/common/shutdown.c | 4 +-- xen/include/xen/shutdown.h | 3 ++- 7 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 xen/arch/ppc/shutdown.c
base-commit: c2a66d0b58b9661037cfed6bf3f8122b3363ca38
Signature · 1 line
2.39.2
PATCH 1/2 xen/shutdown: Fix build issue with shutdown.h on PPC
The use of bool needs xen/types.h, which shutdown.h picks up by chance in all other architectures.
While fixing this, swap u8 for unsigned char in hwdom_shutdown(), and move opt_noreboot into __ro_after_init.
---
CC: Shawn Anastasio <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
--- xen/common/shutdown.c | 4 ++-- xen/include/xen/shutdown.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)
xen/common/shutdown.c +2 -2
@@ -11,7 +11,7 @@#include <public/sched.h> /* opt_noreboot: If true, machine will need manual reset on error. */ -bool __read_mostly opt_noreboot; +bool __ro_after_init opt_noreboot;boolean_param ("noreboot" , opt_noreboot);static void noreturnreboot_or_halt (void )
@@ -29,7 +29,7 @@ static void noreturn reboot_or_halt(void) } } -void hwdom_shutdown (u8 reason) +void hwdom_shutdown (unsigned char reason) {switch ( reason ) {
xen/include/xen/shutdown.h +2 -1
@@ -2,11 +2,12 @@#define __XEN_SHUTDOWN_H__#include <xen/compiler.h> +#include <xen/types.h> /* opt_noreboot: If true, machine will need manual reset on error. */ extern bool opt_noreboot; -void noreturnhwdom_shutdown (u8 reason); +void noreturnhwdom_shutdown (unsigned char reason);void noreturnmachine_restart (unsigned int delay_millisecs);void noreturnmachine_halt (void );
Signature · 1 line
2.39.2
Re: [PATCH 1/2] xen/shutdown: Fix build issue with shutdown.h on PPC
Quoted 7 lines · Andrew Cooper
The use of bool needs
xen/types.h, whichshutdown.hpicks up by chance in all other architectures.While fixing this, swap u8 for unsigned char in
hwdom_shutdown(), and moveopt_norebootinto__ro_after_init.Signed-off-by Andrew Cooper <[email protected]>
PATCH 2/2 ppc/shutdown: Implement machine_{halt,restart}()
In reply to Andrew CooperOPAL has easy APIs for shutdown/reboot, so wire them up.
Then, use machine_halt() rather than an infinite loop at the end of start_xen(). This avoids the Qemu smoke test needing to wait for the full timeout in order to succeed.
(XEN) 8e011600000000c0 is the result of PTE map
Enabled radix in LPCR
Flushed TLB
Hello, ppc64le!
[ 6.341897656,5] OPAL: Shutdown request type 0x0...
---
CC: Shawn Anastasio <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
I got bored testing fixes to the containers...
--- xen/arch/ppc/Makefile | 1 + xen/arch/ppc/ppc64/opal-calls.S | 4 +++ xen/arch/ppc/setup.c | 8 +++--- xen/arch/ppc/shutdown.c | 43 +++++++++++++++++++++++++++++++++ xen/arch/ppc/stubs.c | 12 --------- 5 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 xen/arch/ppc/shutdown.c
xen/arch/ppc/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.init.o obj-y += mm-radix.o obj-y += opal.o obj-y += setup.o +obj-y += shutdown.o obj-y += stubs.o obj-y += tlb-radix.o
xen/arch/ppc/ppc64/opal-calls.S +4 -0
@@ -79,3 +79,7 @@ opal_return_mmu: OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE) OPAL_CALL(opal_console_flush, OPAL_CONSOLE_FLUSH) OPAL_CALL(opal_reinit_cpus, OPAL_REINIT_CPUS) + +OPAL_CALL(opal_cec_power_down, OPAL_CEC_POWER_DOWN) +OPAL_CALL(opal_cec_reboot, OPAL_CEC_REBOOT) +OPAL_CALL(opal_poll_events, OPAL_POLL_EVENTS)
xen/arch/ppc/setup.c +3 -5
@@ -2,6 +2,8 @@#include <xen/init.h> #include <xen/lib.h> #include <xen/mm.h> +#include <xen/shutdown.h> +#include <public/version.h> #include <asm/boot.h> #include <asm/early_printk.h>
@@ -43,11 +45,7 @@ void __init noreturn start_xen(unsigned long r3, unsigned long r4,early_printk ("Hello, ppc64le!\n" ); -for ( ; ; ) -/* Set current hardware thread to very low priority */ -HMT_very_low (); - -unreachable (); +machine_halt (); }void arch_get_xen_caps (xen_capabilities_info_t *info)
xen/arch/ppc/shutdown.c new file +43 -0
43 lines not on this page · raw message
xen/arch/ppc/stubs.c +0 -12
@@ -59,18 +59,6 @@ void vcpu_show_execution_state(struct vcpu *v)BUG_ON ("unimplemented" ); } -/* shutdown.c */ - -void machine_restart (unsigned int delay_millisecs) -{ -BUG_ON ("unimplemented" ); -} - -void machine_halt (void ) -{ -BUG_ON ("unimplemented" ); -} -/* vm_event.c */ void vm_event_fill_regs (vm_event_request_t *req)
Signature · 1 line
2.39.2
Hi Andrew,
Overall this looks good, I just have one comment.
Quoted 9 lines · Andrew Cooper
xen/arch/ppc/shutdown.c new file +3
-0@@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#include <xen/shutdown.h> +
xen/arch/ppc/shutdown.c line 13
Quoted 10 lines
xen/arch/ppc/shutdown.c new file +10
-0+#include <asm/opal-api.h> + +int64_t opal_cec_power_down (uint64_t request); +int64_t opal_cec_reboot (void ); +int64_t opal_poll_events (uint64_t *outstanding_event_mask); + +void machine_halt (void ) +{ +int rc; +
Before the opal_cec_{power_down,reboot} calls are made, any interupts reserved for OPAL to handle need to be masked off.
Since we don't have any set up at this point, I would just add a TODO comment like:
/* TODO: mask any OPAL IRQs before shutting down */
Quoted 8 lines
xen/arch/ppc/shutdown.c new file +8
-0+do { + rc =opal_cec_power_down (0 ); + +if ( rc ==OPAL_BUSY_EVENT ) +opal_poll_events (NULL ); + + }while ( rc ==OPAL_BUSY || rc ==OPAL_BUSY_EVENT ); +
xen/arch/ppc/shutdown.c line 31
Quoted 10 lines
xen/arch/ppc/shutdown.c new file +10
-0+for ( ;; ) +opal_poll_events (NULL ); +} + +void machine_restart (unsigned int delay_millisecs) +{ +int rc; + +/* TODO: mdelay(delay_millisecs); */ +
Ditto.
xen/arch/ppc/shutdown.c line 43
Quoted 12 lines
xen/arch/ppc/shutdown.c new file +12
-0+do { + rc =opal_cec_reboot (); + +if ( rc ==OPAL_BUSY_EVENT ) +opal_poll_events (NULL ); + + }while ( rc ==OPAL_BUSY || rc ==OPAL_BUSY_EVENT ); + +for ( ;; ) +opal_poll_events (NULL ); +} +
Other than that, looks great.
Thanks,
Shawn
Quoted 14 lines · Shawn Anastasio
xen/arch/ppc/shutdown.c line 43
Quoted 12 lines
xen/arch/ppc/shutdown.c new file +12
-0+do { + rc =opal_cec_reboot (); + +if ( rc ==OPAL_BUSY_EVENT ) +opal_poll_events (NULL ); + + }while ( rc ==OPAL_BUSY || rc ==OPAL_BUSY_EVENT ); + +for ( ;; ) +opal_poll_events (NULL ); +} +Other than that, looks great.
Quoted 1 line
Reviewed-by Shawn Anastasio <[email protected]>
Thanks. Fixed up, and queued for 4.20 when the tree opens.
~Andrew