All of lore.kernel.org
 help / color / mirror / Atom feed
From: <suravee.suthikulpanit@amd.com>
To: stefano.stabellini@eu.citrix.com, julien.grall@linaro.org,
	ian.campbell@citrix.com
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>,
	xen-devel@lists.xen.org
Subject: [PATCH 2/2] xen/arm: Use PSCI-0.2 for machine_halt/restart by default
Date: Wed, 1 Oct 2014 15:02:53 -0500	[thread overview]
Message-ID: <1412193773-31042-3-git-send-email-suravee.suthikulpanit@amd.com> (raw)
In-Reply-To: <1412193773-31042-1-git-send-email-suravee.suthikulpanit@amd.com>

From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>

"machine_halt()" and "machine_restart()" are modified to use PSCI interface
by default if PSCI-0.2 is supported. The "raw_machine_reset()" is also removed
since this is unnecessary.

For non-PSCI, platform_poweroff() and platform_reset() are used instead.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 xen/arch/arm/shutdown.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/shutdown.c b/xen/arch/arm/shutdown.c
index adc0529..2289ad1 100644
--- a/xen/arch/arm/shutdown.c
+++ b/xen/arch/arm/shutdown.c
@@ -5,11 +5,7 @@
 #include <xen/lib.h>
 #include <xen/smp.h>
 #include <asm/platform.h>
-
-static void raw_machine_reset(void)
-{
-    platform_reset();
-}
+#include <asm/psci.h>
 
 static void noreturn halt_this_cpu(void *arg)
 {
@@ -18,10 +14,22 @@ static void noreturn halt_this_cpu(void *arg)
 
 void machine_halt(void)
 {
+    int timeout = 10;
+
     watchdog_disable();
     console_start_sync();
     local_irq_enable();
     smp_call_function(halt_this_cpu, NULL, 0);
+    local_irq_disable();
+
+    /* Wait at most another 10ms for all other CPUs to go offline. */
+    while ( (num_online_cpus() > 1) && (timeout-- > 0) )
+        mdelay(1);
+
+    /* Not return if success */
+    call_psci_system_off();
+
+    platform_poweroff();
     halt_this_cpu(NULL);
 }
 
@@ -39,9 +47,12 @@ void machine_restart(unsigned int delay_millisecs)
     while ( (num_online_cpus() > 1) && (timeout-- > 0) )
         mdelay(1);
 
+    /* Not return if success */
+    call_psci_system_reset();
+
     while ( 1 )
     {
-        raw_machine_reset();
+        platform_reset();
         mdelay(100);
     }
 }
-- 
1.9.3

  parent reply	other threads:[~2014-10-01 20:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-01 20:02 [PATCH 0/2] Introduce PSCI-0.2 supports suravee.suthikulpanit
2014-10-01 20:02 ` [PATCH 1/2] xen/arm: Initial support for PSCI-0.2 suravee.suthikulpanit
2014-10-02  9:07   ` Stefano Stabellini
2014-10-02 10:51   ` Julien Grall
2014-10-02 14:19     ` Ian Campbell
2014-10-02 20:17       ` Suravee Suthikulpanit
2014-10-02 14:21   ` Ian Campbell
2014-10-02 19:43     ` Suravee Suthikulpanit
2014-10-01 20:02 ` suravee.suthikulpanit [this message]
2014-10-02  9:04   ` [PATCH 2/2] xen/arm: Use PSCI-0.2 for machine_halt/restart by default Stefano Stabellini
2014-10-02 10:54   ` Julien Grall
2014-10-02 19:51     ` Suravee Suthikulpanit
2014-10-02 21:50       ` Julien Grall
2014-10-03  0:00         ` Suravee Suthikulpanit

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=1412193773-31042-3-git-send-email-suravee.suthikulpanit@amd.com \
    --to=suravee.suthikulpanit@amd.com \
    --cc=ian.campbell@citrix.com \
    --cc=julien.grall@linaro.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --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.