Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757604AbcLOKTi (ORCPT ); Thu, 15 Dec 2016 05:19:38 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:38674 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755077AbcLOKTe (ORCPT ); Thu, 15 Dec 2016 05:19:34 -0500 Date: Thu, 15 Dec 2016 10:09:32 +0000 From: Russell King - ARM Linux To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Arnd Bergmann , Robin Murphy , Linus Walleij , Ben Dooks , Tony Lindgren , Ivaylo Dimitrov , Sebastian Reichel , Aaro Koskinen , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <201612150109.20868@pali> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2983 Lines: 83 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); -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.