From ef36c5ec749bb3b5160e46759a6a7a6a8ac3ebe2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 1 Aug 2008 16:56:13 +0100 Subject: [PATCH] [ide] Check that asynchronous (DMA) submission succeeds If it does not, abort the command immediately rather than dropping it on the floor. Signed-off-by: Ian Jackson --- hw/ide.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/ide.c b/hw/ide.c index f70ea30a..68c6f859 100644 --- a/hw/ide.c +++ b/hw/ide.c @@ -723,6 +723,13 @@ static inline void ide_abort_command(IDEState *s) s->status = READY_STAT | ERR_STAT; s->error = ABRT_ERR; } +static inline void ide_dma_submit_check(IDEState *s, + BlockDriverCompletionFunc *dma_cb, BMDMAState *bm) +{ + if (bm->aiocb) + return; + dma_cb(bm, -1); +} static inline void ide_set_irq(IDEState *s) { @@ -947,6 +954,7 @@ static void ide_read_dma_cb(void *opaque, int ret) #endif bm->aiocb = bdrv_aio_read(s->bs, sector_num, s->io_buffer, n, ide_read_dma_cb, bm); + ide_dma_submit_check(s, ide_read_dma_cb, bm); } static void ide_sector_read_dma(IDEState *s) @@ -1077,6 +1085,7 @@ static void ide_write_dma_cb(void *opaque, int ret) #endif bm->aiocb = bdrv_aio_write(s->bs, sector_num, s->io_buffer, n, ide_write_dma_cb, bm); + ide_dma_submit_check(s, ide_write_dma_cb, bm); } static void ide_sector_write_dma(IDEState *s) -- 2.39.5