Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2689509imm; Mon, 10 Sep 2018 05:10:56 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYGsHH9OekaMBhjIAx+a5mRA2WtoVmheYSH93XNW5Puhvdp5d3IeeyRuiy03TKnOf78efLK X-Received: by 2002:a63:6385:: with SMTP id x127-v6mr22527495pgb.413.1536581456309; Mon, 10 Sep 2018 05:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536581456; cv=none; d=google.com; s=arc-20160816; b=JU0geo0FGr+EV77FeRW0IAQLoECuICXUl4iZbRk0PJm2ty6BPjiAI4blTxsfmmQTa5 Whq0JQ81tKoqWNmzsK9/f2XEk01PO7ThsZYus7+CQJEYSa071Vz3YLEJ8GHtzewbI1lM uW6By95izpmj2Qa40DZCnidLBGCmfsOabl2lajz5BA2k83uaLosQIEfvOHnzkjYp6zp0 0mhQJKXpCqFbLRAvWQEOZzTXf2HG3BLBUJOgKGFDoxpDUpGQen6i060iBBNacTx8C2t7 GUHb68SQcUUTAJUiZo2SoNQx1ehKM9ZF4bYQg+Hkm6WBV3sABybr17ILHdeT8qKP6EJj ScvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=mc26UuR5dKmFOfDl0ahG1ant/pyws8OvJC2+hJ4ZzQQ=; b=agEXk1Wb7ZFa66R4PSm/S8WyMvYjuR07kCoTISsaHn0ZaLTI2b+PoNBs4y7p8yF7VM aKFTGnJJVzXX+/4jkwLREezlFcqHjv4MUKDWHWw31kOQmpJdsOKsBrADtayp4czVYBk2 YOCxXG9GHkqxlDfHOstPAB/+RLoZHgtg2IxEVUWbXENCjBJSBA8i7mkUgiwQHt3TahEr Xx28zczS786XKHzfU8i/hU1ab3E5Nu0b4LbhfeBmJQtEigOrTz1Y7DD0M6OMBan3+LnY 7iIf647mIKKvYU7UcUWKoN/DGFUCYVNFEFLvWia9o6pIfz2r/Ln/axhmtxuOl2VbHGE/ p+/Q== ARC-Authentication-Results: i=1; mx.google.com; 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 a15-v6si19015387pln.137.2018.09.10.05.10.41; Mon, 10 Sep 2018 05:10:56 -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; 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 S1728379AbeIJRDU (ORCPT + 99 others); Mon, 10 Sep 2018 13:03:20 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:41024 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727649AbeIJRDU (ORCPT ); Mon, 10 Sep 2018 13:03:20 -0400 Received: by mail-oi0-f67.google.com with SMTP id k12-v6so39573342oiw.8; Mon, 10 Sep 2018 05:09:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mc26UuR5dKmFOfDl0ahG1ant/pyws8OvJC2+hJ4ZzQQ=; b=a5UW4kffEHloCN9BbhqGpH00j0SPJ8UJ9yGSRvfNu0QoeavvHIgg45KxudU/jG8GiR G8gHzHqwHN/1Z0T5DbUsJRmQ4HjIBDPZjnzHmJIYTYcqzHPFOM/nL4U2GZNTqIR9BuxC HXEnXJuyi6rRN4HDeFVHlMSh1lm6flHYyDI3unTSOiE7kOIhNXq06vsNMUTebNUIAhiz hTXbHPBQeiMp7ErcXmhHkXqbCrztImMYdX8IkFvnrkbbiAbBnF3w72QbGZUVgb2rnfZW c508m2Lp1Ga1G68QZ3EwQ++Q+29fTf9x9XZb6tsj7Fa4bKDeABf/bAsXdmPVjtXrLoaq wlqg== X-Gm-Message-State: APzg51AlGdva8HDdDCQDk8q9Yasb/vCwBgJViX1q2CnEx0e+Cez9kw6q BrLMDexyvUARAZOi2bfcqifwRdkfxV+lVIchrec= X-Received: by 2002:aca:3ad4:: with SMTP id h203-v6mr20456865oia.294.1536581373592; Mon, 10 Sep 2018 05:09:33 -0700 (PDT) MIME-Version: 1.0 References: <20180907185414.2630-1-paul.burton@mips.com> <20180907185414.2630-2-paul.burton@mips.com> In-Reply-To: <20180907185414.2630-2-paul.burton@mips.com> From: Mathieu Malaterre Date: Mon, 10 Sep 2018 14:09:21 +0200 Message-ID: Subject: Re: [PATCH 2/2] MIPS: Fix CONFIG_CMDLINE handling To: Paul Burton Cc: Linux-MIPS , Paul Cercueil , LKML , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Frank Rowand , Jaedon Shin , Rob Herring , "# v4 . 11" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 7, 2018 at 8:55 PM Paul Burton wrote: > > Commit 8ce355cf2e38 ("MIPS: Setup boot_command_line before > plat_mem_setup") fixed a problem for systems which have > CONFIG_CMDLINE_BOOL=y & use a DT with a chosen node that has either no > bootargs property or an empty one. In this configuration > early_init_dt_scan_chosen() copies CONFIG_CMDLINE into > boot_command_line, but the MIPS code doesn't know this so it appends > CONFIG_CMDLINE (via builtin_cmdline) to boot_command_line again. The > result is that boot_command_line contains the arguments from > CONFIG_CMDLINE twice. > > That commit took the approach of simply setting up boot_command_line > from the MIPS code before early_init_dt_scan_chosen() runs, causing it > not to copy CONFIG_CMDLINE to boot_command_line if a chosen node with no > bootargs property is found. > > Unfortunately this is problematic for systems which do have a non-empty > bootargs property & CONFIG_CMDLINE_BOOL=y. There > early_init_dt_scan_chosen() will overwrite boot_command_line with the > arguments from DT, which means we lose those from CONFIG_CMDLINE > entirely. This breaks CONFIG_MIPS_CMDLINE_DTB_EXTEND. If we have > CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER or > CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND selected and the DT has a bootargs > property which we should ignore, it will instead be honoured breaking > those configurations too. > > Fix this by reverting commit 8ce355cf2e38 ("MIPS: Setup > boot_command_line before plat_mem_setup") to restore the former > behaviour, and fixing the CONFIG_CMDLINE duplication issue by instead > providing a no-op implementation of early_init_dt_fixup_cmdline_arch() > to prevent early_init_dt_scan_chosen() from using CONFIG_CMDLINE. Sorry I cannot test this patch ATM. I've simply CCed Paul C. just in case. > Signed-off-by: Paul Burton > Fixes: 8ce355cf2e38 ("MIPS: Setup boot_command_line before plat_mem_setup") > References: https://patchwork.linux-mips.org/patch/18804/ > Cc: Frank Rowand > Cc: Jaedon Shin > Cc: Mathieu Malaterre > Cc: Rob Herring > Cc: devicetree@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: linux-mips@linux-mips.org > Cc: stable@vger.kernel.org # v4.16+ > --- > arch/mips/kernel/setup.c | 47 +++++++++++++++++++++++----------------- > 1 file changed, 27 insertions(+), 20 deletions(-) > > diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c > index c71d1eb7da59..7f755bc8a91c 100644 > --- a/arch/mips/kernel/setup.c > +++ b/arch/mips/kernel/setup.c > @@ -841,11 +841,38 @@ static void __init request_crashkernel(struct resource *res) > #define BUILTIN_EXTEND_WITH_PROM \ > IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND) > > +void __init early_init_dt_fixup_cmdline_arch(char *data) > +{ > + /* > + * Do nothing - arch_mem_init() will assemble our command line below, > + * for both the DT & non-DT cases. > + */ > +} > + > static void __init arch_mem_init(char **cmdline_p) > { > struct memblock_region *reg; > extern void plat_mem_setup(void); > > + /* call board setup routine */ > + plat_mem_setup(); > + > + /* > + * Make sure all kernel memory is in the maps. The "UP" and > + * "DOWN" are opposite for initdata since if it crosses over > + * into another memory section you don't want that to be > + * freed when the initdata is freed. > + */ > + arch_mem_addpart(PFN_DOWN(__pa_symbol(&_text)) << PAGE_SHIFT, > + PFN_UP(__pa_symbol(&_edata)) << PAGE_SHIFT, > + BOOT_MEM_RAM); > + arch_mem_addpart(PFN_UP(__pa_symbol(&__init_begin)) << PAGE_SHIFT, > + PFN_DOWN(__pa_symbol(&__init_end)) << PAGE_SHIFT, > + BOOT_MEM_INIT_RAM); > + > + pr_info("Determined physical RAM map:\n"); > + print_memory_map(); > + > #if defined(CONFIG_CMDLINE_BOOL) && defined(CONFIG_CMDLINE_OVERRIDE) > strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); > #else > @@ -873,26 +900,6 @@ static void __init arch_mem_init(char **cmdline_p) > } > #endif > #endif > - > - /* call board setup routine */ > - plat_mem_setup(); > - > - /* > - * Make sure all kernel memory is in the maps. The "UP" and > - * "DOWN" are opposite for initdata since if it crosses over > - * into another memory section you don't want that to be > - * freed when the initdata is freed. > - */ > - arch_mem_addpart(PFN_DOWN(__pa_symbol(&_text)) << PAGE_SHIFT, > - PFN_UP(__pa_symbol(&_edata)) << PAGE_SHIFT, > - BOOT_MEM_RAM); > - arch_mem_addpart(PFN_UP(__pa_symbol(&__init_begin)) << PAGE_SHIFT, > - PFN_DOWN(__pa_symbol(&__init_end)) << PAGE_SHIFT, > - BOOT_MEM_INIT_RAM); > - > - pr_info("Determined physical RAM map:\n"); > - print_memory_map(); > - > strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); > > *cmdline_p = command_line; > -- > 2.18.0 >