[EARLY RFC][PATCH] dma-buf: Add dma-buf heaps framework
Andrew F. Davis
afd at ti.com
Tue Feb 26 14:04:06 UTC 2019
On 2/25/19 6:55 PM, John Stultz wrote:
> On Mon, Feb 25, 2019 at 6:36 AM Andrew F. Davis <afd at ti.com> wrote:
>> +static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, unsigned int flags)
>> +{
>> + struct dma_heap_buffer *buffer;
>> + int fd, ret;
>> +
>> + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
>> + if (!buffer)
>> + return -ENOMEM;
>> +
>> + buffer->heap = heap;
>> + ret = heap->ops->allocate(heap, buffer, len, flags);
>> + if (ret) {
>> + kfree(buffer);
>> + return ret;
>> + }
>
> Similarly, I think the struct dma_heap_buffer, should be allocated and
> returned by the heap's allocate function.
>
That sound good, we could also then remove the free in buffer_free(),
just wasn't sure about object lifetimes causing issues if it was freed
early and the framework still needed something from it.
Andrew
> That way it can allocate its own larger structure (with the
> dma_heap_buffer as part of it) with private fields, and use
> container_of() to traverse from the buffer to the private data.
>
> Once I get things building, I'll share my changes.
>
> thanks
> -john
>
More information about the dri-devel
mailing list