Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp7900713pxu; Sat, 26 Dec 2020 08:34:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyMIjhSfDE2kJ8Fjqmqqw1xdKDvEsIYS9DniKQzM9Fap3YG1p4EZ3razRfWhQmAqpY1Z/3 X-Received: by 2002:a17:906:d782:: with SMTP id pj2mr35894158ejb.387.1609000493306; Sat, 26 Dec 2020 08:34:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609000493; cv=none; d=google.com; s=arc-20160816; b=PH5LwPxaoDDxYnrM62JA0g4NzAw8SsHN732CSaAo3expNYsTQo6YGhKm77xM6nCMQk bD1GFbgSQGIkZFEm9x+QnxhZeyUZMBRIwxlRWiQsPKkALywhwnYc0jZKjKH/fXb6VFM0 LlL0ZjZ3YdkjHDE5BzZ01eftATDh6zduBnyBJExCuWjBI0oCByyQjE7Oo5tGj7qJkuEn b2SoYCjtPKyWRFRfnPu43lHhQ9fkmxxiHTn+/DC4EwGhxUwkjGsQ+4f6g+Mz1UZEDTKv HVlh/CTboP9vNtF65qMfv23BMrdtb1ZCVcoBGupUdE2XmZENInhAP4bkB9ugNNdwJO1V eXdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=gtpkeBVz5MREbJ4Hh4ldSey/zkGfhttgVGvyAUtLQ9o=; b=NhGZGYBOxCo6ABxWm4sFL3dasaEH/xmfMxhgzi3meI+dVqqNWqRqwR9ZVh1E0DBqly q7L2HKjsHOzPwr+zfiGDB5jULf7JWeoN3o72d8yYWKcmdtfyrqhONQpNlfgWtb1NyRMz nyboMTF/WpLmOQH20ZBODarLAzX5ERkYVK8VHc9tLtlVjhHRUMi09PxEohukmJcEy3PJ CRiy88qkdU6vjuJhPzdB3jYe3JLSyH4/K9HNyFK2v8iYuN51jCYOn49d8ldTh4OYdTfL adEbF12ZTm4Eo9yIYo9fLOvcj+I+9/779jEHhgpxoDsLQ3QXL8XxWS85iFXfvGqT64bq 9Ahw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@konsulko.com header.s=google header.b=nsK5M8nz; 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 cb16si15751177ejb.392.2020.12.26.08.34.30; Sat, 26 Dec 2020 08:34:53 -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=nsK5M8nz; 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 S1726260AbgLZQdv (ORCPT + 99 others); Sat, 26 Dec 2020 11:33:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbgLZQdu (ORCPT ); Sat, 26 Dec 2020 11:33:50 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26A22C0613C1 for ; Sat, 26 Dec 2020 08:33:10 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id c133so5670263wme.4 for ; Sat, 26 Dec 2020 08:33:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gtpkeBVz5MREbJ4Hh4ldSey/zkGfhttgVGvyAUtLQ9o=; b=nsK5M8nz/VjeGsXTO6OlT+E3dnqJjuzsIRdYtR6PlPUDqdCDN3yCv6jqWygj6PLHjE ZSALb7CkX5KZG8SOH52v2VLIZguJ50ITS96gTh77X0LJ7l+SWt/QbV8E63X2YnRgQSZE 6G5jvxVyoCUfMVlps4Y2zq3IDzS+1csIxUclM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gtpkeBVz5MREbJ4Hh4ldSey/zkGfhttgVGvyAUtLQ9o=; b=cfW4o526ihwfD60r+nln0HKWFv7G58sIXv0c+r2KDZgaDMuicW+nRe1OO7uduy0+Mk Xbk+CQovmSOBmN/JGnqMdTAgNq3SIu//1Ky2cLO64IuI/TzDG9nSEbSRNzG/trmo9WSB 6zVcEonRC8Zd1cOlEe5nrU9tqgaXyNH8mX/SRpGycpnTSNjAM48WaCPdxxD1U1rLy2qD MyWgXBfE/MUjFBYGeo2STHIZusMhL6FzQd/ApCwtEcnlr4Ov5fWg1+YzBd6JUHnPJawv 9N7h3lnGoLQ8PA6yPplU//wzuzEWohzCuVLdPgTzBvwmjQugV+wqmNztLpU6mBSETOZJ igYA== X-Gm-Message-State: AOAM533EZVRueBLZGBXhbS40WGpeHvgfZ2W/B7JjWCKnPNdZbHniuExs 15hP6UXkKnr/YYU/0QROqSYYhg== X-Received: by 2002:a1c:4b10:: with SMTP id y16mr13184416wma.73.1609000387485; Sat, 26 Dec 2020 08:33:07 -0800 (PST) Received: from lootbox.konsulko.bg (lan.nucleusys.com. [92.247.61.126]) by smtp.gmail.com with ESMTPSA id r20sm52270387wrg.66.2020.12.26.08.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Dec 2020 08:33:06 -0800 (PST) From: Vitaly Wool To: linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Bin Meng , Anup Patel , Palmer Dabbelt , damien.lemoal@wdc.com, devicetree@vger.kernel.org, Vitaly Wool Subject: [PATCH] riscv: add BUILTIN_DTB support for MMU-enabled targets Date: Sat, 26 Dec 2020 18:30:38 +0200 Message-Id: <20201226163037.43691-1-vitaly.wool@konsulko.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + 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 */ - 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