ddr: fsl: Fix fsl_ddr_sdram_size() for 4GB modules with 32-bit phys_size_t
authorPali Rohár <pali@kernel.org>
Fri, 9 Sep 2022 15:32:43 +0000 (17:32 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 23 Sep 2022 19:13:18 +0000 (15:13 -0400)
commit922460be0b72b40cae52f5e870d38c90b609b64b
tree8cf09a08e273f29f3a514c5c1b6d7b16274dbefd
parentcf4eba4eb66dbf6102200af6ba6f1ee05fabfe3d
ddr: fsl: Fix fsl_ddr_sdram_size() for 4GB modules with 32-bit phys_size_t

Function fsl_ddr_compute() always return size in unsigned long long type,
but function fsl_ddr_sdram_size() returns size in phys_size_t type.

When 36-bit addressing mode is not enabled then phys_size_t type is only
32-bit and thus it cannot store value 4GB (0x100000000). Function
fsl_ddr_sdram_size() in this case returns truncated value 0x0.

Fix this issue by returning the highest representable value, which is
0xffffffff (4GB - 1 byte).

This change fixes crashing of proper U-Boot because it detected 4 GB module
as RAM with zero size.

Signed-off-by: Pali Rohár <pali@kernel.org>
drivers/ddr/fsl/main.c