From patchwork Sat Dec 26 16:30:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Wool X-Patchwork-Id: 352569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92556C433DB for ; Sat, 26 Dec 2020 16:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F75F217A0 for ; Sat, 26 Dec 2020 16:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726185AbgLZQdv (ORCPT ); Sat, 26 Dec 2020 11:33:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbgLZQdu (ORCPT ); Sat, 26 Dec 2020 11:33:50 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F55AC061757 for ; Sat, 26 Dec 2020 08:33:10 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id a6so5668365wmc.2 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=ZLB+eXQ5piHJIM6ujPKAxlDuiXcNp2WWWB+2zVa10RRy4mRPBe5R3wPBd/Sl6qCni1 loLHKnYRRtEfLzrrL7QPeYbh4fLuTR7Zui6yY4O9Kklszk4BfNyopzpnc8f3VOuhRjzE bWTLje8/7PvZ5K3gpEMYV/LpoE8CRvL0bqk1hcJQ7JTknZNlafftfTr28+mJVxtnrEVm jEDTCeIyrV+Ufour2JibshUTuo7xg45z7w7Sp5EYnABaU0YPDkXNB6Xv4gHBuLjSe7vS BmekNntgDlat3PHIyQ7by3TOcKDyhdY4GT4mJn+L747bcyYBeeT/fX3Yof6BlwhhatU6 8lYw== X-Gm-Message-State: AOAM531Qwxe60ti10zKeYiz4fLDQyExaiSrd0KeX/F1sbppBaKH1uZPS P20OskP/YgaR3bWIqROttHSh4vKmU36/GqDf X-Google-Smtp-Source: ABdhPJwj20fCyOf4J8xCHJKDZdEjK/pMUpvZ5ueQPVxSkNMqC94ou5zgiSv6fCXwp7uWbqaG0FsL1A== 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 Precedence: bulk List-ID: X-Mailing-List: devicetree@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();