Re: [PATCH v7 2/5] dma-buf: heaps: Add heap helpers

From: Christoph Hellwig
Date: Thu Jul 25 2019 - 14:06:13 EST


> +struct dma_buf *heap_helper_export_dmabuf(
> + struct heap_helper_buffer *helper_buffer,
> + int fd_flags)

Indentation seems odd here as it doesn't follow any of the usual schools
for multi-level prototypes. But maybe shortening some identifier would
help avoiding that problem altogether :)

> +static void *dma_heap_map_kernel(struct heap_helper_buffer *buffer)
> +{
> + void *vaddr;
> +
> + vaddr = vmap(buffer->pages, buffer->pagecount, VM_MAP, PAGE_KERNEL);
> + if (!vaddr)
> + return ERR_PTR(-ENOMEM);
> +
> + return vaddr;
> +}

Note that a lot of systems don't have highmem at all or don't support
CMA in highmem. So for contigous allocations that aren't highmem we
could skip the vmap here altogether and just use the direct mapping.