hw/arm: Fix Integrator/CP memsz initialization
PATCH 1/1 hw/arm: Fix Integrator/CP memsz initialization
* Do not assume memsz is already initialized in integratorcm_init
* Calculate memsz directly from MachineState
* Get rid of the now unused memsz property
--- hw/arm/integratorcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/integratorcp.c +2 -2
@@ -247,7 +247,9 @@ static void integratorcm_init(Object *obj) {IntegratorCMState *s =INTEGRATOR_CM (obj);SysBusDevice *dev =SYS_BUS_DEVICE (obj); +MachineState *machine =MACHINE (qdev_get_machine ()); + s->memsz = machine->ram_size >>20 ; s->cm_osc =0x01000048 ;/* ??? What should the high bits of this value be? */ s->cm_auxosc =0x0007feff ;
@@ -574,7 +576,6 @@ static void integratorcp_init(MachineState *machine)memory_region_add_subregion (address_space_mem,0x80000000 , ram_alias); dev =qdev_create (NULL ,TYPE_INTEGRATOR_CM ); -qdev_prop_set_uint32 (dev,"memsz" , ram_size >>20 );qdev_init_nofail (dev);sysbus_mmio_map ((SysBusDevice *)dev,0 ,0x10000000 );
@@ -624,7 +625,6 @@ static void integratorcp_machine_init(MachineClass *mc) DEFINE_MACHINE("integratorcp", integratorcp_machine_init)static Property core_properties[] = { -DEFINE_PROP_UINT32 ("memsz" , IntegratorCMState, memsz,0 ),DEFINE_PROP_END_OF_LIST (), };
Quoted 6 lines · Jakub Jermář
* Do not assume memsz is already initialized in
integratorcm_init
* Calculate memsz directly from MachineState
* Get rid of the now unused memsz propertySigned-off-by Jakub Jermar <[email protected]>
Thanks for this patch; this is definitely a bug but I think this is not the best way to fix it.
What we should do is add a realize function to the IntegratorCM device, and move the code that depends on the value of memsz from the init function to the realize function. That way the device doesn't have to know anything about the machine.
thanks
-- PMM
Quoted 8 lines · Peter Maydell
Quoted 6 lines · Jakub Jermář
* Do not assume memsz is already initialized in
integratorcm_init
* Calculate memsz directly from MachineState
* Get rid of the now unused memsz propertySigned-off-by Jakub Jermar <[email protected]>
Quoted 7 lines
Thanks for this patch; this is definitely a bug but I think this is not the best way to fix it.
What we should do is add a realize function to the IntegratorCM device, and move the code that depends on the value of memsz from the init function to the realize function. That way the device doesn't have to know anything about the machine.
Thanks, I will be sending a reworked patch shortly.
Jakub