[RESEND][PATCH v8 3/5] dma-buf: heaps: Add system heap to dmabuf heaps

Hillf Danton hdanton at sina.com
Mon Sep 30 07:43:35 UTC 2019


On Fri,  6 Sep 2019 18:47:09 +0000 John Stultz wrote:
> 
> +static int system_heap_allocate(struct dma_heap *heap,
> +				unsigned long len,
> +				unsigned long fd_flags,
> +				unsigned long heap_flags)
> +{
> +	struct heap_helper_buffer *helper_buffer;
> +	struct dma_buf *dmabuf;
> +	int ret = -ENOMEM;
> +	pgoff_t pg;
> +
> +	helper_buffer = kzalloc(sizeof(*helper_buffer), GFP_KERNEL);
> +	if (!helper_buffer)
> +		return -ENOMEM;
> +
> +	init_heap_helper_buffer(helper_buffer, system_heap_free);
> +	helper_buffer->flags = heap_flags;
> +	helper_buffer->heap = heap;
> +	helper_buffer->size = len;
> +
A couple of lines looks needed to handle len if it is not
PAGE_SIZE aligned.

> +	helper_buffer->pagecount = len / PAGE_SIZE;
> +	helper_buffer->pages = kmalloc_array(helper_buffer->pagecount,
> +					     sizeof(*helper_buffer->pages),
> +					     GFP_KERNEL);



More information about the dri-devel mailing list