diff mbox series

[v5,15/79] arm/imx25_pdk: drop RAM size fixup

Message ID 20200217173452.15243-16-imammedo@redhat.com (mailing list archive)
State New, archived
Headers show
Series refactor main RAM allocation to use hostmem backend | expand

Commit Message

Igor Mammedov Feb. 17, 2020, 5:33 p.m. UTC
If user provided non-sense RAM size, board will complain and
continue running with max RAM size supported.
Also RAM is going to be allocated by generic code, so it won't be
possible for board to fix things up for user.

Make it error message and exit to force user fix CLI,
instead of accepting non-sense CLI values.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: jcd@tribudubois.net
CC: peter.maydell@linaro.org
CC: qemu-arm@nongnu.org
CC: philmd@redhat.com
---
 hw/arm/imx25_pdk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Richard Henderson Feb. 17, 2020, 6:56 p.m. UTC | #1
On 2/17/20 9:33 AM, Igor Mammedov wrote:
>      /* We need to initialize our memory */
>      if (machine->ram_size > (FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE)) {
> -        warn_report("RAM size " RAM_ADDR_FMT " above max supported, "
> +        error_report("RAM size " RAM_ADDR_FMT " above max supported, "
>                      "reduced to %x", machine->ram_size,
>                      FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE);
> -        machine->ram_size = FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE;
> +        exit(EXIT_FAILURE);

The wording here doesn't make sense anymore.
I think it would be better to mirror that used elsewhere:

+        char *sz = size_to_str(mc->default_ram_size);
+        error_report("Invalid RAM size, should be %s", sz);
+        g_free(sz);

With that,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
Philippe Mathieu-Daudé Feb. 18, 2020, 6:51 a.m. UTC | #2
On 2/17/20 7:56 PM, Richard Henderson wrote:
> On 2/17/20 9:33 AM, Igor Mammedov wrote:
>>       /* We need to initialize our memory */
>>       if (machine->ram_size > (FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE)) {
>> -        warn_report("RAM size " RAM_ADDR_FMT " above max supported, "
>> +        error_report("RAM size " RAM_ADDR_FMT " above max supported, "
>>                       "reduced to %x", machine->ram_size,
>>                       FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE);
>> -        machine->ram_size = FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE;
>> +        exit(EXIT_FAILURE);
> 
> The wording here doesn't make sense anymore.
> I think it would be better to mirror that used elsewhere:
> 
> +        char *sz = size_to_str(mc->default_ram_size);
> +        error_report("Invalid RAM size, should be %s", sz);
> +        g_free(sz);
> 
> With that,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Agreed.
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff mbox series

Patch

diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c
index c76fc2bd94..a2b7b35dcc 100644
--- a/hw/arm/imx25_pdk.c
+++ b/hw/arm/imx25_pdk.c
@@ -78,10 +78,10 @@  static void imx25_pdk_init(MachineState *machine)
 
     /* We need to initialize our memory */
     if (machine->ram_size > (FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE)) {
-        warn_report("RAM size " RAM_ADDR_FMT " above max supported, "
+        error_report("RAM size " RAM_ADDR_FMT " above max supported, "
                     "reduced to %x", machine->ram_size,
                     FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE);
-        machine->ram_size = FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE;
+        exit(EXIT_FAILURE);
     }
 
     memory_region_allocate_system_memory(&s->ram, NULL, "imx25.ram",