From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk,
agraf@suse.de, armbru@redhat.com, blauwirbel@gmail.com,
qemu-ppc@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] macio: move DBDMA_init from instance_init to realize
Date: Tue, 29 Sep 2015 14:37:43 +0200 [thread overview]
Message-ID: <1443530263-32340-4-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1443530263-32340-1-git-send-email-pbonzini@redhat.com>
DBDMA_init is not idempotent, and calling it from instance_init
breaks a simple object_new/object_unref pair. Work around this,
pending qdev-ification of DBDMA, by moving the call to realize.
Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/misc/macio/macio.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 2548d96..c661f86 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -131,6 +131,10 @@ static void macio_common_realize(PCIDevice *d, Error **errp)
MacIOState *s = MACIO(d);
SysBusDevice *sysbus_dev;
Error *err = NULL;
+ MemoryRegion *dbdma_mem;
+
+ s->dbdma = DBDMA_init(&dbdma_mem);
+ memory_region_add_subregion(&s->bar, 0x08000, dbdma_mem);
object_property_set_bool(OBJECT(&s->cuda), true, "realized", &err);
if (err) {
@@ -328,16 +332,12 @@ static void macio_newworld_init(Object *obj)
static void macio_instance_init(Object *obj)
{
MacIOState *s = MACIO(obj);
- MemoryRegion *dbdma_mem;
memory_region_init(&s->bar, obj, "macio", 0x80000);
object_initialize(&s->cuda, sizeof(s->cuda), TYPE_CUDA);
qdev_set_parent_bus(DEVICE(&s->cuda), sysbus_get_default());
object_property_add_child(obj, "cuda", OBJECT(&s->cuda), NULL);
-
- s->dbdma = DBDMA_init(&dbdma_mem);
- memory_region_add_subregion(&s->bar, 0x08000, dbdma_mem);
}
static const VMStateDescription vmstate_macio_oldworld = {
--
2.5.0
next prev parent reply other threads:[~2015-09-29 12:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 12:37 [Qemu-devel] [PATCH 0/3] Fix dangling pointers from memory_region_init_* Paolo Bonzini
2015-09-29 12:37 ` [Qemu-devel] [PATCH 1/3] memory: allow destroying a non-empty MemoryRegion Paolo Bonzini
2015-09-29 12:37 ` [Qemu-devel] [PATCH 2/3] hw: do not pass NULL to memory_region_init from instance_init Paolo Bonzini
2015-09-29 12:42 ` Peter Maydell
2015-09-30 8:30 ` Thomas Huth
2015-09-30 13:04 ` Paolo Bonzini
2015-10-01 7:39 ` Markus Armbruster
2015-10-01 8:26 ` Markus Armbruster
2015-10-01 9:27 ` Peter Maydell
2015-09-30 8:57 ` Markus Armbruster
2015-09-30 13:03 ` Paolo Bonzini
2015-10-01 7:39 ` Markus Armbruster
2015-10-01 10:13 ` Paolo Bonzini
2015-10-01 9:38 ` Mark Cave-Ayland
2015-09-29 12:37 ` Paolo Bonzini [this message]
2015-09-30 8:33 ` [Qemu-devel] [PATCH 3/3] macio: move DBDMA_init from instance_init to realize Thomas Huth
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=1443530263-32340-4-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=agraf@suse.de \
--cc=armbru@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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).