[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/16] ide: Ignore double DMA transfer starts/stops
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 15/16] ide: Ignore double DMA transfer starts/stops |
Date: |
Tue, 30 Nov 2010 18:58:19 +0100 |
You can only start a DMA transfer if it's not running yet, and you can only
cancel it if it's running.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
hw/ide/pci.c | 60 ++++++++++++++++++++++++++++++---------------------------
1 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index 3722b77..404f045 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -39,38 +39,42 @@ void bmdma_cmd_writeb(void *opaque, uint32_t addr, uint32_t
val)
#ifdef DEBUG_IDE
printf("%s: 0x%08x\n", __func__, val);
#endif
- if (!(val & BM_CMD_START)) {
- /*
- * We can't cancel Scatter Gather DMA in the middle of the
- * operation or a partial (not full) DMA transfer would reach
- * the storage so we wait for completion instead (we beahve
- * like if the DMA was completed by the time the guest trying
- * to cancel dma with bmdma_cmd_writeb with BM_CMD_START not
- * set).
- *
- * In the future we'll be able to safely cancel the I/O if the
- * whole DMA operation will be submitted to disk with a single
- * aio operation with preadv/pwritev.
- */
- if (bm->aiocb) {
- qemu_aio_flush();
+
+ /* Ignore writes to SSBM if it keeps the old value */
+ if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) {
+ if (!(val & BM_CMD_START)) {
+ /*
+ * We can't cancel Scatter Gather DMA in the middle of the
+ * operation or a partial (not full) DMA transfer would reach
+ * the storage so we wait for completion instead (we beahve
+ * like if the DMA was completed by the time the guest trying
+ * to cancel dma with bmdma_cmd_writeb with BM_CMD_START not
+ * set).
+ *
+ * In the future we'll be able to safely cancel the I/O if the
+ * whole DMA operation will be submitted to disk with a single
+ * aio operation with preadv/pwritev.
+ */
+ if (bm->aiocb) {
+ qemu_aio_flush();
#ifdef DEBUG_IDE
- if (bm->aiocb)
- printf("ide_dma_cancel: aiocb still pending");
- if (bm->status & BM_STATUS_DMAING)
- printf("ide_dma_cancel: BM_STATUS_DMAING still pending");
+ if (bm->aiocb)
+ printf("ide_dma_cancel: aiocb still pending");
+ if (bm->status & BM_STATUS_DMAING)
+ printf("ide_dma_cancel: BM_STATUS_DMAING still pending");
#endif
+ }
+ } else {
+ if (!(bm->status & BM_STATUS_DMAING)) {
+ bm->status |= BM_STATUS_DMAING;
+ /* start dma transfer if possible */
+ if (bm->dma_cb)
+ bm->dma_cb(bm, 0);
+ }
}
- bm->cmd = val & 0x09;
- } else {
- if (!(bm->status & BM_STATUS_DMAING)) {
- bm->status |= BM_STATUS_DMAING;
- /* start dma transfer if possible */
- if (bm->dma_cb)
- bm->dma_cb(bm, 0);
- }
- bm->cmd = val & 0x09;
}
+
+ bm->cmd = val & 0x09;
}
static void bmdma_addr_read(IORange *ioport, uint64_t addr,
--
1.7.2.3
- [Qemu-devel] [PULL 00/16] Block patches, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 06/16] block: Remove unused s->hd in various drivers, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 15/16] ide: Ignore double DMA transfer starts/stops,
Kevin Wolf <=
- [Qemu-devel] [PATCH 11/16] scsi-disk: Remove duplicate cdb parsing, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 13/16] ide: Factor ide_dma_set_inactive out, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 07/16] scsi: Increase the number of possible devices, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 04/16] ide: convert bmdma address ioport to ioport_register(), Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 14/16] ide: Set bus master inactive on error, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 12/16] raw-posix: raw_pwrite comment fixup, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 10/16] scsi: Move sense handling into the driver, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 08/16] scsi: Return SAM status codes, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 05/16] qemu and qemu-xen: support empty write barriers in xen_disk, Kevin Wolf, 2010/11/30
- [Qemu-devel] [PATCH 09/16] scsi: INQUIRY VPD fixes, Kevin Wolf, 2010/11/30