From: Andre Przywara Subject: [PATCH 1/4] arm: parse PSCI node from the host device-tree Date: Mon, 25 Nov 2013 13:02:41 +0100 Message-ID: <1385380964-22230-2-git-send-email-andre.przywara@linaro.org> References: <1385380964-22230-1-git-send-email-andre.przywara@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1385380964-22230-1-git-send-email-andre.przywara@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com Cc: julien.grall@linaro.org, Andre Przywara , patches@linaro.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org 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 callling method, as it does not make much sense currently under Xen. Signed-off-by: Andre Przywara --- xen/arch/arm/smpboot.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 6c90fa6..97bd414 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -89,6 +89,44 @@ smp_clear_cpu_maps (void) cpu_logical_map(0) = READ_SYSREG(MPIDR_EL1) & MPIDR_HWID_MASK; } +uint32_t psci_host_cpu_on_nr; + +static int __init psci_host_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 1; + + ret = dt_property_read_string(psci, "method", &prop_str); + if ( ret ) + { + printk("/psci node does not provide a method (%d)\n", ret); + return 2; + } + + /* 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 3; + } + + if ( !dt_property_read_u32(psci, "cpu_on", &psci_host_cpu_on_nr) ) + { + printk("/psci node is missing the \"cpu_on\" property\n"); + return 4; + } + + return 0; +} + /* Parse the device tree and build the logical map array containing * MPIDR values related to logical cpus * Code base on Linux arch/arm/kernel/devtree.c @@ -107,6 +145,11 @@ void __init smp_init_cpus(void) bool_t bootcpu_valid = 0; int rc; + if ( psci_host_init() == 0 ) + { + printk(XENLOG_INFO "Using PSCI for SMP bringup\n"); + } + if ( (rc = arch_smp_init()) < 0 ) { printk(XENLOG_WARNING "SMP init failed (%d)\n" -- 1.7.12.1