[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cdi-devel] [PATCH 1/4] mem.h: Handling memory areas
On Thu, Feb 11, 2010 at 9:01 AM, Kevin Wolf <kevin@xxxxxxxxxx> wrote:
> This adds a new CDI header cdi/mem.h. It unifies memory allocations
> (and memory areas passed from external sources) for different types
> of DMA, allows the OS layer to back it by shared memory (makes sense
> in a microkernel approach) and probably some more nice things.
> What cdi_mem_alloc/map/free are good for is obvious, I hope.
> To explain the use of the other functions, consider the following.
> Let's take a disk driver as an example. Instead of buffer/size its
> write function will directly get a memory area from the OS. The OS might
> already have allocated the memory physically contiguous, but it doesn't
> need to do so. The driver calls cdi_mem_require_flags which copies the
> data into a suited buffer - but if the OS already did the right thing,
> it's a no-op.
> cdi_mem_copy is for the other way round. Now the disk driver wants to
> read something from its disk. It gets a memory area from the OS and uses
> cdi_mem_require_flags to get something usable for DMA, which may or may
> not involve a copy. When the disk has transferred all the data, the
> driver uses cdi_mem_copy to make sure that the read data ends up in the
> buffer it was passed - and again, if the buffer had already the right
> flags this will be a no-op.
> Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
We can keep trying to find an alternative name for
cdi_mem_require_flags later. It's only the name of a function, after
all... A quick find and replace can fix that later on.
Acked-by: Matthew Iselin <matthew@xxxxxxxxxxxxxx>