From patchwork Mon Dec 2 11:08:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 21928 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 79566244E2 for ; Mon, 2 Dec 2013 11:09:37 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id o6sf42257767oag.7 for ; Mon, 02 Dec 2013 03:09:35 -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=5k/dOfIVGcIe1+EdSsvK+qQ6xobGqmPzRVK/7MZQqt0=; b=MOYwqmxtOp8QtUJdiSvVs1/kVDD0PZhOvrXbA/3c3tIzvjhOrRiUrCgALYdAgsH2P/ g6oalVb/cIT6wVJi318JgPXN0Tkz+zsM+FDHtu2eo/SU//co85CPg+LAl0+kfrg7QoTX 57Z0dztSDtN/7n5WNRyRJm/ydfz/FfMPamBxQpJcXbDA8zK8bbB5aRFkqo7CuM9aFTF0 1S+Y3BW5eIc5QYDEfgICXeuoSwqeyCm2lqcIZYMmK4xSqq66Erz+ahOyaotDKuLk2eCl 3I7Y7qzDSAh+yDMBmdxb0piLggF4geU8Zgc3VvEKB0Oh0iVXy+M+nJhWyNJBFG9DdCfB 0N2w== X-Gm-Message-State: ALoCoQlJWvlBcrBKdy1cWeer2F57GbZ/7OHQoekK93bICGO6ThuaIjgSxKP/+I5FtnNNDO1uRSNh X-Received: by 10.182.16.199 with SMTP id i7mr596763obd.42.1385982575703; Mon, 02 Dec 2013 03:09:35 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.229 with SMTP id u5ls421864qeq.69.gmail; Mon, 02 Dec 2013 03:09:35 -0800 (PST) X-Received: by 10.220.122.129 with SMTP id l1mr112961vcr.48.1385982575610; Mon, 02 Dec 2013 03:09:35 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id a15si29459969vew.7.2013.12.02.03.09.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Dec 2013 03:09:35 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 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.178; Received: by mail-ve0-f178.google.com with SMTP id c14so8524038vea.23 for ; Mon, 02 Dec 2013 03:09:35 -0800 (PST) X-Received: by 10.52.231.39 with SMTP id td7mr5208vdc.106.1385982575521; Mon, 02 Dec 2013 03:09:35 -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 u4csp110796vcz; Mon, 2 Dec 2013 03:09:35 -0800 (PST) X-Received: by 10.205.5.194 with SMTP id oh2mr163801bkb.114.1385982573418; Mon, 02 Dec 2013 03:09:33 -0800 (PST) Received: from mail-bk0-f41.google.com (mail-bk0-f41.google.com [209.85.214.41]) by mx.google.com with ESMTPS id uq6si15581892bkb.327.2013.12.02.03.09.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Dec 2013 03:09:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.41 is neither permitted nor denied by best guess record for domain of andre.przywara@linaro.org) client-ip=209.85.214.41; Received: by mail-bk0-f41.google.com with SMTP id v15so5408368bkz.0 for ; Mon, 02 Dec 2013 03:09:32 -0800 (PST) X-Received: by 10.204.228.11 with SMTP id jc11mr147705bkb.135.1385982572725; Mon, 02 Dec 2013 03:09:32 -0800 (PST) Received: from slackpad.drs.calxeda.com (f053082149.adsl.alicedsl.de. [78.53.82.149]) by mx.google.com with ESMTPSA id z6sm74390807bkn.8.2013.12.02.03.09.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Dec 2013 03:09:32 -0800 (PST) From: Andre Przywara To: Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com Cc: julien.grall@linaro.org, xen-devel@lists.xenproject.org, patches@linaro.org, Andre Przywara Subject: [PATCH v2 3/6] arm: parse PSCI node from the host device-tree Date: Mon, 2 Dec 2013 12:08:55 +0100 Message-Id: <1385982538-17855-4-git-send-email-andre.przywara@linaro.org> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1385982538-17855-1-git-send-email-andre.przywara@linaro.org> References: <1385982538-17855-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.178 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 Acked-by: Ian Campbell --- xen/arch/arm/Makefile | 1 + xen/arch/arm/psci.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/smpboot.c | 7 +++++ xen/include/asm-arm/psci.h | 6 +++++ 4 files changed, 78 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..9ff06cd --- /dev/null +++ b/xen/arch/arm/psci.c @@ -0,0 +1,64 @@ +/* + * 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 + +int psci_available; + +static uint32_t psci_cpu_on_nr; + +int __init psci_init(void) +{ + 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 won't + * just 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; + } + + return 0; +} diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 52cef30..3a9be90 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,12 @@ void __init smp_init_cpus(void) bool_t bootcpu_valid = 0; int rc; + if ( psci_init() == 0 ) + { + printk(XENLOG_INFO "Using PSCI for SMP bringup\n"); + psci_available = 1; + } + 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..2f37612 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 int 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);