[arch-commits] Commit in mesa/repos/testing-x86_64 (10 files)

Laurent Carlier lcarlier at archlinux.org
Fri May 29 08:02:58 UTC 2020


    Date: Friday, May 29, 2020 @ 08:02:57
  Author: lcarlier
Revision: 387800

archrelease: copy trunk to testing-x86_64

Added:
  mesa/repos/testing-x86_64/0001-iris-fix-BO-destruction-in-error-path.patch
    (from rev 387799, mesa/trunk/0001-iris-fix-BO-destruction-in-error-path.patch)
  mesa/repos/testing-x86_64/0002-iris-fix-export-of-GEM-handles.patch
    (from rev 387799, mesa/trunk/0002-iris-fix-export-of-GEM-handles.patch)
  mesa/repos/testing-x86_64/0003-i965-fix-export-of-GEM-handles.patch
    (from rev 387799, mesa/trunk/0003-i965-fix-export-of-GEM-handles.patch)
  mesa/repos/testing-x86_64/LICENSE
    (from rev 387799, mesa/trunk/LICENSE)
  mesa/repos/testing-x86_64/PKGBUILD
    (from rev 387799, mesa/trunk/PKGBUILD)
Deleted:
  mesa/repos/testing-x86_64/0001-iris-fix-BO-destruction-in-error-path.patch
  mesa/repos/testing-x86_64/0002-iris-fix-export-of-GEM-handles.patch
  mesa/repos/testing-x86_64/0003-i965-fix-export-of-GEM-handles.patch
  mesa/repos/testing-x86_64/LICENSE
  mesa/repos/testing-x86_64/PKGBUILD

--------------------------------------------------+
 0001-iris-fix-BO-destruction-in-error-path.patch |   82 +-
 0002-iris-fix-export-of-GEM-handles.patch        |  728 ++++++++++-----------
 0003-i965-fix-export-of-GEM-handles.patch        |  686 +++++++++----------
 LICENSE                                          |  166 ++--
 PKGBUILD                                         |  411 ++++++-----
 5 files changed, 1040 insertions(+), 1033 deletions(-)

Deleted: 0001-iris-fix-BO-destruction-in-error-path.patch
===================================================================
--- 0001-iris-fix-BO-destruction-in-error-path.patch	2020-05-29 08:02:49 UTC (rev 387799)
+++ 0001-iris-fix-BO-destruction-in-error-path.patch	2020-05-29 08:02:57 UTC (rev 387800)
@@ -1,41 +0,0 @@
-From eac7681c13f127d762474a8207399c2eb0c76f30 Mon Sep 17 00:00:00 2001
-From: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
-Date: Sat, 2 May 2020 22:43:22 +0300
-Subject: [PATCH 1/3] iris: fix BO destruction in error path
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
-Cc: <mesa-stable at lists.freedesktop.org>
-Tested-by: Tapani Pälli <tapani.palli at intel.com>
-Signed-off-by: Laurent Carlier <lordheavym at gmail.com>
----
- src/gallium/drivers/iris/iris_bufmgr.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
-index c8e6d0c654b..9064647d0e5 100644
---- a/src/gallium/drivers/iris/iris_bufmgr.c
-+++ b/src/gallium/drivers/iris/iris_bufmgr.c
-@@ -589,6 +589,7 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name,
-                        void *ptr, size_t size,
-                        enum iris_memory_zone memzone)
- {
-+   struct drm_gem_close close = { 0, };
-    struct iris_bo *bo;
- 
-    bo = bo_calloc();
-@@ -634,7 +635,8 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name,
-    return bo;
- 
- err_close:
--   gen_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &bo->gem_handle);
-+   close.handle = bo->gem_handle;
-+   gen_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &close);
- err_free:
-    free(bo);
-    return NULL;
--- 
-2.26.2
-

Copied: mesa/repos/testing-x86_64/0001-iris-fix-BO-destruction-in-error-path.patch (from rev 387799, mesa/trunk/0001-iris-fix-BO-destruction-in-error-path.patch)
===================================================================
--- 0001-iris-fix-BO-destruction-in-error-path.patch	                        (rev 0)
+++ 0001-iris-fix-BO-destruction-in-error-path.patch	2020-05-29 08:02:57 UTC (rev 387800)
@@ -0,0 +1,41 @@
+From eac7681c13f127d762474a8207399c2eb0c76f30 Mon Sep 17 00:00:00 2001
+From: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
+Date: Sat, 2 May 2020 22:43:22 +0300
+Subject: [PATCH 1/3] iris: fix BO destruction in error path
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
+Cc: <mesa-stable at lists.freedesktop.org>
+Tested-by: Tapani Pälli <tapani.palli at intel.com>
+Signed-off-by: Laurent Carlier <lordheavym at gmail.com>
+---
+ src/gallium/drivers/iris/iris_bufmgr.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
+index c8e6d0c654b..9064647d0e5 100644
+--- a/src/gallium/drivers/iris/iris_bufmgr.c
++++ b/src/gallium/drivers/iris/iris_bufmgr.c
+@@ -589,6 +589,7 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name,
+                        void *ptr, size_t size,
+                        enum iris_memory_zone memzone)
+ {
++   struct drm_gem_close close = { 0, };
+    struct iris_bo *bo;
+ 
+    bo = bo_calloc();
+@@ -634,7 +635,8 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name,
+    return bo;
+ 
+ err_close:
+-   gen_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &bo->gem_handle);
++   close.handle = bo->gem_handle;
++   gen_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &close);
+ err_free:
+    free(bo);
+    return NULL;
+-- 
+2.26.2
+

