crocus: Don't call SET_TILING for dmabuf imports

This is a port of c111e9099c 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 b6d45e7f74 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>
This commit is contained in:
Dave Airlie 2021-06-14 11:41:37 +10:00 committed by Marge Bot
parent 98474055d7
commit 4cd0f8535c
3 changed files with 13 additions and 15 deletions

View file

@ -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 (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)) {
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;
}
bo->tiling_mode = get_tiling.tiling_mode;
} else {
bo->tiling_mode = I915_TILING_NONE;
}
out:

View file

@ -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

View file

@ -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",