From nobody Tue Sep 16 12:32:14 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EED0C3DA7D for ; Tue, 3 Jan 2023 18:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238524AbjACSBY (ORCPT ); Tue, 3 Jan 2023 13:01:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238513AbjACSA5 (ORCPT ); Tue, 3 Jan 2023 13:00:57 -0500 Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2F41270; Tue, 3 Jan 2023 10:00:56 -0800 (PST) Received: by mail-il1-f169.google.com with SMTP id bp26so3757088ilb.3; Tue, 03 Jan 2023 10:00:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+wm/VAsCJtckCmZFwW1Ji09pFtmWQae4vzQe50HoWg4=; b=GD2e6mffm45OB2oyL7ZGQGm/93Ivcs5E/RWdFedMvXO6u5dBXcvd2N1LtE0J2/90Mv GlSDLDDcmkzYUxqa8T3ZTdc+MCgs+ryVRx1DaSH+DJada8/DvbGxoXjoWY9u4VI6rnp8 5VyW2Jg3e4MVS+PnbbvLWDGHXSkwrhe283IU7w36baUk6moXB/EKVd52c+LipKXtWehC MqfnPQcMMc7J87bAGZwFYL5FOT20blUDAdYPZoe76K5L8OKL9HrGtTy4fXUDkfajtTMp Qx/26YrfbrUaFyUFGwi0LUhiob0AZLsuhgFdKHizcI7ZiT3CiMw3NdAqNWcOiy9uT5B1 C6WA== X-Gm-Message-State: AFqh2kp54tTVTkEAFec4CPR3+Y/H9KB/hsKGe3u0pHn0j7H4bWt5RO2S CjplyTS2ZvuyOb59sABggTVnIExCEw== X-Google-Smtp-Source: AMrXdXsBQWnE4m6NFOYZRRt+RQrVTDUs7E3tgSd494Hy/6KB47YogIhvaqdpkp8Sjgc46cbAw5DTRQ== X-Received: by 2002:a92:db47:0:b0:303:30a9:326a with SMTP id w7-20020a92db47000000b0030330a9326amr28638434ilq.7.1672768856073; Tue, 03 Jan 2023 10:00:56 -0800 (PST) Received: from robh_at_kernel.org ([64.188.179.248]) by smtp.gmail.com with ESMTPSA id g14-20020a056e021a2e00b00304ae88ebebsm9803549ile.88.2023.01.03.10.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:00:55 -0800 (PST) Received: (nullmailer pid 3492168 invoked by uid 1000); Tue, 03 Jan 2023 18:00:51 -0000 From: Rob Herring Date: Tue, 03 Jan 2023 12:00:31 -0600 Subject: [PATCH 1/2] Revert "of: fdt: Honor CONFIG_CMDLINE* even without /chosen node" MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230103-dt-cmdline-fix-v1-1-7038e88b18b6@kernel.org> References: <20230103-dt-cmdline-fix-v1-0-7038e88b18b6@kernel.org> In-Reply-To: <20230103-dt-cmdline-fix-v1-0-7038e88b18b6@kernel.org> To: Geoff Levand , Alexander Sverdlin , Frank Rowand Cc: Linus Walleij , Arnd Bergmann , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12-dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit a7d550f82b445cf218b47a2c1a9c56e97ecb8c7a. Some arches (PPC at least) don't call early_init_dt_scan_nodes(), so moving the cmdline processing there breaks them. Reported-by: Geoff Levand Cc: Alexander Sverdlin Signed-off-by: Rob Herring Reviewed-by: Alexander Sverdlin Tested-by: Geoff Levand --- 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 b2272bccf85c..7b571a631639 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1173,6 +1173,26 @@ int __init early_init_dt_scan_chosen(char *cmdline) if (p !=3D NULL && l > 0) strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); =20 + /* + * 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(cmdline, " ", COMMAND_LINE_SIZE); + strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); +#elif defined(CONFIG_CMDLINE_FORCE) + strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); +#else + /* No arguments from boot loader, use kernel's cmdl*/ + if (!((char *)cmdline)[0]) + strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); +#endif +#endif /* CONFIG_CMDLINE */ + + pr_debug("Command line is: %s\n", (char *)cmdline); + rng_seed =3D of_get_flat_dt_prop(node, "rng-seed", &l); if (rng_seed && l > 0) { add_bootloader_randomness(rng_seed, l); @@ -1277,26 +1297,6 @@ void __init early_init_dt_scan_nodes(void) if (rc) pr_warn("No chosen node found, continuing without\n"); =20 - /* - * 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) - strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); -#else - /* No arguments from boot loader, use kernel's cmdl */ - if (!boot_command_line[0]) - strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); -#endif -#endif /* CONFIG_CMDLINE */ - - pr_debug("Command line is: %s\n", boot_command_line); - /* Setup memory, calling early_init_dt_add_memory_arch */ early_init_dt_scan_memory(); =20 --=20 2.39.0 From nobody Tue Sep 16 12:32:14 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EB2FC46467 for ; Tue, 3 Jan 2023 18:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238537AbjACSB1 (ORCPT ); Tue, 3 Jan 2023 13:01:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230173AbjACSA4 (ORCPT ); Tue, 3 Jan 2023 13:00:56 -0500 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6608D270; Tue, 3 Jan 2023 10:00:55 -0800 (PST) Received: by mail-il1-f171.google.com with SMTP id d10so18383209ilc.12; Tue, 03 Jan 2023 10:00:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ai+C4kfMYDVX4+GGvR2fZcw0TFCgshT4pT+LtG/a7/c=; b=u5NORUKAjX3NIPccbp4aU6szdijFGUJIpK+gKQCSaMxnbQSGro5UwWRI4oy1lpECFM NRTs+2TW24QBpP1zo/oAYdLMvsPUd/RsGZLVKgL520OOlOo85ZYcBDpvNheF1D0tYsvh bq5pwTfZUO5CPiNbz7NRdvhiInAkz6uYiNtvqolaW12k3h+3ztg3zUMlWH2qBBExhNdw vtNXM47nLLuiahr2I/HNluY1zvQp3Oq0OsBFPXMvs3DCmzrXbPfV9aNJbsL7yFypJlRN QJvFqsg6VtOMQv6WvgdPJmPyBoW1fXZZ1ucOLuf9hYofX2T1Tm/WtEnFt0WegBp4EcYs z0RQ== X-Gm-Message-State: AFqh2koMZLW2qIIUZR7FUNSmTayE1dFjR1tYbxc0pVPi0fYV9mD0dqg9 yQ9Ft3LqiWI2BfVuZSp+QA== X-Google-Smtp-Source: AMrXdXsksLPmE6aWIt4TlmhZsPgEpUfsGIUOklE906/pA/IpeCfW2n4vxsDwSBLBihHE5y3FbqOhVQ== X-Received: by 2002:a05:6e02:12eb:b0:303:94bf:b0bb with SMTP id l11-20020a056e0212eb00b0030394bfb0bbmr39009852iln.29.1672768854567; Tue, 03 Jan 2023 10:00:54 -0800 (PST) Received: from robh_at_kernel.org ([64.188.179.248]) by smtp.gmail.com with ESMTPSA id y16-20020a056e02129000b0030bff5524eesm8092289ilq.50.2023.01.03.10.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:00:54 -0800 (PST) Received: (nullmailer pid 3492170 invoked by uid 1000); Tue, 03 Jan 2023 18:00:51 -0000 From: Rob Herring Date: Tue, 03 Jan 2023 12:00:32 -0600 Subject: [PATCH 2/2] of: fdt: Honor CONFIG_CMDLINE* even without /chosen node, take 2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230103-dt-cmdline-fix-v1-2-7038e88b18b6@kernel.org> References: <20230103-dt-cmdline-fix-v1-0-7038e88b18b6@kernel.org> In-Reply-To: <20230103-dt-cmdline-fix-v1-0-7038e88b18b6@kernel.org> To: Geoff Levand , Alexander Sverdlin , Frank Rowand Cc: Linus Walleij , Arnd Bergmann , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12-dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I do not read a strict requirement on /chosen node in either ePAPR or in Documentation/devicetree. Help text for CONFIG_CMDLINE and CONFIG_CMDLINE_EXTEND doesn't make their behavior explicitly dependent on the presence of /chosen or the presense of /chosen/bootargs. However the early check for /chosen and bailing out in early_init_dt_scan_chosen() skips CONFIG_CMDLINE handling which is not really related to /chosen node or the particular method of passing cmdline from bootloader. This leads to counterintuitive combinations (assuming CONFIG_CMDLINE_EXTEND=3Dy): a) bootargs=3D"foo", CONFIG_CMDLINE=3D"bar" =3D> cmdline=3D=3D"foo bar" b) /chosen missing, CONFIG_CMDLINE=3D"bar" =3D> cmdline=3D=3D"" c) bootargs=3D"", CONFIG_CMDLINE=3D"bar" =3D> cmdline=3D=3D" bar" Rework early_init_dt_scan_chosen() so that the cmdline config options are always handled. [commit msg written by Alexander Sverdlin] Cc: Alexander Sverdlin Cc: Linus Walleij Cc: Arnd Bergmann Signed-off-by: Rob Herring Reviewed-by: Alexander Sverdlin Tested-by: Geoff Levand --- drivers/of/fdt.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 7b571a631639..4b94bb52671e 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1161,18 +1161,32 @@ int __init early_init_dt_scan_chosen(char *cmdline) if (node < 0) node =3D fdt_path_offset(fdt, "/chosen@0"); if (node < 0) - return -ENOENT; + /* Handle the cmdline config options even if no /chosen node */ + goto handle_cmdline; =20 chosen_node_offset =3D node; =20 early_init_dt_check_for_initrd(node); early_init_dt_check_for_elfcorehdr(node); =20 + rng_seed =3D of_get_flat_dt_prop(node, "rng-seed", &l); + if (rng_seed && l > 0) { + add_bootloader_randomness(rng_seed, l); + + /* try to clear seed so it won't be found. */ + fdt_nop_property(initial_boot_params, node, "rng-seed"); + + /* update CRC check value */ + of_fdt_crc32 =3D crc32_be(~0, initial_boot_params, + fdt_totalsize(initial_boot_params)); + } + /* Retrieve command line */ p =3D of_get_flat_dt_prop(node, "bootargs", &l); if (p !=3D NULL && l > 0) strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); =20 +handle_cmdline: /* * CONFIG_CMDLINE is meant to be a default in case nothing else * managed to set the command line, unless CONFIG_CMDLINE_FORCE @@ -1193,18 +1207,6 @@ int __init early_init_dt_scan_chosen(char *cmdline) =20 pr_debug("Command line is: %s\n", (char *)cmdline); =20 - rng_seed =3D of_get_flat_dt_prop(node, "rng-seed", &l); - if (rng_seed && l > 0) { - add_bootloader_randomness(rng_seed, l); - - /* try to clear seed so it won't be found. */ - fdt_nop_property(initial_boot_params, node, "rng-seed"); - - /* update CRC check value */ - of_fdt_crc32 =3D crc32_be(~0, initial_boot_params, - fdt_totalsize(initial_boot_params)); - } - return 0; } =20 --=20 2.39.0