From patchwork Wed Oct 1 08:07:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 38223 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5C1F320549 for ; Wed, 1 Oct 2014 08:10:40 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id p9sf214398lbv.4 for ; Wed, 01 Oct 2014 01:10:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=0WIM4rNtIyGZmKZfRDdwgotBs/cfmkIErrbwstPW7V0=; b=MdRCiOVjOiDQLRHxTzQ7FRKFtHLx89rOwnlUZlzE/SGid9cnSn+kCBz1gDCMFei/0q szVbn1dG/kk4MA99tLh3qCRlaA5x1hMX1jc7UyhHs9C1yyAVz8b9DfU3egjVtpfk3iR2 IHk2GLkNOTcYNudVcLfk01/E+8Nt1+1lKig0ihe+t6JbqTSJNgxbRtoheTlCvWuDdWZ8 MBAOrrpQHabK21yvO5wsIfwcx9FqXJ3neqVP3750vlu8Hj1PhQRaJ4O+/uVB3LwKMquD 4u7f6mQ3PWNYHid9xW2LRcHbqpfR79I4MzDpXsz3VdmVPs5p0bhrUysE+9bM/92qbkoA dHGQ== X-Gm-Message-State: ALoCoQlUJP/xJiVbltG9yxysoVExSZhZTJQL1QNzJIwHoFCaQnm+pWRHDMFal6Q6z1u/t3Tjxj2A X-Received: by 10.112.132.37 with SMTP id or5mr8018929lbb.2.1412151039115; Wed, 01 Oct 2014 01:10:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.131 with SMTP id f3ls116644lae.38.gmail; Wed, 01 Oct 2014 01:10:38 -0700 (PDT) X-Received: by 10.112.149.36 with SMTP id tx4mr50431961lbb.79.1412151038831; Wed, 01 Oct 2014 01:10:38 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com [209.85.215.53]) by mx.google.com with ESMTPS id h5si262203laf.110.2014.10.01.01.10.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 Oct 2014 01:10:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gq15so270024lab.40 for ; Wed, 01 Oct 2014 01:10:38 -0700 (PDT) X-Received: by 10.152.42.136 with SMTP id o8mr53082214lal.71.1412151038756; Wed, 01 Oct 2014 01:10:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp488141lbb; Wed, 1 Oct 2014 01:10:38 -0700 (PDT) X-Received: by 10.52.109.167 with SMTP id ht7mr1603593vdb.33.1412151037659; Wed, 01 Oct 2014 01:10:37 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l2si126629vdi.4.2014.10.01.01.10.37 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 01 Oct 2014 01:10:37 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZExt-0007Un-N7; Wed, 01 Oct 2014 08:08:49 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZExo-0007T6-RR for xen-devel@lists.xen.org; Wed, 01 Oct 2014 08:08:46 +0000 Received: from [85.158.143.35:64660] by server-3.bemta-4.messagelabs.com id 55/D5-06192-C86BB245; Wed, 01 Oct 2014 08:08:44 +0000 X-Env-Sender: Suravee.Suthikulpanit@amd.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1412150922!13048193!1 X-Originating-IP: [157.56.110.111] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9793 invoked from network); 1 Oct 2014 08:08:43 -0000 Received: from mail-bn1on0111.outbound.protection.outlook.com (HELO na01-bn1-obe.outbound.protection.outlook.com) (157.56.110.111) by server-5.tower-21.messagelabs.com with AES256-SHA encrypted SMTP; 1 Oct 2014 08:08:43 -0000 Received: from BY2PR02MB203.namprd02.prod.outlook.com (10.242.232.25) by BY2PR02MB396.namprd02.prod.outlook.com (10.141.141.24) with Microsoft SMTP Server (TLS) id 15.0.1039.15; Wed, 1 Oct 2014 08:08:40 +0000 Received: from BY2PR02CA010.namprd02.prod.outlook.com (10.255.247.30) by BY2PR02MB203.namprd02.prod.outlook.com (10.242.232.25) with Microsoft SMTP Server (TLS) id 15.0.1039.15; Wed, 1 Oct 2014 08:08:39 +0000 Received: from BN1BFFO11FD048.protection.gbl (2a01:111:f400:7c10::1:188) by BY2PR02CA010.outlook.office365.com (2a01:111:e400:2c16::30) with Microsoft SMTP Server (TLS) id 15.0.1039.15 via Frontend Transport; Wed, 1 Oct 2014 08:08:38 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BN1BFFO11FD048.mail.protection.outlook.com (10.58.145.3) with Microsoft SMTP Server id 15.0.1029.15 via Frontend Transport; Wed, 1 Oct 2014 08:08:38 +0000 X-WSS-ID: 0NCRAM9-08-1CW-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 23512D16049; Wed, 1 Oct 2014 03:08:32 -0500 (CDT) Received: from SATLEXDAG05.amd.com (10.181.40.11) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 1 Oct 2014 03:09:01 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by satlexdag05.amd.com (10.181.40.11) with Microsoft SMTP Server id 14.3.195.1; Wed, 1 Oct 2014 04:08:34 -0400 From: To: , , Date: Wed, 1 Oct 2014 03:07:56 -0500 Message-ID: <1412150877-4090-4-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1412150877-4090-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1412150877-4090-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(189002)(199003)(84676001)(50466002)(76176999)(95666004)(85306004)(97736003)(19580405001)(47776003)(48376002)(31966008)(21056001)(107046002)(50986999)(105586002)(36756003)(64706001)(4396001)(106466001)(92566001)(88136002)(89996001)(50226001)(80022003)(87286001)(77156001)(85852003)(86152002)(120916001)(33646002)(68736004)(76482002)(104166001)(87936001)(19580395003)(77096002)(46102003)(20776003)(229853001)(101416001)(575784001)(93916002)(92726001)(99396003)(86362001)(53416004)(2201001)(44976005)(62966002)(102836001)(10300001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR02MB203; H:atltwp02.amd.com; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB203; X-Forefront-PRVS: 0351D213B3 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB396; X-OriginatorOrg: amd4.onmicrosoft.com Cc: Suravee Suthikulpanit , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH 3/4] xen/arm: Add PSCI system_off and system_reset support X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: suravee.suthikulpanit@amd.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Suravee Suthikulpanit This patch adds SMC calls to suport PSCI-0.2 system_off and system_reset, It also adds a call to platform_power_off in machine_halt(). This would allow platform, which implements PSCI-0.2 to properly handle system off and reset. Signed-off-by: Suravee Suthikulpanit --- xen/arch/arm/psci.c | 10 ++++++++++ xen/arch/arm/shutdown.c | 16 ++++++++++------ xen/include/asm-arm/psci.h | 2 ++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c index b6360d5..b0d94a8 100644 --- a/xen/arch/arm/psci.c +++ b/xen/arch/arm/psci.c @@ -58,6 +58,16 @@ int call_psci_cpu_on(int cpu) cpu_logical_map(cpu), __pa(init_secondary), 0); } +void call_psci_system_off(void) +{ + __invoke_psci_fn_smc(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0); +} + +void call_psci_system_reset(void) +{ + __invoke_psci_fn_smc(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0); +} + int __init psci_init(void) { const struct dt_device_node *psci; diff --git a/xen/arch/arm/shutdown.c b/xen/arch/arm/shutdown.c index adc0529..2f63674 100644 --- a/xen/arch/arm/shutdown.c +++ b/xen/arch/arm/shutdown.c @@ -6,11 +6,6 @@ #include #include -static void raw_machine_reset(void) -{ - platform_reset(); -} - static void noreturn halt_this_cpu(void *arg) { stop_cpu(); @@ -18,10 +13,19 @@ 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); + + platform_poweroff(); halt_this_cpu(NULL); } @@ -41,7 +45,7 @@ void machine_restart(unsigned int delay_millisecs) while ( 1 ) { - raw_machine_reset(); + platform_reset(); mdelay(100); } } diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h index 9777c03..de00ee2 100644 --- a/xen/include/asm-arm/psci.h +++ b/xen/include/asm-arm/psci.h @@ -17,6 +17,8 @@ extern bool_t psci_available; int psci_init(void); int call_psci_cpu_on(int cpu); +void call_psci_system_off(void); +void call_psci_system_reset(void); /* functions to handle guest PSCI requests */ int32_t do_psci_cpu_on(uint32_t vcpuid, register_t entry_point);