From patchwork Thu Oct 2 21:29:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 38308 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A0FF6201F1 for ; Thu, 2 Oct 2014 21:31:39 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id n3sf118522wiv.8 for ; Thu, 02 Oct 2014 14:31:38 -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=4PKyeikTa1uEuDPuWLcMaZPJalr3+aRBi6E7w3fHHz4=; b=bm/EO41rfDTDKZxizkmzSRogi9Fd1hVj1WOzcczlIKsvkWWWQYlnbJwdu0uhUe16s4 ZpxG9S1h9aJjYvrrSjO99q1SaoS37POwyipGeaclpxFMmkxpSVoXb9WnxJZWVnGJlCng kZHW5FCjZoYoedK38q2GdYqrb0RZ7L5u2jXJD/Z9cu0sOuX3qPMS76ubIr4O11iA2X5P doyyeQNUqPVV7ObMClQbaRtdU9x8dchwvL80szv7eLIYuZjO9emTmtLTNQx+LG7tl3dA q7lUoYFnfgDNrRVfiP7XTRVvVtZlNJc/G8Uh3GhjGQ4cV3H+C/CDDUuxWFIgj/qJ0WAb EgdA== X-Gm-Message-State: ALoCoQnCaPE1ietbe+5JCQX2+N1gXetgJu+Dze1uxwPDWF5nBztkDTs4aplPD5FzG6AGsaskuOcN X-Received: by 10.180.81.130 with SMTP id a2mr1207687wiy.0.1412285498863; Thu, 02 Oct 2014 14:31:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.68 with SMTP id is4ls325401lac.6.gmail; Thu, 02 Oct 2014 14:31:38 -0700 (PDT) X-Received: by 10.112.50.10 with SMTP id y10mr594999lbn.0.1412285498713; Thu, 02 Oct 2014 14:31:38 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by mx.google.com with ESMTPS id zu10si8329941lbb.80.2014.10.02.14.31.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 14:31:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id q1so3191214lam.22 for ; Thu, 02 Oct 2014 14:31:38 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr1511769lad.40.1412285498633; Thu, 02 Oct 2014 14:31: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 of9csp133112lbb; Thu, 2 Oct 2014 14:31:38 -0700 (PDT) X-Received: by 10.220.132.205 with SMTP id c13mr960916vct.12.1412285495943; Thu, 02 Oct 2014 14:31:35 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id zy10si3531904vdb.64.2014.10.02.14.31.35 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 Oct 2014 14:31:35 -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 1XZnwk-0000BF-Id; Thu, 02 Oct 2014 21:29:58 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZnwj-0000B0-Lp for xen-devel@lists.xen.org; Thu, 02 Oct 2014 21:29:57 +0000 Received: from [85.158.143.35:7048] by server-1.bemta-4.messagelabs.com id 6E/2F-05872-5D3CD245; Thu, 02 Oct 2014 21:29:57 +0000 X-Env-Sender: Suravee.Suthikulpanit@amd.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1412285395!13473516!1 X-Originating-IP: [65.55.169.106] 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 18248 invoked from network); 2 Oct 2014 21:29:56 -0000 Received: from mail-bl2on0106.outbound.protection.outlook.com (HELO na01-bl2-obe.outbound.protection.outlook.com) (65.55.169.106) by server-4.tower-21.messagelabs.com with AES256-SHA encrypted SMTP; 2 Oct 2014 21:29:56 -0000 Received: from BY2PR02CA007.namprd02.prod.outlook.com (10.255.247.27) by BLUPR02MB194.namprd02.prod.outlook.com (10.242.189.152) with Microsoft SMTP Server (TLS) id 15.0.1044.10; Thu, 2 Oct 2014 21:29:53 +0000 Received: from BL2FFO11FD037.protection.gbl (2a01:111:f400:7c09::163) by BY2PR02CA007.outlook.office365.com (2a01:111:e400:2c16::27) with Microsoft SMTP Server (TLS) id 15.0.1044.10 via Frontend Transport; Thu, 2 Oct 2014 21:29:52 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BL2FFO11FD037.mail.protection.outlook.com (10.173.161.133) with Microsoft SMTP Server id 15.0.1029.15 via Frontend Transport; Thu, 2 Oct 2014 21:29:51 +0000 X-WSS-ID: 0NCU6DP-08-JC7-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (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 260C4D1605E; Thu, 2 Oct 2014 16:29:48 -0500 (CDT) Received: from SATLEXDAG05.amd.com (10.181.40.11) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 2 Oct 2014 16:30:14 -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; Thu, 2 Oct 2014 17:29:49 -0400 From: To: , , Date: Thu, 2 Oct 2014 16:29:42 -0500 Message-ID: <1412285383-25735-2-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1412285383-25735-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1412285383-25735-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)(199003)(189002)(31966008)(93916002)(87286001)(87936001)(86362001)(19580395003)(19580405001)(68736004)(80022003)(64706001)(2201001)(20776003)(10300001)(47776003)(84676001)(76176999)(92566001)(106466001)(92726001)(86152002)(53416004)(107046002)(50986999)(88136002)(101416001)(97736003)(21056001)(85852003)(104166001)(33646002)(229853001)(89996001)(102836001)(85306004)(105586002)(48376002)(77096002)(4396001)(99396003)(44976005)(46102003)(36756003)(50226001)(50466002)(62966002)(76482002)(95666004)(77156001)(120916001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR02MB194; H:atltwp02.amd.com; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB194; X-Forefront-PRVS: 03524FBD26 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-OriginatorOrg: amd4.onmicrosoft.com Cc: Suravee Suthikulpanit , xen-devel@lists.xen.org Subject: [Xen-devel] [V2 1/2] xen/arm: Initial support for PSCI-0.2 (cpu_on, system_off, system_reset) 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.49 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: * PSCI_VERSION * CPU_ON * SYSTEM_OFF * SYSTEM_RESET First, the psci_init() is refactored to handle both PSCI-0.1 and PSCI-0.2. To add support for PSCI_VERSION, this patch replaces the "bool_t psci_available" variable with "int psci_ver", which contains the PSCI_VERSION as described in the PSCI-0.2 spec. For v0.1, this psci_ver is 1. Signed-off-by: Suravee Suthikulpanit Reviewed-by: Julien Grall --- xen/arch/arm/arm64/smpboot.c | 2 +- xen/arch/arm/platform.c | 2 +- xen/arch/arm/psci.c | 80 +++++++++++++++++++++++++++++++++++++++----- xen/include/asm-arm/psci.h | 4 ++- 4 files changed, 76 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c index 9146476..341cc77 100644 --- a/xen/arch/arm/arm64/smpboot.c +++ b/xen/arch/arm/arm64/smpboot.c @@ -54,7 +54,7 @@ static void __init smp_spin_table_init(int cpu, struct dt_device_node *dn) static int __init smp_psci_init(int cpu) { - if ( !psci_available ) + if ( !psci_ver ) { printk("CPU%d asks for PSCI, but DTB has no PSCI node\n", cpu); return -ENODEV; diff --git a/xen/arch/arm/platform.c b/xen/arch/arm/platform.c index 74c3328..cb4cda8 100644 --- a/xen/arch/arm/platform.c +++ b/xen/arch/arm/platform.c @@ -110,7 +110,7 @@ int __init platform_specific_mapping(struct domain *d) #ifdef CONFIG_ARM_32 int __init platform_cpu_up(int cpu) { - if ( psci_available ) + if ( psci_ver ) return call_psci_cpu_on(cpu); if ( platform && platform->cpu_up ) diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c index b6360d5..604ff4c 100644 --- a/xen/arch/arm/psci.c +++ b/xen/arch/arm/psci.c @@ -23,7 +23,7 @@ #include #include -bool_t psci_available; +uint32_t psci_ver; #ifdef CONFIG_ARM_32 #define REG_PREFIX "r" @@ -58,16 +58,23 @@ int call_psci_cpu_on(int cpu) cpu_logical_map(cpu), __pa(init_secondary), 0); } -int __init psci_init(void) +void call_psci_system_off(void) +{ + if ( psci_ver > XEN_PSCI_V_0_1 ) + __invoke_psci_fn_smc(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0); +} + +void call_psci_system_reset(void) +{ + if ( psci_ver > XEN_PSCI_V_0_1 ) + __invoke_psci_fn_smc(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0); +} + +int __init psci_is_smc_method(const struct dt_device_node *psci) { - const struct dt_device_node *psci; int ret; const char *prop_str; - psci = dt_find_compatible_node(NULL, NULL, "arm,psci"); - if ( !psci ) - return -ENODEV; - ret = dt_property_read_string(psci, "method", &prop_str); if ( ret ) { @@ -85,19 +92,74 @@ int __init psci_init(void) return -EINVAL; } + return 0; +} + +int __init psci_init_0_1(void) +{ + int ret; + const struct dt_device_node *psci; + + psci = dt_find_compatible_node(NULL, NULL, "arm,psci"); + if ( !psci ) + return -EOPNOTSUPP; + + ret = psci_is_smc_method(psci); + if ( ret ) + return -EINVAL; + if ( !dt_property_read_u32(psci, "cpu_on", &psci_cpu_on_nr) ) { printk("/psci node is missing the \"cpu_on\" property\n"); return -ENOENT; } - psci_available = 1; + psci_ver = XEN_PSCI_V_0_1; + + printk(XENLOG_INFO "Using PSCI-0.1 for SMP bringup\n"); + + return 0; +} + +int __init psci_init_0_2(void) +{ + int ret; + const struct dt_device_node *psci; + + psci = dt_find_compatible_node(NULL, NULL, "arm,psci-0.2"); + if ( !psci ) + return -EOPNOTSUPP; + + ret = psci_is_smc_method(psci); + if ( ret ) + return -EINVAL; + + psci_ver = __invoke_psci_fn_smc(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); + + if ( psci_ver != XEN_PSCI_V_0_2 ) + { + printk("Error: PSCI version %#x is not supported.\n", psci_ver); + return -EOPNOTSUPP; + } + + psci_cpu_on_nr = PSCI_0_2_FN_CPU_ON; - printk(XENLOG_INFO "Using PSCI for SMP bringup\n"); + printk(XENLOG_INFO "Using PSCI-0.2 for SMP bringup\n"); return 0; } +int __init psci_init(void) +{ + int ret; + + ret = psci_init_0_2(); + if ( ret ) + ret = psci_init_0_1(); + + return ret; +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h index 9777c03..5d17ee3 100644 --- a/xen/include/asm-arm/psci.h +++ b/xen/include/asm-arm/psci.h @@ -13,10 +13,12 @@ #define PSCI_DISABLED -8 /* availability of PSCI on the host for SMP bringup */ -extern bool_t psci_available; +extern uint32_t psci_ver; 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);