The VideoCore GPU is indenpendant from the Peripheral block. In the next commit, we will move its instantiation to the SoC block. The "gpu-bus" object will not be accessible in init() but later in realize(). As a preliminary step to keep the diff clearer, move the const link property creation from init() to realize().
Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> --- hw/arm/bcm2835_peripherals.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index 17207ae07e..d51e9c8def 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -82,9 +82,6 @@ static void bcm2835_peripherals_init(Object *obj) object_property_add_alias(obj, "vcram-size", OBJECT(&s->fb), "vcram-size", &error_abort); - object_property_add_const_link(OBJECT(&s->fb), "dma-mr", - OBJECT(&s->gpu_bus_mr), &error_abort); - /* Property channel */ sysbus_init_child_obj(obj, "property", &s->property, sizeof(s->property), TYPE_BCM2835_PROPERTY); @@ -93,8 +90,6 @@ static void bcm2835_peripherals_init(Object *obj) object_property_add_const_link(OBJECT(&s->property), "fb", OBJECT(&s->fb), &error_abort); - object_property_add_const_link(OBJECT(&s->property), "dma-mr", - OBJECT(&s->gpu_bus_mr), &error_abort); /* Random Number Generator */ sysbus_init_child_obj(obj, "rng", &s->rng, sizeof(s->rng), @@ -112,9 +107,6 @@ static void bcm2835_peripherals_init(Object *obj) sysbus_init_child_obj(obj, "dma", &s->dma, sizeof(s->dma), TYPE_BCM2835_DMA); - object_property_add_const_link(OBJECT(&s->dma), "dma-mr", - OBJECT(&s->gpu_bus_mr), &error_abort); - /* Thermal */ sysbus_init_child_obj(obj, "thermal", &s->thermal, sizeof(s->thermal), TYPE_BCM2835_THERMAL); @@ -156,6 +148,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) memory_region_add_subregion_overlap(&s->gpu_bus_mr, BCM2835_VC_PERI_BASE, &s->peri_mr_alias, 1); + obj = OBJECT(&s->gpu_bus_mr); /* RAM is aliased four times (different cache configurations) on the GPU */ for (n = 0; n < 4; n++) { memory_region_init_alias(&s->ram_alias[n], OBJECT(s), @@ -236,6 +229,12 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) return; } + object_property_add_const_link(OBJECT(&s->fb), "dma-mr", obj, &err); + if (err) { + error_propagate(errp, err); + return; + } + object_property_set_uint(OBJECT(&s->fb), ram_size - vcram_size, "vcram-base", &err); if (err) { @@ -255,6 +254,11 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_FB)); /* Property channel */ + object_property_add_const_link(OBJECT(&s->property), "dma-mr", obj, &err); + if (err) { + error_propagate(errp, err); + return; + } object_property_set_bool(OBJECT(&s->property), true, "realized", &err); if (err) { error_propagate(errp, err); @@ -323,6 +327,11 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) INTERRUPT_SDIO)); /* DMA Channels */ + object_property_add_const_link(OBJECT(&s->dma), "dma-mr", obj, &err); + if (err) { + error_propagate(errp, err); + return; + } object_property_set_bool(OBJECT(&s->dma), true, "realized", &err); if (err) { error_propagate(errp, err); -- 2.21.0