From patchwork Fri Nov 7 02:33:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 5249271 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AB6309F39B for ; Fri, 7 Nov 2014 02:37:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B80C02008F for ; Fri, 7 Nov 2014 02:37:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24C3920138 for ; Fri, 7 Nov 2014 02:37:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XmZNt-0003vx-6G; Fri, 07 Nov 2014 02:34:45 +0000 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XmZNq-0003pA-9b for linux-arm-kernel@lists.infradead.org; Fri, 07 Nov 2014 02:34:43 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 2B5D2844CE; Fri, 7 Nov 2014 15:34:12 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1415327652; bh=jInVctmwOvsCtxnsdIabp4Wpu3z2Vf11Kz5m2czGdbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lLzon8qC0fkMh16h7bZoYhE9QEtS9zJxMWmD5qRjrlucWy2mXtbibG1tS6Mw86Zsm JsseF7pE/WKtmsMrh8RP1ffBWrJJYvoNdQhyim+0NJ7Ob7LDd28IAUUqwXk1j3jUkn WCVT2teoTnDiJtCs8gp0FYBGL36jYo5viR55S18g= Received: from alliedtelesyn.co.nz (Not Verified[10.32.16.32]) by mmarshal3.atlnz.lc with MailMarshal (v7, 1, 0, 4874) id ; Fri, 07 Nov 2014 15:34:11 +1300 Received: from MAIL/SpoolDir by alliedtelesyn.co.nz (Mercury 1.48); 7 Nov 14 15:34:38 +1300 Received: from SpoolDir by MAIL (Mercury 1.48); 7 Nov 14 15:34:37 +1300 Received: from chrisp-dl.ws.atlnz.lc (10.33.22.20) by alliedtelesyn.co.nz (Mercury 1.48) with ESMTP; 7 Nov 14 15:34:33 +1300 Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 48EF1C11A7; Fri, 7 Nov 2014 15:34:06 +1300 (NZDT) From: Chris Packham To: Subject: [RFC PATCHv2] ARM: mvebu: Let the device-tree determine smp_ops Date: Fri, 7 Nov 2014 15:33:46 +1300 Message-Id: <1415327626-16079-1-git-send-email-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.2.0.rc0 In-Reply-To: <20141106201603.GF4974@lunn.ch> References: <20141106201603.GF4974@lunn.ch> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141106_183442_844301_497C9904 X-CRM114-Status: GOOD ( 23.81 ) X-Spam-Score: -0.7 (/) Cc: Thomas Petazzoni , Andrew Lunn , Jason Cooper , Boris Brezillon , Chris Packham , Ezequiel Garcia , Gregory Clement , Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,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 The machine specific SMP operations can be configured either via setup_arch or via arm_dt_init_cpu_maps. For the ARMADA_370_XP_DT devices both of these are called and setup_arch wins because it is called last. This means that it is not possible to substitute a different set of SMP operations via the device-tree. For the ARMADA_370_XP_DT compatible devices add a smp_init function that detects if the device tree has an enable-method defined. If it does return true to indicate that the smp_ops have already been set which will prevent setup_arch from overriding them. Signed-off-by: Chris Packham --- Hi, On 11/07/2014 09:16 AM, Andrew Lunn wrote: >> Darn. I thought that might be the case but I wanted to keep the scope of >> my change small. How about making setup_arch check if smp_ops is already >> set? > > I think that would be last resort solution. Try not to touch core code > unless you really have to. > >> Alternatively if we gave ARMADA_370_XP_DT a smp_init function that >> returned non-zero if smp_ops is already set then I think it'd be >> backwards compatible and keep the scope of the change restricted to >> the 370-XP platforms. > > This sounds more reasonable. > > Andrew > So here's my next attempt at a patch that is backwards compatible but allows the device tree to determine smp_ops. The device-tree searching was borrowed from arm_dt_init_cpu_maps which is probably an indication that I'm duplicating something that perhaps I shouldn't. I have reservations about the fact that my code is active upon the device-tree having and enable-method rather than the combination of the device tree having the method and the kernel having that method declared. I'm also not sure that this is the intended use of the smp_init callback (a quick grep through Documentation/ doesn't yield any hits and asm/mach/arch.h doesn't say anything either) but nobody seemed to object when I proposed this usage. For v3 I wonder if I should just add a getter for smp_ops and have armada_smp_init just use that or perhaps have a flag that is set by set_smp_ops_by_method when it knows that the enable-method is something we can use. Or perhaps I'm over-thinking things :). Thanks, Chris arch/arm/mach-mvebu/board-v7.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index 6478626..7e79eb1 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -198,6 +198,31 @@ static void __init mvebu_dt_init(void) of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); } +static bool __init armada_smp_init(void) +{ + struct device_node *cpu, *cpus; + int len; + bool found_method = false; + + cpus = of_find_node_by_path("/cpus"); + if (!cpus) + return false; + + for_each_child_of_node(cpus, cpu) { + if (of_node_cmp(cpu->type, "cpu")) + continue; + if (of_find_property(cpu, "enable-method", &len)) + found_method = true; + } + + /* Fallback to an enable-method in the cpus node */ + if (!found_method) + if (of_find_property(cpus, "enable-method", &len)) + found_method = true; + + return found_method; +} + static const char * const armada_370_xp_dt_compat[] = { "marvell,armada-370-xp", NULL, @@ -206,6 +231,7 @@ static const char * const armada_370_xp_dt_compat[] = { DT_MACHINE_START(ARMADA_370_XP_DT, "Marvell Armada 370/XP (Device Tree)") .l2c_aux_val = 0, .l2c_aux_mask = ~0, + .smp_init = armada_smp_init, .smp = smp_ops(armada_xp_smp_ops), .init_machine = mvebu_dt_init, .init_irq = mvebu_init_irq,