Message ID | 20200217173452.15243-68-imammedo@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | refactor main RAM allocation to use hostmem backend | expand |
On 2/17/20 9:34 AM, 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> > Acked-by: David Gibson <david@gibson.dropbear.id.au> > --- Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
On 2/17/20 6:34 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> > Acked-by: David Gibson <david@gibson.dropbear.id.au> > --- > hw/ppc/spapr.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index c9b2e0a5e0..4d90f99195 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -2634,7 +2634,6 @@ static void spapr_machine_init(MachineState *machine) > PCIHostState *phb; > int i; > MemoryRegion *sysmem = get_system_memory(); > - MemoryRegion *ram = g_new(MemoryRegion, 1); > hwaddr node0_size = spapr_node0_size(machine); > long load_limit, fw_size; > char *filename; > @@ -2813,10 +2812,8 @@ static void spapr_machine_init(MachineState *machine) > kvmppc_enable_h_page_init(); > } > > - /* allocate RAM */ > - memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram", > - machine->ram_size); > - memory_region_add_subregion(sysmem, 0, ram); > + /* map RAM */ > + memory_region_add_subregion(sysmem, 0, machine->ram); > > /* always allocate the device memory information */ > machine->device_memory = g_malloc0(sizeof(*machine->device_memory)); > @@ -4400,6 +4397,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) > mc->no_parallel = 1; > mc->default_boot_order = ""; > mc->default_ram_size = 512 * MiB; > + mc->default_ram_id = "ppc_spapr.ram"; > mc->default_display = "std"; > mc->kvm_type = spapr_kvm_type; > machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE); > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index c9b2e0a5e0..4d90f99195 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2634,7 +2634,6 @@ static void spapr_machine_init(MachineState *machine) PCIHostState *phb; int i; MemoryRegion *sysmem = get_system_memory(); - MemoryRegion *ram = g_new(MemoryRegion, 1); hwaddr node0_size = spapr_node0_size(machine); long load_limit, fw_size; char *filename; @@ -2813,10 +2812,8 @@ static void spapr_machine_init(MachineState *machine) kvmppc_enable_h_page_init(); } - /* allocate RAM */ - memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram", - machine->ram_size); - memory_region_add_subregion(sysmem, 0, ram); + /* map RAM */ + memory_region_add_subregion(sysmem, 0, machine->ram); /* always allocate the device memory information */ machine->device_memory = g_malloc0(sizeof(*machine->device_memory)); @@ -4400,6 +4397,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->no_parallel = 1; mc->default_boot_order = ""; mc->default_ram_size = 512 * MiB; + mc->default_ram_id = "ppc_spapr.ram"; mc->default_display = "std"; mc->kvm_type = spapr_kvm_type; machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE);