From patchwork Mon Nov 25 12:02:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 21734 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9483423FCB for ; Mon, 25 Nov 2013 12:03:16 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf14423194oag.8 for ; Mon, 25 Nov 2013 04:03:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=+6eaAdqxee1gvB2Q9PYL674Q8sXh9pd1u/xJW3u3twI=; b=Dk1urjvK3aNbFviN9p9LxDE5W5u/cJy0I/P0bWf6N2DO9iHC/D6KaF29oPUoMF6EfI J3TqctiT+gLGvnMPD7cf+HwbG+qwGIsfWd85Zw3Z+ixrgArL7ykeHho5N5HlpRwxBoLq rE1zmtaIey9iUM5la7Bvl/l94Z3OTdcyrzLudF7+puk3Rhyxcf6V90jbvGw6FzlbvB/i Mww1z8lKe9opJeiPO/GZqfR7IM6hX2R77kZqzzQFvu8XRbW+hKNdTm662Dw1EgVNmmSn efIHc6C3wK0JNxOvGl5+pqwYAEtD5WL1FiDj1/JQGb+XG4WTajyUTkWgSdpUBnIPPl22 sCAA== X-Gm-Message-State: ALoCoQnaBsPgJ23PPR3macST6dxEQ8wFGZSeEsXiX3tm+Yf+HUEw/mAzTaAL4ou4zf0JrMZJBo/k X-Received: by 10.42.66.147 with SMTP id p19mr7936880ici.12.1385380995871; Mon, 25 Nov 2013 04:03:15 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.38.36 with SMTP id d4ls264486qek.7.gmail; Mon, 25 Nov 2013 04:03:15 -0800 (PST) X-Received: by 10.58.23.33 with SMTP id j1mr21026vef.27.1385380995753; Mon, 25 Nov 2013 04:03:15 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id v1si17713721vdh.100.2013.11.25.04.03.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Nov 2013 04:03:15 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id if17so2593384vcb.25 for ; Mon, 25 Nov 2013 04:03:15 -0800 (PST) X-Received: by 10.52.168.106 with SMTP id zv10mr22174405vdb.21.1385380995636; Mon, 25 Nov 2013 04:03:15 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp128117vcz; Mon, 25 Nov 2013 04:03:15 -0800 (PST) X-Received: by 10.42.32.129 with SMTP id e1mr538567icd.57.1385380994972; Mon, 25 Nov 2013 04:03:14 -0800 (PST) Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) by mx.google.com with ESMTPS id o5si18372263iga.50.2013.11.25.04.03.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Nov 2013 04:03:14 -0800 (PST) Received-SPF: neutral (google.com: 209.85.223.175 is neither permitted nor denied by best guess record for domain of andre.przywara@linaro.org) client-ip=209.85.223.175; Received: by mail-ie0-f175.google.com with SMTP id x13so6487237ief.20 for ; Mon, 25 Nov 2013 04:03:14 -0800 (PST) X-Received: by 10.50.56.44 with SMTP id x12mr12420408igp.41.1385380994688; Mon, 25 Nov 2013 04:03:14 -0800 (PST) Received: from slackpad.drs.calxeda.com (f053083004.adsl.alicedsl.de. [78.53.83.4]) by mx.google.com with ESMTPSA id p14sm25270238igr.7.2013.11.25.04.03.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Nov 2013 04:03:14 -0800 (PST) From: Andre Przywara To: Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com Cc: julien.grall@linaro.org, xen-devel@lists.xen.org, patches@linaro.org, Andre Przywara Subject: [PATCH 2/4] arm: add a function to invoke the PSCI handler and use it Date: Mon, 25 Nov 2013 13:02:42 +0100 Message-Id: <1385380964-22230-3-git-send-email-andre.przywara@linaro.org> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1385380964-22230-1-git-send-email-andre.przywara@linaro.org> References: <1385380964-22230-1-git-send-email-andre.przywara@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: andre.przywara@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The PSCI handler is invoked via a secure monitor call with the arguments defined in registers [1]. Copy the function from the Linux code and adjust it to work on both ARM32 and ARM64. Later use that function instead of the generic GIC SEV kick to actually bring up the secondary CPUs. [1]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0022b/index.html Signed-off-by: Andre Przywara --- xen/arch/arm/arm32/smpboot.c | 1 - xen/arch/arm/smpboot.c | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/arm32/smpboot.c b/xen/arch/arm/arm32/smpboot.c index 88fe8fb..fcf653f 100644 --- a/xen/arch/arm/arm32/smpboot.c +++ b/xen/arch/arm/arm32/smpboot.c @@ -10,7 +10,6 @@ int __init arch_smp_init(void) int __init arch_cpu_init(int cpu, struct dt_device_node *dn) { - /* TODO handle PSCI init */ return 0; } diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 97bd414..44326d8 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -89,6 +89,29 @@ smp_clear_cpu_maps (void) cpu_logical_map(0) = READ_SYSREG(MPIDR_EL1) & MPIDR_HWID_MASK; } +#ifdef CONFIG_ARM_32 +#define REG_PREFIX "r" +#else +#define REG_PREFIX "x" +#endif + +static noinline int __invoke_psci_fn_smc(u32 function_id, u32 arg0, u32 arg1, + u32 arg2) +{ + asm volatile( + __asmeq("%0", REG_PREFIX"0") + __asmeq("%1", REG_PREFIX"1") + __asmeq("%2", REG_PREFIX"2") + __asmeq("%3", REG_PREFIX"3") + "smc #0" + : "+r" (function_id) + : "r" (arg0), "r" (arg1), "r" (arg2)); + + return function_id; +} + +#undef REG_PREFIX + uint32_t psci_host_cpu_on_nr; static int __init psci_host_init(void) @@ -393,10 +416,18 @@ int __cpu_up(unsigned int cpu) return rc; } - /* We don't know the GIC ID of the CPU until it has woken up, so just signal - * everyone and rely on our own smp_up_cpu gate to ensure only the one we - * want gets through. */ - send_SGI_allbutself(GIC_SGI_EVENT_CHECK); + if ( psci_host_cpu_on_nr != 0 ) + { + /* If the DTB provided a PSCI node, use this for kicking the CPUs */ + __invoke_psci_fn_smc( + psci_host_cpu_on_nr, cpu, __pa(init_secondary), 0); + } else + { + /* We don't know the GIC ID of the CPU until it has woken up, so just + * signal everyone and rely on our own smp_up_cpu gate to ensure only + * the one we want gets through. */ + send_SGI_allbutself(GIC_SGI_EVENT_CHECK); + } while ( !cpu_online(cpu) ) {