Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9185728pxu; Mon, 28 Dec 2020 08:43:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJ1LOpVlraAYcBjxN2UX75H/Ji2GaxoYDKxBoeUphFOxw81zanSCa0/94OX7D9sn2LWi/y X-Received: by 2002:a17:906:e212:: with SMTP id gf18mr43005496ejb.551.1609173824453; Mon, 28 Dec 2020 08:43:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173824; cv=none; d=google.com; s=arc-20160816; b=BqZDQO1yLUeAe6dMNBNqcw1EH1ATdmvaAk15QT5yovhtxwrvIucrXMroHSWI34MBNF 5AMxS7m7fLSf8Tk79AFj8yzO6RvAzttM86bm1s39L9Fl32tuFbuZBLs14iKwZ7OfD0/i 7WFbYHb0fIPo0yTUF1DgkW5JAxGOr0lFxMQ5EhpiwCxXAWjR/oEMrrYWQAMp2fTYkxCi Te+eRg7uXHPkUpMoIlEVrPXMbA5iinnEbFXr0yuKZXbRROoDwekaFIC4RkmDL56BbZGN zazlYvJv2fVVW7GXntRM3yu4C8KAUvM4kXC/TtDFSD3piSf4IxRyCUpccRVoCK34yQPX +k0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=l6SS1scNjE1vPCP4wCk2BIZ3zGkp8hqDahwS2HOGBHc=; b=N9FazKUoAB7KtrqIc+nwv8FEYeqlSNFocVBvAe/dPUYUB2B30b9QNO6ZyQCvOcqZLh yqgpRYKrKvyh758Gt0bB7DWfjpE3hnw4IuRq1+4q+A/OrFjYpiBe4GBNntrJHaNUjp6q /+fcthc1lbalEziHGVXIL/4FKSpVZvhitOoScBOLRYNOv3Dfi4TPi/hofqf7s7mGf+uc iq51xLP8uTch5p8fuOmX3MI30P3EyQm1ognHCyn2wyNkI+kDptYcc/K/GqkUqSGqc1zB RZcDNdUO4Det5aJiYa6SU6OHR14eAZdplnHeSb6W6qRUI8KwWX/syk/cbB6n5H4IP6e5 kqvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@konsulko.com header.s=google header.b=cI8VJXC1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id no7si18412313ejb.586.2020.12.28.08.43.21; Mon, 28 Dec 2020 08:43:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@konsulko.com header.s=google header.b=cI8VJXC1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2633793AbgL1Qjg (ORCPT + 99 others); Mon, 28 Dec 2020 11:39:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729444AbgL1Qjb (ORCPT ); Mon, 28 Dec 2020 11:39:31 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C5BFC0613D6 for ; Mon, 28 Dec 2020 08:38:51 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id a12so25107864lfl.6 for ; Mon, 28 Dec 2020 08:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l6SS1scNjE1vPCP4wCk2BIZ3zGkp8hqDahwS2HOGBHc=; b=cI8VJXC1C/bDkRCEq7hbWM0zAjKz9rkUJwyt//MfgJsGxs31rPM8LDXwxR7+KO7bZT Sxb4blwNTPzKpjcqaNAiCVXhq2o0SvFVBjbCCU2lVaeH0O4FWkBotHzFUWtDYXUcuwZe tm6SULa0zv72CxkoEwKgqwMYW3JZAKNRWBBIY= 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=l6SS1scNjE1vPCP4wCk2BIZ3zGkp8hqDahwS2HOGBHc=; b=FNWQZiITwZsX/8po/Y9lz6WnrD3iB60DGBtbB0xWMrlsFisTQ9DS5aI8ErsvZ8VIl3 qLj88Sc+G1+ragZs/yS4US2mlOTEKKSvUAR1EQNdzfKF7w3MoNWkZZJVeRwT3E2ZP3Bn fIWw2nLGHjPSoB8sq9iG7HTl33aBP1Lys/wla5eO+E7eZjJAJ01H0LVNJwou4k0A3Szl ZZgbHHDY1WydVDurHlMUnNRijejrVxXbh+/PmUrimQSpbdbMC+bqGzCRGxIjs14NO6p4 yXoLLg6kVN7PeCs5y2/z5crDY5ACBKQAPqn5Yy2MQ/cvwtqSHlKM8kitE0vk1ggnMBSU LhjA== X-Gm-Message-State: AOAM5300G2zIuWbw5H39wWRlOOR2BbmBbsn56pj3sxISZbaiZjrwZxEN zATdhT26KAaKv/meGPkPXVd5l5OwY3VyqwbDsC8ZOg== X-Received: by 2002:ac2:5edb:: with SMTP id d27mr18240410lfq.411.1609173529728; Mon, 28 Dec 2020 08:38:49 -0800 (PST) MIME-Version: 1.0 References: <20201226163037.43691-1-vitaly.wool@konsulko.com> In-Reply-To: From: Vitaly Wool Date: Mon, 28 Dec 2020 17:38:38 +0100 Message-ID: Subject: Re: [PATCH] riscv: add BUILTIN_DTB support for MMU-enabled targets To: Anup Patel Cc: linux-riscv , "linux-kernel@vger.kernel.org List" , Bin Meng , Palmer Dabbelt , Damien Le Moal , devicetree@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 28, 2020 at 3:10 PM Anup Patel wrote: > > On Mon, Dec 28, 2020 at 7:05 PM Vitaly Wool wrote: > > > > On Mon, Dec 28, 2020 at 12:59 PM Anup Patel wrote: > > > > > > On Sat, Dec 26, 2020 at 10:03 PM Vitaly Wool wrote: > > > > > > > > Sometimes, especially in a production system we may not want to > > > > use a "smart bootloader" like u-boot to load kernel, ramdisk and > > > > device tree from a filesystem on eMMC, but rather load the kernel > > > > from a NAND partition and just run it as soon as we can, and in > > > > this case it is convenient to have device tree compiled into the > > > > kernel binary. Since this case is not limited to MMU-less systems, > > > > let's support it for these which have MMU enabled too. > > > > > > > > Signed-off-by: Vitaly Wool > > > > --- > > > > arch/riscv/Kconfig | 1 - > > > > arch/riscv/mm/init.c | 12 ++++++++++-- > > > > 2 files changed, 10 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > > > index 2b41f6d8e458..9464b4e3a71a 100644 > > > > --- a/arch/riscv/Kconfig > > > > +++ b/arch/riscv/Kconfig > > > > @@ -419,7 +419,6 @@ endmenu > > > > > > > > config BUILTIN_DTB > > > > def_bool n > > > > - depends on RISCV_M_MODE > > > > depends on OF > > > > > > > > menu "Power management options" > > > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > > > > index 87c305c566ac..5d1c7a3ec01c 100644 > > > > --- a/arch/riscv/mm/init.c > > > > +++ b/arch/riscv/mm/init.c > > > > @@ -194,12 +194,20 @@ void __init setup_bootmem(void) > > > > setup_initrd(); > > > > #endif /* CONFIG_BLK_DEV_INITRD */ > > > > > > > > + /* > > > > + * If DTB is built in, no need to reserve its memblock. > > > > + * OTOH, initial_boot_params has to be set to properly copy DTB > > > > + * before unflattening later on. > > > > + */ > > > > + if (IS_ENABLED(CONFIG_BUILTIN_DTB)) > > > > + initial_boot_params = __va(dtb_early_pa); > > > > > > Don't assign initial_boot_params directly here because the > > > early_init_dt_scan() will do it. > > > > early_init_dt_scan will set initial_boot_params to dtb_early_va from > > the early mapping which will be gone by the time > > unflatten_and_copy_device_tree() is called. > > That's why we are doing early_init_dt_verify() again for the MMU-enabled > case which already takes care of your concern. I might be out in the woods here but... Do you mean the call to early_init_dt_verify() in setup_arch() which is compiled out completely in the CONFIG_BUILTIN_DTB case? Or is there any other call that I'm overlooking? Best regards, Vitaly > We use early_init_dt_verify() like most architectures to set the initial DTB. > > > > > > The setup_vm() is supposed to setup dtb_early_va and dtb_early_pa > > > for MMU-enabled case so please add a "#ifdef" over there for the > > > built-in DTB case. > > > > > > > + else > > > > + memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); > > > > + > > > > /* > > > > * Avoid using early_init_fdt_reserve_self() since __pa() does > > > > * not work for DTB pointers that are fixmap addresses > > > > */ > > > > > > This comment needs to be updated and moved along the memblock_reserve() > > > statement. > > > > > > > - memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); > > > > - > > > > early_init_fdt_scan_reserved_mem(); > > > > dma_contiguous_reserve(dma32_phys_limit); > > > > memblock_allow_resize(); > > > > -- > > > > 2.29.2 > > > > > > > > > > This patch should be based upon Damiens builtin DTB patch. > > > Refer, https://www.spinics.net/lists/linux-gpio/msg56616.html > > > > Thanks for the pointer, however I don't think our patches have > > intersections. Besides, Damien is dealing with the MMU-less case > > there. > > Damien's patch is also trying to move to use generic BUILTIN_DTB > support for the MMU-less case so it is similar work hence the chance > of patch conflict. > > Regards, > Anup