From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-arm@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Beniamino Galvani" <b.galvani@gmail.com>,
"Subbaraya Sundeep" <sundeep.lkml@gmail.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH v3 16/17] hw/display/xlnx_dp: Move problematic code from instance_init to realize
Date: Mon, 16 Jul 2018 14:59:33 +0200 [thread overview]
Message-ID: <1531745974-17187-17-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1531745974-17187-1-git-send-email-thuth@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
aux_create_slave() calls qdev_init_nofail() which in turn "realizes"
the corresponding object. This is unlike qdev_create(), and it is wrong
because qdev_init_nofail() must not be called from an instance_init
function. Move qdev_init_nofail() and the subsequent aux_map_slave into
the caller's realize function.
There are two more bugs that needs to be fixed here, too, where the
objects are created but not added as children. Therefore when
you call object_unparent on them, nothing happens.
In particular dpcd and edid give you an infinite loop in bus_unparent,
because device_unparent is not called and does not remove them from
the list of devices on the bus.
Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[thuth: Added Paolo's fixup for the dpcd and edid unparenting]
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/display/xlnx_dp.c | 8 +++++++-
hw/misc/auxbus.c | 18 ++++++++++++------
include/hw/misc/auxbus.h | 14 +++++++++++++-
3 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c
index 5130122..6439bd0 100644
--- a/hw/display/xlnx_dp.c
+++ b/hw/display/xlnx_dp.c
@@ -1234,9 +1234,12 @@ static void xlnx_dp_init(Object *obj)
/*
* Initialize DPCD and EDID..
*/
- s->dpcd = DPCD(aux_create_slave(s->aux_bus, "dpcd", 0x00000));
+ s->dpcd = DPCD(aux_create_slave(s->aux_bus, "dpcd"));
+ object_property_add_child(OBJECT(s), "dpcd", OBJECT(s->dpcd), NULL);
+
s->edid = I2CDDC(qdev_create(BUS(aux_get_i2c_bus(s->aux_bus)), "i2c-ddc"));
i2c_set_slave_address(I2C_SLAVE(s->edid), 0x50);
+ object_property_add_child(OBJECT(s), "edid", OBJECT(s->edid), NULL);
fifo8_create(&s->rx_fifo, 16);
fifo8_create(&s->tx_fifo, 16);
@@ -1248,6 +1251,9 @@ static void xlnx_dp_realize(DeviceState *dev, Error **errp)
DisplaySurface *surface;
struct audsettings as;
+ qdev_init_nofail(DEVICE(s->dpcd));
+ aux_map_slave(AUX_SLAVE(s->dpcd), 0x0000);
+
s->console = graphic_console_init(dev, 0, &xlnx_dp_gfx_ops, s);
surface = qemu_console_surface(s->console);
xlnx_dpdma_set_host_data_location(s->dpdma, DP_GRAPHIC_DMA_CHANNEL,
diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c
index b8a8721..0e56d9a 100644
--- a/hw/misc/auxbus.c
+++ b/hw/misc/auxbus.c
@@ -32,6 +32,7 @@
#include "hw/misc/auxbus.h"
#include "hw/i2c/i2c.h"
#include "monitor/monitor.h"
+#include "qapi/error.h"
#ifndef DEBUG_AUX
#define DEBUG_AUX 0
@@ -63,9 +64,14 @@ static void aux_bus_class_init(ObjectClass *klass, void *data)
AUXBus *aux_init_bus(DeviceState *parent, const char *name)
{
AUXBus *bus;
+ Object *auxtoi2c;
bus = AUX_BUS(qbus_create(TYPE_AUX_BUS, parent, name));
- bus->bridge = AUXTOI2C(qdev_create(BUS(bus), TYPE_AUXTOI2C));
+ auxtoi2c = object_new_with_props(TYPE_AUXTOI2C, OBJECT(bus), "i2c",
+ &error_abort, NULL);
+ qdev_set_parent_bus(DEVICE(auxtoi2c), BUS(bus));
+
+ bus->bridge = AUXTOI2C(auxtoi2c);
/* Memory related. */
bus->aux_io = g_malloc(sizeof(*bus->aux_io));
@@ -74,9 +80,11 @@ AUXBus *aux_init_bus(DeviceState *parent, const char *name)
return bus;
}
-static void aux_bus_map_device(AUXBus *bus, AUXSlave *dev, hwaddr addr)
+void aux_map_slave(AUXSlave *aux_dev, hwaddr addr)
{
- memory_region_add_subregion(bus->aux_io, addr, dev->mmio);
+ DeviceState *dev = DEVICE(aux_dev);
+ AUXBus *bus = AUX_BUS(qdev_get_parent_bus(dev));
+ memory_region_add_subregion(bus->aux_io, addr, aux_dev->mmio);
}
static bool aux_bus_is_bridge(AUXBus *bus, DeviceState *dev)
@@ -260,15 +268,13 @@ static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent)
memory_region_size(s->mmio));
}
-DeviceState *aux_create_slave(AUXBus *bus, const char *type, uint32_t addr)
+DeviceState *aux_create_slave(AUXBus *bus, const char *type)
{
DeviceState *dev;
dev = DEVICE(object_new(type));
assert(dev);
qdev_set_parent_bus(dev, &bus->qbus);
- qdev_init_nofail(dev);
- aux_bus_map_device(AUX_BUS(qdev_get_parent_bus(dev)), AUX_SLAVE(dev), addr);
return dev;
}
diff --git a/include/hw/misc/auxbus.h b/include/hw/misc/auxbus.h
index 68ade8a..c15b444 100644
--- a/include/hw/misc/auxbus.h
+++ b/include/hw/misc/auxbus.h
@@ -123,6 +123,18 @@ I2CBus *aux_get_i2c_bus(AUXBus *bus);
*/
void aux_init_mmio(AUXSlave *aux_slave, MemoryRegion *mmio);
-DeviceState *aux_create_slave(AUXBus *bus, const char *name, uint32_t addr);
+/* aux_create_slave: Create a new device on an AUX bus
+ *
+ * @bus The AUX bus for the new device.
+ * @name The type of the device to be created.
+ */
+DeviceState *aux_create_slave(AUXBus *bus, const char *name);
+
+/* aux_map_slave: Map the mmio for an AUX slave on the bus.
+ *
+ * @dev The AUX slave.
+ * @addr The address for the slave's mmio.
+ */
+void aux_map_slave(AUXSlave *dev, hwaddr addr);
#endif /* HW_MISC_AUXBUS_H */
--
1.8.3.1
next prev parent reply other threads:[~2018-07-16 13:00 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-16 12:59 [Qemu-devel] [PATCH v3 00/17] Fix crashes with introspection of ARM devices Thomas Huth
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 01/17] qom/object: Add a new function object_initialize_child() Thomas Huth
2018-07-16 21:06 ` Eduardo Habkost
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 02/17] hw/core/sysbus: Add a function for creating and attaching an object Thomas Huth
2018-07-16 21:53 ` Alistair Francis
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 03/17] hw/arm/bcm2836: Fix crash with device_add bcm2837 on unsupported machines Thomas Huth
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 04/17] hw/arm/armv7: Fix crash when introspecting the "iotkit" device Thomas Huth
2018-07-16 21:57 ` Alistair Francis
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 05/17] hw/cpu/a15mpcore: Fix introspection problem with the a15mpcore_priv device Thomas Huth
2018-07-16 21:55 ` Alistair Francis
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 06/17] hw/arm/msf2-soc: Fix introspection problem with the "msf2-soc" device Thomas Huth
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 07/17] hw/cpu/a9mpcore: Fix introspection problems with the "a9mpcore_priv" device Thomas Huth
2018-07-16 22:03 ` Alistair Francis
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 08/17] hw/arm/fsl-imx6: Fix introspection problems with the "fsl, imx6" device Thomas Huth
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 09/17] hw/arm/fsl-imx7: Fix introspection problems with the "fsl, imx7" device Thomas Huth
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 10/17] hw/arm/fsl-imx25: Fix introspection problem with the "fsl, imx25" device Thomas Huth
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 11/17] hw/arm/fsl-imx31: Fix introspection problem with the "fsl, imx31" device Thomas Huth
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 12/17] hw/cpu/arm11mpcore: Fix introspection problem with 'arm11mpcore_priv' Thomas Huth
2018-07-16 22:06 ` Alistair Francis
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 13/17] hw/*/realview: Fix introspection problem with 'realview_mpcore' & 'realview_gic' Thomas Huth
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 14/17] hw/arm/allwinner-a10: Fix introspection problem with 'allwinner-a10' Thomas Huth
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 15/17] hw/arm/stm32f205_soc: Fix introspection problem with 'stm32f205-soc' device Thomas Huth
2018-07-16 13:52 ` Peter Maydell
2018-07-16 21:07 ` Eduardo Habkost
2018-07-16 21:59 ` Alistair Francis
2018-07-16 12:59 ` Thomas Huth [this message]
2018-07-16 13:56 ` [Qemu-devel] [PATCH v3 16/17] hw/display/xlnx_dp: Move problematic code from instance_init to realize Peter Maydell
2018-07-16 22:06 ` Alistair Francis
2018-07-16 12:59 ` [Qemu-devel] [PATCH v3 17/17] hw/arm/xlnx-zynqmp: Fix crash when introspecting the "xlnx, zynqmp" device Thomas Huth
2018-07-16 22:08 ` Alistair Francis
2018-07-17 12:14 ` [Qemu-devel] [PATCH v3 00/17] Fix crashes with introspection of ARM devices Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1531745974-17187-17-git-send-email-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=afaerber@suse.de \
--cc=alistair@alistair23.me \
--cc=armbru@redhat.com \
--cc=b.galvani@gmail.com \
--cc=edgar.iglesias@gmail.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sundeep.lkml@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).