[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/11] dma: Avoid reentrancy in DMA transfer handler
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 03/11] dma: Avoid reentrancy in DMA transfer handlers |
Date: |
Mon, 7 Nov 2011 17:55:10 +0100 |
With the conversion of the block layer to coroutines, bdrv_read/write
have changed to run a nested event loop that calls qemu_bh_poll.
Consequently a scheduled BH can be called while a DMA transfer handler
runs and this means that DMA_run becomes reentrant.
Devices haven't been designed to cope with that, so instead of running a
nested transfer handler just wait for the next invocation of the BH from the
main loop.
This fixes some problems with the floppy device.
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/dma.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/hw/dma.c b/hw/dma.c
index 8a7302a..0a9322d 100644
--- a/hw/dma.c
+++ b/hw/dma.c
@@ -358,6 +358,14 @@ static void DMA_run (void)
struct dma_cont *d;
int icont, ichan;
int rearm = 0;
+ static int running = 0;
+
+ if (running) {
+ rearm = 1;
+ goto out;
+ } else {
+ running = 1;
+ }
d = dma_controllers;
@@ -374,6 +382,8 @@ static void DMA_run (void)
}
}
+ running = 0;
+out:
if (rearm)
qemu_bh_schedule_idle(dma_bh);
}
--
1.7.6.4
- [Qemu-devel] [PATCH 00/11] Block patches for 1.0, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 03/11] dma: Avoid reentrancy in DMA transfer handlers,
Kevin Wolf <=
- [Qemu-devel] [PATCH 01/11] qemu-io: Handle create_iovec errors, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 05/11] block/cloop: Use g_free instead of free, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 04/11] block/cloop: Fix coding style, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 08/11] vvfat: need to use first_sectors_number to distinguish fdd/hdd, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 06/11] vvfat: fix out of bounds array_get usage, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 09/11] vvfat: unify and correct computation of sector count, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 02/11] qemu-io: Fix multiwrite_f error handling, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 07/11] vvfat: do not fail if the disk has spare sectors, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 10/11] vvfat: do not hardcode sector counts in error message, Kevin Wolf, 2011/11/07
- [Qemu-devel] [PATCH 11/11] vvfat: reorganize computation of disk geometry, Kevin Wolf, 2011/11/07