From patchwork Mon Apr 6 20:44:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1267079 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=Fsd0JKdn; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48x2pM3ZLJz9sP7 for ; Tue, 7 Apr 2020 06:54:19 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A087804EC; Mon, 6 Apr 2020 22:54:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="Fsd0JKdn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C682E8006B; Mon, 6 Apr 2020 22:54:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6651F8006B for ; Mon, 6 Apr 2020 22:50:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=prvs=358c7da5f=atish.patra@wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1586206209; x=1617742209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aonlAe/N6GO4uq9tk1rExu0UhHEHPUEYSaikCM6sz5M=; b=Fsd0JKdnsIsEH5qVkLOALRBYU+3DhGhBgeVi3DJu//gCP1WJydIjXlFW +ztCFLLOtwy4e2NYg97gGOwlQWWsWttLKJNQjp96cPfDutsX7RhPLtUL/ bMCm2IV5smo7bYSJbhf8AcyEMBOQ30C6wNcQmuyOr34cXtnFeqaPwagXI z1d/z07ZpATRfM3LkVRoLbQjk7bmg8YmOdbl+i8RAIifo/oeK+fBafnq7 EdnlQOxzFE1CQG0qbMsS27v13C9lPilG8O0c2NWV/dO7Z4+NECdCN1+UW zs0ZbUlAR/uU61g+HufYbElKIJaRXm2BxKbLMN4qURQ47x0fyanRSlfqf Q==; IronPort-SDR: hoCozkXAs6jk4Oi3pl+0MXJCqQnTEoDULbWI7xjGNXWVn4zZaIfP6R0evxORAXHLQEtQmTHWST W5kFII6uq0WModby26cFxZbPdnaPrAiRp2LqDFz/rb1J59kaec1YtXEOYZg+fLU7RBzIxiqOZu urlRWbUM9mq3ivoXUCmqN41mOyiueZBRhkPM4ijVB6xM58rFXWrspSBBs6k2DRE1J2tfk3RtKc qyTwkdc1p5S94usroDLF0RDK2AaRXu0XvgQWaRb29qvbrX6kM/7mWrgHJsErmp98uRm/6VhRVg P7g= X-IronPort-AV: E=Sophos;i="5.72,352,1580745600"; d="scan'208";a="136167702" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 07 Apr 2020 04:44:59 +0800 IronPort-SDR: vMkpSMLmlGpSsC7WNQojtKBFPqC7WZFwtndH1/ECQxrrVIKRSmxwo91aKzT4G+XazQWyphyGWg pBlgfqSDBga0z189Kr4zPerrsgMkYx/uF8IN2Tj+BsL2QVT+CsQXkxlVQ6k6KXutneBbe/UcX0 Gr5DZ8KVqpPesIQYvwTI8KWVgpFk3s1FUoeXt1utYlRlhtADn7luuFDQBJG78p2RUSo7DNPIPR ivALFyStG/J30Fd3Cd+ImXXDbQ51/naoRByUbEIyYVssdtjGHoH6ZJe1BRzaI+5YtxZsPM5Q7A aPLETFViQwTxB8gbOAlb3gme Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2020 13:36:16 -0700 IronPort-SDR: hlzXGdewrdusWh7vvuJZfIfXK6u88NkGbgjNJvUa7ONhqxQ4Qm5LVM3lf12mhrp9Ac4hBuCrH5 ZLQY6jFQu+EkGiRlRLLFQzYypCuNfCX2J95fIeBnwjWcZHbKDhedQaEB/jurQC1XCN/BaGTyZO UIrRcsoB4Ae6/T94LF/5ceVm2zsU5mWERUgLKyvYnj5GMjTZs9UNu5c98OXB5nDvLSQSygP2IW 9g+WaY+Sy+B/IiURnRvP6p24DAL+FEmn6gH2rlv59dwmPe4flp2tBD8pzd5tUAYHgeYzc341TP w2Q= WDCIronportException: Internal Received: from thd007499.ad.shared (HELO yoda.hgst.com) ([10.86.55.81]) by uls-op-cesaip01.wdc.com with ESMTP; 06 Apr 2020 13:44:58 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Anup Patel , Bin Meng , Lukas Auer , Heinrich Schuchardt , agraf@csgraf.de, ard.biesheuvel@linaro.org, Marcus Comstedt , Paul Walmsley , Rick Chen , palmer@dabbelt.com Subject: [PATCH v5 3/6] riscv: Provide a mechanism to fix DT for reserved memory Date: Mon, 6 Apr 2020 13:44:50 -0700 Message-Id: <20200406204453.231945-4-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200406204453.231945-1-atish.patra@wdc.com> References: <20200406204453.231945-1-atish.patra@wdc.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean In RISC-V, M-mode software can reserve physical memory regions by setting appropriate physical memory protection (PMP) csr. As the PMP csr are accessible only in M-mode, S-mode U-Boot can not read this configuration directly. However, M-mode software can pass this information via reserved-memory node in device tree so that S-mode software can access this information. This patch provides a framework to copy to the reserved-memory node from one DT to another. This will be used to update the DT used by U-Boot and the DT passed to the next stage OS. Signed-off-by: Atish Patra --- arch/riscv/cpu/start.S | 1 + arch/riscv/include/asm/global_data.h | 1 + arch/riscv/include/asm/u-boot-riscv.h | 2 + arch/riscv/lib/Makefile | 1 + arch/riscv/lib/asm-offsets.c | 1 + arch/riscv/lib/fdt_fixup.c | 102 ++++++++++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 arch/riscv/lib/fdt_fixup.c diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index 6b3ff99c3882..0282685c2906 100644 --- a/arch/riscv/cpu/start.S +++ b/arch/riscv/cpu/start.S @@ -121,6 +121,7 @@ call_board_init_f_0: jal board_init_f_init_reserve + SREG s1, GD_FIRMWARE_FDT_ADDR(gp) /* save the boot hart id to global_data */ SREG tp, GD_BOOT_HART(gp) diff --git a/arch/riscv/include/asm/global_data.h b/arch/riscv/include/asm/global_data.h index b74bd7e738bb..51ac8d1c98e2 100644 --- a/arch/riscv/include/asm/global_data.h +++ b/arch/riscv/include/asm/global_data.h @@ -15,6 +15,7 @@ /* Architecture-specific global data */ struct arch_global_data { long boot_hart; /* boot hart id */ + phys_addr_t firmware_fdt_addr; #ifdef CONFIG_SIFIVE_CLINT void __iomem *clint; /* clint base address */ #endif diff --git a/arch/riscv/include/asm/u-boot-riscv.h b/arch/riscv/include/asm/u-boot-riscv.h index 49febd588102..543a1688db8f 100644 --- a/arch/riscv/include/asm/u-boot-riscv.h +++ b/arch/riscv/include/asm/u-boot-riscv.h @@ -17,5 +17,7 @@ int cleanup_before_linux(void); /* board/.../... */ int board_init(void); void board_quiesce_devices(void); +int riscv_board_reserved_mem_fixup(void *fdt); +int riscv_fdt_copy_resv_mem_node(const void *src_fdt, void *dest_fdt); #endif /* _U_BOOT_RISCV_H_ */ diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index adadbf4bcbef..d132b59ce32c 100644 --- a/arch/riscv/lib/Makefile +++ b/arch/riscv/lib/Makefile @@ -24,6 +24,7 @@ obj-y += reset.o obj-y += setjmp.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SPL_BUILD) += spl.o +obj-y += fdt_fixup.o # For building EFI apps CFLAGS_$(EFI_CRT0) := $(CFLAGS_EFI) diff --git a/arch/riscv/lib/asm-offsets.c b/arch/riscv/lib/asm-offsets.c index 4fa4fd371473..7301c1b98e23 100644 --- a/arch/riscv/lib/asm-offsets.c +++ b/arch/riscv/lib/asm-offsets.c @@ -14,6 +14,7 @@ int main(void) { DEFINE(GD_BOOT_HART, offsetof(gd_t, arch.boot_hart)); + DEFINE(GD_FIRMWARE_FDT_ADDR, offsetof(gd_t, arch.firmware_fdt_addr)); #ifndef CONFIG_XIP DEFINE(GD_AVAILABLE_HARTS, offsetof(gd_t, arch.available_harts)); #endif diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c new file mode 100644 index 000000000000..1fce41490973 --- /dev/null +++ b/arch/riscv/lib/fdt_fixup.c @@ -0,0 +1,102 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Western Digital Corporation or its affiliates + * + */ + +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/** + * riscv_fdt_copy_resv_mem_node() - Copy reserve memory node entry + * @src: Pointer to the source device tree from which reserved memory node + * needs to be copied. + * @dst: Pointer to the destination device tree to which reserved memory node + * needs to be copied. + * + * Return: 0 on success or if source doesn't have reserved memory node. + * Error if copy process failed. + */ +int riscv_fdt_copy_resv_mem_node(const void *src, void *dst) +{ + u32 phandle; + struct fdt_memory pmp_mem; + fdt_addr_t addr; + fdt_size_t size; + int offset, node, err, rmem_offset; + bool nomap = true; + char basename[32] = {0}; + int bname_len; + int max_len = sizeof(basename); + const char *name; + char *temp; + + offset = fdt_path_offset(src, "/reserved-memory"); + if (offset < 0) { + printf("No reserved memory region found in source FDT\n"); + return 0; + } + + fdt_for_each_subnode(node, src, offset) { + name = fdt_get_name(src, node, NULL); + + addr = fdtdec_get_addr_size_auto_noparent(src, node, + "reg", 0, &size, + false); + if (addr == FDT_ADDR_T_NONE) { + debug("failed to read address/size for %s\n", name); + continue; + } + strncpy(basename, name, max_len); + temp = strchr(basename, '@'); + if (temp) { + bname_len = strnlen(basename, max_len) - strnlen(temp, + max_len); + *(basename + bname_len) = '\0'; + } + pmp_mem.start = addr; + pmp_mem.end = addr + size - 1; + err = fdtdec_add_reserved_memory(dst, basename, &pmp_mem, + &phandle); + if (err < 0) { + printf("failed to add reserved memory: %d\n", err); + return err; + } + if (!fdt_getprop(src, node, "no-map", NULL)) + nomap = false; + if (nomap) { + rmem_offset = fdt_node_offset_by_phandle(dst, phandle); + fdt_setprop_empty(dst, rmem_offset, "no-map"); + } + } + + return 0; +} + +/** + * riscv_board_reserved_mem_fixup() - Fix up reserved memory node for a board + * @fdt: Pointer to the device tree in which reserved memory node needs to be + * added. + * + * In RISC-V, any board compiled with OF_SEPARATE needs to copy the reserved + * memory node from the device tree provided by the firmware to the device tree + * used by U-Boot. This is a common function that individual board fixup + * functions can invoke. + * + * Return: 0 on success or error otherwise. + */ +int riscv_board_reserved_mem_fixup(void *fdt) +{ + int err; + void *src_fdt_addr; + + src_fdt_addr = map_sysmem(gd->arch.firmware_fdt_addr, 0); + err = riscv_fdt_copy_resv_mem_node(src_fdt_addr, fdt); + if (err < 0) + return err; + + return 0; +} From patchwork Mon Apr 6 20:44:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1267080 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=hB0yfLwG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48x2pl4XYZz9sP7 for ; Tue, 7 Apr 2020 06:54:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3921A812C4; Mon, 6 Apr 2020 22:54:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="hB0yfLwG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 571D181577; Mon, 6 Apr 2020 22:54:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 96C528006D for ; Mon, 6 Apr 2020 22:50:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=prvs=358c7da5f=atish.patra@wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1586206210; x=1617742210; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=15wEaSM5+aJTlTiM9DMRllUUNc6sZN1168dhM8zY40U=; b=hB0yfLwGCyQhtRWt96A5wDFd+wq5GtN2AVissDSh2iTxdW9wRJUHNv0l ef+NPEuoqgJv/etsjjpxgBOD9g38phAH94YYtQ45GO1x500Xd060RmOp7 8AJcyaosv/EU3uru4jTAsAPj+0kp59K8tqn++HTsLZj3LpHW0qZzMvUTx 1UbjpZM68CPLIgFtgBwqmt1Oeci/BShHmlxjGk9MK+shpFJ81kEFqpugO d211cNbDdsu/2V9qMjn//4YSVd9oh5BbNtMnfYsv8GabJ9mrLTEe2YQOT Ioe7V4suO8Ggro+PPIRNT7gijQVo41qB96WWJ/xoawUQw04gzv1lmMRZc Q==; IronPort-SDR: UD7NONT0QoC9QX4hpbU9KF20BKD4VcA5IUKHihThnPoQxdhwfUJZYpmUtJcolRtbQHXXq9DlMv 7zPlRiqfot5YSGUdQefnks2tF8Av+Si0uPHZfB+n+Dq2wf6SNfCT7M5IG1Y8V9Lu5KS9KW80O1 3dAM/6B3MYyfYTW3FMdisA6rBM469YN4URCBuY7o8YfhxIzUCK9fgs989+l5glUUvugknYs+Va +6MSfYorREf28tU2kfnSw2uEFS/A3yqHrZV3oDPlrLJaQdaDt78JWThg9Unh51tJciIyP8kJmn 3sw= X-IronPort-AV: E=Sophos;i="5.72,352,1580745600"; d="scan'208";a="136167708" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 07 Apr 2020 04:45:00 +0800 IronPort-SDR: pvxRrue3RhDZ8kMv/SmY7MoinpAvwME/rPmusJdcu77dP+ggR2dfNurd98MpW2PJKnsUaWJBya V70tajKFO4PBRyX8RUR/UMuEzd30EZOrpKFljEqa0FNUgjsA/as0wP/6NhYhMqNqLxE5ip8frW NQ0tzFJJh0u/8+10SREiFh6/hftP9aXUV3c3Q1ousVfvdIPVU8dq2NGXrutJjw310w5yrBR/4Q NBQIocGYOeE9OI8xOO3O68WKJOQtzYg5+H7L2/L0ahSqMkcrndPFydzXIY8BpvRAlg2Yh0pdeX QU2mCPVgo8UNZVYTmqLVcDda Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2020 13:36:17 -0700 IronPort-SDR: XAaT36TQZBScQmv3jq7Bdk8ebtYjLSHVGyb/v3fyCAPsSz1FtyMSLkfi6fko/+GG3hF++FomqG DVU8vpWRgYPifA15Nb5sg92PVPD/6zEvxexQvYLfmyqf/mcauLT8dq2j02/Pq3FV+6C/cyvZuS DJ+6EY2wtlI2kDRB8/VJ+DNA7cG+0XYpa8dEyUO/dubIyO2O3IZand7bSdgcr0MP+V6Ef4dbbl 88/CFWCR6BeW/KHQ3WckOwA1kIHP2JviH04bvTp4TTlz9k+4mDPPSD5Z6RXC9YDTdWHYcpSkAL mFM= WDCIronportException: Internal Received: from thd007499.ad.shared (HELO yoda.hgst.com) ([10.86.55.81]) by uls-op-cesaip01.wdc.com with ESMTP; 06 Apr 2020 13:44:59 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Bin Meng , Anup Patel , Lukas Auer , Heinrich Schuchardt , agraf@csgraf.de, ard.biesheuvel@linaro.org, Marcus Comstedt , Paul Walmsley , Rick Chen , palmer@dabbelt.com Subject: [PATCH v5 5/6] riscv: Copy the reserved-memory nodes to final DT Date: Mon, 6 Apr 2020 13:44:52 -0700 Message-Id: <20200406204453.231945-6-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200406204453.231945-1-atish.patra@wdc.com> References: <20200406204453.231945-1-atish.patra@wdc.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean The DT used by U-Boot may be different from the DT being passed to the OS if the DT is loaded from external media such as network or mmc. In that case, the reserved-memory node needs to be copied to the DT passed to the OS. Signed-off-by: Atish Patra Reviewed-by: Bin Meng --- arch/riscv/lib/bootm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index 87cadad5016d..8ff8db6bf533 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -28,8 +28,8 @@ __weak void board_quiesce_devices(void) int arch_fixup_fdt(void *blob) { -#ifdef CONFIG_EFI_LOADER int err; +#ifdef CONFIG_EFI_LOADER u32 size; int chosen_offset; @@ -50,6 +50,12 @@ int arch_fixup_fdt(void *blob) /* Overwrite the boot-hartid as U-Boot is the last stage BL */ fdt_setprop_u32(blob, chosen_offset, "boot-hartid", gd->arch.boot_hart); #endif + + /* Copy the reserved-memory node to the DT used by OS */ + err = riscv_fdt_copy_resv_mem_node(gd->fdt_blob, blob); + if (err < 0) + return err; + return 0; } From patchwork Mon Apr 6 20:44:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1267081 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=AAJgxekA; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48x2tq1sRjz9sP7 for ; Tue, 7 Apr 2020 06:58:11 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C29738006D; Mon, 6 Apr 2020 22:58:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="AAJgxekA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 330A58006D; Mon, 6 Apr 2020 22:58:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8206580199 for ; Mon, 6 Apr 2020 22:54:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=prvs=358c7da5f=atish.patra@wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1586206448; x=1617742448; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z8CGjJF2UQihHs927Igkajd9xRVmjHuVwfs+ZEExYjM=; b=AAJgxekAF8Rg+0FFw8BywuozJrG9lEVCg89E2bzKsoVrEpG6Q7pGEBDc QCxktL8ue1a9uuktw6DyvbfPSxYaBwKRMgSATV2Lmv0T8DK5f34JdEzsC DCRP7H6Ky1wdic82FN8CQ0jEM5SyUuZsXAgFMvbTWdAzEIFrulRQ7QiV1 BLMGXv3hZUBP5nuame9nsiivxOpj69/WK7LikSTb2srjlGs/r0vllIncD yaSHqMApTnpMO/0XWhSHprxpbkDNupjnSauOYUQDd95aqjieRZK9NhAYQ 71T5ZCil5BT5t02AmD688yftaEmN2eHqVxzMXRb8/06YWdHN2unTc5L2m w==; IronPort-SDR: HOFFi5mCOQFsurcUDsd3sie5FuMXC8R/jeMN3D82+z8YOJO3O3x24pjclu3ZI/YO70pxBXTYa2 p/JHmskzFhjWz3e9lyEVZkwZb84HE+3AYjhN9M7IGDv4fJ+1jRfXf3upMjHBo8muE2yxKorC+x Fmre0VMvabj/vrrSiL2QZMZ+DsIc9UfSPm83n51gR49shR9XlmtbzNCTxiRDKYcYz3/duNZ0tR uD8WxDeFtTpflLs/ZKw9SQKgvjjZCx2oyLt211ZE/wH4uwdVFPmFiQUi8YzoeeiytfCupuOsyr laE= X-IronPort-AV: E=Sophos;i="5.72,352,1580745600"; d="scan'208";a="136167715" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 07 Apr 2020 04:45:00 +0800 IronPort-SDR: GVwzMmR9iVSa1pUYpnHC5vDy5Evm9OsvNU46GsIvhZrJHM+iF7sF+DGS5Nv+SiS1ybc5JSRPok cEQ+HNtOiCVOtiuSEvS5MeaMTykjnsjV0BFtWNPfWJ7flx7y50Us3HXFuXKAfyORyYcK3V7LOj xWi9PiAMikZknbfxilFUusAo7JEUVeHwFwO+C+4Hsl9C525seurhTmzS/3MgSfBMLlSIYJ09PR zMULiH9OqSJ01sz3ABcIiWyYqemQ3feP59fTzeJVzj61JM234GlLRp1bLwxComGjuQFd/if5i8 7ZJg4TniL4Kkh+DC9RxTDwAv Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2020 13:36:17 -0700 IronPort-SDR: FX2hp2kJGLi6FatSzd8F0qIIio1FbwlVYtHPk42tIHaJPLrSjWquavy444N+iX30eiMrsOwNQ8 aKJQhyIZmmn6V+Pf2JHKQ9U6dfFRLxD5oGVWzxhlW4EozW5CaqCl9JfLlDDBR57N8mcZQ9hSTg e/gGLLqTfiJaRE7+xEscyPDeOYe3BbHQoH1Kf1LXvrM/IDm5UtlJgKEps2nA/aFb0PQel/XJ83 MolzWBaq1Lu+Bm2YjWUwsORB46wA2hYJ4Am3fe1Sx4w/jAB3O/aNU/fgHU9hajjSpPRjycc8ay rRU= WDCIronportException: Internal Received: from thd007499.ad.shared (HELO yoda.hgst.com) ([10.86.55.81]) by uls-op-cesaip01.wdc.com with ESMTP; 06 Apr 2020 13:45:00 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Bin Meng , Anup Patel , Lukas Auer , Heinrich Schuchardt , agraf@csgraf.de, ard.biesheuvel@linaro.org, Marcus Comstedt , Paul Walmsley , Rick Chen , palmer@dabbelt.com Subject: [PATCH v5 6/6] riscv: Move all fdt fixups together Date: Mon, 6 Apr 2020 13:44:53 -0700 Message-Id: <20200406204453.231945-7-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200406204453.231945-1-atish.patra@wdc.com> References: <20200406204453.231945-1-atish.patra@wdc.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Keep all the fdt fixups together for better code management. Signed-off-by: Atish Patra Reviewed-by: Bin Meng --- arch/riscv/lib/bootm.c | 33 --------------------------------- arch/riscv/lib/fdt_fixup.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index 8ff8db6bf533..0d06095da11a 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -26,39 +26,6 @@ __weak void board_quiesce_devices(void) { } -int arch_fixup_fdt(void *blob) -{ - int err; -#ifdef CONFIG_EFI_LOADER - u32 size; - int chosen_offset; - - size = fdt_totalsize(blob); - err = fdt_open_into(blob, blob, size + 32); - if (err < 0) { - printf("Device Tree can't be expanded to accommodate new node"); - return err; - } - chosen_offset = fdt_path_offset(blob, "/chosen"); - if (chosen_offset < 0) { - err = fdt_add_subnode(blob, 0, "chosen"); - if (err < 0) { - printf("chosen node can not be added\n"); - return err; - } - } - /* Overwrite the boot-hartid as U-Boot is the last stage BL */ - fdt_setprop_u32(blob, chosen_offset, "boot-hartid", gd->arch.boot_hart); -#endif - - /* Copy the reserved-memory node to the DT used by OS */ - err = riscv_fdt_copy_resv_mem_node(gd->fdt_blob, blob); - if (err < 0) - return err; - - return 0; -} - /** * announce_and_cleanup() - Print message and prepare for kernel boot * diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c index af12e484db9b..20e0759f135b 100644 --- a/arch/riscv/lib/fdt_fixup.c +++ b/arch/riscv/lib/fdt_fixup.c @@ -115,3 +115,36 @@ int board_fix_fdt(void *fdt) return 0; } #endif + +int arch_fixup_fdt(void *blob) +{ + int err; +#ifdef CONFIG_EFI_LOADER + u32 size; + int chosen_offset; + + size = fdt_totalsize(blob); + err = fdt_open_into(blob, blob, size + 32); + if (err < 0) { + printf("Device Tree can't be expanded to accommodate new node"); + return err; + } + chosen_offset = fdt_path_offset(blob, "/chosen"); + if (chosen_offset < 0) { + err = fdt_add_subnode(blob, 0, "chosen"); + if (err < 0) { + printf("chosen node can not be added\n"); + return err; + } + } + /* Overwrite the boot-hartid as U-Boot is the last stage BL */ + fdt_setprop_u32(blob, chosen_offset, "boot-hartid", gd->arch.boot_hart); +#endif + + /* Copy the reserved-memory node to the DT used by OS */ + err = riscv_fdt_copy_resv_mem_node(gd->fdt_blob, blob); + if (err < 0) + return err; + + return 0; +}