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 DDF72ECAAA1 for ; Fri, 9 Sep 2022 15:33:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B964384B73; Fri, 9 Sep 2022 17:33:17 +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="Ib393ELa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A25DE84B3C; Fri, 9 Sep 2022 17:33:06 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (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 670EF84B58 for ; Fri, 9 Sep 2022 17:33:02 +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 dfw.source.kernel.org (Postfix) with ESMTPS id A9A9262058; Fri, 9 Sep 2022 15:33:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 847DAC43146; Fri, 9 Sep 2022 15:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662737579; bh=IRxS2SPYidKBOF2BSXhDro2mWGy8Ee8QKknRNc73pF0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ib393ELaxuPjr1dTzEbrvdCXwan/ZbznkShNptOvoX0ZdBNNPEiw/lRZuQJak/YDU WxNr8L2Cj51GD9aqxi1ftIa719bGgwixiEbl70fdOrGL94YmE0D3kR/TyK3Ikw3qaM OLOwEp7EGmZpjSzwHWF66PvapBONQTIhZ+wZdEetNpoPXKq29pKsHI251v5TU0G87s KB6ryFx3cdU2m2nECyDrpB2gqSvP+os3ZUjrJhzzGhrOKEmKb5xCxnaxgYIIfs5xab hdJtSk1J0zSxu5xhOjh6WNBsxBI2kLpOLikuLnnsY+TBN+p0r+Thlfao0s0xIRt8lu LdUIuU3eYDUPA== Received: by pali.im (Postfix) id 1581D1F0E; 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 5/9] ddr: fsl: Fix checking for maximal mappable memory Date: Fri, 9 Sep 2022 17:32:42 +0200 Message-Id: <20220909153246.8455-6-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 Check needs to be done against CONFIG_MAX_MEM_MAPPED macro and not fixed size 4GB (as CONFIG_MAX_MEM_MAPPED can be lower and for example for e500 cores it is just 2GB). Also fix printf re-align, which should be applied only for non-SPL builds, during init_dram() call. Signed-off-by: Pali Rohár --- drivers/ddr/fsl/main.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/ddr/fsl/main.c b/drivers/ddr/fsl/main.c index f389e5ef9524..ec040f265da2 100644 --- a/drivers/ddr/fsl/main.c +++ b/drivers/ddr/fsl/main.c @@ -856,13 +856,22 @@ 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 4G or more. Bad. */ - if ((first_ctrl == 0) && (total_memory >= (1ull << 32))) { + /* Check for more than max memory. Bad. */ + if ((first_ctrl == 0) && (total_memory > CONFIG_MAX_MEM_MAPPED)) { puts("Detected "); print_size(total_memory, " of memory\n"); - printf(" This U-Boot only supports < 4G of DDR\n"); - printf(" You could rebuild it with CONFIG_PHYS_64BIT\n"); - printf(" "); /* re-align to match init_dram print */ +#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"); +#ifndef CONFIG_SPL_BUILD + puts(" "); /* re-align to match init_dram print */ +#endif + puts("You could rebuild it with CONFIG_PHYS_64BIT\n"); +#ifndef CONFIG_SPL_BUILD + puts(" "); /* re-align to match init_dram print */ +#endif total_memory = CONFIG_MAX_MEM_MAPPED; } #endif -- 2.20.1