From patchwork Tue Dec 23 21:13:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 5535551 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 E09EDBEEA8 for ; Tue, 23 Dec 2014 21:17:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED21820108 for ; Tue, 23 Dec 2014 21:17:52 +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 09C332011D for ; Tue, 23 Dec 2014 21:17:52 +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 1Y3Wny-0005Nl-2x; Tue, 23 Dec 2014 21:15:46 +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 1Y3Wn8-0003wZ-44 for linux-arm-kernel@lists.infradead.org; Tue, 23 Dec 2014 21:14:55 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 6290E844D3; Wed, 24 Dec 2014 10:14:31 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1419369271; bh=Jmt8tO99d6s9fBHNYzAMIM7jeAS/kGc/ZHXgx4wLLIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qR6hgMpSMR2BASLLOrSD3guXGQwQHXZJGHFbq7vWV6WZ6joMqhuAQ73ePl7J0X1cP +0fFelZncjMIGnwwPw63EU8aNqxbmQv1FTAKOf1afV7a5n5zUIq/+LKAeC2o84y5nB SBhIeNDkR+8qcH0e94w+DQy6cGKtI9syUj0Jqn24= Received: from alliedtelesyn.co.nz (Not Verified[10.32.16.32]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 3, 0, 7277) id ; Wed, 24 Dec 2014 10:14:28 +1300 Received: from MAIL/SpoolDir by alliedtelesyn.co.nz (Mercury 1.48); 24 Dec 14 10:15:06 +1300 Received: from SpoolDir by MAIL (Mercury 1.48); 24 Dec 14 10:14:41 +1300 Received: from chrisp-dl.ws.atlnz.lc (10.33.22.30) by alliedtelesyn.co.nz (Mercury 1.48) with ESMTP; 24 Dec 14 10:14:38 +1300 Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id E9E8080DF8; Wed, 24 Dec 2014 10:13:58 +1300 (NZDT) From: Chris Packham To: linux-arm-kernel@lists.infradead.org Subject: [RFC/PATCHv2 2/5] ARM: mvebu: use dt_fixup to provide fallback for enable-method Date: Wed, 24 Dec 2014 10:13:29 +1300 Message-Id: <1419369212-17047-3-git-send-email-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.2.0.rc0 In-Reply-To: <1419369212-17047-1-git-send-email-chris.packham@alliedtelesis.co.nz> References: <1419369212-17047-1-git-send-email-chris.packham@alliedtelesis.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141223_131454_607303_711E531A X-CRM114-Status: GOOD ( 15.55 ) X-Spam-Score: -0.1 (/) Cc: Andrew Lunn , Jason Cooper , Boris Brezillon , Chris Packham , Ezequiel Garcia , Gregory Clement , Maxime Ripard , 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=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, 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 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. Additionally Armada 370, which is a single core device, no longer has any smp operations defined. Signed-off-by: Chris Packham --- As Arnd and Maxime suggested this replaces the unconditional setting of smp_ops[1] with a fixup that inserts an appropriate property in the device-tree if needed. It turned out not to be terribly tricky to implement that checked each possible CPU node. One assumption I've made is that the cpu nodes are numbered contiguously but that seems to be reasonable. [1] - http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/309766.html arch/arm/mach-mvebu/board-v7.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index d0d39f1..08eb6a9 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 @@ -198,6 +200,44 @@ 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) +{ + int offset, node; + int i, len; + void *prop; + char buffer[20]; + unsigned long root = of_get_flat_dt_root(); + + if (!IS_ENABLED(CONFIG_SMP) || + !of_flat_dt_is_compatible(root, "marvell,armadaxp")) + return; + + offset = fdt_path_offset(initial_boot_params, "/cpus"); + if (offset < 0) + return; + + prop = fdt_getprop(initial_boot_params, offset, "enable-method", &len); + if (prop) + return; + + for (i = 0; i < NR_CPUS; i++) { + snprintf(buffer, sizeof(buffer), "cpu@%d", i); + node = fdt_subnode_offset(initial_boot_params, offset, buffer); + if (node < 0) + break; + prop = fdt_getprop(initial_boot_params, node, + "enable-method", &len); + if (prop) + return; + } + + pr_info("No enable-method defined. " + "Falling back to \"marvell,armada-xp-smp\"\n"); + + fdt_setprop(initial_boot_params, offset, "enable-method", + "marvell,armada-xp-smp", sizeof("marvell,armada-xp-smp")); +} + static const char * const armada_370_xp_dt_compat[] = { "marvell,armada-370-xp", NULL, @@ -206,11 +246,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[] = {