From patchwork Tue Mar 17 21:19:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1256965 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=By968chO; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48hmKr5jHkz9sPF for ; Wed, 18 Mar 2020 08:20:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2684812D3; Tue, 17 Mar 2020 22:20:16 +0100 (CET) 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="By968chO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DE14181528; Tue, 17 Mar 2020 22:20:12 +0100 (CET) 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 esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (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 31EEE80721 for ; Tue, 17 Mar 2020 22:20:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=3382782c6=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=1584480007; x=1616016007; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aGRwAHLabl4ETDwU1f15Gse6/o8sYxXuAnbohjK+WzA=; b=By968chOCzvWoOm9xweGJ1JnrxtP6tRvyhcZNOCZf+9XA2COAOJyT+f2 alJz4UIegCRaumP0MT1JRDQ3UhapjCqRXMBpsKSSP9UHHnuAeaOg8puy6 uD6OHu9MkY/9B+isaM3TKliMbivqDRC6pO1Od3F1WorpMCYAcUxD3IiZ5 Ah//f+nh3ydpoA63YGPzVKjehIKGWKKwZwDTnFtJn0rCchoxeCwjQ06rc XzbZRzaYMcjP40sj3L8zpD3be3ootEEL3YLudgX/VmMNO7oJ9t02C+cpC iQ+pyJgIzsk+c0y6HOXKqBg12ts7TklcHSS7bgvClynlLIRci9xfsn+Bd w==; IronPort-SDR: scVauOP9BS5Uq6o1YVqMJzGP9IheGFqtsLbsAj+J3skbFtSXREdqVhY6eRHuiq3dk0wUM0udrp GSEWfemBeQ9ASnQa1dKgop1m41WHXB4t5QeJguN5rMe9wyZ16o4UCHWQM668Ku0KsPN2HuqZza sLQnUOZz8CD5Fztv/weuqTuzqfSG7msmNSUEAIamb3LebzDQQSEZawU0PjKILmMqKOjb6Dwn8F tJTdexuCY8bAUiefEpyeawua25wNT1KemsZf2E09I5h0BZNlo3sUi+8PlVNhqTvnJ6Sp1IwK7C C7Y= X-IronPort-AV: E=Sophos;i="5.70,565,1574092800"; d="scan'208";a="133222678" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Mar 2020 05:19:56 +0800 IronPort-SDR: RvsMqO41N84FFuZq7RHY9pWAMQ3Fk2GsC7dM3hwrzxKri5hv2Eq6pHTtn5C8wWHIhTYnxxaTls z66ykwCTlpPe9kot8wyhQKeVgVlMxifaRUjqM9O47huO+Wr8HQaNt7A5gmom29K9SrB0lX2My7 1ju5wd5O1ljimJIeeASfzhmkGfHdIJiaUIUoHz2QS8Faiq90XXTnR7VBFRm1+JWKftIOTtkht6 3e4aRkUtwzgXhuDVFBd5ewzK5hryTLeD5kNODdnzx2HFWe+vI5lH8yGORH7iRIgv889DVVNmgE K3WCu4HBggzHQDI4Jy+NY4TM Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 14:11:23 -0700 IronPort-SDR: VjsdOfRWruvoafC4I4tmQTeF4gEbpFKnixo2+0lhGqNRtdgEK5ycQCBgTZ4eWrl7FtBYkq0K8H taPH2tlfomt+hf+dR+yOcswDp789jeThnnprVepxaBr0YCfr39Tn+COhjRJ6R3TMjzHKqXW8EB c1CR2gFh5bGbeEHUStsUy6ej0o+haomauMDfvoyZ+C3oRtkK4e9Jex47MdyUlWb1DU1ZcYEvRd WAXuoxm/VaFN3FtKUqeirpc4JKz6w8H9ErCsBQqvQGOGljLUXsX6S6j0HsxnVfDysu9lHc364p KVs= WDCIronportException: Internal Received: from mccorma-lt.ad.shared (HELO yoda.hgst.com) ([10.86.54.125]) by uls-op-cesaip02.wdc.com with ESMTP; 17 Mar 2020 14:19:55 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Rick Chen , Alexander Graf , Anup Patel , Bin Meng , Heinrich Schuchardt , Lukas Auer , Palmer Dabbelt , abner.chang@hpe.com, daniel.schaefer@hpe.com Subject: [PATCH v3 1/5] riscv: Add boot hartid to Device tree Date: Tue, 17 Mar 2020 14:19:42 -0700 Message-Id: <20200317211946.28062-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317211946.28062-1-atish.patra@wdc.com> References: <20200317211946.28062-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 Linux booting protocol mandates that register "a0" contains the hartid. However, U-boot can not pass the hartid via a0 during via standard UEFI protocol. DT nodes are commonly used to pass such information to the OS. Add a DT node under chosen node to indicate the boot hartid. EFI stub in Linux kernel will parse this node and pass it to the real kernel in "a0" before jumping to it. Signed-off-by: Atish Patra Reviewed-by: Rick Chen --- arch/riscv/lib/bootm.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index fad16901c5f2..f927694ae32f 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -28,6 +28,28 @@ __weak void board_quiesce_devices(void) int arch_fixup_fdt(void *blob) { + u32 size; + int chosen_offset, err; + + 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 -1; + } + 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 -1; + } + } + + /* Overwrite the boot-hartid as U-Boot is the last state BL */ + fdt_setprop_u32(blob, chosen_offset, "boot-hartid", + gd->arch.boot_hart); + return 0; } From patchwork Tue Mar 17 21:19:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1256966 X-Patchwork-Delegate: xypron.glpk@gmx.de 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=QnW3t5QW; 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 48hmL30zNLz9sPJ for ; Wed, 18 Mar 2020 08:20:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6DD6A814F4; Tue, 17 Mar 2020 22:20:26 +0100 (CET) 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="QnW3t5QW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D76A814F4; Tue, 17 Mar 2020 22:20:14 +0100 (CET) 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 esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (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 1A97280D3F for ; Tue, 17 Mar 2020 22:20:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=3382782c6=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=1584480008; x=1616016008; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dtwQZlUIeFYKUE2WlwdRcCe3V0GVJlw2DUEIvu1z0N0=; b=QnW3t5QWn9PEsTezQuS2dB9graDgPyLI6JbeZ3tre4yYtiVTkNT+mTiw 0B/5sqRdHvI442auhJzAzol9QZl9i5qnyLXXB9OP5fjNtduPLwdMEJgjN q4jL2zK3EHGkSWgC2BzpGSRb3mGzEw6fe15gOMNsPcGVGJAGdI99CVsWR RHBWU6Xsk3xYa9Q74ZR6Ho5G6GxRnXNp+uhhsROvKS/f8Jk6fRUUoHDGG PtqU9FheA+JA8a4wJI02PSriU+ghfQgPyRJBrLUul2x5iHrL0aOKjpc/s PWXjnx7kPQqtmSs2/6fzUOlx2im1N7pJcajFnXb60eBDpcWg/evKRw5aZ Q==; IronPort-SDR: LmV29AZp1HnmmydVfa5UgA+c55Tb1poVOpKy9L250ryysKOTC9KD4yeNKMtmPNWb5PAdquTRWu 4LYAMAGt1zJPU3IfhfbCMQEQm1GN2AHePrevGP6/rLFCmdicpM81ryG3UP9sDct9MWwbaW3hSb Uy967aqtR1udNwusrvefsxDrJmrdWHOoP8p/MyB4dshWOS6wC73oj3T1U5o6O0xcZofZhZUrwp w6NGhVdzbZLRGi8liPzEltm9NdkqNIdnbhVIRV7hn0ZJf3JV7bWsxE3u4JxVNS7iXaIRx7nnUa Nm8= X-IronPort-AV: E=Sophos;i="5.70,565,1574092800"; d="scan'208";a="133222679" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Mar 2020 05:19:56 +0800 IronPort-SDR: +xecwvx4EjH6ocA0OZzeghF3D4Z/4k4AaPJSrjoCi2TGJe95Ui5j3ppxM0np3BGlZ7YW2ZsDiy I2zIhlvamaKuDdg5U+1cgGJQ/72i4uiCmPc/ZoDna1XyyKa8j+JEFj+JmH/CsCELqtR5U5SLCX NMrK3d0vshMHwmDWZj7x/vJvlY8spcxPERXNWfhLrOGcRZE5TNK7ul4EYOOhrdiAaYRaxw2PhO dG+ozRlk1IDCV4NVD6fsmeZB/yc0Bq/lQhkBOJRKozCevU5JeDGnwZRZ/GoejXku9A7hk4wYmm 063f4MVuMoriqxJ0tbHRY8PC Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 14:11:23 -0700 IronPort-SDR: iuO2CWf4OYu9nGxBSHGyuFuJwTm4h2PVqKOgjtUqBgQjS6VkwA88452vMcxOdI+2ktQAu3+gut /x4B7Wp5oBcX7ETQNOlMODDfuYQzqUPv8ahSTYEDFiqp2tKhtVLwlK9D1/wOFHeBCeETcDKZnU fjYDi3TItWDhsnesUXcwG60qqfGgj6a0ND6+addzut3STXBk7mWmOTDJDRQL3EApJ4O0AmUIux HIlkujCHt369+rZ/96/TUHz3eXSj+wQjBC1i7HnfZKOWOnprrJ44LdO9IeXHATd0TTEDxAOObI 5fo= WDCIronportException: Internal Received: from mccorma-lt.ad.shared (HELO yoda.hgst.com) ([10.86.54.125]) by uls-op-cesaip02.wdc.com with ESMTP; 17 Mar 2020 14:19:55 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Alexander Graf , Anup Patel , Bin Meng , Heinrich Schuchardt , Lukas Auer , Palmer Dabbelt , Rick Chen , abner.chang@hpe.com, daniel.schaefer@hpe.com Subject: [PATCH v3 2/5] cmd: bootefi: Parse reserved-memory node from DT Date: Tue, 17 Mar 2020 14:19:43 -0700 Message-Id: <20200317211946.28062-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317211946.28062-1-atish.patra@wdc.com> References: <20200317211946.28062-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 Currently, bootefi only parses memory reservation block to setup EFI reserved memory mappings. However, it doesn't parse the reserved-memory[1] device tree node that also can contain the reserved memory regions. Add capability to parse reserved-memory node and update the EFI memory mappings accordingly. 1. /doc/device-tree-bindings/reserved-memory/reserved-memory.txt] Signed-off-by: Atish Patra --- cmd/bootefi.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 24fc42ae898e..291cb2d69ff6 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -149,6 +149,20 @@ done: return ret; } +static void efi_reserve_memory(uint64_t addr, uint64_t size) +{ + uint64_t pages; + + /* Convert from sandbox address space. */ + addr = (uintptr_t)map_sysmem(addr, 0); + pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK)); + addr &= ~EFI_PAGE_MASK; + if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE, + false) != EFI_SUCCESS) + printf("Reserved memory mapping failed addr %llx size %llx\n", + (unsigned long long)addr, (unsigned long long)size); +} + /** * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges * @@ -161,7 +175,8 @@ done: static void efi_carve_out_dt_rsv(void *fdt) { int nr_rsv, i; - uint64_t addr, size, pages; + uint64_t addr, size; + int nodeoffset, subnode; nr_rsv = fdt_num_mem_rsv(fdt); @@ -169,15 +184,26 @@ static void efi_carve_out_dt_rsv(void *fdt) for (i = 0; i < nr_rsv; i++) { if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0) continue; + efi_reserve_memory(addr, size); + } - /* Convert from sandbox address space. */ - addr = (uintptr_t)map_sysmem(addr, 0); - - pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK)); - addr &= ~EFI_PAGE_MASK; - if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE, - false) != EFI_SUCCESS) - printf("FDT memrsv map %d: Failed to add to map\n", i); + /* process reserved-memory */ + nodeoffset = fdt_subnode_offset(fdt, 0, "reserved-memory"); + if (nodeoffset < 0) + return; + subnode = fdt_first_subnode(fdt, nodeoffset); + while (subnode >= 0) { + /* check if this subnode has a reg property */ + addr = fdtdec_get_addr_size_auto_noparent(fdt, subnode, + "reg", 0, + (fdt_size_t *)&size, + true); + if (addr == FDT_ADDR_T_NONE) { + debug("failed to read address/size\n"); + continue; + } + efi_reserve_memory(addr, size); + subnode = fdt_next_subnode(fdt, subnode); } } From patchwork Tue Mar 17 21:19:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1256971 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=QEDoVqT6; 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 48hmM15RGtz9sPF for ; Wed, 18 Mar 2020 08:21:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 94D8F81704; Tue, 17 Mar 2020 22:20:45 +0100 (CET) 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="QEDoVqT6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2385A814F4; Tue, 17 Mar 2020 22:20:19 +0100 (CET) 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 esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (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 A058081183 for ; Tue, 17 Mar 2020 22:20:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=3382782c6=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=1584480009; x=1616016009; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lo6OnYstWvcWDtUR5FjmiS6jUZVP2B4oACZmBccU1yo=; b=QEDoVqT6T02D4WC0fmm1eTWDaiVjMJJsdbvYpSdFCCkyxF2buQ5DUZg5 rM8uJ9ntq9ODMaux8fQJfnjqhWstVRlOuMYLxxNQ2e9jlFvrglUKJ1rsf 8ZIgFD6lK4cQtR+wUuJ63bMpMk1zI2ueJYeYcnmdKdI3cB8e1WYfqURPE /9NxudOoOvvQk3YaY6KjiDnHNVxrbx5QgNzOUBegH2B92jHylgpeho5a0 qGTnpgPvkpbTG6QPBip1fqj4QCPZgAiQBxyM1WOspGdAffT3lvNFj/I2e r4CS67oocfEhjqg1HieUN7m0nS+vDViDWKEfAPTNG+c7z5Zga5F/L3xGW g==; IronPort-SDR: qjDzQD6ksv19uf+9FNYdU1NtAThEpIilMfgYc2l7U/ilnKzDpoVqYFJnAEtPCx4SxpslKC+Z4j 8CtZlhZaXwP+1s2jhwErUV/oPLctdFo5NpuYt6O/N35ubdmTka7vBeBBnSWmyQtnBaETnsnrzu C3++USr0yJmyn9ObF6YwsuRtP36OLknXjQMf9nwwHoCNpCXUz6QUG/ovA66msPt1+nVkZJhyBO xlzXYMDh9I0ylQ1xf7nsPlFYYcMVg1ME/t3fLn+M8HJTWP4ss6jqhYpmOeP3PHDBCy+pmmSeOL t5c= X-IronPort-AV: E=Sophos;i="5.70,565,1574092800"; d="scan'208";a="133222680" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Mar 2020 05:19:57 +0800 IronPort-SDR: cIkYJ8CBiA5qJNxig6MHwPpDOiFvANCj9/EWWoVIaDRHtK1xwF1wFLLWxs4KSpFQzXe9lCK9Xp SO4Rv1vnJKkkqAWMPo4cnwT+jHmwVkl1ME1j5Kdg2+GsNfrr5SBop/MRHgRgDQi8eU5Sw8Agrl cEbNAmp2Szd6Q91yp9XHSw2GME0GqTdhcC2LMg2CNUaE/lxs22TRdBhGwidruyWTug8dCHUYwZ heZ3foQHmWueRp7yos7r6gjwr0MgKHcnlHLXJdZCQZ2j7n6RN5aB1OYmAA7YthGQZljog0DZC3 w4Xb3mP8+w8mbyWWCvCmVeoB Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 14:11:24 -0700 IronPort-SDR: tYPm82b7/fJQSKeuvHV9gmmzYZ2ctGBADpy/Rw0kBzt+0WFdj2kl/UQkXFzXmwxXg1jBX6Dd/3 CBy5ZlY/P/XDg3GVx2tHTgR179rksCeo+5Jq1b8Yix0PrtRqwcN3bodvvOyiWIDVVHEGXSE8M/ pU4iA/Ry8dGxRrYheK9RWe45xJ80Iv435KdCx5ixSiXHdClWqu1vZlQ8En4XGTbZxmpTq0TvAu uls6fMmRQYBZ3/ZSHWI4rqjcE2V8RuQC/Swo8smw6GVAynRZYMMl3SnTY8JblDs9uX19LETak/ YCw= WDCIronportException: Internal Received: from mccorma-lt.ad.shared (HELO yoda.hgst.com) ([10.86.54.125]) by uls-op-cesaip02.wdc.com with ESMTP; 17 Mar 2020 14:19:56 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Alexander Graf , Anup Patel , Bin Meng , Heinrich Schuchardt , Lukas Auer , Palmer Dabbelt , Rick Chen , abner.chang@hpe.com, daniel.schaefer@hpe.com Subject: [PATCH v3 3/5] riscv: Provide a mechanism to fix DT for reserved memory Date: Tue, 17 Mar 2020 14:19:44 -0700 Message-Id: <20200317211946.28062-4-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317211946.28062-1-atish.patra@wdc.com> References: <20200317211946.28062-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 | 1 + arch/riscv/lib/asm-offsets.c | 1 + arch/riscv/lib/bootm.c | 68 +++++++++++++++++++++++++++ 5 files changed, 72 insertions(+) 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..b7bea0ba184d 100644 --- a/arch/riscv/include/asm/u-boot-riscv.h +++ b/arch/riscv/include/asm/u-boot-riscv.h @@ -17,5 +17,6 @@ int cleanup_before_linux(void); /* board/.../... */ int board_init(void); void board_quiesce_devices(void); +int riscv_board_reserved_mem_fixup(void *fdt); #endif /* _U_BOOT_RISCV_H_ */ 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/bootm.c b/arch/riscv/lib/bootm.c index f927694ae32f..5e907e96701c 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -19,6 +19,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -26,6 +27,73 @@ __weak void board_quiesce_devices(void) { } +int riscv_fdt_copy_resv_mem_node(const void *src, void *dst) +{ + uint32_t phandle; + struct fdt_memory pmp_mem; + fdt_addr_t addr; + fdt_size_t size; + int offset, node, err, rmem_offset; + bool nomap = false; + 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, + true); + 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; + err = fdtdec_add_reserved_memory(dst, basename, &pmp_mem, + &phandle); + if (err < 0) { + printf("failed to add reserved memory: %d\n", err); + return err; + } + rmem_offset = fdt_node_offset_by_phandle(dst, phandle); + nomap = fdt_get_property(src, node, "no-map", NULL); + if (nomap) + fdt_setprop_empty(dst, rmem_offset, "no-map"); + } + + return 0; +} + +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; +} + int arch_fixup_fdt(void *blob) { u32 size; From patchwork Tue Mar 17 21:19:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1256968 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=SZrXu9Jy; 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 48hmLV6ZqHz9sPF for ; Wed, 18 Mar 2020 08:21:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5E69E815E4; Tue, 17 Mar 2020 22:20:35 +0100 (CET) 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="SZrXu9Jy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 979278155C; Tue, 17 Mar 2020 22:20:18 +0100 (CET) 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 esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (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 B858981496 for ; Tue, 17 Mar 2020 22:20:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=3382782c6=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=1584480010; x=1616016010; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fhh3hWeQmSDfvKO3H2a6Lj+gBtOsPtx7IOF1gi8GKGY=; b=SZrXu9JyMn/cHZOQQrRlJzqk0iqAEICEgXvMeDuKYA6A/6iWotlX8mny JIsCEAzk3CHQ5OlDICFoNU9uiouS4zH6COf2ze41tZk3MAvwHk6XEMLsg etit/FZWcvvWFfkT/e4NghQB3NWWMaEjO07fWtFr34pdErRS0LCN5EWyg AgZZtQJ4Mb6QmwobxvlaYSzQNyR2CLL/8a6cESAlpLWy9MmtPwCt4heFT afJN1ZjJ4gQTA+EduP1WLlDA4CFDTUO2tnU4gjxQIwd8UOAaNGkGmhn+j J6FSzZNKLZ7sMq9zNcq6m7gE7JgdILg1LW7xhXLkM2OaQ2x8FR4jXsBWN Q==; IronPort-SDR: wXHSeNx6AC48PM7M2Zwhocbng483GiZPVGZFX6IsmcckY8hg58CzULJn8Ucomhc+6vEefNhqds Q9OOmbINR0RTerIO4myyA0S12bbHc3DKNTb7VT6Sypa9NvWKPd3P8YtXtjlH/1oPJDAtVDGLfq EZ2b/y5ZzjLpKStKI3jyCk8eBxbNfzN8Cra6cTjeIpmnb8oqq4LMTp4uWPHmyPEi0L9VLlisvB 0phj3B4JC5HHSgEf55gWk2An6Fk+oZaE3WMiVIqSWU7tktDKhPVz8C5qXWMp8EyHeTwqrh8D6d KKI= X-IronPort-AV: E=Sophos;i="5.70,565,1574092800"; d="scan'208";a="133222682" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Mar 2020 05:19:57 +0800 IronPort-SDR: U4NQqyMIiOEvYo46BDS9V9d4QH5eGh7w665ancyq8RiJxCadB9mFUchOz80A+EslU5wZbsIw8D OUTSjQ54UsDYyui+gAXLl5HK4FZC4ZD5ChynFi+EX45vxabbf3W2/yEg6Q91owlZijim4/i+dw nMZdin4jVjiQEE6l5CthVZspC5a+Y9Z3wdIuj8r+evvvjtxuBB0PUApdkS7dUiVnrjogfBJynu BxvNSi6XP7vVz1+cGGnsqU9nv0GX26jCobM5LGDbjiiDm43mG1C4yUcwYlnNb1ee9TiRAouSqo Wo00fOWHwNrjm9Nz6DuMlJ+9 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 14:11:24 -0700 IronPort-SDR: iM1BlADrC2ZL1n/T0WwtlwZAO8L8rS32T+swK71TRNtehyuxjUEUqC15YHn8P2x68Esw0BJEDo 7Zv6UokJZ29RSBeY+zJZc0KTlfhABnTuvaInK0vKvI2Sig1LSuHAgejrKFHtRGRQokdGIFL9us ZaYPt20BYr6Bo0X31L2Cap5zs7Pu0Z4Nl8RuqRxm5r8D+9aNMytaaFS4Jk6CC2GqZyXyY+2GhA QPlD9vVFc1fr8gLj5B2K6i3i0Fh67gPDVVhLs5F38vSG20A6Zzxvz1DU9rAeZgI50kSG2kphSE +Lo= WDCIronportException: Internal Received: from mccorma-lt.ad.shared (HELO yoda.hgst.com) ([10.86.54.125]) by uls-op-cesaip02.wdc.com with ESMTP; 17 Mar 2020 14:19:56 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Alexander Graf , Anup Patel , Bin Meng , Heinrich Schuchardt , Lukas Auer , Palmer Dabbelt , Rick Chen , abner.chang@hpe.com, daniel.schaefer@hpe.com Subject: [PATCH v3 4/5] riscv: Setup reserved-memory node for FU540 Date: Tue, 17 Mar 2020 14:19:45 -0700 Message-Id: <20200317211946.28062-5-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317211946.28062-1-atish.patra@wdc.com> References: <20200317211946.28062-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 FU540 uses OF_SEPARATE instead of OF_PRIOR. Enable OF_BOARD_FIXUP to update the DT with reserved-memory node. Signed-off-by: Atish Patra --- board/sifive/fu540/fu540.c | 15 +++++++++++++++ configs/sifive_fu540_defconfig | 1 + 2 files changed, 16 insertions(+) diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c index 47a20902517c..82b3a9c8e729 100644 --- a/board/sifive/fu540/fu540.c +++ b/board/sifive/fu540/fu540.c @@ -141,6 +141,21 @@ int misc_init_r(void) #endif +#ifdef CONFIG_OF_BOARD_FIXUP +int board_fix_fdt(void *fdt) +{ + int err; + + err = riscv_board_reserved_mem_fixup(fdt); + if (err < 0) { + printf("failed to fixup DT for reserved memory: %d\n", err); + return err; + } + + return 0; +} +#endif + int board_init(void) { /* For now nothing to do here. */ diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig index 6d61e6c960ee..8fb3794cd578 100644 --- a/configs/sifive_fu540_defconfig +++ b/configs/sifive_fu540_defconfig @@ -12,3 +12,4 @@ CONFIG_DISPLAY_BOARDINFO=y CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00" CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_DM_MTD=y +CONFIG_OF_BOARD_FIXUP=y From patchwork Tue Mar 17 21:19:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1256967 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=njizNXnn; 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 48hmLH2bX2z9sPF for ; Wed, 18 Mar 2020 08:20:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 416478157B; Tue, 17 Mar 2020 22:20:31 +0100 (CET) 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="njizNXnn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 92E7A80E7C; Tue, 17 Mar 2020 22:20:16 +0100 (CET) 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 esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (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 A75F5812D3 for ; Tue, 17 Mar 2020 22:20:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=3382782c6=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=1584480009; x=1616016009; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Iion5CUeCPY2TmsrIANBc+Hj8ARafdjtPnkjdyk+9eY=; b=njizNXnnHIr7A5Ko97Uu/ZJFgpRSTFdTOgnCHkEBpyMckGvfeMN6XRvU 1xUxOvo2aSRWdqvHjLqBxDJSfC4bIo8p/9QuSxeU9gZd/HAINp+3DYJsk FJLhH0MsryHnMb/Qezpbr2LenMkcrVgRhQijmCSOH6P347iSBcAB7Ba+b mJIwOwUVpaIxRgCPCp5K/wfzIPdIRBvsIQQtHGh6DQkewKgJXcibpTkh0 5t7s7rxgNuNdtI9m9rJ0ENSIOU2wQDdTjvZXYkK6RhWNi3S/DkDtgylsu aYlQW0JVs0vm/eY2w0dqJdpqpSp5LiQjWJoS/Kdkv/kihX7v+zB8Z/nIY g==; IronPort-SDR: BAHwqfliW1TwKgnotQoSMXGWmyyiFXi/U5FTy3ubbj2UGJ6M4M3J3IVyUc0N5gR37vhRyJQvlF 0V22khc+kW4ZgOZ68ZAiDklqhLNVuyAhisB8sS+SMb/zVYQiHA0UcW5gCTZPONWqPtuxR0FgtG txTW/sSFX4RxdKzxoeD5hwQc7c30Q6u+fwNcoh63a/CRgmDw/xkQKgv4CsP1+BHwIUfVfHbkhg bvFI2WT+Rp0JcHZhzJg8W6KFw2u4OtK/UeO8FOpB1lZFsxL9DvGlHK8q8bWQNsm9KlhgqixdTK h4o= X-IronPort-AV: E=Sophos;i="5.70,565,1574092800"; d="scan'208";a="133222684" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Mar 2020 05:19:58 +0800 IronPort-SDR: ERI+IH579eNJ0TX4sBvIdIs3eMXnI6Ns0f+k1aL3eGmQUC1GpyPN93waOtGwwszjd2wtKJeyr0 rPvrh7nTw9L9o77HDKFq53E3Pb5KsFGXkYfskEDXQbpyd406kxOl4ueKfC19XYCNopqNON6qLb ZeIJdvLONyf2gVot3y4eU+Nme9xSznJpdS8VqVytPCHGApboy38GrI9mTcj92AeXGBryoLvgyd kawRDcvjOxrsGn+h7ZpTTinnrk6YYviD3LP3R0fuWxccxwCePNV44jGzlirVVlVS8OMvco3nMc 6f4twQi5sFpymfqCHB1RBGeX Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 14:11:24 -0700 IronPort-SDR: IH+XJNSgiJnCgXbnHL3AQQX+6XwCU5aRPuwGjcYxiFRzKwTa26JSec0ifLx6kuXPTR5flNPsPt FPyPRudls23pU2eeDGToXbnyj3Jb51drZiL89bQd608/BNIRvaXt0oSUHo6p4aW9i98TEVOMyi ZNdd4Rs9lQHPvIV9jqsNUwRLrZyClKd4P0RDr/bad8QU3eitYJdyKqoHJW6g//nnlX1XXDdUMW QEvY0vTAcbDYw+RZDqSzGzDRW4UqQqmnCKE+DgAj6o30e/aGj4AT2+COgNDjgW3hDsQzOeqUBB Hnc= WDCIronportException: Internal Received: from mccorma-lt.ad.shared (HELO yoda.hgst.com) ([10.86.54.125]) by uls-op-cesaip02.wdc.com with ESMTP; 17 Mar 2020 14:19:57 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Alexander Graf , Anup Patel , Bin Meng , Heinrich Schuchardt , Lukas Auer , Palmer Dabbelt , Rick Chen , abner.chang@hpe.com, daniel.schaefer@hpe.com Subject: [PATCH v3 5/5] riscv: Copy the reserved-memory nodes to final DT Date: Tue, 17 Mar 2020 14:19:46 -0700 Message-Id: <20200317211946.28062-6-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317211946.28062-1-atish.patra@wdc.com> References: <20200317211946.28062-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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index 5e907e96701c..1ca8370849a0 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -118,6 +118,11 @@ int arch_fixup_fdt(void *blob) fdt_setprop_u32(blob, chosen_offset, "boot-hartid", gd->arch.boot_hart); + /* 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; }