Patchwork [kvm-unit-tests,v3,4/5] lib: arm: Implement PSCI SYSTEM_OFF in psci_system_off()

login
register
mail settings
Submitter Alexandru Elisei
Date Feb. 4, 2019, 1:44 p.m.
Message ID <20190204134412.47877-5-alexandru.elisei@arm.com>
Download mbox | patch
Permalink /patch/717329/
State New
Headers show

Comments

Alexandru Elisei - Feb. 4, 2019, 1:44 p.m.
A new function, psci_system_off(), is added which implements the PSCI
SYSTEM_OFF function. A call causes the hypervisor to terminate the virtual
machine.

We take this opportunity to rename psci_sys_reset() to psci_system_reset()
to match the name of the PSCI function SYSTEM_RESET that it implements.

Consumers for the function will be added in a later patch.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
---
 lib/arm/asm/psci.h | 3 ++-
 lib/arm/psci.c     | 8 +++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

Patch

diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h
index ed51708fd265..7b956bf5987d 100644
--- a/lib/arm/asm/psci.h
+++ b/lib/arm/asm/psci.h
@@ -6,8 +6,9 @@ 
 extern int psci_invoke(unsigned long function_id, unsigned long arg0,
 		       unsigned long arg1, unsigned long arg2);
 extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point);
-extern void psci_sys_reset(void);
+extern void psci_system_reset(void);
 extern int cpu_psci_cpu_boot(unsigned int cpu);
 extern void cpu_psci_cpu_die(void);
+extern void psci_system_off(void);
 
 #endif /* _ASMARM_PSCI_H_ */
diff --git a/lib/arm/psci.c b/lib/arm/psci.c
index 119f74e57e91..c3d399064ae3 100644
--- a/lib/arm/psci.c
+++ b/lib/arm/psci.c
@@ -48,7 +48,13 @@  void cpu_psci_cpu_die(void)
 	printf("CPU%d unable to power off (error = %d)\n", smp_processor_id(), err);
 }
 
-void psci_sys_reset(void)
+void psci_system_reset(void)
 {
 	psci_invoke(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
 }
+
+void psci_system_off(void)
+{
+	int err = psci_invoke(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
+	printf("CPU%d unable to do system off (error = %d)\n", smp_processor_id(), err);
+}