Mesa (main): crocus: Don't call SET_TILING for dmabuf imports
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 15 00:13:26 UTC 2021
Module: Mesa
Branch: main
Commit: 4cd0f8535ccaa3ddd80bbb16e42f0c527219a761
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4cd0f8535ccaa3ddd80bbb16e42f0c527219a761
Author: Dave Airlie <airlied at gmail.com>
Date: Mon Jun 14 11:41:37 2021 +1000
crocus: Don't call SET_TILING for dmabuf imports
This is a port of c111e9099ceada50a2437e6e2e2a0f7cc6597448 from iris to
crocus.
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.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11352>
---
src/gallium/drivers/crocus/crocus_bufmgr.c | 19 +++++++++----------
src/gallium/drivers/crocus/crocus_bufmgr.h | 3 +--
src/gallium/drivers/crocus/crocus_resource.c | 2 +-
3 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/gallium/drivers/crocus/crocus_bufmgr.c b/src/gallium/drivers/crocus/crocus_bufmgr.c
index caca821cd7e..68e8453f581 100644
--- a/src/gallium/drivers/crocus/crocus_bufmgr.c
+++ b/src/gallium/drivers/crocus/crocus_bufmgr.c
@@ -1219,7 +1219,7 @@ crocus_bo_get_tiling(struct crocus_bo *bo, uint32_t *tiling_mode,
struct crocus_bo *
crocus_bo_import_dmabuf(struct crocus_bufmgr *bufmgr, int prime_fd,
- uint32_t tiling, uint32_t stride)
+ uint32_t tiling)
{
uint32_t handle;
struct crocus_bo *bo;
@@ -1265,18 +1265,17 @@ crocus_bo_import_dmabuf(struct crocus_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 (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
- goto err;
+ if (tiling != -1) {
+ /* Modifiers path */
+ bo->tiling_mode = tiling;
+ } else if (bufmgr->has_tiling_uapi) {
+ struct drm_i915_gem_get_tiling get_tiling = { .handle = bo->gem_handle };
+ if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
+ goto err;
- if (get_tiling.tiling_mode == tiling || tiling > I915_TILING_LAST) {
bo->tiling_mode = get_tiling.tiling_mode;
- bo->swizzle_mode = get_tiling.swizzle_mode;
- /* XXX stride is unknown */
} else {
- if (bo_set_tiling_internal(bo, tiling, stride)) {
- goto err;
- }
+ bo->tiling_mode = I915_TILING_NONE;
}
out:
diff --git a/src/gallium/drivers/crocus/crocus_bufmgr.h b/src/gallium/drivers/crocus/crocus_bufmgr.h
index 8bb328fdeae..52b6d58a078 100644
--- a/src/gallium/drivers/crocus/crocus_bufmgr.h
+++ b/src/gallium/drivers/crocus/crocus_bufmgr.h
@@ -306,8 +306,7 @@ void crocus_destroy_hw_context(struct crocus_bufmgr *bufmgr, uint32_t ctx_id);
int crocus_bo_export_dmabuf(struct crocus_bo *bo, int *prime_fd);
struct crocus_bo *crocus_bo_import_dmabuf(struct crocus_bufmgr *bufmgr,
- int prime_fd, uint32_t tiling,
- uint32_t stride);
+ int prime_fd, uint32_t tiling);
/**
* Exports a bo as a GEM handle into a given DRM file descriptor
diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c
index b5bf5a42e1a..bb67d6f5377 100644
--- a/src/gallium/drivers/crocus/crocus_resource.c
+++ b/src/gallium/drivers/crocus/crocus_resource.c
@@ -868,7 +868,7 @@ crocus_resource_from_handle(struct pipe_screen *pscreen,
else
tiling = I915_TILING_LAST + 1;
res->bo = crocus_bo_import_dmabuf(bufmgr, whandle->handle,
- tiling, whandle->stride);
+ tiling);
break;
case WINSYS_HANDLE_TYPE_SHARED:
res->bo = crocus_bo_gem_create_from_name(bufmgr, "winsys image",
More information about the mesa-commit
mailing list