OSDN Git Service

Relax the restriction and permit read/write access on dma-buf
authorTiago Vignatti <tiago.vignatti@intel.com>
Tue, 26 Jan 2016 12:32:27 +0000 (10:32 -0200)
committerchrome-bot <chrome-bot@chromium.org>
Thu, 24 Mar 2016 09:19:42 +0000 (02:19 -0700)
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 <daniel.thompson@linaro.org>
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 <tiago.vignatti@intel.com>
Tested-by: Tiago Vignatti <tiago.vignatti@intel.com>
Reviewed-by: Ilja Friedel <ihf@chromium.org>
Reviewed-by: Tiago Vignatti <tiago.vignatti@intel.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
gbm.c

diff --git a/gbm.c b/gbm.c
index 671fec0..b438173 100644 (file)
--- 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