From patchwork Thu Dec 5 10:08:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 22052 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f71.google.com (mail-pb0-f71.google.com [209.85.160.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9F028202E0 for ; Thu, 5 Dec 2013 10:08:46 +0000 (UTC) Received: by mail-pb0-f71.google.com with SMTP id uo5sf49182107pbc.10 for ; Thu, 05 Dec 2013 02:08:45 -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=5IDQNh3XQJPYf4H4Zk2cc0H5TvoGN2sPm4i40SErbJI=; b=hN8rHRPVdsfAdurIqbxfzZ7RB1g86CxUY9i1/ONoIPRZOO7r1Vy0XautL14U0aWsE4 XMKKIjtcxGw8unYUSPiB9liOhAptzqwiyh3DSRRobhjZFuOJaXxv1ycEZSk9GE8sU0xM 1apJc30RxJW6eTf1kfxQwRnJZguIm6S4XHc1EoREVxkRO5LQ8PeBN1da+8jIGxDppYUl XM6oXayVIjwhHRqbh+3hzQx4LJaxS6fjcHttZmEeMgTU/4r9cUFnQ9hvyjPwciRmdvFu jIcJo3uph7j7Z8HLvwCUWAiUTbHw0BKIqjqFnsj8yMycqRo+lcRJMyezMi1/eLNBp54m YB4w== X-Gm-Message-State: ALoCoQn+KJctynKAp9jwm48SelulwTC9jxOieFb9xmaMJ+vpdgu4oFjXegQrgcrHl7cdkrK6d8yY X-Received: by 10.66.17.234 with SMTP id r10mr3781884pad.40.1386238125841; Thu, 05 Dec 2013 02:08:45 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.82.49 with SMTP id f17ls746846qey.54.gmail; Thu, 05 Dec 2013 02:08:45 -0800 (PST) X-Received: by 10.52.22.40 with SMTP id a8mr329277vdf.49.1386238125623; Thu, 05 Dec 2013 02:08:45 -0800 (PST) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id sl9si19333814vdc.138.2013.12.05.02.08.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 02:08:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so13661042veb.12 for ; Thu, 05 Dec 2013 02:08:45 -0800 (PST) X-Received: by 10.58.50.194 with SMTP id e2mr11174veo.54.1386238125447; Thu, 05 Dec 2013 02:08:45 -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 u4csp2674vcz; Thu, 5 Dec 2013 02:08:44 -0800 (PST) X-Received: by 10.204.118.131 with SMTP id v3mr18398672bkq.30.1386238124398; Thu, 05 Dec 2013 02:08:44 -0800 (PST) Received: from mail-bk0-f51.google.com (mail-bk0-f51.google.com [209.85.214.51]) by mx.google.com with ESMTPS id tv4si20695128bkb.228.2013.12.05.02.08.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 02:08:44 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.51 is neither permitted nor denied by best guess record for domain of andre.przywara@linaro.org) client-ip=209.85.214.51; Received: by mail-bk0-f51.google.com with SMTP id 6so7192284bkj.10 for ; Thu, 05 Dec 2013 02:08:43 -0800 (PST) X-Received: by 10.205.36.81 with SMTP id sz17mr49796475bkb.29.1386238123801; Thu, 05 Dec 2013 02:08:43 -0800 (PST) Received: from slackpad.drs.calxeda.com (g224192075.adsl.alicedsl.de. [92.224.192.75]) by mx.google.com with ESMTPSA id xm9sm28206859bkb.1.2013.12.05.02.08.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Dec 2013 02:08:42 -0800 (PST) From: Andre Przywara To: Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com Cc: julien.grall@linaro.org, George.Dunlap@eu.citrix.com, xen-devel@lists.xenproject.org, patches@linaro.org, Andre Przywara Subject: [PATCH v3 3/6] arm: parse PSCI node from the host device-tree Date: Thu, 5 Dec 2013 11:08:09 +0100 Message-Id: <1386238092-22216-4-git-send-email-andre.przywara@linaro.org> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1386238092-22216-1-git-send-email-andre.przywara@linaro.org> References: <1386238092-22216-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.128.181 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 availability of a PSCI handler is advertised in the DTB. Find and parse the node (described in the Linux device-tree binding) and save the function number for bringing up a CPU for later usage. We do some sanity checks, especially we deny using HVC as a calling method, as it does not make much sense currently under Xen. Signed-off-by: Andre Przywara --- xen/arch/arm/Makefile | 1 + xen/arch/arm/psci.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/smpboot.c | 4 +++ xen/include/asm-arm/psci.h | 6 ++++ 4 files changed, 79 insertions(+) create mode 100644 xen/arch/arm/psci.c diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 11cf663..d70f6d5 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -5,6 +5,7 @@ subdir-y += platforms obj-$(EARLY_PRINTK) += early_printk.o obj-y += cpu.o obj-y += domain.o +obj-y += psci.o obj-y += vpsci.o obj-y += domctl.o obj-y += sysctl.o diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c new file mode 100644 index 0000000..efb514e --- /dev/null +++ b/xen/arch/arm/psci.c @@ -0,0 +1,68 @@ +/* + * xen/arch/arm/psci.c + * + * PSCI host support + * + * Andre Przywara + * Copyright (c) 2013 Linaro Limited. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + + +#include +#include +#include +#include + +bool_t psci_available; + +static uint32_t psci_cpu_on_nr; + +int __init psci_init(void) +{ + 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 ) + { + printk("/psci node does not provide a method (%d)\n", ret); + return -EINVAL; + } + + /* Since Xen runs in HYP all of the time, it does not make sense to + * let it call into HYP for PSCI handling, since the handler just + * won't be there. So bail out with an error if "smc" is not used. + */ + if ( strcmp(prop_str, "smc") ) + { + printk("/psci method must be smc, but is: \"%s\"\n", prop_str); + 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; + + printk(XENLOG_INFO "Using PSCI for SMP bringup\n"); + + return 0; +} diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 8d96c17..c53c765 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -30,6 +30,7 @@ #include #include #include +#include cpumask_t cpu_online_map; cpumask_t cpu_present_map; @@ -105,6 +106,9 @@ void __init smp_init_cpus(void) bool_t bootcpu_valid = 0; int rc; + /* scan the DTB for a PSCI node and set a global variable */ + psci_init(); + if ( (rc = arch_smp_init()) < 0 ) { printk(XENLOG_WARNING "SMP init failed (%d)\n" diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h index 67d4c35..36ce87d 100644 --- a/xen/include/asm-arm/psci.h +++ b/xen/include/asm-arm/psci.h @@ -6,6 +6,12 @@ #define PSCI_EINVAL -2 #define PSCI_DENIED -3 +/* availability of PSCI on the host for SMP bringup */ +extern bool_t psci_available; + +int psci_init(void); + +/* functions to handle guest PSCI requests */ int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point); int do_psci_cpu_off(uint32_t power_state); int do_psci_cpu_suspend(uint32_t power_state, register_t entry_point);