From patchwork Fri Jun 26 01:16:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1317302 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=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=A0F40KGp; 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 49tJrs1Pwtz9s6w for ; Fri, 26 Jun 2020 11:17:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EC47681E73; Fri, 26 Jun 2020 03:16:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A0F40KGp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48AEE81E73; Fri, 26 Jun 2020 03:16:20 +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,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BE5D381E6C for ; Fri, 26 Jun 2020 03:16:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-pj1-x1041.google.com with SMTP id q90so3485968pjh.3 for ; Thu, 25 Jun 2020 18:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=e7ZFY4W7tjQibExuF3yRAhB3I+q0U46FE9+jf9jo3Kw=; b=A0F40KGpNsErr/+KroGc66I51IVBhtX1tNJhqMOb5lVkW3chUiRtu8ybk19+3LnCYT 0l26crpz0uepUucTh/lfe4wPHlGLkET6M2yxP/45wzfTEBQP8Gkpqj3Zy4D7BOqNGSyn n+i1R4wN6XBpHlSzkLRmd7VPOq0eQajPB25pPgbZMjwUFW9XGOXkiqg/tFg4sCmNhGT9 Exahdb1FX+uzs39tTH4MStOYDDBRNmIhjM9o89gJ1BOU5O3iUQXb6NJSu0eg50hFbfqm Qs+TZpLNXfRKrXA0h/4d55k6s6FpM+2DBvKcoKcEFRmlqu9iETPbrLvHKuAMWB/IQT3b ypWg== 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; bh=e7ZFY4W7tjQibExuF3yRAhB3I+q0U46FE9+jf9jo3Kw=; b=mTORo51X6ihSBOCNX9EtYeDiKVdSdPs2cKA27+LcwbAXYVHgHrF4PJ55D+fMV9CQT4 XZguMvpd+JdHnC/Sb4nzk00S58XKoRQsN8GL+dCZzL4Kr16xoERSlXUUJf4KLa7ZejrV NDKc3cq9TV6OUkBGAyWy4JzUemPzep/hN+RD/V1DQ+t3vX0h9qd01E3yEjlUhzRF4AUK DD6x3GITOcR8mx2rDnlliC4IjqQ84X+xT/c0KOWm91k3GOBKX0D2+hBK/Vlea57lC378 3+udt/5koubhxqz3A+iIYOmlTMwN4HqDpKJvHRBaMZXgMkEi3sUg1KiOtUmEPV7OvLoD D3fA== X-Gm-Message-State: AOAM530mkWv7dn1tJGmWaK/yA4R0iE6Tngc+6YEDSs/MMipN0xJJyB9t bWtW7zvcBHjLTWjcPCxDKwg= X-Google-Smtp-Source: ABdhPJx67tHfjBd31k4xyYPWBFf0u68KQ5JC4wOfi+8cRs7GNCzWQIxQh19I2P70QkmcvCSOb55hFw== X-Received: by 2002:a17:902:c411:: with SMTP id k17mr462370plk.165.1593134174972; Thu, 25 Jun 2020 18:16:14 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id e191sm3268702pfh.42.2020.06.25.18.16.14 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 25 Jun 2020 18:16:14 -0700 (PDT) From: Bin Meng To: Rick Chen , U-Boot Mailing List Cc: Atish Patra , Bin Meng Subject: [PATCH v4 1/3] riscv: Avoid the reserved memory fixup if src and dst point to the same place Date: Thu, 25 Jun 2020 18:16:06 -0700 Message-Id: <1593134168-16266-1-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 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 From: Bin Meng The copy of reserved memory node from source dtb to destination dtb can be avoided if they point to the same place. This is useful when OF_PRIOR_STAGE is used. Signed-off-by: Bin Meng Reviewed-by: Rick Chen Reviewed-by: Atish Patra --- (no changes since v1) arch/riscv/lib/fdt_fixup.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c index 6db48ad..5f523f0 100644 --- a/arch/riscv/lib/fdt_fixup.c +++ b/arch/riscv/lib/fdt_fixup.c @@ -82,10 +82,9 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst) * @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. + * In RISC-V, any board 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. */ @@ -95,6 +94,11 @@ int riscv_board_reserved_mem_fixup(void *fdt) void *src_fdt_addr; src_fdt_addr = map_sysmem(gd->arch.firmware_fdt_addr, 0); + + /* avoid the copy if we are using the same device tree */ + if (src_fdt_addr == fdt) + return 0; + err = riscv_fdt_copy_resv_mem_node(src_fdt_addr, fdt); if (err < 0) return err;