Module: Mesa
Branch: staging/23.3
Commit: 4b4f608e105c34fec91e7e2b6fbe4f162435fb5e
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b4f608e105c34fec91e7e2b6fbe4f162435fb5e

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>
(cherry picked from commit 0eac6298f2eb3030f53ec508af87f0c4488b20cb)

---

 .pick_status.json                       |  2 +-
 src/intel/vulkan/i915/anv_kmd_backend.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 4e85130d7ef..134774af862 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1944,7 +1944,7 @@
         "description": "anv: Fix handling of host_cached_coherent bos in gen9 
lp in older kernels",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "fc0acf6d9019eec93ee1d00b544f69acef936e21",
         "notes": null
diff --git a/src/intel/vulkan/i915/anv_kmd_backend.c 
b/src/intel/vulkan/i915/anv_kmd_backend.c
index d0f99b542bd..7641db181a3 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_SNOOPED) {
+         /* 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;
    }

Reply via email to