Module: Mesa Branch: main Commit: 0eac6298f2eb3030f53ec508af87f0c4488b20cb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0eac6298f2eb3030f53ec508af87f0c4488b20cb
Author: José Roberto de Souza <[email protected]> Date: Mon Dec 4 07:41:39 2023 -0800 anv: Fix handling of host_cached_coherent bos in gen9 lp in older kernels Kernel versions without DRM_I915_QUERY_MEMORY_REGIONS support will take a different code path in i915_gem_create() that lacks the i915_gem_set_caching() call to make cached bos in gen9 lp 1 way coherent. Fixes: fc0acf6d90 ("anv: Move i915 specific gem_set_caching to backend") Signed-off-by: José Roberto de Souza <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26457> --- src/intel/vulkan/i915/anv_kmd_backend.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/intel/vulkan/i915/anv_kmd_backend.c b/src/intel/vulkan/i915/anv_kmd_backend.c index 14b4b9ba0b6..78644f6d121 100644 --- a/src/intel/vulkan/i915/anv_kmd_backend.c +++ b/src/intel/vulkan/i915/anv_kmd_backend.c @@ -59,6 +59,23 @@ i915_gem_create(struct anv_device *device, if (intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create)) return 0; + if (alloc_flags & ANV_BO_ALLOC_HOST_CACHED_COHERENT) { + /* We don't want to change these defaults if it's going to be shared + * with another process. + */ + assert(!(alloc_flags & ANV_BO_ALLOC_EXTERNAL)); + + /* Regular objects are created I915_CACHING_CACHED on LLC platforms and + * I915_CACHING_NONE on non-LLC platforms. For many internal state + * objects, we'd rather take the snooping overhead than risk forgetting + * a CLFLUSH somewhere. Userptr objects are always created as + * I915_CACHING_CACHED, which on non-LLC means snooped so there's no + * need to do this there. + */ + if (device->info->has_caching_uapi && !device->info->has_llc) + i915_gem_set_caching(device, gem_create.handle, I915_CACHING_CACHED); + } + *actual_size = gem_create.size; return gem_create.handle; }
