iris: Don't call SET_TILING for dmabuf imports
authorNanley Chery <nanley.g.chery@intel.com>
Wed, 12 Aug 2020 00:01:31 +0000 (17:01 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 13 Aug 2020 22:03:48 +0000 (22:03 +0000)
Calling SET_TILING on a DMA buffer with the gen12 CCS modifier can fail
unnecessarily. The main surface in the BO is Y-tiled, but the CCS portion is
linear and can have a stride that's not a multiple of 128B. Because SET_TILING
is called on the CCS plane with I915_TILING_Y, the ioctl will sometimes reject
the stride.

SET_TILING was originally used in b6d45e7f748e9ff7e198391f5ce5d1253101fedb to
fix an assertion failure in iris_resource_from_handle. Assigning the BO's
tiling_mode field is sufficient to avoid the failure.

Fixes: c19492bcdb9 ("iris: Handle importing aux-enabled surfaces on TGL")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6296>

src/gallium/drivers/iris/iris_bufmgr.c
src/gallium/drivers/iris/iris_bufmgr.h
src/gallium/drivers/iris/iris_resource.c

index 98b1ca683b14c5d47ffbe40fd75488343aeb414c..a2f60f175afca7dbb476150951219d0faeb9dff5 100644 (file)
@@ -1381,7 +1381,7 @@ bo_set_tiling_internal(struct iris_bo *bo, uint32_t tiling_mode,
 
 struct iris_bo *
 iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd,
-                      int tiling, uint32_t stride)
+                      int tiling)
 {
    uint32_t handle;
    struct iris_bo *bo;
@@ -1441,23 +1441,16 @@ iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd,
    bo->gem_handle = handle;
    _mesa_hash_table_insert(bufmgr->handle_table, &bo->gem_handle, bo);
 
-   struct drm_i915_gem_get_tiling get_tiling = { .handle = bo->gem_handle };
-   if (!bufmgr->has_tiling_uapi)
-      get_tiling.tiling_mode = I915_TILING_NONE;
-   else if (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
-      goto err;
-
-   if (tiling == -1) {
-      bo->tiling_mode = get_tiling.tiling_mode;
-      /* XXX stride is unknown */
-   } else {
+   if (tiling != -1) {
       /* Modifiers path */
-      if (get_tiling.tiling_mode == tiling || !bufmgr->has_tiling_uapi) {
-         bo->tiling_mode = tiling;
-         bo->stride = stride;
-      } else if (bo_set_tiling_internal(bo, tiling, stride)) {
+      bo->tiling_mode = tiling;
+   } else if (bufmgr->has_tiling_uapi) {
+      struct drm_i915_gem_get_tiling get_tiling = { .handle = bo->gem_handle };
+      if (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
          goto err;
-      }
+      bo->tiling_mode = get_tiling.tiling_mode;
+   } else {
+      bo->tiling_mode = I915_TILING_NONE;
    }
 
 out:
index e69b5a55e3f1096fc24f3ef0e9c5319bcd5bcb0c..a2fe96842468827d143f9400858e5740b6b205cc 100644 (file)
@@ -396,7 +396,7 @@ void iris_destroy_hw_context(struct iris_bufmgr *bufmgr, uint32_t ctx_id);
 
 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,
-                                      int tiling, uint32_t stride);
+                                      int tiling);
 
 /**
  * Exports a bo as a GEM handle into a given DRM file descriptor
index 62888bbacd5bec1e2a20320a0be9860e649a84fa..53643d1b16c3cdca54d4cf9a9de4045a65433c75 100644 (file)
@@ -1046,7 +1046,7 @@ iris_resource_from_handle(struct pipe_screen *pscreen,
       else
          tiling = -1;
       res->bo = iris_bo_import_dmabuf(bufmgr, whandle->handle,
-                                      tiling, whandle->stride);
+                                      tiling);
       break;
    case WINSYS_HANDLE_TYPE_SHARED:
       res->bo = iris_bo_gem_create_from_name(bufmgr, "winsys image",