From patchwork Mon Nov 17 23:34:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 5324521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3CCE0C11AC for ; Mon, 17 Nov 2014 23:37:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B47720120 for ; Mon, 17 Nov 2014 23:37:05 +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 6B829200F4 for ; Mon, 17 Nov 2014 23:37:03 +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 1XqVpM-0004m5-9C; Mon, 17 Nov 2014 23:35:24 +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 1XqVpH-00039E-Tv for linux-arm-kernel@lists.infradead.org; Mon, 17 Nov 2014 23:35:21 +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 64F0E8066C; Tue, 18 Nov 2014 12:34:49 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1416267289; bh=w4t9p/05IuMpz9NidVuduC2no1KTxMW2sMYniHPKLSo=; h=Date:From:To:cc:Subject:In-Reply-To:References; b=m1ez0I+lARDMc/llr1q6fP/5W+0DNZLjVUbe4u3N0PG1hKFd9c7aGClFJtjwciyZ9 uFSZ/injOx7aWUnncjl165OGJXolxL8Y1igsUF2qZrO9zEuorskCKkJ+A+ziiUuXAq k59whNfivBKGunOo095bfhRAt1os8h/U4BRHuWvY= Received: from alliedtelesyn.co.nz (Not Verified[10.32.16.32]) by mmarshal3.atlnz.lc with MailMarshal (v7, 1, 0, 4874) id ; Tue, 18 Nov 2014 12:34:49 +1300 Received: from MAIL/SpoolDir by alliedtelesyn.co.nz (Mercury 1.48); 18 Nov 14 12:35:18 +1300 Received: from SpoolDir by MAIL (Mercury 1.48); 18 Nov 14 12:35:13 +1300 Received: from chrisp-dl.ws.atlnz.lc (10.33.22.20) by alliedtelesyn.co.nz (Mercury 1.48) with ESMTP; 18 Nov 14 12:35:12 +1300 Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id AB38BC0290; Tue, 18 Nov 2014 12:34:41 +1300 (NZDT) Received: from localhost (localhost [127.0.0.1]) by chrisp-dl.ws.atlnz.lc (Postfix) with ESMTP id 7C988C0059; Tue, 18 Nov 2014 12:34:41 +1300 (NZDT) Date: Tue, 18 Nov 2014 12:34:41 +1300 (NZDT) From: Chris Packham X-X-Sender: chrisp@chrisp-dl.ws.atlnz.lc To: Thomas Petazzoni Subject: Re: [RFC PATCHv2] ARM: mvebu: Let the device-tree determine smp_ops In-Reply-To: <20141117095640.03e25d17@free-electrons.com> Message-ID: References: <20141106201603.GF4974@lunn.ch> <1415327626-16079-1-git-send-email-chris.packham@alliedtelesis.co.nz> <20141117095640.03e25d17@free-electrons.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141117_153520_400277_6E7164CD X-CRM114-Status: GOOD ( 25.94 ) X-Spam-Score: -0.1 (/) Cc: Andrew Lunn , Jason Cooper , Boris Brezillon , chrisp@ex.alliedtelesis.co.nz, chrisp@alliedtelesyn.co.nz, Ezequiel Garcia , Gregory Clement , Maxime Ripard , linux-arm-kernel@lists.infradead.org, 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: , 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, 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 Hi Thomas, Maxime On Mon, 17 Nov 2014, Thomas Petazzoni wrote: > Dear Chris Packham, > > On Fri, 7 Nov 2014 15:33:46 +1300, Chris Packham wrote: >> 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 > > My colleague Maxime Ripard (in Cc) rightfully suggests exploring a > different option: what about getting rid completely of the .smp field > of the DT_MACHINE structure, and instead have some code run early > enough that looks if an enable-method is defined, and if not, defines > it to the default value. This way, we continue to be backward > compatible in terms of DT, but we always use the enable-method from the > DT, and not sometimes from DT, sometimes from the DT_MACHINE structure. > > Unfortunately, it will have to be done on the flattened DT, because the > DT is unflattened right before the enable-method properties are looked > up: > > unflatten_device_tree(); > > arm_dt_init_cpu_maps(); > > And manipulating the DT in its flattened format, while possible in > ->dt_fixup(), is a pain, and probably doesn't allow adding new > properties anyway. > > So, in the end, maybe this idea doesn't work, I haven't checked > completely. > So yeah it's tricky to work with the flattened dt. Not impossible the powerpc arch code does quite a lot with it. Arm does less but still uses it in atags_to_fdt.c. Below is a rough attempt at an implementation that seems to work. Because of the flattened dt it's harder to iterate through the cpu nodes so I haven't implemented anything to look for an enable-method attached to them. ---- 8< ---- Subject: [PATCH] ARM: mvebu: use dt_fixup to provide fallback for enable-method When the device tree doesn't define an enable-method insert a property into the flattened device tree. arm_dt_init_cpu_maps() will then parse this an set smp_ops appropriately. Now that we have this fallback it is no longer necessary to set .smp in the DT_MACHINE definition. Signed-off-by: Chris Packham --- arch/arm/mach-mvebu/Makefile | 2 ++ arch/arm/mach-mvebu/board-v7.c | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) static const char * const armada_370_xp_dt_compat[] = { "marvell,armada-370-xp", NULL, @@ -192,11 +213,11 @@ 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 = smp_ops(armada_xp_smp_ops), .init_machine = mvebu_dt_init, .init_irq = mvebu_init_irq, .restart = mvebu_restart, .dt_compat = armada_370_xp_dt_compat, + .dt_fixup = armada_370_xp_dt_fixup, MACHINE_END static const char * const armada_375_dt_compat[] = { diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile index 1636cdb..f818eaf 100644 --- a/arch/arm/mach-mvebu/Makefile +++ b/arch/arm/mach-mvebu/Makefile @@ -14,3 +14,5 @@ endif obj-$(CONFIG_MACH_DOVE) += dove.o obj-$(CONFIG_MACH_KIRKWOOD) += kirkwood.o kirkwood-pm.o + +CFLAGS_board-v7.o = -I$(src)/../../../scripts/dtc/libfdt \ No newline at end of file diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index b2524d6..45851a2 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -184,6 +186,25 @@ static void __init mvebu_dt_init(void) of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); } +static void __init armada_370_xp_dt_fixup(void) +{ + void *prop; + int offset; + int len; + + offset = fdt_path_offset(initial_boot_params, "/cpus"); + prop = fdt_getprop(initial_boot_params, offset, "enable-method", &len); + + if (!prop) { + pr_info("No enable-method defined. " + "Falling back to \"marvell,armada-xp-smp\"\n"); + + fdt_appendprop(initial_boot_params, offset, "enable-method", + "marvell,armada-xp-smp", + sizeof("marvell,armada-xp-smp")); + } +} +