From patchwork Sun Sep 24 14:47:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 817913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y0VYl3BRjz9s8J for ; Mon, 25 Sep 2017 00:52:27 +1000 (AEST) Received: from localhost ([::1]:38438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dw8Gf-00069D-Jo for incoming@patchwork.ozlabs.org; Sun, 24 Sep 2017 10:52:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dw8Cb-0002hK-W6 for qemu-devel@nongnu.org; Sun, 24 Sep 2017 10:48:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dw8Ca-0002HE-Hz for qemu-devel@nongnu.org; Sun, 24 Sep 2017 10:48:13 -0400 Received: from chuckie.co.uk ([82.165.15.123]:49765 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dw8CW-00029A-LS; Sun, 24 Sep 2017 10:48:08 -0400 Received: from host86-191-82-173.range86-191.btcentralplus.com ([86.191.82.173] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dw8CU-0006gI-0m; Sun, 24 Sep 2017 15:48:07 +0100 From: Mark Cave-Ayland To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Sun, 24 Sep 2017 15:47:42 +0100 Message-Id: <1506264466-28252-4-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1506264466-28252-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1506264466-28252-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.191.82.173 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 3/7] mac_dbdma: remove DBDMA_init() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Instead we can now instantiate the MAC_DBDMA object directly within the macio device. We also add the DBDMA device as a child property so that it is possible to retrieve later. Signed-off-by: Mark Cave-Ayland --- hw/misc/macio/mac_dbdma.c | 14 -------------- hw/misc/macio/macio.c | 16 ++++++++++++---- include/hw/ppc/mac_dbdma.h | 1 - 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c index 302f131..0eddf2e 100644 --- a/hw/misc/macio/mac_dbdma.c +++ b/hw/misc/macio/mac_dbdma.c @@ -886,20 +886,6 @@ static void dbdma_unassigned_flush(DBDMA_io *io) __func__, ch->channel); } -void* DBDMA_init (MemoryRegion **dbdma_mem) -{ - DBDMAState *s; - SysBusDevice *sbd; - - s = MAC_DBDMA(object_new(TYPE_MAC_DBDMA)); - object_property_set_bool(OBJECT(s), true, "realized", NULL); - - sbd = SYS_BUS_DEVICE(s); - *dbdma_mem = sysbus_mmio_get_region(sbd, 0); - - return s; -} - static void mac_dbdma_init(Object *obj) { SysBusDevice *sbd = SYS_BUS_DEVICE(obj); diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c index 5d57f45..f459f17 100644 --- a/hw/misc/macio/macio.c +++ b/hw/misc/macio/macio.c @@ -41,7 +41,7 @@ typedef struct MacIOState MemoryRegion bar; CUDAState cuda; - void *dbdma; + DBDMAState *dbdma; MemoryRegion *pic_mem; MemoryRegion *escc_mem; uint64_t frequency; @@ -127,10 +127,15 @@ 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->dbdma), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + sysbus_dev = SYS_BUS_DEVICE(s->dbdma); + memory_region_add_subregion(&s->bar, 0x08000, + sysbus_mmio_get_region(sysbus_dev, 0)); object_property_set_bool(OBJECT(&s->cuda), true, "realized", &err); if (err) { @@ -334,6 +339,9 @@ static void macio_instance_init(Object *obj) 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 = MAC_DBDMA(object_new(TYPE_MAC_DBDMA)); + object_property_add_child(obj, "dbdma", OBJECT(s->dbdma), NULL); } static const VMStateDescription vmstate_macio_oldworld = { diff --git a/include/hw/ppc/mac_dbdma.h b/include/hw/ppc/mac_dbdma.h index 4bc6274..26cc469 100644 --- a/include/hw/ppc/mac_dbdma.h +++ b/include/hw/ppc/mac_dbdma.h @@ -174,7 +174,6 @@ void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq, DBDMA_rw rw, DBDMA_flush flush, void *opaque); void DBDMA_kick(DBDMAState *dbdma); -void* DBDMA_init (MemoryRegion **dbdma_mem); #define TYPE_MAC_DBDMA "mac-dbdma" #define MAC_DBDMA(obj) OBJECT_CHECK(DBDMAState, (obj), TYPE_MAC_DBDMA)