Mesa (staging/21.0): i965: export GEM handle with RDWR access rights

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 21 03:56:27 UTC 2021


Module: Mesa
Branch: staging/21.0
Commit: 953c479e16e8bb5bc411ea4464a5ce5772fea7dd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=953c479e16e8bb5bc411ea4464a5ce5772fea7dd

Author: Maksim Sisov <msisov at igalia.com>
Date:   Tue May 18 08:23:56 2021 +0300

i965: export GEM handle with RDWR access rights

There is a regression that made it impossible to export gem
handles with write access.

That is, a client may export gem handles of each buffer plane, then
export dmabuf fds using these handles, and mmap these dmabuf in
a different process (this is what Chromium does).

After https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4861,
it became impossible as mmap resulted in EACCESS error as slightly
different approach was taken for exporting these gem handles.

This CL fixes exporting gem handles (which are exported from dmabuf
fds) by adding the DRM_RDWR flag.

Cc: mesa-stable

Fixes #3119

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10850>
(cherry picked from commit 5eaf8b59c858bc93f0b18045f49dcdfe6b1d6e75)

---

 .pick_status.json                      | 2 +-
 src/mesa/drivers/dri/i965/brw_bufmgr.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index ad63615d95a..6da42ad6306 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1201,7 +1201,7 @@
         "description": "i965: export GEM handle with RDWR access rights",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index 7b861957ffe..006d3b0316f 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -1581,7 +1581,7 @@ brw_bo_gem_export_to_prime(struct brw_bo *bo, int *prime_fd)
    brw_bo_make_external(bo);
 
    if (drmPrimeHandleToFD(bufmgr->fd, bo->gem_handle,
-                          DRM_CLOEXEC, prime_fd) != 0)
+                          DRM_CLOEXEC | DRM_RDWR, prime_fd) != 0)
       return -errno;
 
    bo->reusable = false;



More information about the mesa-commit mailing list