From b96ffe1983295492bc4b4f28b22d6f0e78af69ef Mon Sep 17 00:00:00 2001 From: Tiago Vignatti Date: Tue, 26 Jan 2016 10:32:27 -0200 Subject: [PATCH] Relax the restriction and permit read/write access on dma-buf MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch relax the restriction and permit read/write access on dma-buf. In particular this is necessary for the userspace mmap()ing a dma-buf fd, so Chrome could now use it for unpriviledged Renderers write into a graphics buffer without much difficulty. This has been discussed in upstream here: http://lists.freedesktop.org/archives/dri-devel/2015-December/097562.html Kernel changes are needed to use this userspace feature: Author: Daniel Thompson Date: Fri Jun 19 14:52:28 2015 +0100 drm: prime: Honour O_RDWR during prime-handle-to-fd BUG=chromium:581151 TEST=test_that -b strago $DEVICE graphics_SanAngeles test_that -b strago $DEVICE graphics_GLBench test_that -b strago $DEVICE graphics_Sanity Change-Id: I37aff88623ba6aa45797b0ccb6cd2d15c5c51f41 Reviewed-on: https://chromium-review.googlesource.com/323990 Commit-Ready: Tiago Vignatti Tested-by: Tiago Vignatti Reviewed-by: Ilja Friedel Reviewed-by: Tiago Vignatti Reviewed-by: Stéphane Marchesin --- gbm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gbm.c b/gbm.c index 671fec0..b438173 100644 --- a/gbm.c +++ b/gbm.c @@ -351,6 +351,10 @@ gbm_bo_get_plane_handle(struct gbm_bo *bo, size_t plane) return bo->handles[plane]; } +#ifndef DRM_RDWR +#define DRM_RDWR O_RDWR +#endif + PUBLIC int gbm_bo_get_plane_fd(struct gbm_bo *bo, size_t plane) { @@ -360,7 +364,7 @@ gbm_bo_get_plane_fd(struct gbm_bo *bo, size_t plane) if (drmPrimeHandleToFD( gbm_device_get_fd(bo->gbm), gbm_bo_get_plane_handle(bo, plane).u32, - DRM_CLOEXEC, + DRM_CLOEXEC | DRM_RDWR, &fd)) return -1; else -- 2.11.0