From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de, "Marek Behún" <kabel@kernel.org>,
"Peng Fan" <peng.fan@oss.nxp.com>,
"Tom Rini" <trini@konsulko.com>
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 [thread overview]
Message-ID: <20220909153246.8455-8-pali@kernel.org> (raw)
In-Reply-To: <20220909153246.8455-1-pali@kernel.org>
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 <pali@kernel.org>
---
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
next prev parent reply other threads:[~2022-09-09 15:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 15:32 [PATCH 0/9] Support for 4 GB DDR modules for 32-bit U-Boot builds Pali Rohár
2022-09-09 15:32 ` [PATCH 1/9] common/memsize.c: Fix get_effective_memsize() to always check for CONFIG_MAX_MEM_MAPPED Pali Rohár
2022-09-23 22:48 ` Tom Rini
2022-09-09 15:32 ` [PATCH 2/9] common/memsize.c: Fix get_effective_memsize() to check for overflow Pali Rohár
2022-09-09 15:32 ` [PATCH 3/9] board_f: Fix types for board_get_usable_ram_top() Pali Rohár
2022-09-09 18:21 ` Simon Glass
2022-09-09 15:32 ` [PATCH 4/9] board_f: Fix printing gd->ram_size and gd->ram_top Pali Rohár
2022-09-09 18:20 ` Simon Glass
2022-09-09 21:46 ` Pali Rohár
2022-09-12 13:33 ` Simon Glass
2022-09-09 15:32 ` [PATCH 5/9] ddr: fsl: Fix checking for maximal mappable memory Pali Rohár
2022-09-09 15:32 ` [PATCH 6/9] ddr: fsl: Fix fsl_ddr_sdram_size() for 4GB modules with 32-bit phys_size_t Pali Rohár
2022-09-09 15:32 ` Pali Rohár [this message]
2022-09-09 15:32 ` [PATCH 8/9] ddr: fsl: Fix re-align of verbose DRAM information for non-SPL builds Pali Rohár
2022-09-09 18:21 ` Simon Glass
2022-09-09 19:08 ` Tom Rini
2022-09-09 19:39 ` Simon Glass
2022-09-09 21:05 ` Tom Rini
2022-09-09 15:32 ` [PATCH 9/9] powerpc/mpc85xx: Explain TLB unmapped memory message Pali Rohár
2022-09-11 9:29 ` [PATCH 10/9] powerpc/mpc85xx: Fix re-align of unmapped DDR memory message for non-SPL builds Pali Rohár
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220909153246.8455-8-pali@kernel.org \
--to=pali@kernel.org \
--cc=kabel@kernel.org \
--cc=peng.fan@oss.nxp.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox