From patchwork Fri Jun 26 01:16:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1317301 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=WWs+BDwL; 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 49tJrg675Yz9s6w for ; Fri, 26 Jun 2020 11:17:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4360981E25; Fri, 26 Jun 2020 03:16:22 +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="WWs+BDwL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5E2BE81DF1; 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-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 6B2D981DF1 for ; Fri, 26 Jun 2020 03:16:17 +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-pg1-x544.google.com with SMTP id e9so4202746pgo.9 for ; Thu, 25 Jun 2020 18:16:17 -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:in-reply-to:references; bh=vsX/VG47n+RrRXVo0UW5wEyfNEUIU7xxRSkkugmwWrk=; b=WWs+BDwLW+hU/AXRgyJMtfAmTQwWf0k3CG4W9Mg3do8UqrbcxC2UWomu8zV1mset6a MNBuMEF982UATYc9SD7RotsAphN9PqSsfZVObXWRv3b2/hhzCgSG5nbdlHhnZNSH/WPu hKHhIFxn3h4cZEpL3btxPvbSMTQdpslZQh26/RLc+5qFr3b8dhDpOgRM2dnRhh05wd9S QracJBOyXKsfo+RwG8EdgRufA6SZYSPkD+geHMeMJfP5kp9JQJypW/5CRDDf8wDXvXpd 4aeIXT8ML5iciImzk7hhO5M10BOOqowMOaWtlC23pFJc3AQwmvTZqeYhiJMlqy3lEVEs Qv4Q== 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:in-reply-to :references; bh=vsX/VG47n+RrRXVo0UW5wEyfNEUIU7xxRSkkugmwWrk=; b=d2u+Yi5Is4p8vjttHMmoY8v+yY7bbrWxTo0gMoibeAhxUdgeXkQpqY2pQGQFVBzaLA v/coUDdVdRuzjo2SnZH/knKVabgJ7c/qXuiMSNuGpr+0HFmQIW/PbwH8nvQG7Y8Cg8oo 40utkBj25cXwUuNbMvmzv0nMOq0dt/SrB+zaamkw6aB3qtoMtLiDuscwVyvIUeRPOi5H +ZPVV2GY14Qg8+Yg2EDLieHfm34dE3f/bczMPYLNjSqEedG5I9noFRQoCkk/iqeEgHuW D/J9UZ76KUY6k2PmGHwdYuU9hX2+iHmVZiDRkyiETAdNqMh/RcNTzIVNuO6R2gH7QdrP uArA== X-Gm-Message-State: AOAM5303Tw6n/zBpIohLjvGddXYlpV++mKUfeEH746b0hlcgFW/wgiEr cY11LnzmbfAwRHhlIcmE5cE= X-Google-Smtp-Source: ABdhPJwt/2GKIVFmQSnbjGhGh7CQGtGkkoNB3otSsQ3nttKZVNaa5HXdQ531AC+FlADjmptDVQdH0A== X-Received: by 2002:a63:9246:: with SMTP id s6mr569491pgn.22.1593134175796; Thu, 25 Jun 2020 18:16:15 -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.15 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 25 Jun 2020 18:16:15 -0700 (PDT) From: Bin Meng To: Rick Chen , U-Boot Mailing List Cc: Atish Patra , Bin Meng Subject: [PATCH v4 2/3] riscv: Expand the DT size before copy reserved memory node Date: Thu, 25 Jun 2020 18:16:07 -0700 Message-Id: <1593134168-16266-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1593134168-16266-1-git-send-email-bmeng.cn@gmail.com> References: <1593134168-16266-1-git-send-email-bmeng.cn@gmail.com> 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 FDT blob might not have sufficient space to hold a copy of reserved memory node. Expand it before the copy. Reported-by: Rick Chen Signed-off-by: Bin Meng Reviewed-by: Atish Patra Reviewed-by: Rick Chen --- (no changes since v3) Changes in v3: - Extend the FDT size by 1024 bytes arch/riscv/lib/fdt_fixup.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c index 5f523f0..160ccca 100644 --- a/arch/riscv/lib/fdt_fixup.c +++ b/arch/riscv/lib/fdt_fixup.c @@ -41,6 +41,18 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst) return 0; } + /* + * Extend the FDT by the following estimated size: + * + * Each PMP memory region entry occupies 64 bytes. + * With 16 PMP memory regions we need 64 * 16 = 1024 bytes. + */ + err = fdt_open_into(dst, dst, fdt_totalsize(dst) + 1024); + if (err < 0) { + printf("Device Tree can't be expanded to accommodate new node"); + return err; + } + fdt_for_each_subnode(node, src, offset) { name = fdt_get_name(src, node, NULL);