[Linaro-mm-sig] [PATCH] gpu: drm: Add helpers to allow export gem cma objects

Daniel Vetter daniel at ffwll.ch
Sat Oct 19 12:44:44 CEST 2013


On Fri, Oct 18, 2013 at 11:00:57AM +0200, benjamin.gaignard at linaro.org wrote:
> From: Benjamin Gaignard <benjamin.gaignard at linaro.org>
> 
> DRM already offer helpers to use CMA for dumb buffers.
> This patch add helpers to export/import gem_cam objects and allow them to be mmap from userland.
> The goal is to make working this kind of sequence: create_dumb, get fd from
> buffer handle and then use fd (maybe in another process which may ignore it
> is comming from DRM) to mmap the buffer.
> 
> drm_gem_cma_prime_export() add O_RDWR to flags to be sure that memory
> could be mmapped later with PROT_WRITE flag.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard at linaro.org>

[snip]

> +struct dma_buf *drm_gem_cma_prime_export(struct drm_device *drm_dev,
> +				struct drm_gem_object *obj, int flags)
> +{
> +	struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj);
> +
> +	flags |= O_RDWR;

This here looks funny ... I think either we need to add more flags to the
prime dma-buf exporting to also pass this flag through. Or we should just
generally set this in dma_buf_export. Doing this as an exporter-specific
hack feels wrong.
-Daniel

> +	return dma_buf_export(cma_obj, &drm_gem_cma_dmabuf_ops,
> +			cma_obj->base.size, flags);
> +}
> +EXPORT_SYMBOL_GPL(drm_gem_cma_prime_export);
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the dri-devel mailing list