This patch adds the PSCI CPU_OFF call to the EL3 in order to
trigger powering down of the calling CPU when the CPU is stopped.
If CPU_OFF call fails for some reason, e.g. EL3 does not implement
the PSCI CPU_OFF function, the calling CPU will loop in the infinite
while/wfi, as it was looping before this change.

Signed-off-by: Mirela Simonovic <mirela.simono...@aggios.com>
---
 xen/arch/arm/psci.c        | 5 +++++
 xen/arch/arm/smpboot.c     | 7 +++++++
 xen/include/asm-arm/psci.h | 1 +
 3 files changed, 13 insertions(+)

diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
index 94b616df9b..e9e756e56b 100644
--- a/xen/arch/arm/psci.c
+++ b/xen/arch/arm/psci.c
@@ -46,6 +46,11 @@ int call_psci_cpu_on(int cpu)
     return call_smc(psci_cpu_on_nr, cpu_logical_map(cpu), 
__pa(init_secondary), 0);
 }
 
+int call_psci_cpu_off(void)
+{
+    return call_smc(PSCI_0_2_FN32_CPU_OFF, 0, 0, 0);
+}
+
 void call_psci_system_off(void)
 {
     if ( psci_ver > PSCI_VERSION(0, 1) )
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index b2116f0d2d..5666efcd3a 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -390,11 +390,18 @@ void __cpu_disable(void)
 
 void stop_cpu(void)
 {
+    int errno;
     local_irq_disable();
     cpu_is_dead = true;
     /* Make sure the write happens before we sleep forever */
     dsb(sy);
     isb();
+    /* PSCI cpu off call will return only in case of an error */
+    errno = call_psci_cpu_off();
+    printk(XENLOG_DEBUG "PSCI cpu off call failed for CPU#%d err=%d\n",
+           get_processor_id(), errno);
+    isb();
+    /* If CPU_OFF PSCI call failed stay in the WFI loop */
     while ( 1 )
         wfi();
 }
diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h
index 9ac820e94a..50d668a296 100644
--- a/xen/include/asm-arm/psci.h
+++ b/xen/include/asm-arm/psci.h
@@ -20,6 +20,7 @@ extern uint32_t psci_ver;
 
 int psci_init(void);
 int call_psci_cpu_on(int cpu);
+int call_psci_cpu_off(void);
 void call_psci_system_off(void);
 void call_psci_system_reset(void);
 
-- 
2.13.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to