Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9114475pxu; Mon, 28 Dec 2020 07:01:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/H8OFIi4OtdcT9xkPQdRAVa1+kMiam+ck1V4eg5LFPWRSXeSmcBtGyqBllq2Y4Sx35b0N X-Received: by 2002:aa7:ca03:: with SMTP id y3mr43146893eds.87.1609167705973; Mon, 28 Dec 2020 07:01:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167705; cv=none; d=google.com; s=arc-20160816; b=NFnhag4OjAF+UlJqamTyXw3Ze6igPFYA8C80ESV2F/i35QMuIfQrV6oPli5Rfck8vX he2090oqxVhkEglvmHtkl/taT6L0r4Tg+Vix2XRwzxTwfTuny/EB85bBalK0qfGoxqKx yvugsiJmOmEBnH7yB8Ww/ZzsV7Oqd9NNy8/4nayp2QsHCqKsg8Y9sONPyClSatsEOMJ4 E4PT/jogE3i7dFoj2H8kMAaAmXTzypxMWFJoSYWg2CAeYSgCGRmBx2SJ94Tb2PIJ4IwJ tkKFPSR3GZjAuhwthAtwZke1dVwfHRE1KdhoM7hRcH8T37AOJZGsGLWI5HIGldCJv4aM wFdw== 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=NPeSW+R1SSfRx+04CRlDhpX7N3sgocK07oaNDyUcAtQ=; b=T0QW+2YJj8kn4CrFwGD+QMTGV70D8pflRKPNsUrklTH6TWZxqUCqm8iSlRC5yn6PmH K7feM9scikx5rOU3CLyCy80ezDtROvG/DPanBRUJmEaeiXnslJQBXl9FOlnrXN032QWf iI7pOt9+/3t2PRSbH6HPzkgipwNI722+tgCUwYFksWzzw7JFkSifv0lR8Qi4jW7jVaoC DLyjgc3LQCLD9yvVK4e7VOfFJtuOMMK7zsdOBMlsdY7DhTx5kRSyjg8cvnAi4Y/ODfOL o6W37g3L9kJzRUizQ5h/8F94gb+g1Flw4X4cckeXPjdVXsvHepT4ofD7Cfmjci+UMvZK dJ3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=ca8s8BXf; 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 g2si20915683edn.508.2020.12.28.07.01.23; Mon, 28 Dec 2020 07:01:45 -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=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=ca8s8BXf; 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 S2391774AbgL1O7C (ORCPT + 99 others); Mon, 28 Dec 2020 09:59:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440481AbgL1OOp (ORCPT ); Mon, 28 Dec 2020 09:14:45 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53B7FC061794 for ; Mon, 28 Dec 2020 06:14:05 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id h205so24142714lfd.5 for ; Mon, 28 Dec 2020 06:14:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NPeSW+R1SSfRx+04CRlDhpX7N3sgocK07oaNDyUcAtQ=; b=ca8s8BXf1hhY+CYTlYaY7cbOnbBLNRpJziaNgNL0O1DmVav7uY5DZU2FrvBAul3FPK qASLpWCCyZr9LhbzyJyL0w2jNgqhiCu7DzFiLXvv+70lS6bxurLywKj+A2S933Y09OIR kntxzCfNY2NlsQpftT/btNwnwCnQWF9KIY9dbib2K5X3Ll0lHqxXETqnUCW/U+Fh93zo il/p3u/GOX8kaoIqzEqV+5OycVEntz0Vc7SOeV0vXzya03eFYka/8dnE1D7k/Zgk8ZR9 g55hWD6PTSH11D9lCwPnoTp1QtW0Ks7lGV2ZF8eDa+m4YAOc/9tO9ABvEPrvio0PgqM5 G+0w== 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=NPeSW+R1SSfRx+04CRlDhpX7N3sgocK07oaNDyUcAtQ=; b=Hm2v++mGR0oFTc3Rrw6GWo0u6OAKjjpZLUmwUPsHgIRHoOd84xvy7BVOMF+I4zNPVb tvpk7eW0nm9KTDrst3Jst1De/BORWTJ1hgDDsdSGDQkE0IbGEnKal4XEGRB3lT5btxT9 RGEZCz2Zzt14jTJ6q+eIIxTcwNtcLf80Wh/MnITssXcV/GFlhqixXmsDkHN1967BWaM/ xI6A0TteG7twqyfb+/VKVK82hjqyqRyJ9Fc+g1whyK9qt+TyOScsxau4J7YaONvqFxLR Mve6Ak+gGfnpzsjdcgzGPOPPnlbtiNrr4vyKsg7szFzDFNuER/r/HIuhGr+scCRSjYQk lzPw== X-Gm-Message-State: AOAM532avxFf+I1Il4nrk+DOxM4keM0aIkFVQ0ABxFbEa7CNo8U+IajC 2eJCrHXBye+6KfdMYsi+B60vtZfKjfdRqxYVNplpHw== X-Received: by 2002:a05:651c:202:: with SMTP id y2mr21433617ljn.162.1609164843848; Mon, 28 Dec 2020 06:14:03 -0800 (PST) MIME-Version: 1.0 References: <20201226163037.43691-1-vitaly.wool@konsulko.com> In-Reply-To: From: Anup Patel Date: Mon, 28 Dec 2020 19:43:52 +0530 Message-ID: Subject: Re: [PATCH] riscv: add BUILTIN_DTB support for MMU-enabled targets To: Vitaly Wool 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 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. The throw-away early DTB mapping in early_pg_dir is anyway redundant when we have built-in DTB so this patch needs to add an "#ifdef" around it for the MMU-enabled case. Also, please update dtb_early_va and dtb_early_pa separately for MMU-enabled case in the setup_vm() > > > 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. > > Best regards, > Vitaly Regards, Anup