From c111e9099ceada50a2437e6e2e2a0f7cc6597448 Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Tue, 11 Aug 2020 17:01:31 -0700 Subject: [PATCH] iris: Don't call SET_TILING for dmabuf imports 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 Part-of: --- src/gallium/drivers/iris/iris_bufmgr.c | 25 +++++++++---------------- src/gallium/drivers/iris/iris_bufmgr.h | 2 +- src/gallium/drivers/iris/iris_resource.c | 2 +- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 98b1ca6..a2f60f1 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -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: diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h index e69b5a5..a2fe968 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.h +++ b/src/gallium/drivers/iris/iris_bufmgr.h @@ -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 diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 62888bb..53643d1 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -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", -- 2.7.4