Received: by 10.213.65.68 with SMTP id h4csp1102114imn; Wed, 14 Mar 2018 09:38:55 -0700 (PDT) X-Google-Smtp-Source: AG47ELuIqf3Dv6au+qSsbB/gBv2CqOCvCmqBbbEu/jUb60pESnP0/pMN3ekPMWeTxoYfi/1GjjDT X-Received: by 10.99.3.144 with SMTP id 138mr4286758pgd.364.1521045535768; Wed, 14 Mar 2018 09:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521045535; cv=none; d=google.com; s=arc-20160816; b=0NKYcKW4/xBd7M83ZFNUkOykef20lgalmftmUxmNlOdIDMUoMd5P/W70mtQxbztqQ8 713De4a0gZcvkUrNxIplqIKIYAgTShWEAa/Z61x1Gk/j919Mcf0xENmdM4m0q7iBPYoS EdpGRx0z8FK3Q0Tng+zSSJeBiw5S/ChwtJ2X8aoZBMMpeJisZEmdXy6iSPJGcbA469ip YL5s1XoNYg34/muPcsaxe8qdAadA9wQKginobTWmjoZE0SMu4SVkIBIKXp8UcB3D2iyn 8ZbxzSMyTXYNubRbV3as1WuUKWvDyEQORcgjqR3RYvyiKL78qfttcMUMIfQ4OGHrqpRO zpwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:from:cc:message-id:date:subject :dkim-signature:arc-authentication-results; bh=OqkbVaZXKGTeb+bDRwq/93eJ35ur6B3wy2STMcQsy6s=; b=Fu6RbN0yx25pxCFANazrkyoGa9rCqE7B4Ec8yhQVCf5r7XG0LS+EZ5yciiuqAF60HY wnHaXO55FQLe1Y/wQLvBEnZy7+VYfPbaLCoCxNqUWB25LdiNjv4tTl3HnRKkTPZD2pMS e2GkO4GPhEWUbQ+/nazRH2eD5/X0dNbM5UtZ7ZeHutFhL7eR/wMtKh8VQBcO4TKzq9VU 5FVuufZ/wBxLaVcDyzGEk9MbDTdp83oAYJOQuiwGqUaQQwd/GcpNCbLBg6qW/lYYd90H gxlxUk9dWU43QCN9CjDF0AbRDWTrDj2cLueUQbgX8Cx2GO8Bk8MZQfR/t9FrbFOWlp/j 2rBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=NwDi7CDH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si2136572pga.52.2018.03.14.09.38.39; Wed, 14 Mar 2018 09:38:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=NwDi7CDH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752323AbeCNQg4 (ORCPT + 99 others); Wed, 14 Mar 2018 12:36:56 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:42070 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbeCNQgy (ORCPT ); Wed, 14 Mar 2018 12:36:54 -0400 Received: by mail-pf0-f196.google.com with SMTP id a16so1625571pfn.9 for ; Wed, 14 Mar 2018 09:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=subject:date:message-id:cc:from:to; bh=OqkbVaZXKGTeb+bDRwq/93eJ35ur6B3wy2STMcQsy6s=; b=NwDi7CDHWzo3jHEsnrtXleV676SaFUhu8Hd+woJDZ9ZIeBz3bUUykL8OmiPfYuZXeE 5OfP/CnqZ4Ofvr9zalTN/sMQ2QhBCA3qZ7s07hVXhQjiOQXpiSAXqjOVPo1b21Kp8dCa prKFMSBs9HiJhCng3QthrJZd2eEBmHhRMnUUTcJgkroxLUSumIFCnmi8qHKBc12SwXte KmqyDfRE2SN0Mt1hFWJTCbRYVCjlGOAJI7ewLsJ7XL9Hf0uzWGbdcn1xRrmh38WhWHZc bUgHl5jr+jRC8/AxPXI3+WG6Qpzy2EkzjS7WIbWvw0r8yh93smAT7TmaoRZqh1P+CbYj Dehw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:cc:from:to; bh=OqkbVaZXKGTeb+bDRwq/93eJ35ur6B3wy2STMcQsy6s=; b=TG7IbY6k2sxq0JRffE7jNSo7qPQfMgcwCFnPWSA5poP3mr5KbdW68AK6vGk5tgsi1b /+ImZ+6z56PzJzfEyg58CZQpacc8M01h1SlzeYLjZb0hL04MCuiKyaK8nPp0GS5e2biq O+J3K9Z0F60NuzxeM6HmyDbBb/qY0OclOavy/QLH5Uf6BBExaNEZ97QVDC+N23bT7hbL vmKikrrn23SkQXJt4Gl9saIGVwQVaIJnBaKC4xRNnR+/uywYytp64yQq1aJUXGst8/Xx bO6VHBF689CLQ6QIsSlSWNsV2ZFO5ddeN6Nhm/AG8phqYD+xHRw7Imv9R5If+HeRC0m4 LzRg== X-Gm-Message-State: AElRT7Fa9DhYSdwzHZXmux2n3BO9k7QO+MG34eylh8RXpZmabq3WMic/ AtWb0OwlZuVcUqdWjeI13TUS8w== X-Received: by 10.101.101.205 with SMTP id y13mr4156566pgv.265.1521045413751; Wed, 14 Mar 2018 09:36:53 -0700 (PDT) Received: from localhost ([65.153.83.185]) by smtp.gmail.com with ESMTPSA id r9sm6477675pfg.11.2018.03.14.09.36.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 09:36:50 -0700 (PDT) Subject: [PATCH] of: Respect CONFIG_CMDLINE{,_EXTENED,_FORCE) with no chosen node Date: Wed, 14 Mar 2018 09:31:05 -0700 Message-Id: <20180314163105.8638-1-palmer@sifive.com> X-Mailer: git-send-email 2.16.1 Cc: Palmer Dabbelt , Michael J Clark , Trung Tran , Moritz Fischer From: Palmer Dabbelt To: robh+dt@kernel.org, frowand.list@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Systems that boot without a chosen node in the device tree should still respect the command lines that are built into the kernel. This patch avoids bailing out of the command line argument parsing code when there is no chosen node in the device tree. This is necessary to boot straight to a root file system (ie, without an initramfs) The intent here is that the only functional change is to copy CONFIG_CMDLINE into data if both of them are valid (ie, CONFIG_CMDLINE is defined and data is non-null) on systems where there is no chosen device tree node. I don't actually know what the return values do so I just preserved them. Thanks to Trung and Moritz for finding the bug during our ELC hackathon (and providing the first fix), and Michal for suggesting this fix (which is cleaner than what I was doing). I've given this very minimal testing: it fixes the RISC-V bug (in conjunction with a patch to move from COMMANDLINE_OVERRIDE to COMMANDLINE_FORCE), still works on systems with and without the chosen node, and builds on ARM64. CC: Michael J Clark CC: Trung Tran CC: Moritz Fischer Signed-off-by: Palmer Dabbelt --- drivers/of/fdt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 84aa9d676375..60241b1cb024 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1084,9 +1084,12 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); - if (depth != 1 || !data || + if (!data) + goto no_data; + + if (depth != 1 || (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) - return 0; + goto no_chosen; early_init_dt_check_for_initrd(node); @@ -1117,6 +1120,13 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, /* break now */ return 1; + +no_chosen: +#ifdef CONFIG_CMDLINE + strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); +#endif +no_data: + return 0; } #ifdef CONFIG_HAVE_MEMBLOCK -- 2.16.1