From patchwork Fri Oct 3 14:31:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 38323 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 51C8D2057C for ; Fri, 3 Oct 2014 14:33:18 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id w7sf763286lbi.10 for ; Fri, 03 Oct 2014 07:33:17 -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=QiOgyYz2V4vcDqQaJQJjzLCLtye2HMS4y68EzOUVyrs=; b=T7Lbiobkp4y8xbvJ2JM3MNZ5axwoN99qAHTWw7UIsmJ62Iht0/Iim/Dh+3yKm166vS jGaFLhyI7RT81F0tIyv/89SRbhuSmyHzWdcKxGknIaeVkkpVitAQTYNqvJn2qbUvhCvX amJ6jjpO9mhleMnyzyz02End67rVruqFB89EqLjZROJTI5mEowHhVBJ3Xz3yK6RMubz7 4zMgCjQ6sIGXaj6VEoR2p4M3PSXS3gUrMYjV3tzclN3TPpxBa8wBHr67W/JmTmOOKeZ8 cDTjuhUa/JHd/rrCm3V0cN+9d1VQh8ZDXqSiZum+Y4V6P5ZIElFIh7Z6VWPz9jefrgnY Eocw== X-Gm-Message-State: ALoCoQkpYXLX5imHqCdgGv3G+hVhWG+qFyqpRH/tIVa2kGNFYmyVNjpGD4NaV9yCy1L7cKzaSJ5n X-Received: by 10.180.38.11 with SMTP id c11mr1888277wik.5.1412346797124; Fri, 03 Oct 2014 07:33:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.169 with SMTP id t9ls392008lat.74.gmail; Fri, 03 Oct 2014 07:33:16 -0700 (PDT) X-Received: by 10.152.4.165 with SMTP id l5mr6335993lal.49.1412346796959; Fri, 03 Oct 2014 07:33:16 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by mx.google.com with ESMTPS id e10si11430953lae.93.2014.10.03.07.33.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 Oct 2014 07:33:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hz20so1131442lab.39 for ; Fri, 03 Oct 2014 07:33:16 -0700 (PDT) X-Received: by 10.152.5.168 with SMTP id t8mr6162750lat.67.1412346796825; Fri, 03 Oct 2014 07:33:16 -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 of9csp237931lbb; Fri, 3 Oct 2014 07:33:16 -0700 (PDT) X-Received: by 10.52.163.206 with SMTP id yk14mr3698891vdb.6.1412346795340; Fri, 03 Oct 2014 07:33:15 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id de10si4527113vdd.37.2014.10.03.07.33.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 03 Oct 2014 07:33:15 -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 1Xa3tN-0001UF-Gp; Fri, 03 Oct 2014 14:31:33 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xa3tM-0001TM-Jj for xen-devel@lists.xen.org; Fri, 03 Oct 2014 14:31:32 +0000 Received: from [193.109.254.147:11405] by server-5.bemta-14.messagelabs.com id 18/27-28255-443BE245; Fri, 03 Oct 2014 14:31:32 +0000 X-Env-Sender: Suravee.Suthikulpanit@amd.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1412346684!13225246!1 X-Originating-IP: [65.55.169.122] 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 609 invoked from network); 3 Oct 2014 14:31:25 -0000 Received: from mail-bl2on0122.outbound.protection.outlook.com (HELO na01-bl2-obe.outbound.protection.outlook.com) (65.55.169.122) by server-9.tower-27.messagelabs.com with AES256-SHA encrypted SMTP; 3 Oct 2014 14:31:25 -0000 Received: from BLUPR02CA044.namprd02.prod.outlook.com (25.160.23.162) by BLUPR02MB194.namprd02.prod.outlook.com (10.242.189.152) with Microsoft SMTP Server (TLS) id 15.0.1044.10; Fri, 3 Oct 2014 14:31:22 +0000 Received: from BN1AFFO11FD023.protection.gbl (2a01:111:f400:7c10::118) by BLUPR02CA044.outlook.office365.com (2a01:111:e400:8ad::34) with Microsoft SMTP Server (TLS) id 15.0.1044.10 via Frontend Transport; Fri, 3 Oct 2014 14:31:22 +0000 Received: from atltwp01.amd.com (165.204.84.221) by BN1AFFO11FD023.mail.protection.outlook.com (10.58.52.83) with Microsoft SMTP Server id 15.0.1029.15 via Frontend Transport; Fri, 3 Oct 2014 14:31:21 +0000 X-WSS-ID: 0NCVHO8-07-BDC-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 atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 23358CAE61D; Fri, 3 Oct 2014 09:31:20 -0500 (CDT) Received: from SATLEXDAG04.amd.com (10.181.40.9) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 3 Oct 2014 09:31:45 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by satlexdag04.amd.com (10.181.40.9) with Microsoft SMTP Server id 14.3.195.1; Fri, 3 Oct 2014 10:31:19 -0400 From: To: , , , Date: Fri, 3 Oct 2014 09:31:10 -0500 Message-ID: <1412346671-10974-2-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1412346671-10974-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1412346671-10974-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(199003)(189002)(86362001)(31966008)(87936001)(93916002)(87286001)(80022003)(64706001)(20776003)(10300001)(2201001)(47776003)(76176999)(84676001)(92726001)(106466001)(86152002)(53416004)(88136002)(50986999)(107046002)(92566001)(21056001)(229853001)(97736003)(33646002)(104166001)(85852003)(89996001)(85306004)(102836001)(101416001)(105586002)(48376002)(77096002)(4396001)(95666004)(99396003)(44976005)(36756003)(19580405001)(19580395003)(68736004)(50466002)(46102003)(77156001)(62966002)(76482002)(120916001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR02MB194; H:atltwp01.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: 0353563E2B 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] [PATCH V3 1/2] xen/arm: Initial support for PSCI-0.2 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.52 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 a subset of PSCI-0.2 functions (PSCI_VERSION, CPU_ON, SYSTEM_OFF, SYSTEM_RESET). By default, the psci_init() will use PSCI-0.2. Otherwise, it will use PSCI-0.1 if PSCI-0.2 fails or un-supported. 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. Signed-off-by: Suravee Suthikulpanit --- 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);