From patchwork Mon Oct 12 17:41:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 7378131 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7FCC79F1D5 for ; Mon, 12 Oct 2015 17:41:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A024520674 for ; Mon, 12 Oct 2015 17:41:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD04320748 for ; Mon, 12 Oct 2015 17:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbbJLRlf (ORCPT ); Mon, 12 Oct 2015 13:41:35 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:34815 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751401AbbJLRle (ORCPT ); Mon, 12 Oct 2015 13:41:34 -0400 Received: by wicgb1 with SMTP id gb1so59291239wic.1 for ; Mon, 12 Oct 2015 10:41:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1fsigUCzeSvdEKbqAov2qrcq5HMKyKzL+ISkbcggTyg=; b=Cc7y/GWjEghRraKbbmGL8AxAQ1KNQslKenbbZy8kVnp9/1TJrv+cqnb79O1mSx7bhG CqSyUMHPynC1GhixBoCv86O6boeyTpgtpdhdgQ5gMOMngNLXX+dNxjilMAQHX319wYCl g6b9S4J3Cl4IL/NDjs03NDrOk1EBDkVLGmEuJx86H/7439bvSVd3yjBDnOlTRmbp2VCq jfGNirGgduo2NDwPUWZV16S4bkBOT8DsSVsDAFOXOhmu/6PHP6sYa/ygVRQr2RIQlWpq Qi6Nz2bs4fXJxHSCiT3JSB8ola3i034CsYW1+YPKKyflcE7k0BSjgkBRV6OJ9dynKBgK 4ZYQ== X-Gm-Message-State: ALoCoQkGYd8bIF14B4F9/t9NhifT6FVzQpLJ726kSB5xjTup0Sy7r8/2yxUtph89l9RYCqlK7xuB X-Received: by 10.194.184.73 with SMTP id es9mr37377880wjc.122.1444671693585; Mon, 12 Oct 2015 10:41:33 -0700 (PDT) Received: from localhost.localdomain (LPoitiers-656-1-62-228.w90-63.abo.wanadoo.fr. [90.63.143.228]) by smtp.gmail.com with ESMTPSA id gw8sm50686wib.15.2015.10.12.10.41.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Oct 2015 10:41:33 -0700 (PDT) From: ahaslam@baylibre.com To: magnus.damm@gmail.com, horms@verge.net.au, geert@glider.be Cc: bcousson@baylibre.com, linux-sh@vger.kernel.org, Axel Haslam Subject: [RFC/RFT 3/6] ARM: shmobile: check if cpu is allowed on power on Date: Mon, 12 Oct 2015 19:41:11 +0200 Message-Id: <1444671674-19275-4-git-send-email-ahaslam@baylibre.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1444671674-19275-1-git-send-email-ahaslam@baylibre.com> References: <1444671674-19275-1-git-send-email-ahaslam@baylibre.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Axel Haslam To decide if we can boot cpus that are not part of the boot cluster, we should check if cci and mcpm were correctly enabled and probed. But, mcpm_init is called with an early_init call which is later than apmu_parse_cfg. So, check if a cpu should be allowed to boot direcly from the the power_on function as this will happen after early_init and allow us to check if mcpm and cci are enabled. We use the fact that the boot cpu will always be logical cpu0 to compare each cpus physical cluster and decide if can be turned on or not. Signed-off-by: Axel Haslam --- arch/arm/mach-shmobile/platsmp-apmu.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-shmobile/platsmp-apmu.c b/arch/arm/mach-shmobile/platsmp-apmu.c index d2ff5af..b88d97c 100644 --- a/arch/arm/mach-shmobile/platsmp-apmu.c +++ b/arch/arm/mach-shmobile/platsmp-apmu.c @@ -28,6 +28,8 @@ static struct { void __iomem *iomem; int bit; + unsigned int pcpu; + unsigned int pcluster; } apmu_cpus[NR_CPUS]; #define WUPCR_OFFS 0x10 @@ -37,11 +39,17 @@ static struct { int __maybe_unused apmu_power_on(unsigned int cpu) { void __iomem *p = apmu_cpus[cpu].iomem; + unsigned int pcluster = apmu_cpus[cpu].pcluster; + unsigned int boot_pcluster = apmu_cpus[0].pcluster; int bit = apmu_cpus[cpu].bit; if (!p) return -EINVAL; + if (pcluster != boot_pcluster) { + pr_err("Requested to boot cpu %d on non-boot cluster!\n", cpu); + return -EINVAL; + } /* request power on */ writel_relaxed(BIT(bit), p + WUPCR_OFFS); @@ -101,27 +109,19 @@ static void apmu_parse_cfg(void (*fn)(struct resource *res, int cpu, int bit), u32 id; int k; int bit, index; - bool is_allowed; for (k = 0; k < num; k++) { - /* only enable the cluster that includes the boot CPU */ - is_allowed = false; - for (bit = 0; bit < ARRAY_SIZE(apmu_config[k].cpus); bit++) { - id = apmu_config[k].cpus[bit]; - if (id >= 0) { - if (id == cpu_logical_map(0)) - is_allowed = true; - } - } - if (!is_allowed) - continue; - for (bit = 0; bit < ARRAY_SIZE(apmu_config[k].cpus); bit++) { id = apmu_config[k].cpus[bit]; if (id >= 0) { index = get_logical_index(id); - if (index >= 0) + if (index >= 0) { fn(&apmu_config[k].iomem, index, bit); + apmu_cpus[index].pcpu = + MPIDR_AFFINITY_LEVEL(id, 0); + apmu_cpus[index].pcluster = + MPIDR_AFFINITY_LEVEL(id, 1); + } } } }