[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V3 4/6] ide: orphan all buffered requests on DMA
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH V3 4/6] ide: orphan all buffered requests on DMA cancel |
Date: |
Thu, 12 Nov 2015 16:27:36 +0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, 11/06 09:42, Peter Lieven wrote:
> If the guests canceles a DMA request we can prematurely
> invoke all callbacks of buffered requests and flag all them
> as orphaned. Ideally this avoids the need for draining all
> requests. For CDROM devices this works in 100% of all cases.
>
> Signed-off-by: Peter Lieven <address@hidden>
> ---
> hw/ide/pci.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/hw/ide/pci.c b/hw/ide/pci.c
> index d31ff88..a9e164e 100644
> --- a/hw/ide/pci.c
> +++ b/hw/ide/pci.c
> @@ -240,6 +240,22 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val)
> /* Ignore writes to SSBM if it keeps the old value */
> if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) {
> if (!(val & BM_CMD_START)) {
> + /* First invoke the callbacks of all buffered requests
> + * and flag those requests as orphaned. Ideally there
> + * are no unbuffered (Scatter Gather DMA Requests or
> + * write requests) pending and we can avoid to drain. */
> + IDEBufferedRequest *req;
> + IDEState *s = idebus_active_if(bm->bus);
> + QLIST_FOREACH(req, &s->buffered_requests, list) {
> + if (!req->orphaned) {
> +#ifdef DEBUG_IDE
> + printf("%s: invoking cb %p of buffered request %p with"
> + " -ECANCELED\n", __func__, req->original_cb, req);
> +#endif
> + req->original_cb(req->original_opaque, -ECANCELED);
> + }
> + req->orphaned = true;
> + }
Why not use bdrv_aio_cancel or bdrv_aio_cancel_async with the aio returned by
bdrv_aio_cancel?
Fam
> /*
> * We can't cancel Scatter Gather DMA in the middle of the
> * operation or a partial (not full) DMA transfer would reach
> @@ -253,6 +269,9 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val)
> * aio operation with preadv/pwritev.
> */
> if (bm->bus->dma->aiocb) {
> +#ifdef DEBUG_IDE
> + printf("%s: draining all remaining requests", __func__);
> +#endif
> blk_drain_all();
> assert(bm->bus->dma->aiocb == NULL);
> }
> --
> 1.9.1
>
>
- [Qemu-devel] [PATCH V3 0/6] ide: avoid main-loop hang on CDROM/NFS failure, Peter Lieven, 2015/11/06
- [Qemu-devel] [PATCH V3 4/6] ide: orphan all buffered requests on DMA cancel, Peter Lieven, 2015/11/06
- Re: [Qemu-devel] [PATCH V3 4/6] ide: orphan all buffered requests on DMA cancel,
Fam Zheng <=
- [Qemu-devel] [PATCH V3 1/6] ide/atapi: make PIO read requests async, Peter Lieven, 2015/11/06
- [Qemu-devel] [PATCH V3 2/6] block: add blk_abort_aio_request, Peter Lieven, 2015/11/06
- [Qemu-devel] [PATCH V3 3/6] ide: add support for IDEBufferedRequest, Peter Lieven, 2015/11/06
- [Qemu-devel] [PATCH V3 6/6] ide: enable buffered requests for PIO read requests, Peter Lieven, 2015/11/06
- [Qemu-devel] [PATCH V3 5/6] ide: enable buffered requests for ATAPI devices, Peter Lieven, 2015/11/06