Blame 0030-dma-Avoid-reentrancy-in-DMA-transfer-handlers.patch
|
Justin M. Forbes |
6f9d9c |
From 86f1e4e2f57af82aae0944ed704ab91dc36fc9b7 Mon Sep 17 00:00:00 2001
|
|
Justin M. Forbes |
6f9d9c |
From: Kevin Wolf <kwolf@redhat.com>
|
|
Justin M. Forbes |
6f9d9c |
Date: Fri, 28 Oct 2011 05:28:13 -0400
|
|
Justin M. Forbes |
6f9d9c |
Subject: [PATCH 2/2] dma: Avoid reentrancy in DMA transfer handlers
|
|
Justin M. Forbes |
6f9d9c |
|
|
Justin M. Forbes |
6f9d9c |
With the conversion of the block layer to coroutines, bdrv_read/write
|
|
Justin M. Forbes |
6f9d9c |
have changed to run a nested event loop that calls qemu_bh_poll.
|
|
Justin M. Forbes |
6f9d9c |
Consequently a scheduled BH can be called while a DMA transfer handler
|
|
Justin M. Forbes |
6f9d9c |
runs and this means that DMA_run becomes reentrant.
|
|
Justin M. Forbes |
6f9d9c |
|
|
Justin M. Forbes |
6f9d9c |
Devices haven't been designed to cope with that, so instead of running a
|
|
Justin M. Forbes |
6f9d9c |
nested transfer handler just wait for the next invocation of the BH from the
|
|
Justin M. Forbes |
6f9d9c |
main loop.
|
|
Justin M. Forbes |
6f9d9c |
|
|
Justin M. Forbes |
6f9d9c |
This fixes some problems with the floppy device.
|
|
Justin M. Forbes |
6f9d9c |
|
|
Justin M. Forbes |
6f9d9c |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
Justin M. Forbes |
6f9d9c |
---
|
|
Justin M. Forbes |
6f9d9c |
hw/dma.c | 10 ++++++++++
|
|
Justin M. Forbes |
6f9d9c |
1 files changed, 10 insertions(+), 0 deletions(-)
|
|
Justin M. Forbes |
6f9d9c |
|
|
Justin M. Forbes |
6f9d9c |
diff --git a/hw/dma.c b/hw/dma.c
|
|
Justin M. Forbes |
6f9d9c |
index 8a7302a..0a9322d 100644
|
|
Justin M. Forbes |
6f9d9c |
--- a/hw/dma.c
|
|
Justin M. Forbes |
6f9d9c |
+++ b/hw/dma.c
|
|
Justin M. Forbes |
6f9d9c |
@@ -358,6 +358,14 @@ static void DMA_run (void)
|
|
Justin M. Forbes |
6f9d9c |
struct dma_cont *d;
|
|
Justin M. Forbes |
6f9d9c |
int icont, ichan;
|
|
Justin M. Forbes |
6f9d9c |
int rearm = 0;
|
|
Justin M. Forbes |
6f9d9c |
+ static int running = 0;
|
|
Justin M. Forbes |
6f9d9c |
+
|
|
Justin M. Forbes |
6f9d9c |
+ if (running) {
|
|
Justin M. Forbes |
6f9d9c |
+ rearm = 1;
|
|
Justin M. Forbes |
6f9d9c |
+ goto out;
|
|
Justin M. Forbes |
6f9d9c |
+ } else {
|
|
Justin M. Forbes |
6f9d9c |
+ running = 1;
|
|
Justin M. Forbes |
6f9d9c |
+ }
|
|
Justin M. Forbes |
6f9d9c |
|
|
Justin M. Forbes |
6f9d9c |
d = dma_controllers;
|
|
Justin M. Forbes |
6f9d9c |
|
|
Justin M. Forbes |
6f9d9c |
@@ -374,6 +382,8 @@ static void DMA_run (void)
|
|
Justin M. Forbes |
6f9d9c |
}
|
|
Justin M. Forbes |
6f9d9c |
}
|
|
Justin M. Forbes |
6f9d9c |
|
|
Justin M. Forbes |
6f9d9c |
+ running = 0;
|
|
Justin M. Forbes |
6f9d9c |
+out:
|
|
Justin M. Forbes |
6f9d9c |
if (rearm)
|
|
Justin M. Forbes |
6f9d9c |
qemu_bh_schedule_idle(dma_bh);
|
|
Justin M. Forbes |
6f9d9c |
}
|
|
Justin M. Forbes |
6f9d9c |
--
|
|
Justin M. Forbes |
6f9d9c |
1.7.7.5
|
|
Justin M. Forbes |
6f9d9c |
|