iris: Use set PAT extension on BO creation for MTL
authorJordan Justen <jordan.l.justen@intel.com>
Mon, 3 Apr 2023 08:19:00 +0000 (04:19 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 27 Jun 2023 22:06:19 +0000 (22:06 +0000)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22878>

src/gallium/drivers/iris/i915/iris_kmd_backend.c

index b56cd36..b1f2c79 100644 (file)
@@ -41,7 +41,9 @@ i915_gem_create(struct iris_bufmgr *bufmgr,
                 uint16_t regions_count, uint64_t size,
                 enum iris_heap heap_flags, unsigned alloc_flags)
 {
-   if (unlikely(!iris_bufmgr_get_device_info(bufmgr)->mem.use_class_instance)) {
+   const struct intel_device_info *devinfo =
+      iris_bufmgr_get_device_info(bufmgr);
+   if (unlikely(!devinfo->mem.use_class_instance)) {
       struct drm_i915_gem_create create_legacy = { .size = size };
 
       assert(regions_count == 1 &&
@@ -77,7 +79,7 @@ i915_gem_create(struct iris_bufmgr *bufmgr,
                      &ext_regions.base);
 
    if (iris_bufmgr_vram_size(bufmgr) > 0 &&
-       !intel_vram_all_mappable(iris_bufmgr_get_device_info(bufmgr)) &&
+       !intel_vram_all_mappable(devinfo) &&
        heap_flags == IRIS_HEAP_DEVICE_LOCAL_PREFERRED)
       create.flags |= I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS;
 
@@ -91,6 +93,16 @@ i915_gem_create(struct iris_bufmgr *bufmgr,
                         &protected_param.base);
    }
 
+   /* Set PAT param */
+   struct drm_i915_gem_create_ext_set_pat set_pat_param = { 0 };
+   if (devinfo->has_set_pat_uapi) {
+      set_pat_param.pat_index =
+         iris_pat_index_for_bo_flags(devinfo, alloc_flags);
+      intel_gem_add_ext(&create.extensions,
+                        I915_GEM_CREATE_EXT_SET_PAT,
+                        &set_pat_param.base);
+   }
+
    if (intel_ioctl(iris_bufmgr_get_fd(bufmgr), DRM_IOCTL_I915_GEM_CREATE_EXT,
                    &create))
       return 0;