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 72444C6379F for ; Tue, 21 Feb 2023 08:35:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1282585A30; Tue, 21 Feb 2023 09:35:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=collabora.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=collabora.com header.i=@collabora.com header.b="iBFAglFc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8F4285A36; Tue, 21 Feb 2023 09:35:24 +0100 (CET) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 161B185A26 for ; Tue, 21 Feb 2023 09:35:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=eugen.hristev@collabora.com Received: from [192.168.0.125] (unknown [82.76.24.202]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ehristev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 14FED66021BD; Tue, 21 Feb 2023 08:35:21 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676968521; bh=8+aTDIvQewxD538BDUI+z5HAupIHVaE3X+z4NIgdK+w=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=iBFAglFcxNCQzkPx7DqRzKkhagyMQpUyit/aYKcGaIzZuBn6FK/5jcyl1/mh52wq/ g1gjvctIhuSGDEI9DgodVcoiH9xzC2+TgmErfU6vFVXgtNBCYHUYM5e2Uomr1FOQ3T qUz0Nuhwi74ECnPk/IHvVW1EytW2Hwr0ACjlAsMLVsjk8EHC7yrCQlN+6K6nNWkyKN Ar6vBN3iVkxu6HJx9nrv7pu6H2Z1yBZXrrPo4mQ8rQvozp6Wuigix2IAqtZTaBHT8W s4aDTitMCuhb89KTtEKbihFFS6Czl8gZ/+bzRiGEAiI8ZoFbCA2MCgiT+A5U8wO1qo 0qvmk7/Tip3+g== Message-ID: <3ffb58b4-7276-1bec-54a4-3888d43d2127@collabora.com> Date: Tue, 21 Feb 2023 10:35:18 +0200 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 2/2] board: rock5b-rk3588: add memory gaps into kernel's DTB To: Mark Kettenis Cc: jagan@edgeble.ai, jonas@kwiboo.se, sjg@chromium.org, philipp.tomsich@vrull.eu, kever.yang@rock-chips.com, u-boot@lists.denx.de References: <20230216132905.333332-1-eugen.hristev@collabora.com> <20230216132905.333332-2-eugen.hristev@collabora.com> <875ybwt0no.fsf@bloch.sibelius.xs4all.nl> Content-Language: en-US From: Eugen Hristev In-Reply-To: <875ybwt0no.fsf@bloch.sibelius.xs4all.nl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 2/21/23 00:47, Mark Kettenis wrote: >> From: Eugen Hristev >> Date: Thu, 16 Feb 2023 15:29:05 +0200 >> >> 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. > > I can confirm that using the full 16GB of memory on the rock5b causes > prolems for OpenBSD as well. > > Was wondering whether excluding these regions was better done by > adding reserved-memory nodes in the device tree though like what is > done in the meson-g12-common.dtsi file for example. But does it work fine with this patch ? > >> Signed-off-by: Eugen Hristev >> --- >> >> 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 >> -- >> 2.34.1 >> >>