Mesa (master): iris: Don't call SET_TILING for dmabuf imports
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Aug 13 22:12:19 UTC 2020
Module: Mesa
Branch: master
Commit: c111e9099ceada50a2437e6e2e2a0f7cc6597448
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c111e9099ceada50a2437e6e2e2a0f7cc6597448
Author: Nanley Chery <nanley.g.chery at intel.com>
Date: Tue Aug 11 17:01:31 2020 -0700
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 <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6296>
---
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 98b1ca683b1..a2f60f175af 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 e69b5a55e3f..a2fe9684246 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 62888bbacd5..53643d1b16c 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",
More information about the mesa-commit
mailing list