All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mirela Simonovic <mirela.simonovic@aggios.com>
To: xen-devel@lists.xen.org
Cc: edgar.iglesias@xilinx.com, julien.grall@arm.com,
	sstabellini@kernel.org,
	Mirela Simonovic <mirela.simonovic@aggios.com>
Subject: [PATCH v2 03/10] xen/arm: Implement CPU_OFF PSCI call (physical interface)
Date: Fri, 20 Apr 2018 14:25:06 +0200	[thread overview]
Message-ID: <20180420122513.27292-4-mirela.simonovic@aggios.com> (raw)
In-Reply-To: <20180420122513.27292-1-mirela.simonovic@aggios.com>

During the system suspend to RAM non-boot CPUs will be hotplugged.
This will be triggered via disable_nonboot_cpus() call. When
hotplugged the CPU will end up in an infinite wfi loop in stop_cpu().
This patch adds PSCI CPU_OFF call to the EL3 with the aim to get powered
down the calling CPU during the suspend.
If PSCI CPU_OFF call to the EL3 succeeds it will not return. Otherwise,
when the PSCI CPU_OFF call returns we'll raise panic, because the calling
CPU could be enabled afterwards.
If a CPU executes stop_cpu() when the system is not suspending the
calling CPU will loop in the infinite while/wfi, as it was looping
before this change.
Note that there is no check for PSCI version in PSCI CPU_OFF
implementation because the version will be checked prior to triggering
the system suspend.

Signed-off-by: Mirela Simonovic <mirela.simonovic@aggios.com>

---
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
---
Changes in v2:
-Issue PSCI CPU_OFF only if the system is suspending
-If PSCI CPU_OFF call fails (unlikely to ever happen) raise panic
-Fixed commit message
---
 xen/arch/arm/psci.c        | 11 +++++++++++
 xen/arch/arm/smpboot.c     |  3 +++
 xen/include/asm-arm/psci.h |  1 +
 3 files changed, 15 insertions(+)

diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
index 94b616df9b..7f7b0695a3 100644
--- a/xen/arch/arm/psci.c
+++ b/xen/arch/arm/psci.c
@@ -46,6 +46,17 @@ int call_psci_cpu_on(int cpu)
     return call_smc(psci_cpu_on_nr, cpu_logical_map(cpu), __pa(init_secondary), 0);
 }
 
+void call_psci_cpu_off(void)
+{
+    int errno;
+
+    /* If successfull the PSCI cpu_off call doesn't return */
+    errno = call_smc(PSCI_0_2_FN32_CPU_OFF, 0, 0, 0);
+    if ( errno )
+        panic("PSCI cpu off failed for CPU%d err=%d\n", get_processor_id(),
+              errno);
+}
+
 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..1ca3d63261 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -395,6 +395,9 @@ void stop_cpu(void)
     /* Make sure the write happens before we sleep forever */
     dsb(sy);
     isb();
+    if ( system_state == SYS_STATE_suspend )
+        call_psci_cpu_off();
+
     while ( 1 )
         wfi();
 }
diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h
index 9ac820e94a..832f77afff 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);
+void 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

  parent reply	other threads:[~2018-04-20 12:25 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 12:25 [PATCH v2 00/10] xen/arm64: Suspend preconditions and CPU hotplug fixes Mirela Simonovic
2018-04-20 12:25 ` [PATCH v2 01/10] xen/arm64: Added handling of the trapped access to OSLSR register Mirela Simonovic
2018-04-23 11:13   ` Julien Grall
2018-04-20 12:25 ` [PATCH v2 02/10] xen/arm: Ignore write to GICD_ISACTIVERn registers (vgic-v2) Mirela Simonovic
2018-04-23 11:15   ` Julien Grall
2018-04-24 11:02     ` Mirela Simonovic
2018-04-24 16:12       ` Julien Grall
2018-04-24 16:45         ` Mirela Simonovic
2018-04-20 12:25 ` Mirela Simonovic [this message]
2018-04-23 11:21   ` [PATCH v2 03/10] xen/arm: Implement CPU_OFF PSCI call (physical interface) Julien Grall
2018-04-23 17:12     ` Mirela Simonovic
2018-04-23 17:15       ` Julien Grall
2018-04-20 12:25 ` [PATCH v2 04/10] xen/arm: Remove __initdata and __init to enable CPU hotplug Mirela Simonovic
2018-04-23 11:21   ` Julien Grall
2018-04-20 12:25 ` [PATCH v2 05/10] xen/arm: Setup virtual paging for non-boot CPUs on hotplug/resume Mirela Simonovic
2018-04-23 11:28   ` Julien Grall
2018-04-24 14:50     ` Mirela Simonovic
2018-04-24 16:33       ` Julien Grall
2018-04-25  8:23       ` Julien Grall
2018-04-20 12:25 ` [PATCH v2 06/10] xen/common: Restore IRQ affinity when hotplugging a pCPU Mirela Simonovic
2018-04-20 12:25 ` [PATCH v2 07/10] xen/arm: Release maintenance interrupt when CPU is hot-unplugged Mirela Simonovic
2018-04-23 11:33   ` Julien Grall
2018-04-25 13:09     ` Mirela Simonovic
2018-04-25 13:23       ` Julien Grall
2018-04-25 14:28         ` Mirela Simonovic
2018-04-26 10:08           ` Julien Grall
2018-04-26 14:23             ` Tim Deegan
2018-04-27  9:28               ` Julien Grall
2018-04-27 14:15                 ` Tim Deegan
2018-04-27 14:38                   ` Mirela Simonovic
2018-04-27 15:12                     ` Julien Grall
2018-05-09 10:10                       ` Mirela Simonovic
2018-05-09 11:01                         ` Julien Grall
2018-05-09 11:14                           ` Mirela Simonovic
2018-05-09 11:15                             ` Julien Grall
2018-04-20 12:25 ` [PATCH v2 08/10] xen/arm: Release timer interrupts " Mirela Simonovic
2018-04-25 10:34   ` Mirela Simonovic
2018-04-25 10:38     ` Julien Grall
2018-04-20 12:25 ` [PATCH v2 09/10] xen/arm: Free memory allocated for sibling/core maps on CPU hot-unplug Mirela Simonovic
2018-04-23 11:38   ` Julien Grall
2018-04-27 11:14     ` Mirela Simonovic
2018-04-20 12:25 ` [PATCH v2 10/10] xen/arm: Call check_local_cpu_errata for secondary CPU only on boot Mirela Simonovic
2018-04-23 11:46   ` Julien Grall
2018-04-25 15:13     ` Mirela Simonovic
2018-04-26 10:18       ` Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180420122513.27292-4-mirela.simonovic@aggios.com \
    --to=mirela.simonovic@aggios.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.