From patchwork Wed Nov 18 09:28:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Fedin X-Patchwork-Id: 7647531 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 37C55BF90C for ; Wed, 18 Nov 2015 09:30:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5BCCE20443 for ; Wed, 18 Nov 2015 09:30:45 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 43E6520600 for ; Wed, 18 Nov 2015 09:30:44 +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 1Zyz2c-0007HV-NQ; Wed, 18 Nov 2015 09:28:38 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zyz2Y-00079x-IZ for linux-arm-kernel@lists.infradead.org; Wed, 18 Nov 2015 09:28:35 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NY000HKG7MXKU80@mailout1.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 18 Nov 2015 09:28:09 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-b7-564c44a90f15 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 62.E9.21385.9A44C465; Wed, 18 Nov 2015 09:28:09 +0000 (GMT) Received: from fedinw7x64.rnd.samsung.ru ([106.109.131.169]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NY000F0H7MTV970@eusync4.samsung.com>; Wed, 18 Nov 2015 09:28:09 +0000 (GMT) From: Pavel Fedin To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH] arm64: Implement CONFIG_CMDLINE_EXTEND Date: Wed, 18 Nov 2015 12:28:05 +0300 Message-id: <1447838885-9888-1-git-send-email-p.fedin@samsung.com> X-Mailer: git-send-email 2.4.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkluLIzCtJLcpLzFFi42I5/e/4Nd2VLj5hBv9XiFu8X9bDaDH/yDlW i5lv/rNZHPizg9Fi0+NrrBate4+wW7z8eILFgd1jzbw1jB47Z91l99i0qpPN4861PWwem5fU e3zeJBfAFsVlk5Kak1mWWqRvl8CV0bLxL1vBctGKthU9bA2MkwW7GDk5JARMJFbsmsYCYYtJ XLi3nq2LkYtDSGApo8Tv9WcYIZw2Jolvr2awglSxCahLnP76AaxDRMBFovPBOhaQImaBo4wS 209/ZwdJCAuYS+zo7QVrYBFQlVjy7y8ziM0r4CTx5vRsNoh1chJXrk9nm8DIvYCRYRWjaGpp ckFxUnqukV5xYm5xaV66XnJ+7iZGSMB83cG49JjVIUYBDkYlHt7Exd5hQqyJZcWVuYcYJTiY lUR43+v6hAnxpiRWVqUW5ccXleakFh9ilOZgURLnnbnrfYiQQHpiSWp2ampBahFMlomDU6qB MeZqYkox4/Ur8wSOagou/2TVM9WpZ69zmPv6zs1TtjL0XVbwjrzdwrF9+oEdf5btLPbYHewj OOWF4fvsQ5/9bi/kzz3UU1AqJNLAcu3R0ayNAkaRj6+tfsN2O4RHeUJ1Bo8zE0ty5vIskdhd Taoex0+odbw5UR5YUTk3mStXICq4TnB61OQ7SizFGYmGWsxFxYkA9KUy+RQCAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151118_012834_796579_5243D443 X-CRM114-Status: GOOD ( 18.18 ) X-Spam-Score: -7.5 (-------) 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: Grant Likely , Catalin Marinas , Rob Herring , Will Deacon , Frank Rowand 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.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Add an option to extend built-in command line with one obtained from the device tree. This option is very useful for, for example, switching between some stable and development version, when one of them requires additional arguments (e. g. to turn on some extra debug). It can be annoying to reprogram command line in the bootloaded every time. Actually, this patch introduces the necessary support to all architectures using the device tree, however only arm64 Kconfig is modified, because this is the only platform i can test. Signed-off-by: Pavel Fedin --- arch/arm64/Kconfig | 18 ++++++++++++++++++ drivers/of/fdt.c | 12 ++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 9ac16a4..c741837 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -695,6 +695,23 @@ config CMDLINE entering them here. As a minimum, you should specify the the root device (e.g. root=/dev/nfs). +choice + prompt "Kernel command line type" if CMDLINE != "" + default CMDLINE_FROM_BOOTLOADER + +config CMDLINE_FROM_BOOTLOADER + bool "Use bootloader kernel arguments if available" + help + Uses the command-line options passed by the boot loader. If + the boot loader doesn't provide any, the default kernel command + string provided in CMDLINE will be used. + +config CMDLINE_EXTEND + bool "Extend bootloader kernel arguments" + help + The command-line arguments provided by the boot loader will be + appended to the default kernel command string. + config CMDLINE_FORCE bool "Always use the default kernel command string" help @@ -702,6 +719,7 @@ config CMDLINE_FORCE loader passes other arguments to the kernel. This is useful if you cannot or don't want to change the command-line options your boot loader passes to the kernel. +endchoice config EFI_STUB bool diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index d243029..494307e 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -949,8 +949,16 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, /* Retrieve command line */ p = of_get_flat_dt_prop(node, "bootargs", &l); - if (p != NULL && l > 0) - strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE)); + if (p != NULL && l > 0) { + int offset = 0; +#ifdef CONFIG_CMDLINE +#ifdef CONFIG_CMDLINE_EXTEND + strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); + offset = strlcat(data, " ", COMMAND_LINE_SIZE); +#endif +#endif + strlcpy(data + offset, p, min(l, COMMAND_LINE_SIZE - offset)); + } /* * CONFIG_CMDLINE is meant to be a default in case nothing else