[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Originally in qemu when a IDE dma transfer is started which is triggered
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 602f7fc3e1b139937d3404b5dae7a70635db4250 # Parent d6ebcfc5a30b0cfc70f77a547abb3dd06a30358c Originally in qemu when a IDE dma transfer is started which is triggered by access to 0xc000 port in VMX, qemu will blocked there until it finished. And during that block, there are extra dom switches between dom0 and idle domain, and VMX can't be resumed. By making real IDE dma tranfer run in another thread, qemu will return and VMX resume on time and there are fewer cycle wasted. Signed-off-by: Ke Yu <ke.yu@xxxxxxxxx> Signed-off-by: Xiaowei Yang <xiaowei.yang@xxxxxxxxx> diff -r d6ebcfc5a30b -r 602f7fc3e1b1 tools/ioemu/hw/ide.c --- a/tools/ioemu/hw/ide.c Thu Oct 27 16:27:04 2005 +++ b/tools/ioemu/hw/ide.c Thu Oct 27 16:29:39 2005 @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "vl.h" +#include <pthread.h> /* debug IDE devices */ //#define DEBUG_IDE @@ -359,6 +360,48 @@ IDEState ide_if[4]; BMDMAState bmdma[2]; } PCIIDEState; + +#define DMA_MULTI_THREAD + +#ifdef DMA_MULTI_THREAD + +static int file_pipes[2]; + +static void ide_dma_loop(BMDMAState *bm); +static void dma_thread_loop(BMDMAState *bm); + +static void *dma_thread_func(void* opaque) +{ + BMDMAState* req; + + while (read(file_pipes[0], &req, sizeof(req))) { + dma_thread_loop(req); + } + + return NULL; +} + +static void dma_create_thread() +{ + pthread_t tid; + int rt; + + if (pipe(file_pipes) != 0){ + fprintf(stderr, "create pipe failed\n"); + exit(1); + } + + if ( (rt = pthread_create(&tid, NULL, dma_thread_func, NULL)) ) { + fprintf(stderr, "Oops, dma thread creation failed, errno=%d\n", rt); + exit(1); + } + + if ( (rt = pthread_detach(tid)) ) { + fprintf(stderr, "Oops, dma thread detachment failed, errno=%d\n", rt); + exit(1); + } +} +#endif //DMA_MULTI_THREAD static void ide_dma_start(IDEState *s, IDEDMAFunc *dma_cb); @@ -1978,7 +2021,15 @@ /* XXX: full callback usage to prepare non blocking I/Os support - error handling */ +#ifdef DMA_MULTI_THREAD static void ide_dma_loop(BMDMAState *bm) +{ + write(file_pipes[1], &bm, sizeof(bm)); +} +static void dma_thread_loop(BMDMAState *bm) +#else +static void ide_dma_loop(BMDMAState *bm) +#endif //DMA_MULTI_THREAD { struct { uint32_t addr; @@ -2166,6 +2217,9 @@ d->ide_if[i].pci_dev = (PCIDevice *)d; ide_init2(&d->ide_if[0], 16, hd_table[0], hd_table[1]); ide_init2(&d->ide_if[2], 16, hd_table[2], hd_table[3]); +#ifdef DMA_MULTI_THREAD + dma_create_thread(); +#endif //DMA_MULTI_THREAD } /* hd_table must contain 4 block drivers */ @@ -2196,6 +2250,9 @@ ide_init2(&d->ide_if[2], 15, hd_table[2], hd_table[3]); ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6); ide_init_ioport(&d->ide_if[2], 0x170, 0x376); +#ifdef DMA_MULTI_THREAD + dma_create_thread(); +#endif //DMA_MULTI_THREAD } /***********************************************************/ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |