Message ID | 20191020225650.3671-8-philmd@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | hw: Let the machine be the owner of the system memory | expand |
On Sun, Oct 20, 2019 at 4:10 PM Philippe Mathieu-Daudé <philmd@redhat.com> wrote: > > All the memory_region_allocate_system_memory() calls are in the > board_init() code. From the 58 calls in the repository, only > 4 set the 'owner' parameter. It is obvious we want the Machine > to be the owner of the RAM, so we want to use OBJECT(machine) > as owner. We can simplify a bit by passing MachineState to > memory_region_allocate_system_memory(). In preparation of this > refactor, first drop the 'owner' argument from these 4 uses. > > $ git grep memory_region_allocate_system_memory hw/ | wc -l > 58 > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > hw/alpha/typhoon.c | 2 +- > hw/arm/raspi.c | 2 +- > hw/hppa/machine.c | 2 +- > hw/sparc/sun4m.c | 2 +- > 4 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c > index 179e1f7658..8489ec335c 100644 > --- a/hw/alpha/typhoon.c > +++ b/hw/alpha/typhoon.c > @@ -851,7 +851,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, > > /* Main memory region, 0x00.0000.0000. Real hardware supports 32GB, > but the address space hole reserved at this point is 8TB. */ > - memory_region_allocate_system_memory(&s->ram_region, OBJECT(s), "ram", > + memory_region_allocate_system_memory(&s->ram_region, NULL, "ram", > ram_size); > memory_region_add_subregion(addr_space, 0, &s->ram_region); > > diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c > index 615d755879..f76b6eaad3 100644 > --- a/hw/arm/raspi.c > +++ b/hw/arm/raspi.c > @@ -182,7 +182,7 @@ static void raspi_init(MachineState *machine, int version) > &error_abort, NULL); > > /* Allocate and map RAM */ > - memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram", > + memory_region_allocate_system_memory(&s->ram, NULL, "ram", > machine->ram_size); > /* FIXME: Remove when we have custom CPU address space support */ > memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0); > diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c > index 953d454f48..dbe1ff0fe5 100644 > --- a/hw/hppa/machine.c > +++ b/hw/hppa/machine.c > @@ -96,7 +96,7 @@ static void machine_hppa_init(MachineState *machine) > > /* Main memory region. */ > ram_region = g_new(MemoryRegion, 1); > - memory_region_allocate_system_memory(ram_region, OBJECT(machine), > + memory_region_allocate_system_memory(ram_region, NULL, > "ram", ram_size); > memory_region_add_subregion(addr_space, 0, ram_region); > > diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c > index 6c5a17a020..0bb7524655 100644 > --- a/hw/sparc/sun4m.c > +++ b/hw/sparc/sun4m.c > @@ -788,7 +788,7 @@ static void ram_realize(DeviceState *dev, Error **errp) > RamDevice *d = SUN4M_RAM(dev); > SysBusDevice *sbd = SYS_BUS_DEVICE(dev); > > - memory_region_allocate_system_memory(&d->ram, OBJECT(d), "sun4m.ram", > + memory_region_allocate_system_memory(&d->ram, NULL, "sun4m.ram", > d->size); > sysbus_init_mmio(sbd, &d->ram); > } > -- > 2.21.0 > >
On Tue, Oct 22, 2019 at 1:23 AM Alistair Francis <alistair23@gmail.com> wrote: > > On Sun, Oct 20, 2019 at 4:10 PM Philippe Mathieu-Daudé > <philmd@redhat.com> wrote: > > > > All the memory_region_allocate_system_memory() calls are in the > > board_init() code. From the 58 calls in the repository, only > > 4 set the 'owner' parameter. It is obvious we want the Machine > > to be the owner of the RAM, so we want to use OBJECT(machine) > > as owner. We can simplify a bit by passing MachineState to > > memory_region_allocate_system_memory(). In preparation of this > > refactor, first drop the 'owner' argument from these 4 uses. > > > > $ git grep memory_region_allocate_system_memory hw/ | wc -l > > 58 > > > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > > Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Artyom Tarasenko <atar4qemu@gmail.com> > > Alistair > > > --- > > hw/alpha/typhoon.c | 2 +- > > hw/arm/raspi.c | 2 +- > > hw/hppa/machine.c | 2 +- > > hw/sparc/sun4m.c | 2 +- > > 4 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c > > index 179e1f7658..8489ec335c 100644 > > --- a/hw/alpha/typhoon.c > > +++ b/hw/alpha/typhoon.c > > @@ -851,7 +851,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, > > > > /* Main memory region, 0x00.0000.0000. Real hardware supports 32GB, > > but the address space hole reserved at this point is 8TB. */ > > - memory_region_allocate_system_memory(&s->ram_region, OBJECT(s), "ram", > > + memory_region_allocate_system_memory(&s->ram_region, NULL, "ram", > > ram_size); > > memory_region_add_subregion(addr_space, 0, &s->ram_region); > > > > diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c > > index 615d755879..f76b6eaad3 100644 > > --- a/hw/arm/raspi.c > > +++ b/hw/arm/raspi.c > > @@ -182,7 +182,7 @@ static void raspi_init(MachineState *machine, int version) > > &error_abort, NULL); > > > > /* Allocate and map RAM */ > > - memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram", > > + memory_region_allocate_system_memory(&s->ram, NULL, "ram", > > machine->ram_size); > > /* FIXME: Remove when we have custom CPU address space support */ > > memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0); > > diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c > > index 953d454f48..dbe1ff0fe5 100644 > > --- a/hw/hppa/machine.c > > +++ b/hw/hppa/machine.c > > @@ -96,7 +96,7 @@ static void machine_hppa_init(MachineState *machine) > > > > /* Main memory region. */ > > ram_region = g_new(MemoryRegion, 1); > > - memory_region_allocate_system_memory(ram_region, OBJECT(machine), > > + memory_region_allocate_system_memory(ram_region, NULL, > > "ram", ram_size); > > memory_region_add_subregion(addr_space, 0, ram_region); > > > > diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c > > index 6c5a17a020..0bb7524655 100644 > > --- a/hw/sparc/sun4m.c > > +++ b/hw/sparc/sun4m.c > > @@ -788,7 +788,7 @@ static void ram_realize(DeviceState *dev, Error **errp) > > RamDevice *d = SUN4M_RAM(dev); > > SysBusDevice *sbd = SYS_BUS_DEVICE(dev); > > > > - memory_region_allocate_system_memory(&d->ram, OBJECT(d), "sun4m.ram", > > + memory_region_allocate_system_memory(&d->ram, NULL, "sun4m.ram", > > d->size); > > sysbus_init_mmio(sbd, &d->ram); > > } > > -- > > 2.21.0 > > > >
diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c index 179e1f7658..8489ec335c 100644 --- a/hw/alpha/typhoon.c +++ b/hw/alpha/typhoon.c @@ -851,7 +851,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, /* Main memory region, 0x00.0000.0000. Real hardware supports 32GB, but the address space hole reserved at this point is 8TB. */ - memory_region_allocate_system_memory(&s->ram_region, OBJECT(s), "ram", + memory_region_allocate_system_memory(&s->ram_region, NULL, "ram", ram_size); memory_region_add_subregion(addr_space, 0, &s->ram_region); diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 615d755879..f76b6eaad3 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -182,7 +182,7 @@ static void raspi_init(MachineState *machine, int version) &error_abort, NULL); /* Allocate and map RAM */ - memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram", + memory_region_allocate_system_memory(&s->ram, NULL, "ram", machine->ram_size); /* FIXME: Remove when we have custom CPU address space support */ memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0); diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 953d454f48..dbe1ff0fe5 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -96,7 +96,7 @@ static void machine_hppa_init(MachineState *machine) /* Main memory region. */ ram_region = g_new(MemoryRegion, 1); - memory_region_allocate_system_memory(ram_region, OBJECT(machine), + memory_region_allocate_system_memory(ram_region, NULL, "ram", ram_size); memory_region_add_subregion(addr_space, 0, ram_region); diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 6c5a17a020..0bb7524655 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -788,7 +788,7 @@ static void ram_realize(DeviceState *dev, Error **errp) RamDevice *d = SUN4M_RAM(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - memory_region_allocate_system_memory(&d->ram, OBJECT(d), "sun4m.ram", + memory_region_allocate_system_memory(&d->ram, NULL, "sun4m.ram", d->size); sysbus_init_mmio(sbd, &d->ram); }
All the memory_region_allocate_system_memory() calls are in the board_init() code. From the 58 calls in the repository, only 4 set the 'owner' parameter. It is obvious we want the Machine to be the owner of the RAM, so we want to use OBJECT(machine) as owner. We can simplify a bit by passing MachineState to memory_region_allocate_system_memory(). In preparation of this refactor, first drop the 'owner' argument from these 4 uses. $ git grep memory_region_allocate_system_memory hw/ | wc -l 58 Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- hw/alpha/typhoon.c | 2 +- hw/arm/raspi.c | 2 +- hw/hppa/machine.c | 2 +- hw/sparc/sun4m.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)