Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AAD6BC64ED6 for ; Tue, 28 Feb 2023 03:10:52 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E480085953; Tue, 28 Feb 2023 04:10:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 2A82A85953; Tue, 28 Feb 2023 04:10:46 +0100 (CET) Received: from mail-m11874.qiye.163.com (mail-m11874.qiye.163.com [115.236.118.74]) (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 A971485AB1 for ; Tue, 28 Feb 2023 04:10:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kever.yang@rock-chips.com Received: from [172.16.12.93] (unknown [58.22.7.114]) by mail-m11874.qiye.163.com (Hmail) with ESMTPA id 9C71F3C0193; Tue, 28 Feb 2023 11:10:27 +0800 (CST) Message-ID: <07e75e92-e887-d4da-ac44-6e716515acbe@rock-chips.com> Date: Tue, 28 Feb 2023 11:10:27 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v2 2/2] board: rock5b-rk3588: add memory gaps into kernel's DTB Content-Language: en-US To: Eugen Hristev , jagan@edgeble.ai, jonas@kwiboo.se Cc: u-boot@lists.denx.de, sjg@chromium.org, philipp.tomsich@vrull.eu References: <20230222090513.146446-1-eugen.hristev@collabora.com> <20230222090513.146446-2-eugen.hristev@collabora.com> From: Kever Yang In-Reply-To: <20230222090513.146446-2-eugen.hristev@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQklKGVZJQx4eTkpKHkwYQx5VEwETFh oSFyQUDg9ZV1kYEgtZQVlOQ1VJSVVMVUpKT1lXWRYaDxIVHRRZQVlPS0hVSkpLSEpMVUpLS1VLWQ Y+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6N1E6Ghw*AT0RUUg9EzIwDC8* LE1PCxNVSlVKTUxMTk5IQ0lDSE1PVTMWGhIXVRAeDR4JVQIaFRw7CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlOQ1VJSVVMVUpKT1lXWQgBWUFPSE1KNwY+ X-HM-Tid: 0a8695ffffca2eb0kusn9c71f3c0193 X-HM-MType: 1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean On 2023/2/22 17:05, Eugen Hristev wrote: > RK3588 has two memory gaps when using 16 GiB DRAM size: > [0x3fc000000 , 0x3fc500000] > and > [0x3fff00000 , 0x3ffffffff] > > If the kernel is agnostic to these gaps, accessing the area causes > a SError panic. > > Hence, add reserved memory areas in kernel's DTB before booting. > > Signed-off-by: Eugen Hristev Reviewed-by: Kever Yang Thanks, - Kever > --- > > Hi, > > These memory gaps are required because the kernel crashes with a SError if > accessing that area. > It appears the ATAGs provide DDR banks that do not include those specific > two regions. > To be able to boot the kernel, those areas have to be reserved. > Maybe someone from Rockchip could have an explanation to this behavior? > Otherwise we have to block them at this level. > If those memory ranges are reserved for a dedicated purpose we can come up > with a better solution, w.r.t. the purpose of the regions. > > Thanks ! > Eugen > > board/radxa/rock5b-rk3588/rock5b-rk3588.c | 35 +++++++++++++++++++++++ > configs/rock5b-rk3588_defconfig | 1 + > 2 files changed, 36 insertions(+) > > diff --git a/board/radxa/rock5b-rk3588/rock5b-rk3588.c b/board/radxa/rock5b-rk3588/rock5b-rk3588.c > index b5d74798f3b9..5c3b52b94898 100644 > --- a/board/radxa/rock5b-rk3588/rock5b-rk3588.c > +++ b/board/radxa/rock5b-rk3588/rock5b-rk3588.c > @@ -2,3 +2,38 @@ > /* > * Copyright (c) 2023 Collabora Ltd. > */ > + > +#include > +#include > + > +#ifdef CONFIG_OF_BOARD_SETUP > +int rock5b_add_reserved_memory_fdt_nodes(void *new_blob) > +{ > + struct fdt_memory gap1 = { > + .start = 0x3fc000000, > + .end = 0x3fc4fffff, > + }; > + struct fdt_memory gap2 = { > + .start = 0x3fff00000, > + .end = 0x3ffffffff, > + }; > + unsigned long flags = FDTDEC_RESERVED_MEMORY_NO_MAP; > + unsigned int ret; > + > + /* > + * Inject the reserved-memory nodes into the DTS > + */ > + ret = fdtdec_add_reserved_memory(new_blob, "gap1", &gap1, NULL, 0, > + NULL, flags); > + if (ret) > + return ret; > + > + return fdtdec_add_reserved_memory(new_blob, "gap2", &gap2, NULL, 0, > + NULL, flags); > +} > + > +int ft_board_setup(void *blob, struct bd_info *bd) > +{ > + return rock5b_add_reserved_memory_fdt_nodes(blob); > +} > +#endif > diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig > index 9b7db7de64be..f3026c7ea166 100644 > --- a/configs/rock5b-rk3588_defconfig > +++ b/configs/rock5b-rk3588_defconfig > @@ -26,6 +26,7 @@ CONFIG_FIT=y > CONFIG_FIT_VERBOSE=y > CONFIG_SPL_FIT_SIGNATURE=y > CONFIG_SPL_LOAD_FIT=y > +CONFIG_OF_BOARD_SETUP=y > CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-rock-5b.dtb" > # CONFIG_DISPLAY_CPUINFO is not set > CONFIG_DISPLAY_BOARDINFO_LATE=y