From patchwork Thu Dec 15 10:09:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 9475811 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EC33B60571 for ; Thu, 15 Dec 2016 10:14:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4AAC285E7 for ; Thu, 15 Dec 2016 10:14:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6CBD2870F; Thu, 15 Dec 2016 10:14:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D9BD2285E7 for ; Thu, 15 Dec 2016 10:14:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cHT1c-0007ke-F1; Thu, 15 Dec 2016 10:12:32 +0000 Received: from pandora.armlinux.org.uk ([78.32.30.218]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cHT1X-0007gg-NT for linux-arm-kernel@lists.infradead.org; Thu, 15 Dec 2016 10:12:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=WkDwcOF/2sviUdQhpkPlMssPqlDirIoSFLcJlWR5mwU=; b=KA8A5woEC9MpC5KV2GDWRwPPe8E3t/lzg0d98F1dJAY1qd2VN+cG1P+Dvj5qp1Rb4BKUAJEwdwAVdQelrB0e88MIHuQ4qYVwobUV0knichTFu5rFJENEdR+wh9VYhGK5MIcg/PauFs3ayd7o0+XVKOybrzar2Q38mP28qwfGqw0=; Received: from n2100.armlinux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:40275) by pandora.armlinux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1cHSyl-0001yX-Jc; Thu, 15 Dec 2016 10:09:35 +0000 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.76) (envelope-from ) id 1cHSyi-0001fQ-FU; Thu, 15 Dec 2016 10:09:32 +0000 Date: Thu, 15 Dec 2016 10:09:32 +0000 From: Russell King - ARM Linux To: Pali =?iso-8859-1?Q?Roh=E1r?= Subject: Re: [PATCH] arm: dt: Initialize boot_command_line from CONFIG_CMDLINE in case DT does not provide /chosen/bootargs Message-ID: <20161215100931.GJ14217@n2100.armlinux.org.uk> References: <1481749963-8664-1-git-send-email-pali.rohar@gmail.com> <20161214235224.GH14217@n2100.armlinux.org.uk> <201612150109.20868@pali> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <201612150109.20868@pali> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161215_021228_281093_261BB569 X-CRM114-Status: GOOD ( 17.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ivaylo Dimitrov , Pavel Machek , Arnd Bergmann , Aaro Koskinen , Tony Lindgren , Linus Walleij , Sebastian Reichel , linux-kernel@vger.kernel.org, Ben Dooks , Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Dec 15, 2016 at 01:09:20AM +0100, Pali Rohár wrote: > If cmdline is not in DT, but /chosen exists, then function > early_init_dt_scan_chosen() use cmdline from CONFIG_CMDLINE. Ah, yes. Looks to me then as if the bug exists there, and not in arch code then. early_init_dt_scan_chosen() completely ignores the CMDLINE options if the chosen node is not found. > What is reason that CONFIG_CMDLINE is not supported for DT? Sorry, that's my mistake - as you've pointed out above, it is supported but via generic code. I was only looking at arch code when I made the statement. This patch (untested) should solve it: drivers/of/fdt.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index c89d5d231a0e..fb89157332c6 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1073,26 +1073,6 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, if (p != NULL && l > 0) strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE)); - /* - * CONFIG_CMDLINE is meant to be a default in case nothing else - * managed to set the command line, unless CONFIG_CMDLINE_FORCE - * is set in which case we override whatever was found earlier. - */ -#ifdef CONFIG_CMDLINE -#if defined(CONFIG_CMDLINE_EXTEND) - strlcat(data, " ", COMMAND_LINE_SIZE); - strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); -#elif defined(CONFIG_CMDLINE_FORCE) - strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); -#else - /* No arguments from boot loader, use kernel's cmdl*/ - if (!((char *)data)[0]) - strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); -#endif -#endif /* CONFIG_CMDLINE */ - - pr_debug("Command line is: %s\n", (char*)data); - /* break now */ return 1; } @@ -1205,6 +1185,26 @@ void __init early_init_dt_scan_nodes(void) /* Retrieve various information from the /chosen node */ of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); + /* + * CONFIG_CMDLINE is meant to be a default in case nothing else + * managed to set the command line, unless CONFIG_CMDLINE_FORCE + * is set in which case we override whatever was found earlier. + */ +#ifdef CONFIG_CMDLINE +#if defined(CONFIG_CMDLINE_EXTEND) + strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); + strlcat(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); +#elif defined(CONFIG_CMDLINE_FORCE) + strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); +#else + /* No arguments from boot loader, use kernel's cmdline */ + if (!boot_command_line[0]) + strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); +#endif +#endif /* CONFIG_CMDLINE */ + + pr_debug("Command line is: %s\n", boot_command_line); + /* Initialize {size,address}-cells info */ of_scan_flat_dt(early_init_dt_scan_root, NULL);