[v2,30/86] arm:sbsa-ref: use memdev for RAM
diff mbox series

Message ID 1579100861-73692-31-git-send-email-imammedo@redhat.com
State New
Headers show
Series
  • refactor main RAM allocation to use hostmem backend
Related show

Commit Message

Igor Mammedov Jan. 15, 2020, 3:06 p.m. UTC
memory_region_allocate_system_memory() API is going away, so
replace it with memdev allocated MemoryRegion. The later is
initialized by generic code, so board only needs to opt in
to memdev scheme by providing
  MachineClass::default_ram_id
and using MachineState::ram instead of manually initializing
RAM memory region.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: peter.maydell@linaro.org
CC: qemu-arm@nongnu.org
CC: radoslaw.biernacki@linaro.org
CC: leif.lindholm@linaro.org
---
 hw/arm/sbsa-ref.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Philippe Mathieu-Daudé Jan. 15, 2020, 7:09 p.m. UTC | #1
On 1/15/20 4:06 PM, Igor Mammedov wrote:
> memory_region_allocate_system_memory() API is going away, so
> replace it with memdev allocated MemoryRegion. The later is
> initialized by generic code, so board only needs to opt in
> to memdev scheme by providing
>    MachineClass::default_ram_id
> and using MachineState::ram instead of manually initializing
> RAM memory region.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> CC: peter.maydell@linaro.org
> CC: qemu-arm@nongnu.org
> CC: radoslaw.biernacki@linaro.org
> CC: leif.lindholm@linaro.org
> ---
>   hw/arm/sbsa-ref.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index 9b5bcb5..1cba9fc 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -593,7 +593,6 @@ static void sbsa_ref_init(MachineState *machine)
>       MachineClass *mc = MACHINE_GET_CLASS(machine);
>       MemoryRegion *sysmem = get_system_memory();
>       MemoryRegion *secure_sysmem = g_new(MemoryRegion, 1);
> -    MemoryRegion *ram = g_new(MemoryRegion, 1);
>       bool firmware_loaded;
>       const CPUArchIdList *possible_cpus;
>       int n, sbsa_max_cpus;
> @@ -685,9 +684,8 @@ static void sbsa_ref_init(MachineState *machine)
>           object_unref(cpuobj);
>       }
>   
> -    memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram",
> -                                         machine->ram_size);
> -    memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram);
> +    memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base,
> +                                machine->ram);
>   
>       create_fdt(sms);
>   
> @@ -785,6 +783,7 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data)
>       mc->block_default_type = IF_IDE;
>       mc->no_cdrom = 1;
>       mc->default_ram_size = 1 * GiB;
> +    mc->default_ram_id = "sbsa-ref.ram";
>       mc->default_cpus = 4;
>       mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids;
>       mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props;
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Patch
diff mbox series

diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index 9b5bcb5..1cba9fc 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -593,7 +593,6 @@  static void sbsa_ref_init(MachineState *machine)
     MachineClass *mc = MACHINE_GET_CLASS(machine);
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *secure_sysmem = g_new(MemoryRegion, 1);
-    MemoryRegion *ram = g_new(MemoryRegion, 1);
     bool firmware_loaded;
     const CPUArchIdList *possible_cpus;
     int n, sbsa_max_cpus;
@@ -685,9 +684,8 @@  static void sbsa_ref_init(MachineState *machine)
         object_unref(cpuobj);
     }
 
-    memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram",
-                                         machine->ram_size);
-    memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram);
+    memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base,
+                                machine->ram);
 
     create_fdt(sms);
 
@@ -785,6 +783,7 @@  static void sbsa_ref_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_IDE;
     mc->no_cdrom = 1;
     mc->default_ram_size = 1 * GiB;
+    mc->default_ram_id = "sbsa-ref.ram";
     mc->default_cpus = 4;
     mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids;
     mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props;