Commit 6512a2a7106480c19183d6466a6845bc9bdf6ec0
1 parent
c07a9008
Implement cancellation method for dma async I/O (Avi Kivity)
Move the dma helpers to a private aio pool, and implement a cancellation method for them. Should prevent issues when cancelling I/O while dma is in progress. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6872 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
16 additions
and
1 deletions
dma-helpers.c
| @@ -10,6 +10,8 @@ | @@ -10,6 +10,8 @@ | ||
| 10 | #include "dma.h" | 10 | #include "dma.h" |
| 11 | #include "block_int.h" | 11 | #include "block_int.h" |
| 12 | 12 | ||
| 13 | +static AIOPool dma_aio_pool; | ||
| 14 | + | ||
| 13 | void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint) | 15 | void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint) |
| 14 | { | 16 | { |
| 15 | qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry)); | 17 | qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry)); |
| @@ -126,7 +128,7 @@ static BlockDriverAIOCB *dma_bdrv_io( | @@ -126,7 +128,7 @@ static BlockDriverAIOCB *dma_bdrv_io( | ||
| 126 | DMABlockState *dbs = qemu_malloc(sizeof(*dbs)); | 128 | DMABlockState *dbs = qemu_malloc(sizeof(*dbs)); |
| 127 | 129 | ||
| 128 | dbs->bs = bs; | 130 | dbs->bs = bs; |
| 129 | - dbs->acb = qemu_aio_get(bs, cb, opaque); | 131 | + dbs->acb = qemu_aio_get_pool(&dma_aio_pool, bs, cb, opaque); |
| 130 | dbs->sg = sg; | 132 | dbs->sg = sg; |
| 131 | dbs->sector_num = sector_num; | 133 | dbs->sector_num = sector_num; |
| 132 | dbs->sg_cur_index = 0; | 134 | dbs->sg_cur_index = 0; |
| @@ -153,3 +155,14 @@ BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, | @@ -153,3 +155,14 @@ BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, | ||
| 153 | return dma_bdrv_io(bs, sg, sector, cb, opaque, 1); | 155 | return dma_bdrv_io(bs, sg, sector, cb, opaque, 1); |
| 154 | } | 156 | } |
| 155 | 157 | ||
| 158 | +static void dma_aio_cancel(BlockDriverAIOCB *acb) | ||
| 159 | +{ | ||
| 160 | + DMABlockState *dbs = (DMABlockState *)acb->opaque; | ||
| 161 | + | ||
| 162 | + bdrv_aio_cancel(dbs->acb); | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +void dma_helper_init(void) | ||
| 166 | +{ | ||
| 167 | + aio_pool_init(&dma_aio_pool, sizeof(BlockDriverAIOCB), dma_aio_cancel); | ||
| 168 | +} |
dma.h
| @@ -37,5 +37,6 @@ BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs, | @@ -37,5 +37,6 @@ BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs, | ||
| 37 | BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, | 37 | BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, |
| 38 | QEMUSGList *sg, uint64_t sector, | 38 | QEMUSGList *sg, uint64_t sector, |
| 39 | BlockDriverCompletionFunc *cb, void *opaque); | 39 | BlockDriverCompletionFunc *cb, void *opaque); |
| 40 | +void dma_helper_init(void); | ||
| 40 | 41 | ||
| 41 | #endif | 42 | #endif |
vl.c
| @@ -5515,6 +5515,7 @@ int main(int argc, char **argv, char **envp) | @@ -5515,6 +5515,7 @@ int main(int argc, char **argv, char **envp) | ||
| 5515 | cpu_exec_init_all(tb_size * 1024 * 1024); | 5515 | cpu_exec_init_all(tb_size * 1024 * 1024); |
| 5516 | 5516 | ||
| 5517 | bdrv_init(); | 5517 | bdrv_init(); |
| 5518 | + dma_helper_init(); | ||
| 5518 | 5519 | ||
| 5519 | /* we always create the cdrom drive, even if no disk is there */ | 5520 | /* we always create the cdrom drive, even if no disk is there */ |
| 5520 | 5521 |