qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 05/10] dma-helpers: add dma_buf_read and dma_buf


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 05/10] dma-helpers: add dma_buf_read and dma_buf_write
Date: Thu, 11 Aug 2011 21:06:50 +0100

On Thu, Aug 11, 2011 at 4:27 PM, Paolo Bonzini <address@hidden> wrote:
> On 08/11/2011 05:12 PM, Kevin Wolf wrote:
>>>
>>> >  Another possibility is always completing DMA in a bottom half.  This
>>> >  ensures that the callback can access the AIOCB, but it exposes an
>>> >  implementation detail to the caller, so I don't like it.
>>
>> At least in the block layer, AIO callbacks may never be called before
>> the submission function has returned. I think this makes the DMA helpers
>> provide the same behaviour.
>>
>> But I'm not sure if the definition of the AIOCB struct isn't private to
>> the block layer.
>
> Yes, it is; I would add a getter that is specific to the DMAAIOCB.

You don't need to make the dma_bdrv_io() cb function a
BlockDriverCompletionFunc.  Instead define a DMACompletionFunc:

typedef void DMACompletionFunc(void *opaque, int ret,
target_phys_addr_t residual);

The only one invoking dbs->common.cb is dma-helpers.c so you can just
avoid using common.cb and instead use a DMACompletionFunc cb.

Perhaps the AIOCB concept can be made generic where BlockDriverAIOCB
inherits from it.  I'm not even so sure that keeping a
BlockDriverState pointer around is that useful.  At least
dma-helpers.c seems to think it's too much typing and it just
duplicates the bs field into DMAAIOCB directly :).  The question then
becomes how to abstract the typed callback function nicely.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]