Received: from eggs.gnu.org ([2001:4830:134:3::10]:53531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtRkg-0002fV-Dj for qemu-devel@nongnu.org; Sun, 30 Jun 2013 20:13:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtRkb-0004at-1R for qemu-devel@nongnu.org; Sun, 30 Jun 2013 20:13:54 -0400 From: Alexander Graf Date: Mon, 1 Jul 2013 02:13:38 +0200 Message-Id: <1372637622-50697-14-git-send-email-agraf@suse.de> In-Reply-To: <1372637622-50697-1-git-send-email-agraf@suse.de> References: <1372637622-50697-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH 13/17] PPC: dbdma: Wait for DMA until we have data List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-ppc@nongnu.org Cc: Kevin Wolf , programmingkidx@gmail.com, mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org We should only start processing DMA requests when we have data to process. Hold off working through the DMA shuffling until the IDE core told us that it's ready. This is required because the guest can program the DMA engine or the IDE transfer first. Both are legal. Signed-off-by: Alexander Graf --- v1 -> v2: - move processing to bool --- hw/ide/macio.c | 19 +++++++++++++++++++ hw/ppc/mac.h | 1 + 2 files changed, 20 insertions(+) diff --git a/hw/ide/macio.c b/hw/ide/macio.c index 2729c62..9e613a9 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -64,6 +64,14 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) goto done; } + if (!m->dma_active) { + MACIO_DPRINTF("waiting for data (%#x - %#x - %x)\n", + s->nsector, io->len, s->status); + /* data not ready yet, wait for the channel to get restarted */ + io->processing = false; + return; + } + MACIO_DPRINTF("io_buffer_size = %#x\n", s->io_buffer_size); if (s->io_buffer_size > 0) { @@ -80,6 +88,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) if (s->packet_transfer_size <= 0) { MACIO_DPRINTF("end of transfer\n"); ide_atapi_cmd_ok(s); + m->dma_active = false; } if (io->len == 0) { @@ -130,6 +139,14 @@ static void pmac_ide_transfer_cb(void *opaque, int ret) goto done; } + if (!m->dma_active) { + MACIO_DPRINTF("waiting for data (%#x - %#x - %x)\n", + s->nsector, io->len, s->status); + /* data not ready yet, wait for the channel to get restarted */ + io->processing = false; + return; + } + sector_num = ide_get_sector(s); MACIO_DPRINTF("io_buffer_size = %#x\n", s->io_buffer_size); if (s->io_buffer_size > 0) { @@ -145,6 +162,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret) MACIO_DPRINTF("end of transfer\n"); s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); + m->dma_active = false; } if (io->len == 0) { @@ -379,6 +397,7 @@ static void ide_dbdma_start(IDEDMA *dma, IDEState *s, MACIOIDEState *m = container_of(dma, MACIOIDEState, dma); MACIO_DPRINTF("\n"); + m->dma_active = true; DBDMA_kick(m->dbdma); } diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h index 27c4ca3..1e578dd 100644 --- a/hw/ppc/mac.h +++ b/hw/ppc/mac.h @@ -133,6 +133,7 @@ typedef struct MACIOIDEState { BlockDriverAIOCB *aiocb; IDEDMA dma; void *dbdma; + bool dma_active; } MACIOIDEState; void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table); -- 1.8.1.4