Deleted: 0002-iris-fix-export-of-GEM-handles.patch
===================================================================
--- 0002-iris-fix-export-of-GEM-handles.patch	2020-05-29 08:02:49 UTC (rev 387799)
+++ 0002-iris-fix-export-of-GEM-handles.patch	2020-05-29 08:02:57 UTC (rev 387800)
@@ -1,364 +0,0 @@
-From e01e146e35681dbdc68d70a2118b71a78ef67e6a Mon Sep 17 00:00:00 2001
-From: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
-Date: Sat, 2 May 2020 16:46:47 +0300
-Subject: [PATCH 2/3] iris: fix export of GEM handles
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-We reuse DRM file descriptors internally. Therefore when we export a
-GEM handle we must do so in the file descriptor used externally.
-
-v2: Don't bother checking fd equals, they're always different
-    Fix dmabuf leak
-    Fix GEM handle leaks by tracking exported handles
-
-v3: Check os_same_file_description error (Michel)
-    Don't create multiple exports for a given GEM table
-
-v4: Add WARN_ONCE (Ken)
-    Rename external_fd to winsys_fd
-
-v5: Remove export lock in favor of bufmgr's
-
-Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
-Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2882
-Fixes: 7557f1605968 ("iris: share buffer managers accross screens")
-Tested-by: Eric Engestrom <eric at engestrom.ch>
-Tested-by: Tapani Pälli <tapani.palli at intel.com>
-Signed-off-by: Laurent Carlier <lordheavym at gmail.com>
----
- src/gallium/drivers/iris/iris_bufmgr.c   | 108 ++++++++++++++++++++++-
- src/gallium/drivers/iris/iris_bufmgr.h   |  16 ++++
- src/gallium/drivers/iris/iris_resource.c |  33 +++++--
- src/gallium/drivers/iris/iris_screen.c   |   2 +
- src/gallium/drivers/iris/iris_screen.h   |   8 +-
- 5 files changed, 157 insertions(+), 10 deletions(-)
-
-diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
-index 9064647d0e5..3c39769b9cb 100644
---- a/src/gallium/drivers/iris/iris_bufmgr.c
-+++ b/src/gallium/drivers/iris/iris_bufmgr.c
-@@ -63,6 +63,7 @@
- #include "util/macros.h"
- #include "util/hash_table.h"
- #include "util/list.h"
-+#include "util/os_file.h"
- #include "util/u_dynarray.h"
- #include "util/vma.h"
- #include "iris_bufmgr.h"
-@@ -91,6 +92,17 @@
- 
- #define PAGE_SIZE 4096
- 
-+#define WARN_ONCE(cond, fmt...) do {                            \
-+   if (unlikely(cond)) {                                        \
-+      static bool _warned = false;                              \
-+      if (!_warned) {                                           \
-+         fprintf(stderr, "WARNING: ");                          \
-+         fprintf(stderr, fmt);                                  \
-+         _warned = true;                                        \
-+      }                                                         \
-+   }                                                            \
-+} while (0)
-+
- #define FILE_DEBUG_FLAG DEBUG_BUFMGR
- 
- static inline int
-@@ -126,6 +138,16 @@ struct bo_cache_bucket {
-    uint64_t size;
- };
- 
-+struct bo_export {
-+   /** File descriptor associated with a handle export. */
-+   int drm_fd;
-+
-+   /** GEM handle in drm_fd */
-+   uint32_t gem_handle;
-+
-+   struct list_head link;
-+};
-+
- struct iris_bufmgr {
-    /**
-     * List into the list of bufmgr.
-@@ -349,9 +371,13 @@ static struct iris_bo *
- bo_calloc(void)
- {
-    struct iris_bo *bo = calloc(1, sizeof(*bo));
--   if (bo) {
--      bo->hash = _mesa_hash_pointer(bo);
--   }
-+   if (!bo)
-+      return NULL;
-+
-+   list_inithead(&bo->exports);
-+
-+   bo->hash = _mesa_hash_pointer(bo);
-+
-    return bo;
- }
- 
-@@ -707,6 +733,7 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr,
- 
-    bo->tiling_mode = get_tiling.tiling_mode;
-    bo->swizzle_mode = get_tiling.swizzle_mode;
-+
-    /* XXX stride is unknown */
-    DBG("bo_create_from_handle: %d (%s)\n", handle, bo->name);
- 
-@@ -735,6 +762,16 @@ bo_close(struct iris_bo *bo)
- 
-       entry = _mesa_hash_table_search(bufmgr->handle_table, &bo->gem_handle);
-       _mesa_hash_table_remove(bufmgr->handle_table, entry);
-+
-+      list_for_each_entry_safe(struct bo_export, export, &bo->exports, link) {
-+         struct drm_gem_close close = { .handle = export->gem_handle };
-+         gen_ioctl(export->drm_fd, DRM_IOCTL_GEM_CLOSE, &close);
-+
-+         list_del(&export->link);
-+         free(export);
-+      }
-+   } else {
-+      assert(list_is_empty(&bo->exports));
-    }
- 
-    /* Close this object */
-@@ -1490,6 +1527,71 @@ iris_bo_flink(struct iris_bo *bo, uint32_t *name)
-    return 0;
- }
- 
-+int
-+iris_bo_export_gem_handle_for_device(struct iris_bo *bo, int drm_fd,
-+                                     uint32_t *out_handle)
-+{
-+   /* Only add the new GEM handle to the list of export if it belongs to a
-+    * different GEM device. Otherwise we might close the same buffer multiple
-+    * times.
-+    */
-+   struct iris_bufmgr *bufmgr = bo->bufmgr;
-+   int ret = os_same_file_description(drm_fd, bufmgr->fd);
-+   WARN_ONCE(ret < 0,
-+             "Kernel has no file descriptor comparison support: %s\n",
-+             strerror(errno));
-+   if (ret == 0) {
-+      *out_handle = iris_bo_export_gem_handle(bo);
-+      return 0;
-+   }
-+
-+   struct bo_export *export = calloc(1, sizeof(*export));
-+   if (!export)
-+      return -ENOMEM;
-+
-+   export->drm_fd = drm_fd;
-+
-+   int dmabuf_fd = -1;
-+   int err = iris_bo_export_dmabuf(bo, &dmabuf_fd);
-+   if (err) {
-+      free(export);
-+      return err;
-+   }
-+
-+   mtx_lock(&bufmgr->lock);
-+   err = drmPrimeFDToHandle(drm_fd, dmabuf_fd, &export->gem_handle);
-+   close(dmabuf_fd);
-+   if (err) {
-+      mtx_unlock(&bufmgr->lock);
-+      free(export);
-+      return err;
-+   }
-+
-+   iris_bo_make_external_locked(bo);
-+
-+   bool found = false;
-+   list_for_each_entry(struct bo_export, iter, &bo->exports, link) {
-+      if (iter->drm_fd != drm_fd)
-+         continue;
-+      /* Here we assume that for a given DRM fd, we'll always get back the
-+       * same GEM handle for a given buffer.
-+       */
-+      assert(iter->gem_handle == export->gem_handle);
-+      free(export);
-+      export = iter;
-+      found = true;
-+      break;
-+   }
-+   if (!found)
-+      list_addtail(&export->link, &bo->exports);
-+
-+   mtx_unlock(&bufmgr->lock);
-+
-+   *out_handle = export->gem_handle;
-+
-+   return 0;
-+}
-+
- static void
- add_bucket(struct iris_bufmgr *bufmgr, int size)
- {
-diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h
-index d7edda23aca..084de82c375 100644
---- a/src/gallium/drivers/iris/iris_bufmgr.h
-+++ b/src/gallium/drivers/iris/iris_bufmgr.h
-@@ -28,6 +28,7 @@
- #include <stdint.h>
- #include <stdio.h>
- #include <sys/types.h>
-+#include "c11/threads.h"
- #include "util/macros.h"
- #include "util/u_atomic.h"
- #include "util/list.h"
-@@ -166,6 +167,9 @@ struct iris_bo {
-    /** BO cache list */
-    struct list_head head;
- 
-+   /** List of GEM handle exports of this buffer (bo_export) */
-+   struct list_head exports;
-+
-    /**
-     * Boolean of whether the GPU is definitely not accessing the buffer.
-     *
-@@ -365,6 +369,18 @@ int iris_bo_export_dmabuf(struct iris_bo *bo, int *prime_fd);
- struct iris_bo *iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd,
-                                       uint32_t tiling, uint32_t stride);
- 
-+/**
-+ * Exports a bo as a GEM handle into a given DRM file descriptor
-+ * \param bo Buffer to export
-+ * \param drm_fd File descriptor where the new handle is created
-+ * \param out_handle Pointer to store the new handle
-+ *
-+ * Returns 0 if the buffer was successfully exported, a non zero error code
-+ * otherwise.
-+ */
-+int iris_bo_export_gem_handle_for_device(struct iris_bo *bo, int drm_fd,
-+                                         uint32_t *out_handle);
-+
- uint32_t iris_bo_export_gem_handle(struct iris_bo *bo);
- 
- int iris_reg_read(struct iris_bufmgr *bufmgr, uint32_t offset, uint64_t *out);
-diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
-index 3d2805f3548..0f71c5a8593 100644
---- a/src/gallium/drivers/iris/iris_resource.c
-+++ b/src/gallium/drivers/iris/iris_resource.c
-@@ -1139,7 +1139,7 @@ iris_resource_disable_aux_on_first_query(struct pipe_resource *resource,
- }
- 
- static bool
--iris_resource_get_param(struct pipe_screen *screen,
-+iris_resource_get_param(struct pipe_screen *pscreen,
-                         struct pipe_context *context,
-                         struct pipe_resource *resource,
-                         unsigned plane,
-@@ -1148,6 +1148,7 @@ iris_resource_get_param(struct pipe_screen *screen,
-                         unsigned handle_usage,
-                         uint64_t *value)
- {
-+   struct iris_screen *screen = (struct iris_screen *)pscreen;
-    struct iris_resource *res = (struct iris_resource *)resource;
-    bool mod_with_aux =
-       res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE;
-@@ -1156,7 +1157,7 @@ iris_resource_get_param(struct pipe_screen *screen,
-    unsigned handle;
- 
-    if (iris_resource_unfinished_aux_import(res))
--      iris_resource_finish_aux_import(screen, res);
-+      iris_resource_finish_aux_import(pscreen, res);
- 
-    struct iris_bo *bo = wants_aux ? res->aux.bo : res->bo;
- 
-@@ -1188,9 +1189,19 @@ iris_resource_get_param(struct pipe_screen *screen,
-       if (result)
-          *value = handle;
-       return result;
--   case PIPE_RESOURCE_PARAM_HANDLE_TYPE_KMS:
--      *value = iris_bo_export_gem_handle(bo);
-+   case PIPE_RESOURCE_PARAM_HANDLE_TYPE_KMS: {
-+      /* Because we share the same drm file across multiple iris_screen, when
-+       * we export a GEM handle we must make sure it is valid in the DRM file
-+       * descriptor the caller is using (this is the FD given at screen
-+       * creation).
-+       */
-+      uint32_t handle;
-+      if (iris_bo_export_gem_handle_for_device(bo, screen->winsys_fd, &handle))
-+         return false;
-+      *value = handle;
-       return true;
-+   }
-+
-    case PIPE_RESOURCE_PARAM_HANDLE_TYPE_FD:
-       result = iris_bo_export_dmabuf(bo, (int *) &handle) == 0;
-       if (result)
-@@ -1208,6 +1219,7 @@ iris_resource_get_handle(struct pipe_screen *pscreen,
-                          struct winsys_handle *whandle,
-                          unsigned usage)
- {
-+   struct iris_screen *screen = (struct iris_screen *) pscreen;
-    struct iris_resource *res = (struct iris_resource *)resource;
-    bool mod_with_aux =
-       res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE;
-@@ -1245,9 +1257,18 @@ iris_resource_get_handle(struct pipe_screen *pscreen,
-    switch (whandle->type) {
-    case WINSYS_HANDLE_TYPE_SHARED:
-       return iris_bo_flink(bo, &whandle->handle) == 0;
--   case WINSYS_HANDLE_TYPE_KMS:
--      whandle->handle = iris_bo_export_gem_handle(bo);
-+   case WINSYS_HANDLE_TYPE_KMS: {
-+      /* Because we share the same drm file across multiple iris_screen, when
-+       * we export a GEM handle we must make sure it is valid in the DRM file
-+       * descriptor the caller is using (this is the FD given at screen
-+       * creation).
-+       */
-+      uint32_t handle;
-+      if (iris_bo_export_gem_handle_for_device(bo, screen->winsys_fd, &handle))
-+         return false;
-+      whandle->handle = handle;
-       return true;
-+   }
-    case WINSYS_HANDLE_TYPE_FD:
-       return iris_bo_export_dmabuf(bo, (int *) &whandle->handle) == 0;
-    }
-diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c
-index 94ee60eb016..3e2761aecc3 100644
---- a/src/gallium/drivers/iris/iris_screen.c
-+++ b/src/gallium/drivers/iris/iris_screen.c
-@@ -559,6 +559,7 @@ iris_screen_destroy(struct iris_screen *screen)
-    u_transfer_helper_destroy(screen->base.transfer_helper);
-    iris_bufmgr_unref(screen->bufmgr);
-    disk_cache_destroy(screen->disk_cache);
-+   close(screen->winsys_fd);
-    ralloc_free(screen);
- }
- 
-@@ -717,6 +718,7 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
-       return NULL;
- 
-    screen->fd = iris_bufmgr_get_fd(screen->bufmgr);
-+   screen->winsys_fd = fd;
- 
-    screen->aperture_bytes = get_aperture_size(fd);
- 
-diff --git a/src/gallium/drivers/iris/iris_screen.h b/src/gallium/drivers/iris/iris_screen.h
-index 5ec58f6c216..afae2037b9f 100644
---- a/src/gallium/drivers/iris/iris_screen.h
-+++ b/src/gallium/drivers/iris/iris_screen.h
-@@ -144,9 +144,15 @@ struct iris_screen {
-    /** Global slab allocator for iris_transfer_map objects */
-    struct slab_parent_pool transfer_pool;
- 
--   /** drm device file descriptor, on shared with bufmgr, do not close. */
-+   /** drm device file descriptor, shared with bufmgr, do not close. */
-    int fd;
- 
-+   /**
-+    * drm device file descriptor to used for window system integration, owned
-+    * by iris_screen, can be a different DRM instance than fd.
-+    */
-+   int winsys_fd;
-+
-    /** PCI ID for our GPU device */
-    int pci_id;
- 
--- 
-2.26.2
-

Copied: mesa/repos/testing-x86_64/0002-iris-fix-export-of-GEM-handles.patch (from rev 387799, mesa/trunk/0002-iris-fix-export-of-GEM-handles.patch)
===================================================================
--- 0002-iris-fix-export-of-GEM-handles.patch	                        (rev 0)
+++ 0002-iris-fix-export-of-GEM-handles.patch	2020-05-29 08:02:57 UTC (rev 387800)
@@ -0,0 +1,364 @@
+From e01e146e35681dbdc68d70a2118b71a78ef67e6a Mon Sep 17 00:00:00 2001
+From: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
+Date: Sat, 2 May 2020 16:46:47 +0300
+Subject: [PATCH 2/3] iris: fix export of GEM handles
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+We reuse DRM file descriptors internally. Therefore when we export a
+GEM handle we must do so in the file descriptor used externally.
+
+v2: Don't bother checking fd equals, they're always different
+    Fix dmabuf leak
+    Fix GEM handle leaks by tracking exported handles
+
+v3: Check os_same_file_description error (Michel)
+    Don't create multiple exports for a given GEM table
+
+v4: Add WARN_ONCE (Ken)
+    Rename external_fd to winsys_fd
+
+v5: Remove export lock in favor of bufmgr's
+
+Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
+Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2882
+Fixes: 7557f1605968 ("iris: share buffer managers accross screens")
+Tested-by: Eric Engestrom <eric at engestrom.ch>
+Tested-by: Tapani Pälli <tapani.palli at intel.com>
+Signed-off-by: Laurent Carlier <lordheavym at gmail.com>
+---
+ src/gallium/drivers/iris/iris_bufmgr.c   | 108 ++++++++++++++++++++++-
+ src/gallium/drivers/iris/iris_bufmgr.h   |  16 ++++
+ src/gallium/drivers/iris/iris_resource.c |  33 +++++--
+ src/gallium/drivers/iris/iris_screen.c   |   2 +
+ src/gallium/drivers/iris/iris_screen.h   |   8 +-
+ 5 files changed, 157 insertions(+), 10 deletions(-)
+
+diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
+index 9064647d0e5..3c39769b9cb 100644
+--- a/src/gallium/drivers/iris/iris_bufmgr.c
++++ b/src/gallium/drivers/iris/iris_bufmgr.c
+@@ -63,6 +63,7 @@
+ #include "util/macros.h"
+ #include "util/hash_table.h"
+ #include "util/list.h"
++#include "util/os_file.h"
+ #include "util/u_dynarray.h"
+ #include "util/vma.h"
+ #include "iris_bufmgr.h"
+@@ -91,6 +92,17 @@
+ 
+ #define PAGE_SIZE 4096
+ 
++#define WARN_ONCE(cond, fmt...) do {                            \
++   if (unlikely(cond)) {                                        \
++      static bool _warned = false;                              \
++      if (!_warned) {                                           \
++         fprintf(stderr, "WARNING: ");                          \
++         fprintf(stderr, fmt);                                  \
++         _warned = true;                                        \
++      }                                                         \
++   }                                                            \
++} while (0)
++
+ #define FILE_DEBUG_FLAG DEBUG_BUFMGR
+ 
+ static inline int
+@@ -126,6 +138,16 @@ struct bo_cache_bucket {
+    uint64_t size;
+ };
+ 
++struct bo_export {
++   /** File descriptor associated with a handle export. */
++   int drm_fd;
++
++   /** GEM handle in drm_fd */
++   uint32_t gem_handle;
++
++   struct list_head link;
++};
++
+ struct iris_bufmgr {
+    /**
+     * List into the list of bufmgr.
+@@ -349,9 +371,13 @@ static struct iris_bo *
+ bo_calloc(void)
+ {
+    struct iris_bo *bo = calloc(1, sizeof(*bo));
+-   if (bo) {
+-      bo->hash = _mesa_hash_pointer(bo);
+-   }
++   if (!bo)
++      return NULL;
++
++   list_inithead(&bo->exports);
++
++   bo->hash = _mesa_hash_pointer(bo);
++
+    return bo;
+ }
+ 
+@@ -707,6 +733,7 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr,
+ 
+    bo->tiling_mode = get_tiling.tiling_mode;
+    bo->swizzle_mode = get_tiling.swizzle_mode;
++
+    /* XXX stride is unknown */
+    DBG("bo_create_from_handle: %d (%s)\n", handle, bo->name);
+ 
+@@ -735,6 +762,16 @@ bo_close(struct iris_bo *bo)
+ 
+       entry = _mesa_hash_table_search(bufmgr->handle_table, &bo->gem_handle);
+       _mesa_hash_table_remove(bufmgr->handle_table, entry);
++
++      list_for_each_entry_safe(struct bo_export, export, &bo->exports, link) {
++         struct drm_gem_close close = { .handle = export->gem_handle };
++         gen_ioctl(export->drm_fd, DRM_IOCTL_GEM_CLOSE, &close);
++
++         list_del(&export->link);
++         free(export);
++      }
++   } else {
++      assert(list_is_empty(&bo->exports));
+    }
+ 
+    /* Close this object */
+@@ -1490,6 +1527,71 @@ iris_bo_flink(struct iris_bo *bo, uint32_t *name)
+    return 0;
+ }
+ 
++int
++iris_bo_export_gem_handle_for_device(struct iris_bo *bo, int drm_fd,
++                                     uint32_t *out_handle)
++{
++   /* Only add the new GEM handle to the list of export if it belongs to a
++    * different GEM device. Otherwise we might close the same buffer multiple
++    * times.
++    */
++   struct iris_bufmgr *bufmgr = bo->bufmgr;
++   int ret = os_same_file_description(drm_fd, bufmgr->fd);
++   WARN_ONCE(ret < 0,
++             "Kernel has no file descriptor comparison support: %s\n",
++             strerror(errno));
++   if (ret == 0) {
++      *out_handle = iris_bo_export_gem_handle(bo);
++      return 0;
++   }
++
++   struct bo_export *export = calloc(1, sizeof(*export));
++   if (!export)
++      return -ENOMEM;
++
++   export->drm_fd = drm_fd;
++
++   int dmabuf_fd = -1;
++   int err = iris_bo_export_dmabuf(bo, &dmabuf_fd);
++   if (err) {
++      free(export);
++      return err;
++   }
++
++   mtx_lock(&bufmgr->lock);
++   err = drmPrimeFDToHandle(drm_fd, dmabuf_fd, &export->gem_handle);
++   close(dmabuf_fd);
++   if (err) {
++      mtx_unlock(&bufmgr->lock);
++      free(export);
++      return err;
++   }
++
++   iris_bo_make_external_locked(bo);
++
++   bool found = false;
++   list_for_each_entry(struct bo_export, iter, &bo->exports, link) {
++      if (iter->drm_fd != drm_fd)
++         continue;
++      /* Here we assume that for a given DRM fd, we'll always get back the
++       * same GEM handle for a given buffer.
++       */
++      assert(iter->gem_handle == export->gem_handle);
++      free(export);
++      export = iter;
++      found = true;
++      break;
++   }
++   if (!found)
++      list_addtail(&export->link, &bo->exports);
++
++   mtx_unlock(&bufmgr->lock);
++
++   *out_handle = export->gem_handle;
++
++   return 0;
++}
++
+ static void
+ add_bucket(struct iris_bufmgr *bufmgr, int size)
+ {
+diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h
+index d7edda23aca..084de82c375 100644
+--- a/src/gallium/drivers/iris/iris_bufmgr.h
++++ b/src/gallium/drivers/iris/iris_bufmgr.h
+@@ -28,6 +28,7 @@
+ #include <stdint.h>
+ #include <stdio.h>
+ #include <sys/types.h>
++#include "c11/threads.h"
+ #include "util/macros.h"
+ #include "util/u_atomic.h"
+ #include "util/list.h"
+@@ -166,6 +167,9 @@ struct iris_bo {
+    /** BO cache list */
+    struct list_head head;
+ 
++   /** List of GEM handle exports of this buffer (bo_export) */
++   struct list_head exports;
++
+    /**
+     * Boolean of whether the GPU is definitely not accessing the buffer.
+     *
+@@ -365,6 +369,18 @@ int iris_bo_export_dmabuf(struct iris_bo *bo, int *prime_fd);
+ struct iris_bo *iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd,
+                                       uint32_t tiling, uint32_t stride);
+ 
++/**
++ * Exports a bo as a GEM handle into a given DRM file descriptor
++ * \param bo Buffer to export
++ * \param drm_fd File descriptor where the new handle is created
++ * \param out_handle Pointer to store the new handle
++ *
++ * Returns 0 if the buffer was successfully exported, a non zero error code
++ * otherwise.
++ */
++int iris_bo_export_gem_handle_for_device(struct iris_bo *bo, int drm_fd,
++                                         uint32_t *out_handle);
++
+ uint32_t iris_bo_export_gem_handle(struct iris_bo *bo);
+ 
+ int iris_reg_read(struct iris_bufmgr *bufmgr, uint32_t offset, uint64_t *out);
+diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
+index 3d2805f3548..0f71c5a8593 100644
+--- a/src/gallium/drivers/iris/iris_resource.c
++++ b/src/gallium/drivers/iris/iris_resource.c
+@@ -1139,7 +1139,7 @@ iris_resource_disable_aux_on_first_query(struct pipe_resource *resource,
+ }
+ 
+ static bool
+-iris_resource_get_param(struct pipe_screen *screen,
++iris_resource_get_param(struct pipe_screen *pscreen,
+                         struct pipe_context *context,
+                         struct pipe_resource *resource,
+                         unsigned plane,
+@@ -1148,6 +1148,7 @@ iris_resource_get_param(struct pipe_screen *screen,
+                         unsigned handle_usage,
+                         uint64_t *value)
+ {
++   struct iris_screen *screen = (struct iris_screen *)pscreen;
+    struct iris_resource *res = (struct iris_resource *)resource;
+    bool mod_with_aux =
+       res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE;
+@@ -1156,7 +1157,7 @@ iris_resource_get_param(struct pipe_screen *screen,
+    unsigned handle;
+ 
+    if (iris_resource_unfinished_aux_import(res))
+-      iris_resource_finish_aux_import(screen, res);
++      iris_resource_finish_aux_import(pscreen, res);
+ 
+    struct iris_bo *bo = wants_aux ? res->aux.bo : res->bo;
+ 
+@@ -1188,9 +1189,19 @@ iris_resource_get_param(struct pipe_screen *screen,
+       if (result)
+          *value = handle;
+       return result;
+-   case PIPE_RESOURCE_PARAM_HANDLE_TYPE_KMS:
+-      *value = iris_bo_export_gem_handle(bo);
++   case PIPE_RESOURCE_PARAM_HANDLE_TYPE_KMS: {
++      /* Because we share the same drm file across multiple iris_screen, when
++       * we export a GEM handle we must make sure it is valid in the DRM file
++       * descriptor the caller is using (this is the FD given at screen
++       * creation).
++       */
++      uint32_t handle;
++      if (iris_bo_export_gem_handle_for_device(bo, screen->winsys_fd, &handle))
++         return false;
++      *value = handle;
+       return true;
++   }
++
+    case PIPE_RESOURCE_PARAM_HANDLE_TYPE_FD:
+       result = iris_bo_export_dmabuf(bo, (int *) &handle) == 0;
+       if (result)
+@@ -1208,6 +1219,7 @@ iris_resource_get_handle(struct pipe_screen *pscreen,
+                          struct winsys_handle *whandle,
+                          unsigned usage)
+ {
++   struct iris_screen *screen = (struct iris_screen *) pscreen;
+    struct iris_resource *res = (struct iris_resource *)resource;
+    bool mod_with_aux =
+       res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE;
+@@ -1245,9 +1257,18 @@ iris_resource_get_handle(struct pipe_screen *pscreen,
+    switch (whandle->type) {
+    case WINSYS_HANDLE_TYPE_SHARED:
+       return iris_bo_flink(bo, &whandle->handle) == 0;
+-   case WINSYS_HANDLE_TYPE_KMS:
+-      whandle->handle = iris_bo_export_gem_handle(bo);
++   case WINSYS_HANDLE_TYPE_KMS: {
++      /* Because we share the same drm file across multiple iris_screen, when
++       * we export a GEM handle we must make sure it is valid in the DRM file
++       * descriptor the caller is using (this is the FD given at screen
++       * creation).
++       */
++      uint32_t handle;
++      if (iris_bo_export_gem_handle_for_device(bo, screen->winsys_fd, &handle))
++         return false;
++      whandle->handle = handle;
+       return true;
++   }
+    case WINSYS_HANDLE_TYPE_FD:
+       return iris_bo_export_dmabuf(bo, (int *) &whandle->handle) == 0;
+    }
+diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c
+index 94ee60eb016..3e2761aecc3 100644
+--- a/src/gallium/drivers/iris/iris_screen.c
++++ b/src/gallium/drivers/iris/iris_screen.c
+@@ -559,6 +559,7 @@ iris_screen_destroy(struct iris_screen *screen)
+    u_transfer_helper_destroy(screen->base.transfer_helper);
+    iris_bufmgr_unref(screen->bufmgr);
+    disk_cache_destroy(screen->disk_cache);
++   close(screen->winsys_fd);
+    ralloc_free(screen);
+ }
+ 
+@@ -717,6 +718,7 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
+       return NULL;
+ 
+    screen->fd = iris_bufmgr_get_fd(screen->bufmgr);
++   screen->winsys_fd = fd;
+ 
+    screen->aperture_bytes = get_aperture_size(fd);
+ 
+diff --git a/src/gallium/drivers/iris/iris_screen.h b/src/gallium/drivers/iris/iris_screen.h
+index 5ec58f6c216..afae2037b9f 100644
+--- a/src/gallium/drivers/iris/iris_screen.h
++++ b/src/gallium/drivers/iris/iris_screen.h
+@@ -144,9 +144,15 @@ struct iris_screen {
+    /** Global slab allocator for iris_transfer_map objects */
+    struct slab_parent_pool transfer_pool;
+ 
+-   /** drm device file descriptor, on shared with bufmgr, do not close. */
++   /** drm device file descriptor, shared with bufmgr, do not close. */
+    int fd;
+ 
++   /**
++    * drm device file descriptor to used for window system integration, owned
++    * by iris_screen, can be a different DRM instance than fd.
++    */
++   int winsys_fd;
++
+    /** PCI ID for our GPU device */
+    int pci_id;
+ 
+-- 
+2.26.2
+

Deleted: 0003-i965-fix-export-of-GEM-handles.patch
===================================================================
--- 0003-i965-fix-export-of-GEM-handles.patch	2020-05-29 08:02:49 UTC (rev 387799)
+++ 0003-i965-fix-export-of-GEM-handles.patch	2020-05-29 08:02:57 UTC (rev 387800)
@@ -1,343 +0,0 @@
-From e45e6fb29a008006af354f317bd82da2aed8ccf6 Mon Sep 17 00:00:00 2001
-From: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
-Date: Sat, 2 May 2020 16:59:19 +0300
-Subject: [PATCH 3/3] i965: fix export of GEM handles
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-We reuse DRM file descriptors internally. Therefore when we export a
-GEM handle we must do so in the file descriptor used externally.
-
-v2: Fix dmabuf leak
-    Fix GEM handle leaks by tracking exported handles
-
-v3: Check os_same_file_description error (Michel)
-    Don't create multiple exports for a given GEM table
-
-v4: Add WARN_ONCE
-
-Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
-Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2882
-Fixes: 4094558e8643 ("i965: share buffer managers across screens")
-Tested-by: Eric Engestrom <eric at engestrom.ch>
-Tested-by: Tapani Pälli <tapani.palli at intel.com>
-Signed-off-by: Laurent Carlier <lordheavym at gmail.com>
----
- src/mesa/drivers/dri/i965/brw_bufmgr.c        | 122 +++++++++++++++++-
- src/mesa/drivers/dri/i965/brw_bufmgr.h        |  20 +++
- src/mesa/drivers/dri/i965/intel_batchbuffer.c |   6 +
- src/mesa/drivers/dri/i965/intel_screen.c      |  11 +-
- 4 files changed, 154 insertions(+), 5 deletions(-)
-
-diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
-index 9b706c42e38..ce904727674 100644
---- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
-+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
-@@ -58,6 +58,7 @@
- #include "util/macros.h"
- #include "util/hash_table.h"
- #include "util/list.h"
-+#include "util/os_file.h"
- #include "util/u_dynarray.h"
- #include "util/vma.h"
- #include "brw_bufmgr.h"
-@@ -74,6 +75,20 @@
- #define VG(x)
- #endif
- 
-+/* Bufmgr is not aware of brw_context. */
-+#undef WARN_ONCE
-+#define WARN_ONCE(cond, fmt...) do {                            \
-+   if (unlikely(cond)) {                                        \
-+      static bool _warned = false;                              \
-+      if (!_warned) {                                           \
-+         fprintf(stderr, "WARNING: ");                          \
-+         fprintf(stderr, fmt);                                  \
-+         _warned = true;                                        \
-+      }                                                         \
-+   }                                                            \
-+} while (0)
-+
-+
- /* VALGRIND_FREELIKE_BLOCK unfortunately does not actually undo the earlier
-  * VALGRIND_MALLOCLIKE_BLOCK but instead leaves vg convinced the memory is
-  * leaked. All because it does not call VG(cli_free) from its
-@@ -135,6 +150,16 @@ struct bo_cache_bucket {
-    struct util_dynarray vma_list[BRW_MEMZONE_COUNT];
- };
- 
-+struct bo_export {
-+   /** File descriptor associated with a handle export. */
-+   int drm_fd;
-+
-+   /** GEM handle in drm_fd */
-+   uint32_t gem_handle;
-+
-+   struct list_head link;
-+};
-+
- struct brw_bufmgr {
-    uint32_t refcount;
- 
-@@ -158,6 +183,7 @@ struct brw_bufmgr {
-    bool has_mmap_wc:1;
-    bool has_mmap_offset:1;
-    bool bo_reuse:1;
-+   bool file_cmp_failed:1;
- 
-    uint64_t initial_kflags;
- };
-@@ -484,6 +510,18 @@ brw_bo_cache_purge_bucket(struct brw_bufmgr *bufmgr,
-    }
- }
- 
-+static struct brw_bo *
-+bo_calloc(void)
-+{
-+   struct brw_bo *bo = calloc(1, sizeof(*bo));
-+   if (!bo)
-+      return NULL;
-+
-+   list_inithead(&bo->exports);
-+
-+   return bo;
-+}
-+
- static struct brw_bo *
- bo_alloc_internal(struct brw_bufmgr *bufmgr,
-                   const char *name,
-@@ -557,6 +595,7 @@ retry:
-       }
- 
-       if (alloc_from_cache) {
-+         assert(list_is_empty(&bo->exports));
-          if (!brw_bo_madvise(bo, I915_MADV_WILLNEED)) {
-             bo_free(bo);
-             brw_bo_cache_purge_bucket(bufmgr, bucket);
-@@ -589,7 +628,7 @@ retry:
-          bo->gtt_offset = 0ull;
-       }
-    } else {
--      bo = calloc(1, sizeof(*bo));
-+      bo = bo_calloc();
-       if (!bo)
-          goto err;
- 
-@@ -760,11 +799,12 @@ brw_bo_gem_create_from_name(struct brw_bufmgr *bufmgr,
-     */
-    bo = hash_find_bo(bufmgr->handle_table, open_arg.handle);
-    if (bo) {
-+      assert(list_is_empty(&bo->exports));
-       brw_bo_reference(bo);
-       goto out;
-    }
- 
--   bo = calloc(1, sizeof(*bo));
-+   bo = bo_calloc();
-    if (!bo)
-       goto out;
- 
-@@ -834,6 +874,9 @@ bo_free(struct brw_bo *bo)
- 
-       entry = _mesa_hash_table_search(bufmgr->handle_table, &bo->gem_handle);
-       _mesa_hash_table_remove(bufmgr->handle_table, entry);
-+
-+   } else {
-+      assert(list_is_empty(&bo->exports));
-    }
- 
-    /* Close this object */
-@@ -883,6 +926,14 @@ bo_unreference_final(struct brw_bo *bo, time_t time)
- 
-    DBG("bo_unreference final: %d (%s)\n", bo->gem_handle, bo->name);
- 
-+   list_for_each_entry_safe(struct bo_export, export, &bo->exports, link) {
-+      struct drm_gem_close close = { .handle = export->gem_handle };
-+      gen_ioctl(export->drm_fd, DRM_IOCTL_GEM_CLOSE, &close);
-+
-+      list_del(&export->link);
-+      free(export);
-+   }
-+
-    bucket = bucket_for_size(bufmgr, bo->size);
-    /* Put the buffer into our internal cache for reuse if we can. */
-    if (bufmgr->bo_reuse && bo->reusable && bucket != NULL &&
-@@ -1440,11 +1491,12 @@ brw_bo_gem_create_from_prime_internal(struct brw_bufmgr *bufmgr, int prime_fd,
-     */
-    bo = hash_find_bo(bufmgr->handle_table, handle);
-    if (bo) {
-+      assert(list_is_empty(&bo->exports));
-       brw_bo_reference(bo);
-       goto out;
-    }
- 
--   bo = calloc(1, sizeof(*bo));
-+   bo = bo_calloc();
-    if (!bo)
-       goto out;
- 
-@@ -1579,6 +1631,70 @@ brw_bo_flink(struct brw_bo *bo, uint32_t *name)
-    return 0;
- }
- 
-+int
-+brw_bo_export_gem_handle_for_device(struct brw_bo *bo, int drm_fd,
-+                                    uint32_t *out_handle)
-+{
-+   struct brw_bufmgr *bufmgr = bo->bufmgr;
-+
-+   /* Only add the new GEM handle to the list of export if it belongs to a
-+    * different GEM device. Otherwise we might close the same buffer multiple
-+    * times.
-+    */
-+   int ret = os_same_file_description(drm_fd, bufmgr->fd);
-+   WARN_ONCE(ret < 0,
-+             "Kernel has no file descriptor comparison support: %s\n",
-+             strerror(errno));
-+   if (ret == 0) {
-+      *out_handle = brw_bo_export_gem_handle(bo);
-+      return 0;
-+   }
-+
-+   struct bo_export *export = calloc(1, sizeof(*export));
-+   if (!export)
-+      return -ENOMEM;
-+
-+   export->drm_fd = drm_fd;
-+
-+   int dmabuf_fd = -1;
-+   int err = brw_bo_gem_export_to_prime(bo, &dmabuf_fd);
-+   if (err) {
-+      free(export);
-+      return err;
-+   }
-+
-+   mtx_lock(&bufmgr->lock);
-+   err = drmPrimeFDToHandle(drm_fd, dmabuf_fd, &export->gem_handle);
-+   close(dmabuf_fd);
-+   if (err) {
-+      mtx_unlock(&bufmgr->lock);
-+      free(export);
-+      return err;
-+   }
-+
-+   bool found = false;
-+   list_for_each_entry(struct bo_export, iter, &bo->exports, link) {
-+      if (iter->drm_fd != drm_fd)
-+         continue;
-+      /* Here we assume that for a given DRM fd, we'll always get back the
-+       * same GEM handle for a given buffer.
-+       */
-+      assert(iter->gem_handle == export->gem_handle);
-+      free(export);
-+      export = iter;
-+      found = true;
-+      break;
-+   }
-+   if (!found)
-+      list_addtail(&export->link, &bo->exports);
-+
-+   mtx_unlock(&bufmgr->lock);
-+
-+   *out_handle = export->gem_handle;
-+
-+   return 0;
-+}
-+
- static void
- add_bucket(struct brw_bufmgr *bufmgr, int size)
- {
-diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h b/src/mesa/drivers/dri/i965/brw_bufmgr.h
-index 499309b5bd3..32346ff8a30 100644
---- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
-+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
-@@ -39,6 +39,7 @@
- #include <stdio.h>
- #include <time.h>
- 
-+#include "c11/threads.h"
- #include "util/u_atomic.h"
- #include "util/list.h"
- 
-@@ -179,6 +180,13 @@ struct brw_bo {
-    /** BO cache list */
-    struct list_head head;
- 
-+   /**
-+    * List of GEM handle exports of this buffer (bo_export).
-+    *
-+    * Hold bufmgr->lock when using this list.
-+    */
-+   struct list_head exports;
-+
-    /**
-     * Boolean of whether this buffer can be re-used
-     */
-@@ -372,6 +380,18 @@ struct brw_bo *brw_bo_gem_create_from_prime_tiled(struct brw_bufmgr *bufmgr,
- 
- uint32_t brw_bo_export_gem_handle(struct brw_bo *bo);
- 
-+/**
-+ * Exports a bo as a GEM handle into a given DRM file descriptor
-+ * \param bo Buffer to export
-+ * \param drm_fd File descriptor where the new handle is created
-+ * \param out_handle Pointer to store the new handle
-+ *
-+ * Returns 0 if the buffer was successfully exported, a non zero error code
-+ * otherwise.
-+ */
-+int brw_bo_export_gem_handle_for_device(struct brw_bo *bo, int drm_fd,
-+                                        uint32_t *out_handle);
-+
- int brw_reg_read(struct brw_bufmgr *bufmgr, uint32_t offset,
-                  uint64_t *result);
- 
-diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
-index bfb39c1ea86..eab6bb2bf72 100644
---- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
-+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
-@@ -507,11 +507,17 @@ grow_buffer(struct brw_context *brw,
-    new_bo->refcount = bo->refcount;
-    bo->refcount = 1;
- 
-+   assert(list_is_empty(&bo->exports));
-+   assert(list_is_empty(&new_bo->exports));
-+
-    struct brw_bo tmp;
-    memcpy(&tmp, bo, sizeof(struct brw_bo));
-    memcpy(bo, new_bo, sizeof(struct brw_bo));
-    memcpy(new_bo, &tmp, sizeof(struct brw_bo));
- 
-+   list_inithead(&bo->exports);
-+   list_inithead(&new_bo->exports);
-+
-    grow->partial_bo = new_bo; /* the one reference of the OLD bo */
-    grow->partial_bytes = existing_bytes;
- }
-diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
-index f2fbe70cada..cfc70ff7303 100644
---- a/src/mesa/drivers/dri/i965/intel_screen.c
-+++ b/src/mesa/drivers/dri/i965/intel_screen.c
-@@ -901,9 +901,16 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
-    case __DRI_IMAGE_ATTRIB_STRIDE:
-       *value = image->pitch;
-       return true;
--   case __DRI_IMAGE_ATTRIB_HANDLE:
--      *value = brw_bo_export_gem_handle(image->bo);
-+   case __DRI_IMAGE_ATTRIB_HANDLE: {
-+      __DRIscreen *dri_screen = image->screen->driScrnPriv;
-+      uint32_t handle;
-+      if (brw_bo_export_gem_handle_for_device(image->bo,
-+                                              dri_screen->fd,
-+                                              &handle))
-+         return false;
-+      *value = handle;
-       return true;
-+   }
-    case __DRI_IMAGE_ATTRIB_NAME:
-       return !brw_bo_flink(image->bo, (uint32_t *) value);
-    case __DRI_IMAGE_ATTRIB_FORMAT:
--- 
-2.26.2
-

Copied: mesa/repos/testing-x86_64/0003-i965-fix-export-of-GEM-handles.patch (from rev 387799, mesa/trunk/0003-i965-fix-export-of-GEM-handles.patch)
===================================================================
--- 0003-i965-fix-export-of-GEM-handles.patch	                        (rev 0)
+++ 0003-i965-fix-export-of-GEM-handles.patch	2020-05-29 08:02:57 UTC (rev 387800)
@@ -0,0 +1,343 @@
+From e45e6fb29a008006af354f317bd82da2aed8ccf6 Mon Sep 17 00:00:00 2001
+From: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
+Date: Sat, 2 May 2020 16:59:19 +0300
+Subject: [PATCH 3/3] i965: fix export of GEM handles
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+We reuse DRM file descriptors internally. Therefore when we export a
+GEM handle we must do so in the file descriptor used externally.
+
+v2: Fix dmabuf leak
+    Fix GEM handle leaks by tracking exported handles
+
+v3: Check os_same_file_description error (Michel)
+    Don't create multiple exports for a given GEM table
+
+v4: Add WARN_ONCE
+
+Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
+Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2882
+Fixes: 4094558e8643 ("i965: share buffer managers across screens")
+Tested-by: Eric Engestrom <eric at engestrom.ch>
+Tested-by: Tapani Pälli <tapani.palli at intel.com>
+Signed-off-by: Laurent Carlier <lordheavym at gmail.com>
+---
+ src/mesa/drivers/dri/i965/brw_bufmgr.c        | 122 +++++++++++++++++-
+ src/mesa/drivers/dri/i965/brw_bufmgr.h        |  20 +++
+ src/mesa/drivers/dri/i965/intel_batchbuffer.c |   6 +
+ src/mesa/drivers/dri/i965/intel_screen.c      |  11 +-
+ 4 files changed, 154 insertions(+), 5 deletions(-)
+
+diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
+index 9b706c42e38..ce904727674 100644
+--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
++++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
+@@ -58,6 +58,7 @@
+ #include "util/macros.h"
+ #include "util/hash_table.h"
+ #include "util/list.h"
++#include "util/os_file.h"
+ #include "util/u_dynarray.h"
+ #include "util/vma.h"
+ #include "brw_bufmgr.h"
+@@ -74,6 +75,20 @@
+ #define VG(x)
+ #endif
+ 
++/* Bufmgr is not aware of brw_context. */
++#undef WARN_ONCE
++#define WARN_ONCE(cond, fmt...) do {                            \
++   if (unlikely(cond)) {                                        \
++      static bool _warned = false;                              \
++      if (!_warned) {                                           \
++         fprintf(stderr, "WARNING: ");                          \
++         fprintf(stderr, fmt);                                  \
++         _warned = true;                                        \
++      }                                                         \
++   }                                                            \
++} while (0)
++
++
+ /* VALGRIND_FREELIKE_BLOCK unfortunately does not actually undo the earlier
+  * VALGRIND_MALLOCLIKE_BLOCK but instead leaves vg convinced the memory is
+  * leaked. All because it does not call VG(cli_free) from its
+@@ -135,6 +150,16 @@ struct bo_cache_bucket {
+    struct util_dynarray vma_list[BRW_MEMZONE_COUNT];
+ };
+ 
++struct bo_export {
++   /** File descriptor associated with a handle export. */
++   int drm_fd;
++
++   /** GEM handle in drm_fd */
++   uint32_t gem_handle;
++
++   struct list_head link;
++};
++
+ struct brw_bufmgr {
+    uint32_t refcount;
+ 
+@@ -158,6 +183,7 @@ struct brw_bufmgr {
+    bool has_mmap_wc:1;
+    bool has_mmap_offset:1;
+    bool bo_reuse:1;
++   bool file_cmp_failed:1;
+ 
+    uint64_t initial_kflags;
+ };
+@@ -484,6 +510,18 @@ brw_bo_cache_purge_bucket(struct brw_bufmgr *bufmgr,
+    }
+ }
+ 
++static struct brw_bo *
++bo_calloc(void)
++{
++   struct brw_bo *bo = calloc(1, sizeof(*bo));
++   if (!bo)
++      return NULL;
++
++   list_inithead(&bo->exports);
++
++   return bo;
++}
++
+ static struct brw_bo *
+ bo_alloc_internal(struct brw_bufmgr *bufmgr,
+                   const char *name,
+@@ -557,6 +595,7 @@ retry:
+       }
+ 
+       if (alloc_from_cache) {
++         assert(list_is_empty(&bo->exports));
+          if (!brw_bo_madvise(bo, I915_MADV_WILLNEED)) {
+             bo_free(bo);
+             brw_bo_cache_purge_bucket(bufmgr, bucket);
+@@ -589,7 +628,7 @@ retry:
+          bo->gtt_offset = 0ull;
+       }
+    } else {
+-      bo = calloc(1, sizeof(*bo));
++      bo = bo_calloc();
+       if (!bo)
+          goto err;
+ 
+@@ -760,11 +799,12 @@ brw_bo_gem_create_from_name(struct brw_bufmgr *bufmgr,
+     */
+    bo = hash_find_bo(bufmgr->handle_table, open_arg.handle);
+    if (bo) {
++      assert(list_is_empty(&bo->exports));
+       brw_bo_reference(bo);
+       goto out;
+    }
+ 
+-   bo = calloc(1, sizeof(*bo));
++   bo = bo_calloc();
+    if (!bo)
+       goto out;
+ 
+@@ -834,6 +874,9 @@ bo_free(struct brw_bo *bo)
+ 
+       entry = _mesa_hash_table_search(bufmgr->handle_table, &bo->gem_handle);
+       _mesa_hash_table_remove(bufmgr->handle_table, entry);
++
++   } else {
++      assert(list_is_empty(&bo->exports));
+    }
+ 
+    /* Close this object */
+@@ -883,6 +926,14 @@ bo_unreference_final(struct brw_bo *bo, time_t time)
+ 
+    DBG("bo_unreference final: %d (%s)\n", bo->gem_handle, bo->name);
+ 
++   list_for_each_entry_safe(struct bo_export, export, &bo->exports, link) {
++      struct drm_gem_close close = { .handle = export->gem_handle };
++      gen_ioctl(export->drm_fd, DRM_IOCTL_GEM_CLOSE, &close);
++
++      list_del(&export->link);
++      free(export);
++   }
++
+    bucket = bucket_for_size(bufmgr, bo->size);
+    /* Put the buffer into our internal cache for reuse if we can. */
+    if (bufmgr->bo_reuse && bo->reusable && bucket != NULL &&
+@@ -1440,11 +1491,12 @@ brw_bo_gem_create_from_prime_internal(struct brw_bufmgr *bufmgr, int prime_fd,
+     */
+    bo = hash_find_bo(bufmgr->handle_table, handle);
+    if (bo) {
++      assert(list_is_empty(&bo->exports));
+       brw_bo_reference(bo);
+       goto out;
+    }
+ 
+-   bo = calloc(1, sizeof(*bo));
++   bo = bo_calloc();
+    if (!bo)
+       goto out;
+ 
+@@ -1579,6 +1631,70 @@ brw_bo_flink(struct brw_bo *bo, uint32_t *name)
+    return 0;
+ }
+ 
++int
++brw_bo_export_gem_handle_for_device(struct brw_bo *bo, int drm_fd,
++                                    uint32_t *out_handle)
++{
++   struct brw_bufmgr *bufmgr = bo->bufmgr;
++
++   /* Only add the new GEM handle to the list of export if it belongs to a
++    * different GEM device. Otherwise we might close the same buffer multiple
++    * times.
++    */
++   int ret = os_same_file_description(drm_fd, bufmgr->fd);
++   WARN_ONCE(ret < 0,
++             "Kernel has no file descriptor comparison support: %s\n",
++             strerror(errno));
++   if (ret == 0) {
++      *out_handle = brw_bo_export_gem_handle(bo);
++      return 0;
++   }
++
++   struct bo_export *export = calloc(1, sizeof(*export));
++   if (!export)
++      return -ENOMEM;
++
++   export->drm_fd = drm_fd;
++
++   int dmabuf_fd = -1;
++   int err = brw_bo_gem_export_to_prime(bo, &dmabuf_fd);
++   if (err) {
++      free(export);
++      return err;
++   }
++
++   mtx_lock(&bufmgr->lock);
++   err = drmPrimeFDToHandle(drm_fd, dmabuf_fd, &export->gem_handle);
++   close(dmabuf_fd);
++   if (err) {
++      mtx_unlock(&bufmgr->lock);
++      free(export);
++      return err;
++   }
++
++   bool found = false;
++   list_for_each_entry(struct bo_export, iter, &bo->exports, link) {
++      if (iter->drm_fd != drm_fd)
++         continue;
++      /* Here we assume that for a given DRM fd, we'll always get back the
++       * same GEM handle for a given buffer.
++       */
++      assert(iter->gem_handle == export->gem_handle);
++      free(export);
++      export = iter;
++      found = true;
++      break;
++   }
++   if (!found)
++      list_addtail(&export->link, &bo->exports);
++
++   mtx_unlock(&bufmgr->lock);
++
++   *out_handle = export->gem_handle;
++
++   return 0;
++}
++
+ static void
+ add_bucket(struct brw_bufmgr *bufmgr, int size)
+ {
+diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h b/src/mesa/drivers/dri/i965/brw_bufmgr.h
+index 499309b5bd3..32346ff8a30 100644
+--- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
++++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
+@@ -39,6 +39,7 @@
+ #include <stdio.h>
+ #include <time.h>
+ 
++#include "c11/threads.h"
+ #include "util/u_atomic.h"
+ #include "util/list.h"
+ 
+@@ -179,6 +180,13 @@ struct brw_bo {
+    /** BO cache list */
+    struct list_head head;
+ 
++   /**
++    * List of GEM handle exports of this buffer (bo_export).
++    *
++    * Hold bufmgr->lock when using this list.
++    */
++   struct list_head exports;
++
+    /**
+     * Boolean of whether this buffer can be re-used
+     */
+@@ -372,6 +380,18 @@ struct brw_bo *brw_bo_gem_create_from_prime_tiled(struct brw_bufmgr *bufmgr,
+ 
+ uint32_t brw_bo_export_gem_handle(struct brw_bo *bo);
+ 
++/**
++ * Exports a bo as a GEM handle into a given DRM file descriptor
++ * \param bo Buffer to export
++ * \param drm_fd File descriptor where the new handle is created
++ * \param out_handle Pointer to store the new handle
++ *
++ * Returns 0 if the buffer was successfully exported, a non zero error code
++ * otherwise.
++ */
++int brw_bo_export_gem_handle_for_device(struct brw_bo *bo, int drm_fd,
++                                        uint32_t *out_handle);
++
+ int brw_reg_read(struct brw_bufmgr *bufmgr, uint32_t offset,
+                  uint64_t *result);
+ 
+diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+index bfb39c1ea86..eab6bb2bf72 100644
+--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
++++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+@@ -507,11 +507,17 @@ grow_buffer(struct brw_context *brw,
+    new_bo->refcount = bo->refcount;
+    bo->refcount = 1;
+ 
++   assert(list_is_empty(&bo->exports));
++   assert(list_is_empty(&new_bo->exports));
++
+    struct brw_bo tmp;
+    memcpy(&tmp, bo, sizeof(struct brw_bo));
+    memcpy(bo, new_bo, sizeof(struct brw_bo));
+    memcpy(new_bo, &tmp, sizeof(struct brw_bo));
+ 
++   list_inithead(&bo->exports);
++   list_inithead(&new_bo->exports);
++
+    grow->partial_bo = new_bo; /* the one reference of the OLD bo */
+    grow->partial_bytes = existing_bytes;
+ }
+diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
+index f2fbe70cada..cfc70ff7303 100644
+--- a/src/mesa/drivers/dri/i965/intel_screen.c
++++ b/src/mesa/drivers/dri/i965/intel_screen.c
+@@ -901,9 +901,16 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
+    case __DRI_IMAGE_ATTRIB_STRIDE:
+       *value = image->pitch;
+       return true;
+-   case __DRI_IMAGE_ATTRIB_HANDLE:
+-      *value = brw_bo_export_gem_handle(image->bo);
++   case __DRI_IMAGE_ATTRIB_HANDLE: {
++      __DRIscreen *dri_screen = image->screen->driScrnPriv;
++      uint32_t handle;
++      if (brw_bo_export_gem_handle_for_device(image->bo,
++                                              dri_screen->fd,
++                                              &handle))
++         return false;
++      *value = handle;
+       return true;
++   }
+    case __DRI_IMAGE_ATTRIB_NAME:
+       return !brw_bo_flink(image->bo, (uint32_t *) value);
+    case __DRI_IMAGE_ATTRIB_FORMAT:
+-- 
+2.26.2
+

Deleted: LICENSE
===================================================================
--- LICENSE	2020-05-29 08:02:49 UTC (rev 387799)
+++ LICENSE	2020-05-29 08:02:57 UTC (rev 387800)
@@ -1,83 +0,0 @@
-The Mesa 3D Graphics Library
-
-Disclaimer
-
-   Mesa is a 3-D graphics library with an API which is very similar to
-   that of [1]OpenGL.* To the extent that Mesa utilizes the OpenGL command
-   syntax or state machine, it is being used with authorization from
-   [2]Silicon Graphics, Inc.(SGI). However, the author does not possess an
-   OpenGL license from SGI, and makes no claim that Mesa is in any way a
-   compatible replacement for OpenGL or associated with SGI. Those who
-   want a licensed implementation of OpenGL should contact a licensed
-   vendor.
-
-   Please do not refer to the library as MesaGL (for legal reasons). It's
-   just Mesa or The Mesa 3-D graphics library.
-
-   * OpenGL is a trademark of [3]Silicon Graphics Incorporated.
-
-License / Copyright Information
-
-   The Mesa distribution consists of several components. Different
-   copyrights and licenses apply to different components. For example, the
-   GLX client code uses the SGI Free Software License B, and some of the
-   Mesa device drivers are copyrighted by their authors. See below for a
-   list of Mesa's main components and the license for each.
-
-   The core Mesa library is licensed according to the terms of the MIT
-   license. This allows integration with the XFree86, Xorg and DRI
-   projects.
-
-   The default Mesa license is as follows:
-
-Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-Attention, Contributors
-
-   When contributing to the Mesa project you must agree to the licensing
-   terms of the component to which you're contributing. The following
-   section lists the primary components of the Mesa distribution and their
-   respective licenses.
-
-Mesa Component Licenses
-
-Component         Location               License
-------------------------------------------------------------------
-Main Mesa code    src/mesa/              MIT
-
-Device drivers    src/mesa/drivers/*     MIT, generally
-
-Gallium code      src/gallium/           MIT
-
-Ext headers       include/GL/glext.h     Khronos
-                  include/GL/glxext.h
-
-GLX client code   src/glx/               SGI Free Software License B
-
-C11 thread        include/c11/threads*.h Boost (permissive) emulation
-
-   In general, consult the source files for license terms.
-
-References
-
-   1. https://www.opengl.org/
-   2. https://www.sgi.com/
-   3. https://www.sgi.com/

Copied: mesa/repos/testing-x86_64/LICENSE (from rev 387799, mesa/trunk/LICENSE)
===================================================================
--- LICENSE	                        (rev 0)
+++ LICENSE	2020-05-29 08:02:57 UTC (rev 387800)
@@ -0,0 +1,83 @@
+The Mesa 3D Graphics Library
+
+Disclaimer
+
+   Mesa is a 3-D graphics library with an API which is very similar to
+   that of [1]OpenGL.* To the extent that Mesa utilizes the OpenGL command
+   syntax or state machine, it is being used with authorization from
+   [2]Silicon Graphics, Inc.(SGI). However, the author does not possess an
+   OpenGL license from SGI, and makes no claim that Mesa is in any way a
+   compatible replacement for OpenGL or associated with SGI. Those who
+   want a licensed implementation of OpenGL should contact a licensed
+   vendor.
+
+   Please do not refer to the library as MesaGL (for legal reasons). It's
+   just Mesa or The Mesa 3-D graphics library.
+
+   * OpenGL is a trademark of [3]Silicon Graphics Incorporated.
+
+License / Copyright Information
+
+   The Mesa distribution consists of several components. Different
+   copyrights and licenses apply to different components. For example, the
+   GLX client code uses the SGI Free Software License B, and some of the
+   Mesa device drivers are copyrighted by their authors. See below for a
+   list of Mesa's main components and the license for each.
+
+   The core Mesa library is licensed according to the terms of the MIT
+   license. This allows integration with the XFree86, Xorg and DRI
+   projects.
+
+   The default Mesa license is as follows:
+
+Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+Attention, Contributors
+
+   When contributing to the Mesa project you must agree to the licensing
+   terms of the component to which you're contributing. The following
+   section lists the primary components of the Mesa distribution and their
+   respective licenses.
+
+Mesa Component Licenses
+
+Component         Location               License
+------------------------------------------------------------------
+Main Mesa code    src/mesa/              MIT
+
+Device drivers    src/mesa/drivers/*     MIT, generally
+
+Gallium code      src/gallium/           MIT
+
+Ext headers       include/GL/glext.h     Khronos
+                  include/GL/glxext.h
+
+GLX client code   src/glx/               SGI Free Software License B
+
+C11 thread        include/c11/threads*.h Boost (permissive) emulation
+
+   In general, consult the source files for license terms.
+
+References
+
+   1. https://www.opengl.org/
+   2. https://www.sgi.com/
+   3. https://www.sgi.com/

Deleted: PKGBUILD
===================================================================
--- PKGBUILD	2020-05-29 08:02:49 UTC (rev 387799)
+++ PKGBUILD	2020-05-29 08:02:57 UTC (rev 387800)
@@ -1,202 +0,0 @@
-# Maintainer: Jan de Groot <jgc at archlinux.org>
-# Maintainer: Andreas Radke <andyrtr at archlinux.org>
-
-pkgbase=mesa
-pkgname=('vulkan-mesa-layer' 'opencl-mesa' 'vulkan-intel' 'vulkan-radeon' 'libva-mesa-driver' 'mesa-vdpau' 'mesa')
-pkgdesc="An open-source implementation of the OpenGL specification"
-pkgver=20.1.0
-pkgrel=2
-arch=('x86_64')
-makedepends=('python-mako' 'libxml2' 'libx11' 'xorgproto' 'libdrm' 'libxshmfence' 'libxxf86vm'
-             'libxdamage' 'libvdpau' 'libva' 'wayland' 'wayland-protocols' 'zstd'
-             'elfutils' 'llvm' 'libomxil-bellagio' 'libclc' 'clang' 'libglvnd' 'libunwind' 'lm_sensors'
-             'libxrandr' 'valgrind' 'glslang' 'meson')
-url="https://www.mesa3d.org/"
-license=('custom')
-source=(https://mesa.freedesktop.org/archive/mesa-${pkgver}.tar.xz{,.sig}
-	0001-iris-fix-BO-destruction-in-error-path.patch
-	0002-iris-fix-export-of-GEM-handles.patch
-	0003-i965-fix-export-of-GEM-handles.patch 
-        LICENSE)
-sha512sums=('f49230d18febe1bfd7c6282ab95fc244530f5cef56df0f804d8bece8a70bafcb445b8b83df96ad1b4c5af022c4e39a71f19a8f7e47b1fb09ada2b1a1317ff3be'
-            'SKIP'
-            '456d1296ac8ce01d2f1e0c9d9cb8fc995d5f5e5de8f56a3487452a131a7ccfa4beaeb3fc693afbf4691e8de90e399d86bb121cd7514a981fe96b4333df980af3'
-            '7903c26dcb11932f26dcc6ffd2fd2ecd05840141dc2abfcaf404716320927cd40ba472c434a6e4ae9a08fafa7d54bdb26890efd2177634947f134de6d1fb7315'
-            '9fe91699d00a9eee4de5b1e60dd14e7cde83933d2fff13f09fd24687addc84a3f9a6c512e02587ceabe6a4c459dbd1f452953ab741ac4843526e1504c12cf5d7'
-            'f9f0d0ccf166fe6cb684478b6f1e1ab1f2850431c06aa041738563eb1808a004e52cdec823c103c9e180f03ffc083e95974d291353f0220fe52ae6d4897fecc7')
-validpgpkeys=('8703B6700E7EE06D7A39B8D6EDAE37B02CEB490D'  # Emil Velikov <emil.l.velikov at gmail.com>
-              '946D09B5E4C9845E63075FF1D961C596A7203456'  # Andres Gomez <tanty at igalia.com>
-              'E3E8F480C52ADD73B278EE78E1ECBE07D7D70895'  # Juan Antonio Suárez Romero (Igalia, S.L.) <jasuarez at igalia.com>
-              'A5CC9FEC93F2F837CB044912336909B6B25FADFA'  # Juan A. Suarez Romero <jasuarez at igalia.com>
-              '71C4B75620BC75708B4BDB254C95FAAB3EB073EC'  # Dylan Baker <dylan at pnwbakers.com>
-              'CC31EF29D32A6637889530F2481D0E9D964E5593') # Eric Engestrom <eric at engestrom.ch>
-
-prepare() {
-  cd mesa-$pkgver
-
-  # fix https://gitlab.freedesktop.org/mesa/mesa/-/issues/2882
-  patch -Np1 -i ../0001-iris-fix-BO-destruction-in-error-path.patch
-  patch -Np1 -i ../0002-iris-fix-export-of-GEM-handles.patch
-  patch -Np1 -i ../0003-i965-fix-export-of-GEM-handles.patch 
-}
-
-build() {
-  arch-meson mesa-$pkgver build \
-    -D b_lto=true \
-    -D b_ndebug=true \
-    -D platforms=x11,wayland,drm,surfaceless \
-    -D dri-drivers=i915,i965,r100,r200,nouveau \
-    -D gallium-drivers=r300,r600,radeonsi,nouveau,virgl,svga,swrast,swr,iris \
-    -D vulkan-drivers=amd,intel \
-    -D vulkan-overlay-layer=true \
-    -D swr-arches=avx,avx2 \
-    -D dri3=true \
-    -D egl=true \
-    -D gallium-extra-hud=true \
-    -D gallium-nine=true \
-    -D gallium-omx=bellagio \
-    -D gallium-opencl=icd \
-    -D gallium-va=true \
-    -D gallium-vdpau=true \
-    -D gallium-xa=true \
-    -D gallium-xvmc=false \
-    -D gbm=true \
-    -D gles1=false \
-    -D gles2=true \
-    -D glvnd=true \
-    -D glx=dri \
-    -D libunwind=true \
-    -D llvm=true \
-    -D lmsensors=true \
-    -D osmesa=gallium \
-    -D shared-glapi=true \
-    -D valgrind=true
-
-  # Print config
-  meson configure build
-
-  ninja -C build xmlpool-pot xmlpool-update-po xmlpool-gmo
-  ninja -C build
-
-  # fake installation to be seperated into packages
-  # outside of fakeroot but mesa doesn't need to chown/mod
-  DESTDIR="${srcdir}/fakeinstall" ninja -C build install
-}
-
-_install() {
-  local src f dir
-  for src; do
-    f="${src#fakeinstall/}"
-    dir="${pkgdir}/${f%/*}"
-    install -m755 -d "${dir}"
-    mv -v "${src}" "${dir}/"
-  done
-}
-
-package_vulkan-mesa-layer() {
-  pkgdesc="Vulkan overlay layer to display information about the application"
-
-  _install fakeinstall/usr/share/vulkan/explicit_layer.d
-  _install fakeinstall/usr/lib/libVkLayer_MESA_overlay.so
-  _install fakeinstall/usr/bin/mesa-overlay-control.py
-
-  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
-}
-
-package_opencl-mesa() {
-  pkgdesc="OpenCL support for AMD/ATI Radeon mesa drivers"
-  depends=('expat' 'libdrm' 'libelf' 'libclc' 'clang' 'zstd')
-  optdepends=('opencl-headers: headers necessary for OpenCL development')
-  provides=('opencl-driver')
-
-  _install fakeinstall/etc/OpenCL
-  _install fakeinstall/usr/lib/lib*OpenCL*
-  _install fakeinstall/usr/lib/gallium-pipe
-
-  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
-}
-
-package_vulkan-intel() {
-  pkgdesc="Intel's Vulkan mesa driver"
-  depends=('wayland' 'libx11' 'libxshmfence' 'libdrm' 'zstd')
-  optdepends=('vulkan-mesa-layer: a vulkan layer to display information using an overlay')
-  provides=('vulkan-driver')
-
-  _install fakeinstall/usr/share/vulkan/icd.d/intel_icd*.json
-  _install fakeinstall/usr/lib/libvulkan_intel.so
-  _install fakeinstall/usr/include/vulkan/vulkan_intel.h
-
-  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
-}
-
-package_vulkan-radeon() {
-  pkgdesc="Radeon's Vulkan mesa driver"
-  depends=('wayland' 'libx11' 'libxshmfence' 'libelf' 'libdrm' 'zstd' 'llvm-libs')
-  optdepends=('vulkan-mesa-layer: a vulkan layer to display information using an overlay')
-  provides=('vulkan-driver')
-
-  _install fakeinstall/usr/share/vulkan/icd.d/radeon_icd*.json
-  _install fakeinstall/usr/lib/libvulkan_radeon.so
-
-  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
-}
-
-package_libva-mesa-driver() {
-  pkgdesc="VA-API implementation for gallium"
-  depends=('libdrm' 'libx11' 'llvm-libs' 'expat' 'libelf' 'libxshmfence' 'zstd')
-
-  _install fakeinstall/usr/lib/dri/*_drv_video.so
-
-  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
-}
-
-package_mesa-vdpau() {
-  pkgdesc="Mesa VDPAU drivers"
-  depends=('libdrm' 'libx11' 'llvm-libs' 'expat' 'libelf' 'libxshmfence' 'zstd')
-
-  _install fakeinstall/usr/lib/vdpau
-
-  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
-}
-
-package_mesa() {
-  depends=('libdrm' 'wayland' 'libxxf86vm' 'libxdamage' 'libxshmfence' 'libelf'
-           'libomxil-bellagio' 'libunwind' 'llvm-libs' 'lm_sensors' 'libglvnd')
-  optdepends=('opengl-man-pages: for the OpenGL API man pages'
-              'mesa-vdpau: for accelerated video playback'
-              'libva-mesa-driver: for accelerated video playback')
-  provides=('mesa-libgl' 'opengl-driver')
-  conflicts=('mesa-libgl')
-  replaces=('mesa-libgl')
-
-  _install fakeinstall/usr/share/drirc.d/00-mesa-defaults.conf
-  _install fakeinstall/usr/share/glvnd/egl_vendor.d/50_mesa.json
-
-  # ati-dri, nouveau-dri, intel-dri, svga-dri, swrast, swr
-  _install fakeinstall/usr/lib/dri/*_dri.so
-
-  _install fakeinstall/usr/lib/bellagio
-  _install fakeinstall/usr/lib/d3d
-  _install fakeinstall/usr/lib/lib{gbm,glapi}.so*
-  _install fakeinstall/usr/lib/libOSMesa.so*
-  _install fakeinstall/usr/lib/libxatracker.so*
-  _install fakeinstall/usr/lib/libswrAVX*.so*
-
-  # in vulkan-headers
-  rm -rv fakeinstall/usr/include/vulkan
-
-  _install fakeinstall/usr/include
-  _install fakeinstall/usr/lib/pkgconfig
-
-  # libglvnd support
-  _install fakeinstall/usr/lib/libGLX_mesa.so*
-  _install fakeinstall/usr/lib/libEGL_mesa.so*
-
-  # indirect rendering
-  ln -s /usr/lib/libGLX_mesa.so.0 "${pkgdir}/usr/lib/libGLX_indirect.so.0"
-  
-  # make sure there are no files left to install
-  find fakeinstall -depth -print0 | xargs -0 rmdir
-
-  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
-}

Copied: mesa/repos/testing-x86_64/PKGBUILD (from rev 387799, mesa/trunk/PKGBUILD)
===================================================================
--- PKGBUILD	                        (rev 0)
+++ PKGBUILD	2020-05-29 08:02:57 UTC (rev 387800)
@@ -0,0 +1,209 @@
+# Maintainer: Jan de Groot <jgc at archlinux.org>
+# Maintainer: Andreas Radke <andyrtr at archlinux.org>
+
+pkgbase=mesa
+pkgname=('vulkan-mesa-layers' 'opencl-mesa' 'vulkan-intel' 'vulkan-radeon' 'libva-mesa-driver' 'mesa-vdpau' 'mesa')
+pkgdesc="An open-source implementation of the OpenGL specification"
+pkgver=20.1.0
+pkgrel=3
+arch=('x86_64')
+makedepends=('python-mako' 'libxml2' 'libx11' 'xorgproto' 'libdrm' 'libxshmfence' 'libxxf86vm'
+             'libxdamage' 'libvdpau' 'libva' 'wayland' 'wayland-protocols' 'zstd'
+             'elfutils' 'llvm' 'libomxil-bellagio' 'libclc' 'clang' 'libglvnd' 'libunwind' 'lm_sensors'
+             'libxrandr' 'valgrind' 'glslang' 'meson')
+url="https://www.mesa3d.org/"
+license=('custom')
+source=(https://mesa.freedesktop.org/archive/mesa-${pkgver}.tar.xz{,.sig}
+	0001-iris-fix-BO-destruction-in-error-path.patch
+	0002-iris-fix-export-of-GEM-handles.patch
+	0003-i965-fix-export-of-GEM-handles.patch 
+        LICENSE)
+sha512sums=('f49230d18febe1bfd7c6282ab95fc244530f5cef56df0f804d8bece8a70bafcb445b8b83df96ad1b4c5af022c4e39a71f19a8f7e47b1fb09ada2b1a1317ff3be'
+            'SKIP'
+            '456d1296ac8ce01d2f1e0c9d9cb8fc995d5f5e5de8f56a3487452a131a7ccfa4beaeb3fc693afbf4691e8de90e399d86bb121cd7514a981fe96b4333df980af3'
+            '7903c26dcb11932f26dcc6ffd2fd2ecd05840141dc2abfcaf404716320927cd40ba472c434a6e4ae9a08fafa7d54bdb26890efd2177634947f134de6d1fb7315'
+            '9fe91699d00a9eee4de5b1e60dd14e7cde83933d2fff13f09fd24687addc84a3f9a6c512e02587ceabe6a4c459dbd1f452953ab741ac4843526e1504c12cf5d7'
+            'f9f0d0ccf166fe6cb684478b6f1e1ab1f2850431c06aa041738563eb1808a004e52cdec823c103c9e180f03ffc083e95974d291353f0220fe52ae6d4897fecc7')
+validpgpkeys=('8703B6700E7EE06D7A39B8D6EDAE37B02CEB490D'  # Emil Velikov <emil.l.velikov at gmail.com>
+              '946D09B5E4C9845E63075FF1D961C596A7203456'  # Andres Gomez <tanty at igalia.com>
+              'E3E8F480C52ADD73B278EE78E1ECBE07D7D70895'  # Juan Antonio Suárez Romero (Igalia, S.L.) <jasuarez at igalia.com>
+              'A5CC9FEC93F2F837CB044912336909B6B25FADFA'  # Juan A. Suarez Romero <jasuarez at igalia.com>
+              '71C4B75620BC75708B4BDB254C95FAAB3EB073EC'  # Dylan Baker <dylan at pnwbakers.com>
+              'CC31EF29D32A6637889530F2481D0E9D964E5593') # Eric Engestrom <eric at engestrom.ch>
+
+prepare() {
+  cd mesa-$pkgver
+
+  # fix https://gitlab.freedesktop.org/mesa/mesa/-/issues/2882
+  patch -Np1 -i ../0001-iris-fix-BO-destruction-in-error-path.patch
+  patch -Np1 -i ../0002-iris-fix-export-of-GEM-handles.patch
+  patch -Np1 -i ../0003-i965-fix-export-of-GEM-handles.patch 
+}
+
+build() {
+  arch-meson mesa-$pkgver build \
+    -D b_lto=true \
+    -D b_ndebug=true \
+    -D platforms=x11,wayland,drm,surfaceless \
+    -D dri-drivers=i915,i965,r100,r200,nouveau \
+    -D gallium-drivers=r300,r600,radeonsi,nouveau,virgl,svga,swrast,swr,iris \
+    -D vulkan-drivers=amd,intel \
+    -D vulkan-overlay-layer=true \
+	-D vulkan-device-select-layer=true \
+    -D swr-arches=avx,avx2 \
+    -D dri3=true \
+    -D egl=true \
+    -D gallium-extra-hud=true \
+    -D gallium-nine=true \
+    -D gallium-omx=bellagio \
+    -D gallium-opencl=icd \
+    -D gallium-va=true \
+    -D gallium-vdpau=true \
+    -D gallium-xa=true \
+    -D gallium-xvmc=false \
+    -D gbm=true \
+    -D gles1=false \
+    -D gles2=true \
+    -D glvnd=true \
+    -D glx=dri \
+    -D libunwind=true \
+    -D llvm=true \
+    -D lmsensors=true \
+    -D osmesa=gallium \
+    -D shared-glapi=true \
+    -D valgrind=true
+
+  # Print config
+  meson configure build
+
+  ninja -C build xmlpool-pot xmlpool-update-po xmlpool-gmo
+  ninja -C build
+
+  # fake installation to be seperated into packages
+  # outside of fakeroot but mesa doesn't need to chown/mod
+  DESTDIR="${srcdir}/fakeinstall" ninja -C build install
+}
+
+_install() {
+  local src f dir
+  for src; do
+    f="${src#fakeinstall/}"
+    dir="${pkgdir}/${f%/*}"
+    install -m755 -d "${dir}"
+    mv -v "${src}" "${dir}/"
+  done
+}
+
+package_vulkan-mesa-layers() {
+  pkgdesc="Mesa's Vulkan layers"
+  depends=('libdrm' 'libxcb' 'wayland')
+  conflicts=('vulkan-mesa-layer')
+  replaces=('vulkan-mesa-layer')
+
+  _install fakeinstall/usr/share/vulkan/explicit_layer.d
+  _install fakeinstall/usr/lib/libVkLayer_MESA_overlay.so
+  _install fakeinstall/usr/bin/mesa-overlay-control.py
+
+  _install fakeinstall/usr/share/vulkan/implicit_layer.d
+  _install fakeinstall/usr/lib/libVkLayer_MESA_device_select.so
+
+  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
+}
+
+package_opencl-mesa() {
+  pkgdesc="OpenCL support for AMD/ATI Radeon mesa drivers"
+  depends=('expat' 'libdrm' 'libelf' 'libclc' 'clang' 'zstd')
+  optdepends=('opencl-headers: headers necessary for OpenCL development')
+  provides=('opencl-driver')
+
+  _install fakeinstall/etc/OpenCL
+  _install fakeinstall/usr/lib/lib*OpenCL*
+  _install fakeinstall/usr/lib/gallium-pipe
+
+  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
+}
+
+package_vulkan-intel() {
+  pkgdesc="Intel's Vulkan mesa driver"
+  depends=('wayland' 'libx11' 'libxshmfence' 'libdrm' 'zstd')
+  optdepends=('vulkan-mesa-layer: a vulkan layer to display information using an overlay')
+  provides=('vulkan-driver')
+
+  _install fakeinstall/usr/share/vulkan/icd.d/intel_icd*.json
+  _install fakeinstall/usr/lib/libvulkan_intel.so
+  _install fakeinstall/usr/include/vulkan/vulkan_intel.h
+
+  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
+}
+
+package_vulkan-radeon() {
+  pkgdesc="Radeon's Vulkan mesa driver"
+  depends=('wayland' 'libx11' 'libxshmfence' 'libelf' 'libdrm' 'zstd' 'llvm-libs')
+  optdepends=('vulkan-mesa-layer: a vulkan layer to display information using an overlay')
+  provides=('vulkan-driver')
+
+  _install fakeinstall/usr/share/vulkan/icd.d/radeon_icd*.json
+  _install fakeinstall/usr/lib/libvulkan_radeon.so
+
+  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
+}
+
+package_libva-mesa-driver() {
+  pkgdesc="VA-API implementation for gallium"
+  depends=('libdrm' 'libx11' 'llvm-libs' 'expat' 'libelf' 'libxshmfence' 'zstd')
+
+  _install fakeinstall/usr/lib/dri/*_drv_video.so
+
+  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
+}
+
+package_mesa-vdpau() {
+  pkgdesc="Mesa VDPAU drivers"
+  depends=('libdrm' 'libx11' 'llvm-libs' 'expat' 'libelf' 'libxshmfence' 'zstd')
+
+  _install fakeinstall/usr/lib/vdpau
+
+  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
+}
+
+package_mesa() {
+  depends=('libdrm' 'wayland' 'libxxf86vm' 'libxdamage' 'libxshmfence' 'libelf'
+           'libomxil-bellagio' 'libunwind' 'llvm-libs' 'lm_sensors' 'libglvnd')
+  optdepends=('opengl-man-pages: for the OpenGL API man pages'
+              'mesa-vdpau: for accelerated video playback'
+              'libva-mesa-driver: for accelerated video playback')
+  provides=('mesa-libgl' 'opengl-driver')
+  conflicts=('mesa-libgl')
+  replaces=('mesa-libgl')
+
+  _install fakeinstall/usr/share/drirc.d/00-mesa-defaults.conf
+  _install fakeinstall/usr/share/glvnd/egl_vendor.d/50_mesa.json
+
+  # ati-dri, nouveau-dri, intel-dri, svga-dri, swrast, swr
+  _install fakeinstall/usr/lib/dri/*_dri.so
+
+  _install fakeinstall/usr/lib/bellagio
+  _install fakeinstall/usr/lib/d3d
+  _install fakeinstall/usr/lib/lib{gbm,glapi}.so*
+  _install fakeinstall/usr/lib/libOSMesa.so*
+  _install fakeinstall/usr/lib/libxatracker.so*
+  _install fakeinstall/usr/lib/libswrAVX*.so*
+
+  # in vulkan-headers
+  rm -rv fakeinstall/usr/include/vulkan
+
+  _install fakeinstall/usr/include
+  _install fakeinstall/usr/lib/pkgconfig
+
+  # libglvnd support
+  _install fakeinstall/usr/lib/libGLX_mesa.so*
+  _install fakeinstall/usr/lib/libEGL_mesa.so*
+
+  # indirect rendering
+  ln -s /usr/lib/libGLX_mesa.so.0 "${pkgdir}/usr/lib/libGLX_indirect.so.0"
+  
+  # make sure there are no files left to install
+  find fakeinstall -depth -print0 | xargs -0 rmdir
+
+  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
+}


More information about the arch-commits mailing list