From mboxrd@z Thu Jan 1 00:00:00 1970 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 D4111ECAAA1 for ; Fri, 9 Sep 2022 15:34:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A2F4D84BA0; Fri, 9 Sep 2022 17:33:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org 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=kernel.org header.i=@kernel.org header.b="dOSaoaSP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 73CAC84B3C; Fri, 9 Sep 2022 17:33:09 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (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 81B2784B66 for ; Fri, 9 Sep 2022 17:33:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 09598B8256A; Fri, 9 Sep 2022 15:33:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1366C433D6; Fri, 9 Sep 2022 15:33:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662737581; bh=WPc/Qwex+kxqqRzlMwuc68edKQvWkj1EHL2pKxUdQxw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dOSaoaSP005hDBeZpyPY0tkjMuS0+LSydwJMYC1K1nUnT3uUy/4cudCUOVvXq8CRr YGOTvjucMzb4ASPhYx4jT2Rji7NT92iaJHiTxkLRD8KmTuRUbSejHym3+DnEHxLGGK WYO5c71zIr0+/GH8A+m2+jJb0kAPPGnHFG2rhX7bg0JJPV76cHb6n8snR1iQwu3DFC 9lpky7rGNlMrF8S+ZTCHBGud8gbaPDmTKGlhWWjS026ODvw2IEczar8yiqNrErQQcL Vrzm9CfjUAE8MP60+J+kwbGAPovA1Z2xTG0nxlm5B1mHyO2ISUKQEZFXl44aS4RvJ6 sef+jIa+Jne3g== Received: by pali.im (Postfix) id E2C9D1FCD; Fri, 9 Sep 2022 17:32:58 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de, =?UTF-8?q?Marek=20Beh=C3=BAn?= , Peng Fan , Tom Rini Subject: [PATCH 7/9] ddr: fsl: Allow to detect 4 GB DDR modules in 32-bit mode Date: Fri, 9 Sep 2022 17:32:44 +0200 Message-Id: <20220909153246.8455-8-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220909153246.8455-1-pali@kernel.org> References: <20220909153246.8455-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 U-Boot core code already handles the case when RAM size is bigger than CONFIG_MAX_MEM_MAPPED. So there is no need to do duplicate check in fsl ddr driver for CONFIG_MAX_MEM_MAPPED. Instead simplify code to just check if RAM size can be representable in phys_size_t type. And avoid printing warning if phys_size_t is just 1 byte smaller than RAM size, which is the typical situation with 4 GB DDR module. Signed-off-by: Pali Rohár --- drivers/ddr/fsl/main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/ddr/fsl/main.c b/drivers/ddr/fsl/main.c index dd55e61a7a73..577ca569b042 100644 --- a/drivers/ddr/fsl/main.c +++ b/drivers/ddr/fsl/main.c @@ -856,15 +856,18 @@ phys_size_t __fsl_ddr_sdram(fsl_ddr_info_t *pinfo) debug("total_memory by %s = %llu\n", __func__, total_memory); #if !defined(CONFIG_PHYS_64BIT) - /* Check for more than max memory. Bad. */ - if ((first_ctrl == 0) && (total_memory > CONFIG_MAX_MEM_MAPPED)) { + /* + * Show warning about big DDR moodules. But avoid warning for 4 GB DDR + * modules when U-Boot supports RAM of maximal size 4 GB - 1 byte. + */ + if ((first_ctrl == 0) && (total_memory - 1 > (phys_size_t)~0ULL)) { puts("Detected "); print_size(total_memory, " of memory\n"); #ifndef CONFIG_SPL_BUILD puts(" "); /* re-align to match init_dram print */ #endif puts("This U-Boot only supports <= "); - print_size(CONFIG_MAX_MEM_MAPPED, " of DDR\n"); + print_size((unsigned long long)((phys_size_t)~0ULL)+1, " of DDR\n"); #ifndef CONFIG_SPL_BUILD puts(" "); /* re-align to match init_dram print */ #endif @@ -872,10 +875,13 @@ phys_size_t __fsl_ddr_sdram(fsl_ddr_info_t *pinfo) #ifndef CONFIG_SPL_BUILD puts(" "); /* re-align to match init_dram print */ #endif - total_memory = CONFIG_MAX_MEM_MAPPED; } #endif + /* Ensure that total_memory does not overflow on return */ + if (total_memory > (phys_size_t)~0ULL) + total_memory = (phys_size_t)~0ULL; + return total_memory; } -- 2.20.1