Skip to content

Commit

Permalink
macio: use the existing IDEDMA aiocb to hold the active DMA aiocb
Browse files Browse the repository at this point in the history
Currently the aiocb is held within MACIOIDEState, however the IDE core code
assumes that the current actvie DMA aiocb is held in aiocb in a few places,
e.g. ide_bus_reset() and ide_reset().

Switch over to using IDEDMA aiocb to store the aiocb for the current active
DMA request so that bus resets and restarts are handled correctly. As a
consequence we can now use ide_set_inactive() rather than handling its
functionality ourselves.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
  • Loading branch information
mcayland authored and dgibson committed Jan 30, 2016
1 parent 6a9620e commit 03c1280
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
20 changes: 12 additions & 8 deletions hw/ide/macio.c
Expand Up @@ -120,8 +120,8 @@ static void pmac_dma_read(BlockBackend *blk,
MACIO_DPRINTF("--- Block read transfer - sector_num: %" PRIx64 " "
"nsector: %x\n", (offset >> 9), (bytes >> 9));

m->aiocb = blk_aio_readv(blk, (offset >> 9), &io->iov, (bytes >> 9),
cb, io);
s->bus->dma->aiocb = blk_aio_readv(blk, (offset >> 9), &io->iov,
(bytes >> 9), cb, io);
}

static void pmac_dma_write(BlockBackend *blk,
Expand Down Expand Up @@ -205,8 +205,8 @@ static void pmac_dma_write(BlockBackend *blk,
MACIO_DPRINTF("--- Block write transfer - sector_num: %" PRIx64 " "
"nsector: %x\n", (offset >> 9), (bytes >> 9));

m->aiocb = blk_aio_writev(blk, (offset >> 9), &io->iov, (bytes >> 9),
cb, io);
s->bus->dma->aiocb = blk_aio_writev(blk, (offset >> 9), &io->iov,
(bytes >> 9), cb, io);
}

static void pmac_dma_trim(BlockBackend *blk,
Expand All @@ -232,8 +232,8 @@ static void pmac_dma_trim(BlockBackend *blk,
s->io_buffer_index += io->len;
io->len = 0;

m->aiocb = ide_issue_trim(blk, (offset >> 9), &io->iov, (bytes >> 9),
cb, io);
s->bus->dma->aiocb = ide_issue_trim(blk, (offset >> 9), &io->iov,
(bytes >> 9), cb, io);
}

static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
Expand Down Expand Up @@ -292,6 +292,8 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
} else {
block_acct_done(blk_get_stats(s->blk), &s->acct);
}

ide_set_inactive(s, false);
io->dma_end(opaque);
}

Expand All @@ -306,7 +308,6 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)

if (ret < 0) {
MACIO_DPRINTF("DMA error: %d\n", ret);
m->aiocb = NULL;
ide_dma_error(s);
goto done;
}
Expand Down Expand Up @@ -357,6 +358,8 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
block_acct_done(blk_get_stats(s->blk), &s->acct);
}
}

ide_set_inactive(s, false);
io->dma_end(opaque);
}

Expand Down Expand Up @@ -394,8 +397,9 @@ static void pmac_ide_transfer(DBDMA_io *io)
static void pmac_ide_flush(DBDMA_io *io)
{
MACIOIDEState *m = io->opaque;
IDEState *s = idebus_active_if(&m->bus);

if (m->aiocb) {
if (s->bus->dma->aiocb) {
blk_drain_all();
}
}
Expand Down
1 change: 0 additions & 1 deletion hw/ppc/mac.h
Expand Up @@ -134,7 +134,6 @@ typedef struct MACIOIDEState {

MemoryRegion mem;
IDEBus bus;
BlockAIOCB *aiocb;
IDEDMA dma;
void *dbdma;
bool dma_active;
Expand Down

0 comments on commit 03c1280

Please sign in to comment.