From patchwork Tue Jun 9 13:33:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 49655 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 38766245D4 for ; Tue, 9 Jun 2015 13:34:23 +0000 (UTC) Received: by laar3 with SMTP id r3sf4764352laa.3 for ; Tue, 09 Jun 2015 06:34:22 -0700 (PDT) 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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=GZMk9gUNBiX6mjMcbAx9QnaBAslBMM5+I4Iy6sd21VI=; b=Fd0QPE2A20J9BPl63VkK2AvIVGMZNG33T4GLQYGeo92x7Y26yuNMqd+UHOQFuk11Fa DwmQipLDg6NvgY000O+PL9ESnhFR/nWFBS9IRXkIla5pgtHPZfKobUQPrkZ7lVINB7ls mDNTTZnTHGGzRD0GANc6kd4ahVIKOoIIr5RLPqBXTig2SRoF+ZF6gCKxzmuxCH7aoWhk 77hMDO0lH/qFLusJTVmHrRgTPoXXlLI0wuv5vyvFgOXesBa1sFw0ZI6ksJETWJoedfYQ ojvYBmRzNoGu3vU+rRTZvn53hWE1hEJlxODwgAvkxxuDNrOJDnPDn68S0jyTeDSkQWqa JuhA== X-Gm-Message-State: ALoCoQkQ+tIkJuPAuQXGl9vODvs2ASdJ04LZLX8CEtiDHLItl1K71UjBuutKfvARneMkKPCtt0gj X-Received: by 10.112.84.104 with SMTP id x8mr21825153lby.23.1433856862117; Tue, 09 Jun 2015 06:34:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.246.35 with SMTP id xt3ls65468lac.37.gmail; Tue, 09 Jun 2015 06:34:21 -0700 (PDT) X-Received: by 10.152.45.9 with SMTP id i9mr22093800lam.87.1433856861881; Tue, 09 Jun 2015 06:34:21 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id bc7si5758696lbc.144.2015.06.09.06.34.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2015 06:34:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbcmx3 with SMTP id mx3so10769950lbc.1 for ; Tue, 09 Jun 2015 06:34:21 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr22536394lae.19.1433856861760; Tue, 09 Jun 2015 06:34:21 -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.108.230 with SMTP id hn6csp2616256lbb; Tue, 9 Jun 2015 06:34:20 -0700 (PDT) X-Received: by 10.70.92.34 with SMTP id cj2mr39508806pdb.116.1433856859627; Tue, 09 Jun 2015 06:34:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si8976778pdm.181.2015.06.09.06.34.18; Tue, 09 Jun 2015 06:34:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271AbbFINeC (ORCPT + 28 others); Tue, 9 Jun 2015 09:34:02 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:34965 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753290AbbFINdw (ORCPT ); Tue, 9 Jun 2015 09:33:52 -0400 Received: by wgme6 with SMTP id e6so13576320wgm.2 for ; Tue, 09 Jun 2015 06:33:51 -0700 (PDT) X-Received: by 10.180.105.74 with SMTP id gk10mr8461243wib.29.1433856831061; Tue, 09 Jun 2015 06:33:51 -0700 (PDT) Received: from localhost.localdomain (cpc14-aztw22-2-0-cust189.18-1.cable.virginm.net. [82.45.1.190]) by mx.google.com with ESMTPSA id ha4sm2912842wib.0.2015.06.09.06.33.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jun 2015 06:33:50 -0700 (PDT) From: Peter Griffin To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, srinivas.kandagatla@gmail.com, patrice.chotard@st.com, maxime.coquelin@st.com, khilman@kernel.org, arnd@arndb.de, olof@lixom.net Cc: peter.griffin@linaro.org, lee.jones@linaro.org, devicetree@vger.kernel.org Subject: [PATCH v2 1/3] ARM: STi: Add code to release secondary cores from holding pen. Date: Tue, 9 Jun 2015 14:33:42 +0100 Message-Id: <1433856824-30689-2-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433856824-30689-1-git-send-email-peter.griffin@linaro.org> References: <1433856824-30689-1-git-send-email-peter.griffin@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.griffin@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 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-Post: , List-Help: , List-Archive: List-Unsubscribe: , Most upstream devs boot STi platform via JTAG which abuses the boot process by setting the PC of secondary cores directly. As a consquence, booting STi platforms via u-boot results in only the primary core being brought up as the code to manage the holding pen is not upstream. This patch adds the necessary code to bring the secondary cores out of the holding pen. It uses the cpu-release-addr DT property to get the address of the holding pen from the bootloader. With this patch booting upstream kernels via u-boot works correctly: [ 0.045456] CPU: Testing write buffer coherency: ok [ 0.045597] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 [ 0.045734] Setting up static identity map for 0x40209000 - 0x40209098 [ 0.065047] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001 [ 0.065081] Brought up 2 CPUs [ 0.065089] SMP: Total of 2 processors activated (5983.43 BogoMIPS). [ 0.065092] CPU: All CPU(s) started in SVC mode. Signed-off-by: Peter Griffin Acked-by: Maxime Coquelin --- arch/arm/mach-sti/headsmp.S | 1 + arch/arm/mach-sti/platsmp.c | 55 ++++++++++++++++++++++++++++++++++++++++++--- arch/arm/mach-sti/smp.h | 2 ++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-sti/headsmp.S b/arch/arm/mach-sti/headsmp.S index 4c09bae..e0ad4517 100644 --- a/arch/arm/mach-sti/headsmp.S +++ b/arch/arm/mach-sti/headsmp.S @@ -37,6 +37,7 @@ pen: ldr r7, [r6] * should now contain the SVC stack for this core */ b secondary_startup +ENDPROC(sti_secondary_startup) 1: .long . .long pen_release diff --git a/arch/arm/mach-sti/platsmp.c b/arch/arm/mach-sti/platsmp.c index d4b624f..86bb48d8 100644 --- a/arch/arm/mach-sti/platsmp.c +++ b/arch/arm/mach-sti/platsmp.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -99,14 +100,62 @@ static int sti_boot_secondary(unsigned int cpu, struct task_struct *idle) static void __init sti_smp_prepare_cpus(unsigned int max_cpus) { - void __iomem *scu_base = NULL; - struct device_node *np = of_find_compatible_node( - NULL, NULL, "arm,cortex-a9-scu"); + struct device_node *np; + void __iomem *scu_base; + u32 __iomem *cpu_strt_ptr; + u32 release_phys; + int cpu; + unsigned long entry_pa = virt_to_phys(sti_secondary_startup); + + np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu"); + if (np) { scu_base = of_iomap(np, 0); scu_enable(scu_base); of_node_put(np); } + + if (max_cpus <= 1) + return; + + for_each_possible_cpu(cpu) { + + np = of_get_cpu_node(cpu, NULL); + + if (!np) + continue; + + if (of_property_read_u32(np, "cpu-release-addr", + &release_phys)) { + pr_err("CPU %d: missing or invalid cpu-release-addr " + "property\n", cpu); + continue; + } + + /* + * holding pen is usually configured in SBC DMEM but can also be + * in RAM. + */ + + if (!memblock_is_memory(release_phys)) + cpu_strt_ptr = + ioremap(release_phys, sizeof(release_phys)); + else + cpu_strt_ptr = + (u32 __iomem *)phys_to_virt(release_phys); + + __raw_writel(entry_pa, cpu_strt_ptr); + + /* + * wmb so that data is actually written + * before cache flush is done + */ + smp_wmb(); + sync_cache_w(cpu_strt_ptr); + + if (!memblock_is_memory(release_phys)) + iounmap(cpu_strt_ptr); + } } struct smp_operations __initdata sti_smp_ops = { diff --git a/arch/arm/mach-sti/smp.h b/arch/arm/mach-sti/smp.h index 1871b72..ae22707 100644 --- a/arch/arm/mach-sti/smp.h +++ b/arch/arm/mach-sti/smp.h @@ -14,4 +14,6 @@ extern struct smp_operations sti_smp_ops; +void sti_secondary_startup(void); + #endif