[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/43] i8257: rewrite DMA_schedule to avoid hooking i
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 08/43] i8257: rewrite DMA_schedule to avoid hooking into the CPU loop |
Date: |
Wed, 9 Sep 2015 15:49:38 +0200 |
The i8257 DMA controller uses an idle bottom half, which by default
does not cause the main loop to exit. Therefore, the DMA_schedule
function is there to ensure that the CPU relinquishes the iothread
mutex to the iothread.
However, this is not enough since the iothread will call
aio_compute_timeout() and go to sleep again. In the iothread
world, forcing execution of the idle bottom half is much simpler,
and only requires a call to qemu_notify_event(). Do it, removing
the need for the "cpu_request_exit" pseudo-irq. The next patch
will remove it.
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/block/fdc.c | 2 +-
hw/dma/i8257.c | 18 ++++++++++++------
hw/sparc/sun4m.c | 2 +-
hw/sparc64/sun4u.c | 2 +-
include/hw/isa/isa.h | 2 +-
5 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 5e1b67e..6686a72 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -1417,7 +1417,7 @@ static void fdctrl_start_transfer(FDCtrl *fdctrl, int
direction)
* recall us...
*/
DMA_hold_DREQ(fdctrl->dma_chann);
- DMA_schedule(fdctrl->dma_chann);
+ DMA_schedule();
} else {
/* Start transfer */
fdctrl_transfer_handler(fdctrl, fdctrl->dma_chann, 0,
diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index a414029..409ba7d 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -358,6 +358,7 @@ static void channel_run (int ncont, int ichan)
}
static QEMUBH *dma_bh;
+static bool dma_bh_scheduled;
static void DMA_run (void)
{
@@ -390,12 +391,15 @@ static void DMA_run (void)
running = 0;
out:
- if (rearm)
+ if (rearm) {
qemu_bh_schedule_idle(dma_bh);
+ dma_bh_scheduled = true;
+ }
}
static void DMA_run_bh(void *unused)
{
+ dma_bh_scheduled = false;
DMA_run();
}
@@ -458,12 +462,14 @@ int DMA_write_memory (int nchan, void *buf, int pos, int
len)
return len;
}
-/* request the emulator to transfer a new DMA memory block ASAP */
-void DMA_schedule(int nchan)
+/* request the emulator to transfer a new DMA memory block ASAP (even
+ * if the idle bottom half would not have exited the iothread yet).
+ */
+void DMA_schedule(void)
{
- struct dma_cont *d = &dma_controllers[nchan > 3];
-
- qemu_irq_pulse(*d->cpu_request_exit);
+ if (dma_bh_scheduled) {
+ qemu_notify_event();
+ }
}
static void dma_reset(void *opaque)
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 68ac4d8..ebaae9d 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -109,7 +109,7 @@ int DMA_write_memory (int nchan, void *buf, int pos, int
size)
}
void DMA_hold_DREQ (int nchan) {}
void DMA_release_DREQ (int nchan) {}
-void DMA_schedule(int nchan) {}
+void DMA_schedule(void) {}
void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit)
{
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 30cfa0e..44eb4eb 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -112,7 +112,7 @@ int DMA_write_memory (int nchan, void *buf, int pos, int
size)
}
void DMA_hold_DREQ (int nchan) {}
void DMA_release_DREQ (int nchan) {}
-void DMA_schedule(int nchan) {}
+void DMA_schedule(void) {}
void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit)
{
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index f21ceaa..81b94ea 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -112,7 +112,7 @@ int DMA_read_memory (int nchan, void *buf, int pos, int
size);
int DMA_write_memory (int nchan, void *buf, int pos, int size);
void DMA_hold_DREQ (int nchan);
void DMA_release_DREQ (int nchan);
-void DMA_schedule(int nchan);
+void DMA_schedule(void);
void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
void DMA_register_channel (int nchan,
DMA_transfer_handler transfer_handler,
--
2.4.3
- [Qemu-devel] [PULL 00/43] First batch of misc changes for 2.5 (2015-09-09), Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 02/43] seqlock: add missing 'inline' to seqlock_read_retry, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 01/43] qemu-thread: handle spurious futex_wait wakeups, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 03/43] seqlock: read sequence number atomically, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 04/43] cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 05/43] iohandler: Use aio API, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 08/43] i8257: rewrite DMA_schedule to avoid hooking into the CPU loop,
Paolo Bonzini <=
- [Qemu-devel] [PULL 06/43] block/iscsi: validate block size returned from target, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 10/43] tcg: introduce tcg_current_cpu, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 07/43] Added generic panic handler qemu_system_guest_panicked(), Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 09/43] i8257: remove cpu_request_exit irq, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 14/43] tcg: synchronize exit_request and tcg_current_cpu accesses, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 15/43] use qemu_cpu_kick instead of cpu_exit or qemu_cpu_kick_thread, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 11/43] remove qemu/tls.h, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 13/43] tcg: synchronize cpu->exit_request and cpu->tcg_exit_req accesses, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 16/43] tcg: signal-free qemu_cpu_kick, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 12/43] tcg: assign cpu->current_tb in a simpler place, Paolo Bonzini, 2015/09/09