From patchwork Thu Jun 25 07:37:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1316766 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=jnr277Y/; 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 49ssMw2m7mz9sSn for ; Thu, 25 Jun 2020 17:39:08 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 905B082119; Thu, 25 Jun 2020 09:38:38 +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="jnr277Y/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1A4F4820D2; Thu, 25 Jun 2020 09:38: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,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (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 E72F5820CF for ; Thu, 25 Jun 2020 09:38: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=bmeng.cn@gmail.com Received: by mail-wm1-x343.google.com with SMTP id u26so6083007wmn.1 for ; Thu, 25 Jun 2020 00:38:23 -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=xbU4r26L6KLKm8jbuk7MdHOtQKg9xnF7RqP4ltiVAa0=; b=jnr277Y/Rkq0Io/KKpcMOm6v8HKzWWfh2I4xHjVb5T327rdXeSBQVPu9BPhiYKDxNI 4dkRaJnonC5UORnujaTEg3DsPgFsNjivVp9P8c4RjpG/eGzk9+HmKHtdC7Q5jOjvP0Ld nuX9hT2c8jKOwYVQAkJAd8mlmgpNbf56KjGlqwynNKRALqFr4k6Q4ZWGCvZ5rzVYf+jz y2xuNPA4KtLp5RkvQ+lk6QGauUKL/pGoeHFq9ZImAgjnJ1dEx4UFdMNCVWAr8B7p8YR/ Mi1c9WADU0so3iHvXHZgA8Z5GiZzbmkRYvOeb4O+fv5xl7vhTOgJdrq5kU7KyMPjX8O6 NbJg== 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=xbU4r26L6KLKm8jbuk7MdHOtQKg9xnF7RqP4ltiVAa0=; b=d/qmidEfGGC6Ky7GasYhUb+OG+s1kn4q2XzKQDC+ye9FN1SIznn86nfIe9kW6mcBzY vqY64TlHsw/O/ixJIvt5nAuUTIzqvZCFzVGMs7BOecvcDINK/HhwOUjD3oJL6NHfKTm+ utXucMAZAGvbWBSg9pA/d5gYsyBXx7za1627Ejq2bmK/rDMQTmcbtxNXNOx5l7dOQTFv mnKsyx6m09ZIO1NYbQd9r/NXq+99lmcncjRz/hijn0N8YynOeYM1kUUtC2WQIHZkpwvz oDGyXgSNXvCIACYj3aw76Z8XkLVYmGS5++aIV3jlPqVbKVgGRP6An7STE8GCgvgkqNWk 0aZA== X-Gm-Message-State: AOAM531qfAVVdujAq08tS+nIUJsl7xAdKKG9CYHEN8Kc6A5dthL+lqi1 yPBSAWpEKqyLNH29YTpS1Vk= X-Google-Smtp-Source: ABdhPJxqUIooO9Gl2NtgLVGO1wjkLGPV/qLa+kdh6WPiI3Wmrn6Al/Dj9UKcx1grw/L8Es4ypzkvjg== X-Received: by 2002:a7b:cd06:: with SMTP id f6mr1895669wmj.8.1593070702629; Thu, 25 Jun 2020 00:38:22 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id w13sm30844529wrr.67.2020.06.25.00.38.21 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 25 Jun 2020 00:38:22 -0700 (PDT) From: Bin Meng To: Rick Chen , U-Boot Mailing List Cc: Atish Patra , Bin Meng Subject: [PATCH v3 2/3] riscv: Expand the DT size before copy reserved memory node Date: Thu, 25 Jun 2020 00:37:25 -0700 Message-Id: <1593070646-6774-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1593070646-6774-1-git-send-email-bmeng.cn@gmail.com> References: <1593070646-6774-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 --- 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);