From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4FWg-0007Uv-Ou for qemu-devel@nongnu.org; Mon, 16 Oct 2017 20:14:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4FWf-00056x-R8 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 20:14:30 -0400 Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 16 Oct 2017 21:12:08 -0300 Message-Id: <20171017001209.32276-39-f4bug@amsat.org> In-Reply-To: <20171017001209.32276-1-f4bug@amsat.org> References: <20171017001209.32276-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v2 38/39] hw/dma/i82374: avoid multiple creations on the same ISA bus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , Thomas Huth , Markus Armbruster , Paolo Bonzini , "Michael S. Tsirkin" , Aurelien Jarno , Yongbok Kim , Richard Henderson , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , David Gibson , Alexander Graf , Mark Cave-Ayland , Artyom Tarasenko , Michael Tokarev , Eduardo Otubo , Eduardo Habkost Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, qemu-trivial@nongnu.org $ ./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374 qemu-system-ppc64: -device i82374: DMA already initialized on ISA bus Reported-by: Eduardo Otubo Suggested-by: Eduardo Habkost Signed-off-by: Philippe Mathieu-Daudé --- hw/dma/i82374.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/dma/i82374.c b/hw/dma/i82374.c index 6c0f975df0..280e64f0fa 100644 --- a/hw/dma/i82374.c +++ b/hw/dma/i82374.c @@ -23,6 +23,7 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/isa/isa.h" #define TYPE_I82374 "i82374" @@ -117,13 +118,19 @@ static const MemoryRegionPortio i82374_portio_list[] = { static void i82374_realize(DeviceState *dev, Error **errp) { I82374State *s = I82374(dev); + ISABus *isa_bus = isa_bus_from_device(ISA_DEVICE(dev)); + + if (isa_bus->dma[0] || isa_bus->dma[1]) { + error_setg(errp, "DMA already initialized on ISA bus"); + return; + } portio_list_init(&s->port_list, OBJECT(s), i82374_portio_list, s, "i82374"); portio_list_add(&s->port_list, isa_address_space_io(&s->parent_obj), s->iobase); - DMA_init(isa_bus_from_device(ISA_DEVICE(dev)), 1); + DMA_init(isa_bus, 1); memset(s->commands, 0, sizeof(s->commands)); } -- 2.15.0.rc0