eliminate remaining places that abuse memory_region_allocate_system_memory()
cover eliminate remaining places that abuse memory_region_allocate_system_memory()
Series cleans up remaining boards that call memory_region_allocate_system_memory() multiple times, violating interface contract (the function should be called only once).
With that cleaned up, it should be possible to switch from adhoc RAM allocation in memory_region_allocate_system_memory()->allocate_system_memory_nonnuma() to memory-backend based allocation, remaining roadblock for doing it is deprecated -mem-path fallback to RAM allocation, which is scheduled for removal at 4.3 merge window. So remaining patches to consolidate system RAM allocation around memory-backends and aliasing -mem-path/mem-prealloc to it are postponed till then.
Igor Mammedov (3):
sparc64: use memory_region_allocate_system_memory() only for '-m'
specified RAM
ppc: rs6000_mc: drop usage of memory_region_allocate_system_memory()
hppa: drop usage of memory_region_allocate_system_memory() for ROM
hw/hppa/machine.c | 5 ++--- hw/ppc/rs6000_mc.c | 15 ++++++++++----- hw/sparc64/niagara.c | 25 +++++++++++++------------ 3 files changed, 25 insertions(+), 20 deletions(-)
Signature · 1 line
2.18.1
PATCH 1/3 sparc64: use memory_region_allocate_system_memory() only for '-m' specified RAM
memory_region_allocate_system_memory() was designed to be called for allocating inital RAM. Using it mutiple times within one board is not supported and could fail if -mem-path with non hugepage path is used.
Keep using memory_region_allocate_system_memory() only for initial RAM and use memory_region_init_ram() for the rest fixed size regions.
--- hw/sparc64/niagara.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
hw/sparc64/niagara.c +13 -12
@@ -36,6 +36,7 @@#include "qemu/error-report.h" #include "sysemu/qtest.h" #include "sysemu/sysemu.h" +#include "qapi/error.h" typedef struct NiagaraBoardState { MemoryRegion hv_ram;
@@ -106,8 +107,8 @@ static void niagara_init(MachineState *machine)/* init CPUs */ sparc64_cpu_devinit (machine->cpu_type,NIAGARA_PROM_BASE );/* set up devices */ -memory_region_allocate_system_memory (&s->hv_ram,NULL ,"sun4v-hv.ram" , -NIAGARA_HV_RAM_SIZE ); +memory_region_init_ram (&s->hv_ram,NULL ,"sun4v-hv.ram" , +NIAGARA_HV_RAM_SIZE , &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_HV_RAM_BASE , &s->hv_ram); memory_region_allocate_system_memory(&s->partition_ram, NULL,
@@ -116,17 +117,17 @@ static void niagara_init(MachineState *machine)memory_region_add_subregion (sysmem,NIAGARA_PARTITION_RAM_BASE , &s->partition_ram); -memory_region_allocate_system_memory (&s->nvram,NULL , -"sun4v.nvram" ,NIAGARA_NVRAM_SIZE ); +memory_region_init_ram (&s->nvram,NULL ,"sun4v.nvram" ,NIAGARA_NVRAM_SIZE , + &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_NVRAM_BASE , &s->nvram); -memory_region_allocate_system_memory (&s->md_rom,NULL , -"sun4v-md.rom" ,NIAGARA_MD_ROM_SIZE ); +memory_region_init_ram (&s->md_rom,NULL ,"sun4v-md.rom" , +NIAGARA_MD_ROM_SIZE , &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_MD_ROM_BASE , &s->md_rom); -memory_region_allocate_system_memory (&s->hv_rom,NULL , -"sun4v-hv.rom" ,NIAGARA_HV_ROM_SIZE ); +memory_region_init_ram (&s->hv_rom,NULL ,"sun4v-hv.rom" , +NIAGARA_HV_ROM_SIZE , &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_HV_ROM_BASE , &s->hv_rom); -memory_region_allocate_system_memory (&s->prom,NULL , -"sun4v.prom" ,PROM_SIZE_MAX ); +memory_region_init_ram (&s->prom,NULL ,"sun4v.prom" ,PROM_SIZE_MAX , + &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_PROM_BASE , &s->prom);add_rom_or_fail ("nvram1" ,NIAGARA_NVRAM_BASE );
@@ -143,8 +144,8 @@ static void niagara_init(MachineState *machine)BlockBackend *blk =blk_by_legacy_dinfo (dinfo);int size =blk_getlength (blk);if (size >0 ) { -memory_region_allocate_system_memory (&s->vdisk_ram,NULL , -"sun4v_vdisk.ram" , size); +memory_region_init_ram (&s->vdisk_ram,NULL ,"sun4v_vdisk.ram" , size, + &error_fatal);memory_region_add_subregion (get_system_memory (),NIAGARA_VDISK_BASE , &s->vdisk_ram); dinfo->is_default =1 ;
Signature · 1 line
2.18.1
Re: [PATCH 1/3] sparc64: use memory_region_allocate_system_memory() only for '-m' specified RAM
Quoted 25 lines · Igor Mammedov
memory_region_allocate_system_memory()was designed to be called for allocating inital RAM. Using it mutiple times within one board is not supported and could fail if -mem-path with non hugepage path is used.Keep using
memory_region_allocate_system_memory()only for initial RAM and usememory_region_init_ram()for the rest fixed size regions.Signed-off-by Igor Mammedov <[email protected]>--- hw/sparc64/niagara.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)hw/sparc64/niagara.c +1
-0@@ -36,6 +36,7 @@#include "qemu/error-report.h" #include "sysemu/qtest.h" #include "sysemu/sysemu.h" +#include "qapi/error.h" typedef struct NiagaraBoardState { MemoryRegion hv_ram;
hw/sparc64/niagara.c static void niagara_init(MachineState *machine) · line 114
Quoted 10 lines
hw/sparc64/niagara.c +2
-2@@ -106,8 +107,8 @@ static void niagara_init(MachineState *machine)/* init CPUs */ sparc64_cpu_devinit (machine->cpu_type,NIAGARA_PROM_BASE );/* set up devices */ -memory_region_allocate_system_memory (&s->hv_ram,NULL ,"sun4v-hv.ram" , -NIAGARA_HV_RAM_SIZE ); +memory_region_init_ram (&s->hv_ram,NULL ,"sun4v-hv.ram" , +NIAGARA_HV_RAM_SIZE , &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_HV_RAM_BASE , &s->hv_ram); memory_region_allocate_system_memory(&s->partition_ram, NULL,
Did we have an issue calling memory_region_allocate_system_memory() *after* memory_region_init_ram() by the past? Maybe not, or it is fixed, and your patch is fine:
Quoted 38 lines
hw/sparc64/niagara.c +10
-10@@ -116,17 +117,17 @@ static void niagara_init(MachineState *machine)memory_region_add_subregion (sysmem,NIAGARA_PARTITION_RAM_BASE , &s->partition_ram); -memory_region_allocate_system_memory (&s->nvram,NULL , -"sun4v.nvram" ,NIAGARA_NVRAM_SIZE ); +memory_region_init_ram (&s->nvram,NULL ,"sun4v.nvram" ,NIAGARA_NVRAM_SIZE , + &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_NVRAM_BASE , &s->nvram); -memory_region_allocate_system_memory (&s->md_rom,NULL , -"sun4v-md.rom" ,NIAGARA_MD_ROM_SIZE ); +memory_region_init_ram (&s->md_rom,NULL ,"sun4v-md.rom" , +NIAGARA_MD_ROM_SIZE , &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_MD_ROM_BASE , &s->md_rom); -memory_region_allocate_system_memory (&s->hv_rom,NULL , -"sun4v-hv.rom" ,NIAGARA_HV_ROM_SIZE ); +memory_region_init_ram (&s->hv_rom,NULL ,"sun4v-hv.rom" , +NIAGARA_HV_ROM_SIZE , &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_HV_ROM_BASE , &s->hv_rom); -memory_region_allocate_system_memory (&s->prom,NULL , -"sun4v.prom" ,PROM_SIZE_MAX ); +memory_region_init_ram (&s->prom,NULL ,"sun4v.prom" ,PROM_SIZE_MAX , + &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_PROM_BASE , &s->prom);add_rom_or_fail ("nvram1" ,NIAGARA_NVRAM_BASE );@@ -143,8 +144,8 @@ static void niagara_init(MachineState *machine)BlockBackend *blk =blk_by_legacy_dinfo (dinfo);int size =blk_getlength (blk);if (size >0 ) { -memory_region_allocate_system_memory (&s->vdisk_ram,NULL , -"sun4v_vdisk.ram" , size); +memory_region_init_ram (&s->vdisk_ram,NULL ,"sun4v_vdisk.ram" , size, + &error_fatal);memory_region_add_subregion (get_system_memory (),NIAGARA_VDISK_BASE , &s->vdisk_ram); dinfo->is_default =1 ;
Re: [PATCH 1/3] sparc64: use memory_region_allocate_system_memory() only for '-m' specified RAM
Quoted 35 lines · On Tue, 8 Oct 2019 14:09:28 +0200 Philippe Mathieu-Daudé <[email protected]>…
Quoted 34 lines · Igor Mammedov
memory_region_allocate_system_memory()was designed to be called for allocating inital RAM. Using it mutiple times within one board is not supported and could fail if -mem-path with non hugepage path is used.Keep using
memory_region_allocate_system_memory()only for initial RAM and usememory_region_init_ram()for the rest fixed size regions.Signed-off-by Igor Mammedov <[email protected]>--- hw/sparc64/niagara.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)hw/sparc64/niagara.c +3
-2@@ -36,6 +36,7 @@#include "qemu/error-report.h" #include "sysemu/qtest.h" #include "sysemu/sysemu.h" +#include "qapi/error.h" typedef struct NiagaraBoardState { MemoryRegion hv_ram;@@ -106,8 +107,8 @@ static void niagara_init(MachineState *machine)/* init CPUs */ sparc64_cpu_devinit (machine->cpu_type,NIAGARA_PROM_BASE );/* set up devices */ -memory_region_allocate_system_memory (&s->hv_ram,NULL ,"sun4v-hv.ram" , -NIAGARA_HV_RAM_SIZE ); +memory_region_init_ram (&s->hv_ram,NULL ,"sun4v-hv.ram" , +NIAGARA_HV_RAM_SIZE , &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_HV_RAM_BASE , &s->hv_ram);
Quoted 4 lines
hw/sparc64/niagara.c static void niagara_init(MachineState *machine) · line 114
Quoted 1 line
hw/sparc64/niagara.c +0
-0memory_region_allocate_system_memory(&s->partition_ram, NULL,Did we have an issue calling
memory_region_allocate_system_memory()*after*memory_region_init_ram()by the past?
I don't recall any, memory_region_init_ram() is essentially the same as memory_region_allocate_system_memory() for most of emulated machines (i.e. non-numa, no mem-path cases)
Quoted 2 lines
Maybe not, or it is fixed, and your patch is fine:
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Thanks!
Quoted 40 lines
Quoted 39 lines
hw/sparc64/niagara.c +10
-10@@ -116,17 +117,17 @@ static void niagara_init(MachineState *machine)memory_region_add_subregion (sysmem,NIAGARA_PARTITION_RAM_BASE , &s->partition_ram); -memory_region_allocate_system_memory (&s->nvram,NULL , -"sun4v.nvram" ,NIAGARA_NVRAM_SIZE ); +memory_region_init_ram (&s->nvram,NULL ,"sun4v.nvram" ,NIAGARA_NVRAM_SIZE , + &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_NVRAM_BASE , &s->nvram); -memory_region_allocate_system_memory (&s->md_rom,NULL , -"sun4v-md.rom" ,NIAGARA_MD_ROM_SIZE ); +memory_region_init_ram (&s->md_rom,NULL ,"sun4v-md.rom" , +NIAGARA_MD_ROM_SIZE , &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_MD_ROM_BASE , &s->md_rom); -memory_region_allocate_system_memory (&s->hv_rom,NULL , -"sun4v-hv.rom" ,NIAGARA_HV_ROM_SIZE ); +memory_region_init_ram (&s->hv_rom,NULL ,"sun4v-hv.rom" , +NIAGARA_HV_ROM_SIZE , &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_HV_ROM_BASE , &s->hv_rom); -memory_region_allocate_system_memory (&s->prom,NULL , -"sun4v.prom" ,PROM_SIZE_MAX ); +memory_region_init_ram (&s->prom,NULL ,"sun4v.prom" ,PROM_SIZE_MAX , + &error_fatal);memory_region_add_subregion (sysmem,NIAGARA_PROM_BASE , &s->prom);add_rom_or_fail ("nvram1" ,NIAGARA_NVRAM_BASE );@@ -143,8 +144,8 @@ static void niagara_init(MachineState *machine)BlockBackend *blk =blk_by_legacy_dinfo (dinfo);int size =blk_getlength (blk);if (size >0 ) { -memory_region_allocate_system_memory (&s->vdisk_ram,NULL , -"sun4v_vdisk.ram" , size); +memory_region_init_ram (&s->vdisk_ram,NULL ,"sun4v_vdisk.ram" , size, + &error_fatal);memory_region_add_subregion (get_system_memory (),NIAGARA_VDISK_BASE , &s->vdisk_ram); dinfo->is_default =1 ;
PATCH 2/3 ppc: rs6000_mc: drop usage of memory_region_allocate_system_memory()
In reply to Igor Mammedovrs6000mc_realize() violates memory_region_allocate_system_memory() contract by calling it multiple times which could break -mem-path. Replace it with plain memory_region_init_ram() instead.
--- hw/ppc/rs6000_mc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
hw/ppc/rs6000_mc.c +10 -5
@@ -144,6 +144,7 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)RS6000MCState *s =RS6000MC_DEVICE (dev);int socket =0 ;unsigned int ram_size = s->ram_size / MiB; +Error *local_err =NULL ;while (socket <6 ) {if (ram_size >=64 ) {
@@ -165,19 +166,21 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)if (s->simm_size[socket]) {char name[] ="simm.?" ; name[5 ] = socket +'0' ; -memory_region_allocate_system_memory (&s->simm[socket],OBJECT (dev), - name, - s->simm_size[socket] * MiB); +memory_region_init_ram (&s->simm[socket],OBJECT (dev), name, + s->simm_size[socket] * MiB, &local_err); +if (local_err) { + goto out; + }memory_region_add_subregion_overlap (get_system_memory (),0 , &s->simm[socket], socket); } }if (ram_size) {/* unable to push all requested RAM in SIMMs */ -error_setg (errp,"RAM size incompatible with this board. " +error_setg (&local_err,"RAM size incompatible with this board. " "Try again with something else, like %" PRId64" MB" , s->ram_size / MiB - ram_size); -return ; + goto out; }if (s->autoconfigure) {
@@ -193,6 +196,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)isa_register_portio_list (ISA_DEVICE (dev), &s->portio,0x0 , rs6000mc_port_list, s,"rs6000mc" ); +out: +error_propagate (errp, local_err); }static const VMStateDescription vmstate_rs6000mc = {
Signature · 1 line
2.18.1
Re: [PATCH 2/3] ppc: rs6000_mc: drop usage of memory_region_allocate_system_memory()
Quoted 5 lines · Igor Mammedov
rs6000mc_realize()violatesmemory_region_allocate_system_memory()contract by calling it multiple times which could break -mem-path. Replace it with plainmemory_region_init_ram()instead.Signed-off-by Igor Mammedov <[email protected]>
Quoted 53 lines
--- hw/ppc/rs6000_mc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)hw/ppc/rs6000_mc.c +10
-5@@ -144,6 +144,7 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)RS6000MCState *s =RS6000MC_DEVICE (dev);int socket =0 ;unsigned int ram_size = s->ram_size / MiB; +Error *local_err =NULL ;while (socket <6 ) {if (ram_size >=64 ) {@@ -165,19 +166,21 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)if (s->simm_size[socket]) {char name[] ="simm.?" ; name[5 ] = socket +'0' ; -memory_region_allocate_system_memory (&s->simm[socket],OBJECT (dev), - name, - s->simm_size[socket] * MiB); +memory_region_init_ram (&s->simm[socket],OBJECT (dev), name, + s->simm_size[socket] * MiB, &local_err); +if (local_err) { + goto out; + }memory_region_add_subregion_overlap (get_system_memory (),0 , &s->simm[socket], socket); } }if (ram_size) {/* unable to push all requested RAM in SIMMs */ -error_setg (errp,"RAM size incompatible with this board. " +error_setg (&local_err,"RAM size incompatible with this board. " "Try again with something else, like %" PRId64" MB" , s->ram_size / MiB - ram_size); -return ; + goto out; }if (s->autoconfigure) {@@ -193,6 +196,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)isa_register_portio_list (ISA_DEVICE (dev), &s->portio,0x0 , rs6000mc_port_list, s,"rs6000mc" ); +out: +error_propagate (errp, local_err); }static const VMStateDescription vmstate_rs6000mc = {
Re: [PATCH 2/3] ppc: rs6000_mc: drop usage of memory_region_allocate_system_memory()
In reply to Igor MammedovQuoted 5 lines · Igor Mammedov
rs6000mc_realize()violatesmemory_region_allocate_system_memory()contract by calling it multiple times which could break -mem-path. Replace it with plainmemory_region_init_ram()instead.Signed-off-by Igor Mammedov <[email protected]>
Or would you like me to merge this through my tree?
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH 2/3] ppc: rs6000_mc: drop usage of memory_region_allocate_system_memory()
Quoted 10 lines · On Wed, 9 Oct 2019 12:21:06 +1100 David Gibson <[email protected]>…
Quoted 5 lines · Igor Mammedov
rs6000mc_realize()violatesmemory_region_allocate_system_memory()contract by calling it multiple times which could break -mem-path. Replace it with plainmemory_region_init_ram()instead.Signed-off-by Igor Mammedov <[email protected]>Acked-by David Gibson <[email protected]>Or would you like me to merge this through my tree?
(since it doesn't belong to a particular tree, I'd need find some to take in in)
Since you volunteered :),
please merge this series via your tree.
Thanks!
Re: [PATCH 2/3] ppc: rs6000_mc: drop usage of memory_region_allocate_system_memory()
Quoted 12 lines · Igor Mammedov
Quoted 9 lines · On Wed, 9 Oct 2019 12:21:06 +1100 David Gibson <[email protected]>…
Quoted 5 lines · Igor Mammedov
rs6000mc_realize()violatesmemory_region_allocate_system_memory()contract by calling it multiple times which could break -mem-path. Replace it with plainmemory_region_init_ram()instead.Signed-off-by Igor Mammedov <[email protected]>Acked-by David Gibson <[email protected]>
Quoted 8 lines
Quoted 1 line
Or would you like me to merge this through my tree?
(since it doesn't belong to a particular tree, I'd need find some to take in in)
Since you volunteered :),
please merge this series via your tree.
Uhhh.. I was offering to take this patch, not the whole series. I'm not real comfortable taking the others, since they don't involve ppc code, nor are they prereqs for or motivated by any ppc change.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 3/3 hppa: drop usage of memory_region_allocate_system_memory() for ROM
In reply to Igor Mammedovmachine_hppa_init() violates memory_region_allocate_system_memory() contract by calling it multiple times which could break with -mem-path. Replace the second usage (for 'rom') with memory_region_init_ram() instead.
--- hw/hppa/machine.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hw/hppa/machine.c +2 -3
@@ -161,9 +161,8 @@ static void machine_hppa_init(MachineState *machine)g_free (firmware_filename); rom_region =g_new (MemoryRegion,1 ); -memory_region_allocate_system_memory (rom_region,OBJECT (machine), -"firmware" , - (FIRMWARE_END -FIRMWARE_START )); +memory_region_init_ram (rom_region,NULL ,"firmware" , + (FIRMWARE_END -FIRMWARE_START ), &error_fatal);memory_region_add_subregion (addr_space,FIRMWARE_START , rom_region);/* Load kernel */
Signature · 1 line
2.18.1
Re: [PATCH 3/3] hppa: drop usage of memory_region_allocate_system_memory() for ROM
Quoted 16 lines · Igor Mammedov
machine_hppa_init()violatesmemory_region_allocate_system_memory()contract by calling it multiple times which could break with -mem-path. Replace the second usage (for 'rom') withmemory_region_init_ram()instead.Signed-off-by Igor Mammedov <[email protected]>--- hw/hppa/machine.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)hw/hppa/machine.c +0
-0@@ -161,9 +161,8 @@ static void machine_hppa_init(MachineState *machine)g_free (firmware_filename);
hw/hppa/machine.c static void machine_hppa_init(MachineState *machine) · line 168
Quoted 10 lines
hw/hppa/machine.c +2
-3rom_region =g_new (MemoryRegion,1 ); -memory_region_allocate_system_memory (rom_region,OBJECT (machine), -"firmware" , - (FIRMWARE_END -FIRMWARE_START )); +memory_region_init_ram (rom_region,NULL ,"firmware" , + (FIRMWARE_END -FIRMWARE_START ), &error_fatal);memory_region_add_subregion (addr_space,FIRMWARE_START , rom_region);/* Load kernel */
Re: [PATCH 3/3] hppa: drop usage of memory_region_allocate_system_memory() for ROM
In reply to Igor MammedovQuoted 16 lines · Igor Mammedov
machine_hppa_init()violatesmemory_region_allocate_system_memory()contract by calling it multiple times which could break with -mem-path. Replace the second usage (for 'rom') withmemory_region_init_ram()instead.Signed-off-by Igor Mammedov <[email protected]>--- hw/hppa/machine.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)hw/hppa/machine.c +0
-0@@ -161,9 +161,8 @@ static void machine_hppa_init(MachineState *machine)g_free (firmware_filename);
hw/hppa/machine.c static void machine_hppa_init(MachineState *machine) · line 168
Quoted 10 lines
hw/hppa/machine.c +2
-3rom_region =g_new (MemoryRegion,1 ); -memory_region_allocate_system_memory (rom_region,OBJECT (machine), -"firmware" , - (FIRMWARE_END -FIRMWARE_START )); +memory_region_init_ram (rom_region,NULL ,"firmware" , + (FIRMWARE_END -FIRMWARE_START ), &error_fatal);memory_region_add_subregion (addr_space,FIRMWARE_START , rom_region);/* Load kernel */
Hi Igor,
Quoted 11 lines · Igor Mammedov
Series cleans up remaining boards that call
memory_region_allocate_system_memory()multiple times, violating interface contract (the function should be called only once).With that cleaned up, it should be possible to switch from adhoc RAM allocation in memory_region_allocate_system_memory()->allocate_system_memory_nonnuma() to memory-backend based allocation, remaining roadblock for doing it is deprecated -mem-path fallback to RAM allocation, which is scheduled for removal at 4.3 merge window. So remaining patches to consolidate system RAM allocation around memory-backends and aliasing -mem-path/mem-prealloc to it are postponed till then.
How do we protect the codebase for new boards to not make the same mistake?
What about some code like this snippet (or nicer, but since this is a developer error, and assert is enough IMO):
-- >8 --
hw/core/numa.c +5 -0
@@ -484,6 +484,11 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,const char *name, uint64_t ram_size) { + static bool nonnuma_system_memory_allocated; + +g_assert (!nonnuma_system_memory_allocated); + nonnuma_system_memory_allocated = true; +if (mem_path) {#ifdef __linux__Error *err =NULL ;
---
$ hppa-softmmu/qemu-system-hppa ** ERROR:/home/phil/source/qemu/hw/core/numa.c:489:allocate_system_memory_nonnuma: assertion failed: (!nonnuma_system_memory_allocated) Aborted (core dumped)
Quoted 15 lines · On Tue, 8 Oct 2019 14:41:25 +0200 Philippe Mathieu-Daudé <[email protected]>…
Hi Igor,
Quoted 11 lines · Igor Mammedov
Series cleans up remaining boards that call
memory_region_allocate_system_memory()multiple times, violating interface contract (the function should be called only once).With that cleaned up, it should be possible to switch from adhoc RAM allocation in memory_region_allocate_system_memory()->allocate_system_memory_nonnuma() to memory-backend based allocation, remaining roadblock for doing it is deprecated -mem-path fallback to RAM allocation, which is scheduled for removal at 4.3 merge window. So remaining patches to consolidate system RAM allocation around memory-backends and aliasing -mem-path/mem-prealloc to it are postponed till then.
Quoted 4 lines
How do we protect the codebase for new boards to not make the same mistake?
What about some code like this snippet (or nicer, but since this is a developer error, and assert is enough IMO):
probably it's not worth effort (it's not too long till 4.2 softfreeze).
Like cover letter say, I'm planing to finish refactoring of memory_region_allocate_system_memory() and I hope this function will be gone during 4.3 and most boards will only need to map pre-created (by common code) memory-backend wherever they used to map RAM memory region.
Quoted 26 lines
-- >8 --
hw/core/numa.c +5
-0@@ -484,6 +484,11 @@ static voidallocate_system_memory_nonnuma (MemoryRegion *mr, Object *owner, const char *name, uint64_t ram_size) { +static bool nonnuma_system_memory_allocated; + +g_assert (!nonnuma_system_memory_allocated); + nonnuma_system_memory_allocated = true; +if (mem_path) {#ifdef __linux__Error *err = NULL;---
$ hppa-softmmu/qemu-system-hppa ** ERROR:/home/phil/source/qemu/hw/core/numa.c:489:allocate_system_memory_nonnuma: assertion failed: (!nonnuma_system_memory_allocated) Aborted (core dumped)
Quoted 5 lines · On Tue, 8 Oct 2019 07:33:15 -0400 Igor Mammedov <[email protected]> wrote:
Series cleans up remaining boards that call
memory_region_allocate_system_memory()multiple times, violating interface contract (the function should be called only once).
Quoted 7 lines
With that cleaned up, it should be possible to switch from adhoc RAM allocation in memory_region_allocate_system_memory()->allocate_system_memory_nonnuma() to memory-backend based allocation, remaining roadblock for doing it is deprecated -mem-path fallback to RAM allocation, which is scheduled for removal at 4.3 merge window. So remaining patches to consolidate system RAM allocation around memory-backends and aliasing -mem-path/mem-prealloc to it are postponed till then.
Eduardo,
This patches are fixing various machines across tree, so series does not belong to any particular arch specific tree, can you merge it via generic machine tree?
Quoted 13 lines
Igor Mammedov (3):
sparc64: usememory_region_allocate_system_memory()only for '-m'
specified RAM
ppc:rs6000_mc: drop usage ofmemory_region_allocate_system_memory()
hppa: drop usage ofmemory_region_allocate_system_memory()for ROMhw/hppa/machine.c | 5 ++--- hw/ppc/rs6000_mc.c | 15 ++++++++++----- hw/sparc64/niagara.c | 25 +++++++++++++------------ 3 files changed, 25 insertions(+), 20 deletions(-)
On Thu, 10 Oct 2019 19:35:03 +0200
Igor Mammedov <[email protected]> wrote:
Forgot to actually CC Eduardo,
Quoted 2 lines
On Tue, 8 Oct 2019 07:33:15 -0400
Igor Mammedov <[email protected]> wrote:
...
Quoted 21 lines
Eduardo,
This patches are fixing various machines across tree, so series does not belong to any particular arch specific tree, can you merge it via generic machine tree?
Quoted 13 lines
Igor Mammedov (3):
sparc64: usememory_region_allocate_system_memory()only for '-m'
specified RAM
ppc:rs6000_mc: drop usage ofmemory_region_allocate_system_memory()
hppa: drop usage ofmemory_region_allocate_system_memory()for ROMhw/hppa/machine.c | 5 ++--- hw/ppc/rs6000_mc.c | 15 ++++++++++----- hw/sparc64/niagara.c | 25 +++++++++++++------------ 3 files changed, 25 insertions(+), 20 deletions(-)
Ping?
Quoted 27 lines · Igor Mammedov
On Thu, 10 Oct 2019 19:35:03 +0200
Igor Mammedov <[email protected]> wrote:Forgot to actually CC Eduardo,
Quoted 2 lines
On Tue, 8 Oct 2019 07:33:15 -0400
Igor Mammedov <[email protected]> wrote:...
Quoted 19 lines
Eduardo,
This patches are fixing various machines across tree, so series does not belong to any particular arch specific tree, can you merge it via generic machine tree?
Quoted 13 lines
Igor Mammedov (3):
sparc64: usememory_region_allocate_system_memory()only for '-m'
specified RAM
ppc:rs6000_mc: drop usage ofmemory_region_allocate_system_memory()
hppa: drop usage ofmemory_region_allocate_system_memory()for ROMhw/hppa/machine.c | 5 ++--- hw/ppc/rs6000_mc.c | 15 ++++++++++----- hw/sparc64/niagara.c | 25 +++++++++++++------------ 3 files changed, 25 insertions(+), 20 deletions(-)
Quoted 1 line · Philippe Mathieu-Daudé
Ping?
Sorry, missed this. queued on machine-next. Pull request will be submitted today or tomorrow.
Quoted 29 lines · Igor Mammedov
Quoted 27 lines
On Thu, 10 Oct 2019 19:35:03 +0200
Igor Mammedov <[email protected]> wrote:Forgot to actually CC Eduardo,
Quoted 2 lines
On Tue, 8 Oct 2019 07:33:15 -0400
Igor Mammedov <[email protected]> wrote:...
Quoted 19 lines
Eduardo,
This patches are fixing various machines across tree, so series does not belong to any particular arch specific tree, can you merge it via generic machine tree?
Quoted 13 lines
Igor Mammedov (3):
sparc64: usememory_region_allocate_system_memory()only for '-m'
specified RAM
ppc:rs6000_mc: drop usage ofmemory_region_allocate_system_memory()
hppa: drop usage ofmemory_region_allocate_system_memory()for ROMhw/hppa/machine.c | 5 ++--- hw/ppc/rs6000_mc.c | 15 ++++++++++----- hw/sparc64/niagara.c | 25 +++++++++++++------------ 3 files changed, 25 insertions(+), 20 deletions(-)
Signature · 1 line
Eduardo
Hi Igor,
Quoted 19 lines · Igor Mammedov
Series cleans up remaining boards that call
memory_region_allocate_system_memory()multiple times, violating interface contract (the function should be called only once).With that cleaned up, it should be possible to switch from adhoc RAM allocation in memory_region_allocate_system_memory()->allocate_system_memory_nonnuma() to memory-backend based allocation, remaining roadblock for doing it is deprecated -mem-path fallback to RAM allocation, which is scheduled for removal at 4.3 merge window. So remaining patches to consolidate system RAM allocation around memory-backends and aliasing -mem-path/mem-prealloc to it are postponed till then.
Igor Mammedov (3):
sparc64: usememory_region_allocate_system_memory()only for '-m'
specified RAM
ppc:rs6000_mc: drop usage ofmemory_region_allocate_system_memory()
hppa: drop usage ofmemory_region_allocate_system_memory()for ROM
Quoted 3 lines
hw/hppa/machine.c | 5 ++--- hw/ppc/rs6000_mc.c | 15 ++++++++++----- hw/sparc64/niagara.c | 25 +++++++++++++------------
What about the TYPE_SUN4M_MEMORY device in hw/sparc/sun4m.c?
Quoted 22 lines · On Mon, 21 Oct 2019 10:59:56 +0200 Philippe Mathieu-Daudé <[email protected]>…
Hi Igor,
Quoted 19 lines · Igor Mammedov
Series cleans up remaining boards that call
memory_region_allocate_system_memory()multiple times, violating interface contract (the function should be called only once).With that cleaned up, it should be possible to switch from adhoc RAM allocation in memory_region_allocate_system_memory()->allocate_system_memory_nonnuma() to memory-backend based allocation, remaining roadblock for doing it is deprecated -mem-path fallback to RAM allocation, which is scheduled for removal at 4.3 merge window. So remaining patches to consolidate system RAM allocation around memory-backends and aliasing -mem-path/mem-prealloc to it are postponed till then.
Igor Mammedov (3):
sparc64: usememory_region_allocate_system_memory()only for '-m'
specified RAM
ppc:rs6000_mc: drop usage ofmemory_region_allocate_system_memory()
hppa: drop usage ofmemory_region_allocate_system_memory()for ROM
Quoted 5 lines
Quoted 3 lines
hw/hppa/machine.c | 5 ++--- hw/ppc/rs6000_mc.c | 15 ++++++++++----- hw/sparc64/niagara.c | 25 +++++++++++++------------What about the
TYPE_SUN4M_MEMORYdevice inhw/sparc/sun4m.c?
it has only one call site so it's not issue this series targets. I'll take care of it in follow up series, which will deal with converting memory_region_allocate_system_memory() to memdev only (probably I'll drop TYPE_SUN4M_MEMORY altogether)