qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] dma: Avoid reentrancy in DMA transfer handlers


From: Kevin Wolf
Subject: [Qemu-devel] [PATCH] dma: Avoid reentrancy in DMA transfer handlers
Date: Fri, 28 Oct 2011 16:18:21 +0200

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 |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/hw/dma.c b/hw/dma.c
index 8a7302a..e8d6341 100644
--- a/hw/dma.c
+++ b/hw/dma.c
@@ -358,6 +358,13 @@ static void DMA_run (void)
     struct dma_cont *d;
     int icont, ichan;
     int rearm = 0;
+    static int running = 0;
+
+    if (running) {
+        goto out;
+    } else {
+        running = 1;
+    }
 
     d = dma_controllers;
 
@@ -374,6 +381,8 @@ static void DMA_run (void)
         }
     }
 
+out:
+    running = 0;
     if (rearm)
         qemu_bh_schedule_idle(dma_bh);
 }
-- 
1.7.6.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]