<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
> On 09/05/2023 00:48, fei.yang@intel.com wrote:
<div class="ContentPasted0">>> From: Fei Yang <fei.yang@intel.com></div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> Currently the KMD is using enum i915_cache_level to set caching policy for</div>
<div class="ContentPasted0">>> buffer objects. This is flaky because the PAT index which really controls</div>
<div class="ContentPasted0">>> the caching behavior in PTE has far more levels than what's defined in the</div>
<div class="ContentPasted0">>> enum. In addition, the PAT index is platform dependent, having to translate</div>
<div class="ContentPasted0">>> between i915_cache_level and PAT index is not reliable, and makes the code</div>
<div class="ContentPasted0">>> more complicated.</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> From UMD's perspective there is also a necessity to set caching policy for</div>
<div class="ContentPasted0">>> performance fine tuning. It's much easier for the UMD to directly use PAT</div>
<div class="ContentPasted0">>> index because the behavior of each PAT index is clearly defined in Bspec.</div>
<div class="ContentPasted0">>> Having the abstracted i915_cache_level sitting in between would only cause</div>
<div class="ContentPasted0">>> more ambiguity. PAT is expected to work much like MOCS already works today,</div>
<div class="ContentPasted0">>> and by design userspace is expected to select the index that exactly</div>
<div class="ContentPasted0">>> matches the desired behavior described in the hardware specification.</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> For these reasons this patch replaces i915_cache_level with PAT index. Also</div>
<div class="ContentPasted0">>> note, the cache_level is not completely removed yet, because the KMD still</div>
<div class="ContentPasted0">>> has the need of creating buffer objects with simple cache settings such as</div>
<div class="ContentPasted0">>> cached, uncached, or writethrough. For kernel objects, cache_level is used</div>
<div class="ContentPasted0">>> for simplicity and backward compatibility. For Pre-gen12 platforms PAT can</div>
<div class="ContentPasted0">>> have 1:1 mapping to i915_cache_level, so these two are interchangeable. see</div>
<div class="ContentPasted0">>> the use of LEGACY_CACHELEVEL.</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> One consequence of this change is that gen8_pte_encode is no longer working</div>
<div class="ContentPasted0">>> for gen12 platforms due to the fact that gen12 platforms has different PAT</div>
<div class="ContentPasted0">>> definitions. In the meantime the mtl_pte_encode introduced specfically for</div>
<div class="ContentPasted0">>> MTL becomes generic for all gen12 platforms. This patch renames the MTL</div>
<div class="ContentPasted0">>> PTE encode function into gen12_pte_encode and apply it to all gen12. Even</div>
<div class="ContentPasted0">>> though this change looks unrelated, but separating them would temporarily</div>
<div class="ContentPasted0">>> break gen12 PTE encoding, thus squash them in one patch.</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> Special note: this patch changes the way caching behavior is controlled in</div>
<div class="ContentPasted0">>> the sense that some objects are left to be managed by userspace. For such</div>
<div class="ContentPasted0">>> objects we need to be careful not to change the userspace settings.There</div>
<div class="ContentPasted0">>> are kerneldoc and comments added around obj->cache_coherent, cache_dirty,</div>
<div class="ContentPasted0">>> and how to bypass the checkings by i915_gem_object_has_cache_level. For</div>
<div class="ContentPasted0">>> full understanding, these changes need to be looked at together with the</div>
<div class="ContentPasted0">>> two follow-up patches, one disables the {set|get}_caching ioctl's and the</div>
<div class="ContentPasted0">>> other adds set_pat extension to the GEM_CREATE uAPI.</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> Bspec: 63019</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> Cc: Chris Wilson <chris.p.wilson@linux.intel.com></div>
<div class="ContentPasted0">>> Signed-off-by: Fei Yang <fei.yang@intel.com></div>
<div class="ContentPasted0">>> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com></div>
<div class="ContentPasted0">>> Reviewed-by: Matt Roper <matthew.d.roper@intel.com></div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> To be squashed</div>
<div class="ContentPasted0">>> ---</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/display/intel_dpt.c      | 12 +--</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gem/i915_gem_domain.c    | 58 +++++++++----</div>
<div class="ContentPasted0">>>   .../gpu/drm/i915/gem/i915_gem_execbuffer.c    | 15 +++-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gem/i915_gem_mman.c      | 11 ++-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gem/i915_gem_object.c    | 51 ++++++++++-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gem/i915_gem_object.h    |  4 +</div>
<div class="ContentPasted0">>>   .../gpu/drm/i915/gem/i915_gem_object_types.h  | 44 +++++++++-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gem/i915_gem_stolen.c    |  4 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c  |  8 +-</div>
<div class="ContentPasted0">>>   .../gpu/drm/i915/gem/selftests/huge_pages.c   |  2 +-</div>
<div class="ContentPasted0">>>   .../drm/i915/gem/selftests/i915_gem_migrate.c |  2 +-</div>
<div class="ContentPasted0">>>   .../drm/i915/gem/selftests/i915_gem_mman.c    |  2 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/gen6_ppgtt.c          | 10 ++-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/gen8_ppgtt.c          | 84 +++++++++----------</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/gen8_ppgtt.h          |  3 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/intel_ggtt.c          | 82 +++++++++---------</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/intel_gtt.h           | 18 ++--</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/intel_migrate.c       | 47 ++++++-----</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/intel_migrate.h       | 13 ++-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/intel_ppgtt.c         |  4 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/selftest_migrate.c    | 47 ++++++-----</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/selftest_reset.c      |  8 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/selftest_timeline.c   |  2 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/selftest_tlb.c        |  4 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c      | 10 ++-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/i915_debugfs.c           | 53 +++++++++---</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/i915_gem.c               | 27 +++++-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/i915_gpu_error.c         |  8 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/i915_vma.c               | 16 ++--</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/i915_vma.h               |  2 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/i915_vma_types.h         |  2 -</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/selftests/i915_gem.c     |  5 +-</div>
<div class="ContentPasted0">>>   .../gpu/drm/i915/selftests/i915_gem_evict.c   |  4 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 15 ++--</div>
<div class="ContentPasted0">>>   .../drm/i915/selftests/intel_memory_region.c  |  4 +-</div>
<div class="ContentPasted0">>>   drivers/gpu/drm/i915/selftests/mock_gtt.c     |  8 +-</div>
<div class="ContentPasted0">>>   36 files changed, 451 insertions(+), 238 deletions(-)</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c b/drivers/gpu/drm/i915/display/intel_dpt.c</div>
<div class="ContentPasted0">>> index c5eacfdba1a5..7c5fddb203ba 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/display/intel_dpt.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/display/intel_dpt.c</div>
<div class="ContentPasted0">>> @@ -43,24 +43,24 @@ static void gen8_set_pte(void __iomem *addr, gen8_pte_t pte)</div>
<div class="ContentPasted0">>>   static void dpt_insert_page(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                            dma_addr_t addr,</div>
<div class="ContentPasted0">>>                            u64 offset,</div>
<div class="ContentPasted0">>> -                         enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                         unsigned int pat_index,</div>
<div class="ContentPasted0">>>                            u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_dpt *dpt = i915_vm_to_dpt(vm);</div>
<div class="ContentPasted0">>>        gen8_pte_t __iomem *base = dpt->iomem;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        gen8_set_pte(base + offset / I915_GTT_PAGE_SIZE,</div>
<div class="ContentPasted0">>> -                  vm->pte_encode(addr, level, flags));</div>
<div class="ContentPasted0">>> +                  vm->pte_encode(addr, pat_index, flags));</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void dpt_insert_entries(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                               struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                            enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                            unsigned int pat_index,</div>
<div class="ContentPasted0">>>                               u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_dpt *dpt = i915_vm_to_dpt(vm);</div>
<div class="ContentPasted0">>>        gen8_pte_t __iomem *base = dpt->iomem;</div>
<div class="ContentPasted0">>> -     const gen8_pte_t pte_encode = vm->pte_encode(0, level, flags);</div>
<div class="ContentPasted0">>> +     const gen8_pte_t pte_encode = vm->pte_encode(0, pat_index, flags);</div>
<div class="ContentPasted0">>>        struct sgt_iter sgt_iter;</div>
<div class="ContentPasted0">>>        dma_addr_t addr;</div>
<div class="ContentPasted0">>>        int i;</div>
<div class="ContentPasted0">>> @@ -83,7 +83,7 @@ static void dpt_clear_range(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>   static void dpt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                         struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                         struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                      enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                      unsigned int pat_index,</div>
<div class="ContentPasted0">>>                         u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        u32 pte_flags;</div>
<div class="ContentPasted0">>> @@ -98,7 +98,7 @@ static void dpt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>        if (vma_res->bi.lmem)</div>
<div class="ContentPasted0">>>                pte_flags |= PTE_LM;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     vm->insert_entries(vm, vma_res, cache_level, pte_flags);</div>
<div class="ContentPasted0">>> +     vm->insert_entries(vm, vma_res, pat_index, pte_flags);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        vma_res->page_sizes_gtt = I915_GTT_PAGE_SIZE;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c</div>
<div class="ContentPasted0">>> index d2d5a24301b2..05107a6efe45 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c</div>
<div class="ContentPasted0">>> @@ -27,8 +27,15 @@ static bool gpu_write_needs_clflush(struct drm_i915_gem_object *obj)</div>
<div class="ContentPasted0">>>        if (IS_DGFX(i915))</div>
<div class="ContentPasted0">>>                return false;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     return !(obj->cache_level == I915_CACHE_NONE ||</div>
<div class="ContentPasted0">>> -              obj->cache_level == I915_CACHE_WT);</div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * For objects created by userspace through GEM_CREATE with pat_index</div>
<div class="ContentPasted0">>> +      * set by set_pat extension, i915_gem_object_has_cache_level() will</div>
<div class="ContentPasted0">>> +      * always return true, because the coherency of such object is managed</div>
<div class="ContentPasted0">>> +      * by userspace. Othereise the call here would fall back to checking</div>
<div class="ContentPasted0">>> +      * whether the object is un-cached or write-through.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>> +     return !(i915_gem_object_has_cache_level(obj, I915_CACHE_NONE) ||</div>
<div class="ContentPasted0">>> +              i915_gem_object_has_cache_level(obj, I915_CACHE_WT));</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   bool i915_gem_cpu_write_needs_clflush(struct drm_i915_gem_object *obj)</div>
<div class="ContentPasted0">>> @@ -267,7 +274,13 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        int ret;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     if (obj->cache_level == cache_level)</div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * For objects created by userspace through GEM_CREATE with pat_index</div>
<div class="ContentPasted0">>> +      * set by set_pat extension, simply return 0 here without touching</div>
<div class="ContentPasted0">>> +      * the cache setting, because such objects should have an immutable</div>
<div class="ContentPasted0">>> +      * cache setting by desgin and always managed by userspace.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>> +     if (i915_gem_object_has_cache_level(obj, cache_level))</div>
<div class="ContentPasted0">>>                return 0;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        ret = i915_gem_object_wait(obj,</div>
<div class="ContentPasted0">>> @@ -278,10 +291,8 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>>                return ret;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        /* Always invalidate stale cachelines */</div>
<div class="ContentPasted0">>> -     if (obj->cache_level != cache_level) {</div>
<div class="ContentPasted0">>> -             i915_gem_object_set_cache_coherency(obj, cache_level);</div>
<div class="ContentPasted0">>> -             obj->cache_dirty = true;</div>
<div class="ContentPasted0">>> -     }</div>
<div class="ContentPasted0">>> +     i915_gem_object_set_cache_coherency(obj, cache_level);</div>
<div class="ContentPasted0">>> +     obj->cache_dirty = true;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        /* The cache-level will be applied when each vma is rebound. */</div>
<div class="ContentPasted0">>>        return i915_gem_object_unbind(obj,</div>
<div class="ContentPasted0">>> @@ -306,20 +317,22 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,</div>
<div class="ContentPasted0">>>                goto out;</div>
<div class="ContentPasted0">>>        }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     switch (obj->cache_level) {</div>
<div class="ContentPasted0">>> -     case I915_CACHE_LLC:</div>
<div class="ContentPasted0">>> -     case I915_CACHE_L3_LLC:</div>
<div class="ContentPasted0">>> -             args->caching = I915_CACHING_CACHED;</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * This ioctl should be disabled for the objects with pat_index</div>
<div class="ContentPasted0">>> +      * set by user space.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>> +     if (obj->pat_set_by_user) {</div>
<div class="ContentPasted0">>> +             err = -EOPNOTSUPP;</div>
<div class="ContentPasted0">>> +             goto out;</div>
<div class="ContentPasted0">>> +     }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     case I915_CACHE_WT:</div>
<div class="ContentPasted0">>> +     if (i915_gem_object_has_cache_level(obj, I915_CACHE_LLC) ||</div>
<div class="ContentPasted0">>> +         i915_gem_object_has_cache_level(obj, I915_CACHE_L3_LLC))</div>
<div class="ContentPasted0">>> +             args->caching = I915_CACHING_CACHED;</div>
<div class="ContentPasted0">>> +     else if (i915_gem_object_has_cache_level(obj, I915_CACHE_WT))</div>
<div class="ContentPasted0">>>                args->caching = I915_CACHING_DISPLAY;</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -</div>
<div class="ContentPasted0">>> -     default:</div>
<div class="ContentPasted0">>> +     else</div>
<div class="ContentPasted0">>>                args->caching = I915_CACHING_NONE;</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -     }</div>
<div class="ContentPasted0">>>   out:</div>
<div class="ContentPasted0">>>        rcu_read_unlock();</div>
<div class="ContentPasted0">>>        return err;</div>
<div class="ContentPasted0">>> @@ -364,6 +377,15 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,</div>
<div class="ContentPasted0">>>        if (!obj)</div>
<div class="ContentPasted0">>>                return -ENOENT;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * This ioctl should be disabled for the objects with pat_index</div>
<div class="ContentPasted0">>> +      * set by user space.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>> +     if (obj->pat_set_by_user) {</div>
<div class="ContentPasted0">>> +             ret = -EOPNOTSUPP;</div>
<div class="ContentPasted0">>> +             goto out;</div>
<div class="ContentPasted0">>> +     }</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>>        /*</div>
<div class="ContentPasted0">>>         * The caching mode of proxy object is handled by its generator, and</div>
<div class="ContentPasted0">>>         * not allowed to be changed by userspace.</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c</div>
<div class="ContentPasted0">>> index 3aeede6aee4d..5fb459ea4294 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c</div>
<div class="ContentPasted0">>> @@ -640,9 +640,15 @@ static inline int use_cpu_reloc(const struct reloc_cache *cache,</div>
<div class="ContentPasted0">>>        if (DBG_FORCE_RELOC == FORCE_GTT_RELOC)</div>
<div class="ContentPasted0">>>                return false;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * For objects created by userspace through GEM_CREATE with pat_index</div>
<div class="ContentPasted0">>> +      * set by set_pat extension, i915_gem_object_has_cache_level() always</div>
<div class="ContentPasted0">>> +      * return true, otherwise the call would fall back to checking whether</div>
<div class="ContentPasted0">>> +      * the object is un-cached.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>>        return (cache->has_llc ||</div>
<div class="ContentPasted0">>>                obj->cache_dirty ||</div>
<div class="ContentPasted0">>> -             obj->cache_level != I915_CACHE_NONE);</div>
<div class="ContentPasted0">>> +             !i915_gem_object_has_cache_level(obj, I915_CACHE_NONE));</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static int eb_reserve_vma(struct i915_execbuffer *eb,</div>
<div class="ContentPasted0">>> @@ -1324,7 +1330,10 @@ static void *reloc_iomap(struct i915_vma *batch,</div>
<div class="ContentPasted0">>>        if (drm_mm_node_allocated(&cache->node)) {</div>
<div class="ContentPasted0">>>                ggtt->vm.insert_page(&ggtt->vm,</div>
<div class="ContentPasted0">>>                                     i915_gem_object_get_dma_address(obj, page),</div>
<div class="ContentPasted0">>> -                                  offset, I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                  offset,</div>
<div class="ContentPasted0">>> +                                  i915_gem_get_pat_index(ggtt->vm.i915,</div>
<div class="ContentPasted0">>> +                                                         I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                  0);</div>
<div class="ContentPasted0">>>        } else {</div>
<div class="ContentPasted0">>>                offset += page << PAGE_SHIFT;</div>
<div class="ContentPasted0">>>        }</div>
<div class="ContentPasted0">>> @@ -1464,7 +1473,7 @@ eb_relocate_entry(struct i915_execbuffer *eb,</div>
<div class="ContentPasted0">>>                        reloc_cache_unmap(&eb->reloc_cache);</div>
<div class="ContentPasted0">>>                        mutex_lock(&vma->vm->mutex);</div>
<div class="ContentPasted0">>>                        err = i915_vma_bind(target->vma,</div>
<div class="ContentPasted0">>> -                                         target->vma->obj->cache_level,</div>
<div class="ContentPasted0">>> +                                         target->vma->obj->pat_index,</div>
<div class="ContentPasted0">>>                                            PIN_GLOBAL, NULL, NULL);</div>
<div class="ContentPasted0">>>                        mutex_unlock(&vma->vm->mutex);</div>
<div class="ContentPasted0">>>                        reloc_cache_remap(&eb->reloc_cache, ev->vma->obj);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c</div>
<div class="ContentPasted0">>> index 3dbacdf0911a..4e7a838ab7bd 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c</div>
<div class="ContentPasted0">>> @@ -383,7 +383,16 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf)</div>
<div class="ContentPasted0">>>        }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        /* Access to snoopable pages through the GTT is incoherent. */</div>
<div class="ContentPasted0">>> -     if (obj->cache_level != I915_CACHE_NONE && !HAS_LLC(i915)) {</div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * For objects created by userspace through GEM_CREATE with pat_index</div>
<div class="ContentPasted0">>> +      * set by set_pat extension, coherency is managed by userspace, make</div>
<div class="ContentPasted0">>> +      * sure we don't fail handling the vm fault by calling</div>
<div class="ContentPasted0">>> +      * i915_gem_object_has_cache_level() which always return true for such</div>
<div class="ContentPasted0">>> +      * objects. Otherwise this helper function would fall back to checking</div>
<div class="ContentPasted0">>> +      * whether the object is un-cached.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>> +     if (!(i915_gem_object_has_cache_level(obj, I915_CACHE_NONE) ||</div>
<div class="ContentPasted0">>> +           HAS_LLC(i915))) {</div>
<div class="ContentPasted0">>>                ret = -EFAULT;</div>
<div class="ContentPasted0">>>                goto err_unpin;</div>
<div class="ContentPasted0">>>        }</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c</div>
<div class="ContentPasted0">>> index 8c70a0ec7d2f..46a19b099ec8 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/i915_gem_object.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c</div>
<div class="ContentPasted0">>> @@ -54,6 +54,24 @@ unsigned int i915_gem_get_pat_index(struct drm_i915_private *i915,</div>
<div class="ContentPasted0">>>        return INTEL_INFO(i915)->cachelevel_to_pat[level];</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> +bool i915_gem_object_has_cache_level(const struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>> +                                  enum i915_cache_level lvl)</div>
<div class="ContentPasted0">>> +{</div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * In case the pat_index is set by user space, this kernel mode</div>
<div class="ContentPasted0">>> +      * driver should leave the coherency to be managed by user space,</div>
<div class="ContentPasted0">>> +      * simply return true here.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>> +     if (obj->pat_set_by_user)</div>
<div class="ContentPasted0">>> +             return true;</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * Otherwise the pat_index should have been converted from cache_level</div>
<div class="ContentPasted0">>> +      * so that the following comparison is valid.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>> +     return obj->pat_index == i915_gem_get_pat_index(obj_to_i915(obj), lvl);</div>
<div class="ContentPasted0">>> +}</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>>   struct drm_i915_gem_object *i915_gem_object_alloc(void)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct drm_i915_gem_object *obj;</div>
<div class="ContentPasted0">>> @@ -133,7 +151,7 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct drm_i915_private *i915 = to_i915(obj->base.dev);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     obj->cache_level = cache_level;</div>
<div class="ContentPasted0">>> +     obj->pat_index = i915_gem_get_pat_index(i915, cache_level);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        if (cache_level != I915_CACHE_NONE)</div>
<div class="ContentPasted0">>>                obj->cache_coherent = (I915_BO_CACHE_COHERENT_FOR_READ |</div>
<div class="ContentPasted0">>> @@ -148,6 +166,37 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>>                !IS_DGFX(i915);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> +/**</div>
<div class="ContentPasted0">>> + * i915_gem_object_set_pat_index - set PAT index to be used in PTE encode</div>
<div class="ContentPasted0">>> + * @obj: #drm_i915_gem_object</div>
<div class="ContentPasted0">>> + * @pat_index: PAT index</div>
<div class="ContentPasted0">>> + *</div>
<div class="ContentPasted0">>> + * This is a clone of i915_gem_object_set_cache_coherency taking pat index</div>
<div class="ContentPasted0">>> + * instead of cache_level as its second argument.</div>
<div class="ContentPasted0">>> + */</div>
<div class="ContentPasted0">>> +void i915_gem_object_set_pat_index(struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>> +                                unsigned int pat_index)</div>
<div class="ContentPasted0">>> +{</div>
<div class="ContentPasted0">>> +     struct drm_i915_private *i915 = to_i915(obj->base.dev);</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     if (obj->pat_index == pat_index)</div>
<div class="ContentPasted0">>> +             return;</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     obj->pat_index = pat_index;</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     if (pat_index != i915_gem_get_pat_index(i915, I915_CACHE_NONE))</div>
<div class="ContentPasted0">>> +             obj->cache_coherent = (I915_BO_CACHE_COHERENT_FOR_READ |</div>
<div class="ContentPasted0">>> +                                    I915_BO_CACHE_COHERENT_FOR_WRITE);</div>
<div class="ContentPasted0">>> +     else if (HAS_LLC(i915))</div>
<div class="ContentPasted0">>> +             obj->cache_coherent = I915_BO_CACHE_COHERENT_FOR_READ;</div>
<div class="ContentPasted0">>> +     else</div>
<div class="ContentPasted0">>> +             obj->cache_coherent = 0;</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     obj->cache_dirty =</div>
<div class="ContentPasted0">>> +             !(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE) &&</div>
<div class="ContentPasted0">>> +             !IS_DGFX(i915);</div>
<div class="ContentPasted0">>> +}</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>>   bool i915_gem_object_can_bypass_llc(struct drm_i915_gem_object *obj)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct drm_i915_private *i915 = to_i915(obj->base.dev);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h</div>
<div class="ContentPasted0">>> index 284e1aa396cd..884a17275b3a 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/i915_gem_object.h</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h</div>
<div class="ContentPasted0">>> @@ -34,6 +34,8 @@ static inline bool i915_gem_object_size_2big(u64 size)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   unsigned int i915_gem_get_pat_index(struct drm_i915_private *i915,</div>
<div class="ContentPasted0">>>                                    enum i915_cache_level level);</div>
<div class="ContentPasted0">>> +bool i915_gem_object_has_cache_level(const struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>> +                                  enum i915_cache_level lvl);</div>
<div class="ContentPasted0">>>   void i915_gem_init__objects(struct drm_i915_private *i915);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   void i915_objects_module_exit(void);</div>
<div class="ContentPasted0">>> @@ -764,6 +766,8 @@ bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object *obj);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>>                                         unsigned int cache_level);</div>
<div class="ContentPasted0">>> +void i915_gem_object_set_pat_index(struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>> +                                unsigned int pat_index);</div>
<div class="ContentPasted0">>>   bool i915_gem_object_can_bypass_llc(struct drm_i915_gem_object *obj);</div>
<div class="ContentPasted0">>>   void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj);</div>
<div class="ContentPasted0">>>   void i915_gem_object_flush_if_display_locked(struct drm_i915_gem_object *obj);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h</div>
<div class="ContentPasted0">>> index bf0bd8e11355..adf4c2b28135 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h</div>
<div class="ContentPasted0">>> @@ -364,15 +364,42 @@ struct drm_i915_gem_object {</div>
<div class="ContentPasted0">>>   #define I915_BO_FLAG_STRUCT_PAGE BIT(0) /* Object backed by struct pages */</div>
<div class="ContentPasted0">>>   #define I915_BO_FLAG_IOMEM       BIT(1) /* Object backed by IO memory */</div>
<div class="ContentPasted0">>>        /**</div>
<div class="ContentPasted0">>> -      * @cache_level: The desired GTT caching level.</div>
<div class="ContentPasted0">>> +      * @pat_index: The desired PAT index.</div>
<div class="ContentPasted0">>> +      *</div>
<div class="ContentPasted0">>> +      * See hardware specification for valid PAT indices for each platform.</div>
<div class="ContentPasted0">>> +      * This field used to contain a value of enum i915_cache_level. It's</div>
<div class="ContentPasted0">>> +      * changed to an unsigned int because PAT indices are being used by</div>
<div class="ContentPasted0">>> +      * both UMD and KMD for caching policy control after GEN12.</div>
<div class="ContentPasted0">>> +      * For backward compatibility, this field will continue to contain</div>
<div class="ContentPasted0">>> +      * value of i915_cache_level for pre-GEN12 platforms so that the PTE</div>
<div class="ContentPasted0">>> +      * encode functions for these legacy platforms can stay the same.</div>
<div class="ContentPasted0">>> +      * In the meantime platform specific tables are created to translate</div>
<div class="ContentPasted0">>> +      * i915_cache_level into pat index, for more details check the macros</div>
<div class="ContentPasted0">>> +      * defined i915/i915_pci.c, e.g. PVC_CACHELEVEL.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">> Dunno - this still reads a bit wonky to me. It was unsigned int already</div>
<div class="ContentPasted0">> and also it does not hold i915_cache_level on legacy platforms, right?</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">v8 sent with some clarification.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">>> +     unsigned int pat_index:6;</div>
<div class="ContentPasted0">>> +     /**</div>
<div class="ContentPasted0">>> +      * @pat_set_by_user: Indicate whether pat_index is set by user space</div>
<div class="ContentPasted0">>>         *</div>
<div class="ContentPasted0">>> -      * See enum i915_cache_level for possible values, along with what</div>
<div class="ContentPasted0">>> -      * each does.</div>
<div class="ContentPasted0">>> +      * This field is set to false by default, only set to true if the</div>
<div class="ContentPasted0">>> +      * pat_index is set by user space. By design, user space is capable of</div>
<div class="ContentPasted0">>> +      * managing caching behavior by setting pat_index, in which case this</div>
<div class="ContentPasted0">>> +      * kernel mode driver should never touch the pat_index.</div>
<div class="ContentPasted0">>>         */</div>
<div class="ContentPasted0">>> -     unsigned int cache_level:3;</div>
<div class="ContentPasted0">>> +     unsigned int pat_set_by_user;</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">> Unsigned int:1 to fit into the bitfield sandwitch better?</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">okay</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">>>        /**</div>
<div class="ContentPasted0">>>         * @cache_coherent:</div>
<div class="ContentPasted0">>>         *</div>
<div class="ContentPasted0">>> +      * Note: with the change above which replaced cache_level with</div>
<div class="ContentPasted0">>> +      * pat_index, the use of cache_coherent is limited to objects created</div>
<div class="ContentPasted0">>> +      * by kernel. Check for @pat_set_by_user to find out if an object is</div>
<div class="ContentPasted0">>> +      * created by userspace or kernel. A later patch will disable the</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">>pat_set_by_user is not about who created the object, no? And it is not</div>
<div class="ContentPasted0">>in a later patch any longer.</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">>> +      * ioctl's to change cache settings for objects with pat_index set by</div>
<div class="ContentPasted0">>> +      * userspace. Please don't assume @cache_coherent having the flags set</div>
<div class="ContentPasted0">>> +      * as describe here for these objects. Also see the helper function</div>
<div class="ContentPasted0">>> +      * i915_gem_object_has_cache_level() for possible ways to bypass the</div>
<div class="ContentPasted0">>> +      * use of this field.</div>
<div class="ContentPasted0">>> +      *</div>
<div class="ContentPasted0">>>         * Track whether the pages are coherent with the GPU if reading or</div>
<div class="ContentPasted0">>>         * writing through the CPU caches. The largely depends on the</div>
<div class="ContentPasted0">>>         * @cache_level setting.</div>
<div class="ContentPasted0">>> @@ -446,6 +473,15 @@ struct drm_i915_gem_object {</div>
<div class="ContentPasted0">>>        /**</div>
<div class="ContentPasted0">>>         * @cache_dirty:</div>
<div class="ContentPasted0">>>         *</div>
<div class="ContentPasted0">>> +      * Note: with the change above which replaced cache_level with</div>
<div class="ContentPasted0">>> +      * pat_index, the use of cache_dirty is limited to objects created</div>
<div class="ContentPasted0">>> +      * by kernel. Check for @pat_set_by_user to find out if an object is</div>
<div class="ContentPasted0">>> +      * created by userspace or kernel. A later patch will disable the</div>
<div class="ContentPasted0">>> +      * ioctl's to change cache settings for objects with pat_index set by</div>
<div class="ContentPasted0">>> +      * userspace. Please don't assume @cache_dirty is set as describe here</div>
<div class="ContentPasted0">>> +      * for these objects. Also see i915_gem_object_has_cache_level() for</div>
<div class="ContentPasted0">>> +      * possible ways to bypass the use of this field.</div>
<div class="ContentPasted0">>> +      *</div>
<div class="ContentPasted0">>>         * Track if we are we dirty with writes through the CPU cache for this</div>
<div class="ContentPasted0">>>         * object. As a result reading directly from main memory might yield</div>
<div class="ContentPasted0">>>         * stale data.</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c</div>
<div class="ContentPasted0">>> index ee492d823f1b..3b094d36a0b0 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c</div>
<div class="ContentPasted0">>> @@ -565,7 +565,9 @@ static void dbg_poison(struct i915_ggtt *ggtt,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                ggtt->vm.insert_page(&ggtt->vm, addr,</div>
<div class="ContentPasted0">>>                                     ggtt->error_capture.start,</div>
<div class="ContentPasted0">>> -                                  I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                  i915_gem_get_pat_index(ggtt->vm.i915,</div>
<div class="ContentPasted0">>> +                                                         I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                  0);</div>
<div class="ContentPasted0">>>                mb();</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                s = io_mapping_map_wc(&ggtt->iomap,</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c</div>
<div class="ContentPasted0">>> index 69eb20ed4d47..7078af2f8f79 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c</div>
<div class="ContentPasted0">>> @@ -214,7 +214,8 @@ static struct dma_fence *i915_ttm_accel_move(struct ttm_buffer_object *bo,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                intel_engine_pm_get(to_gt(i915)->migrate.context->engine);</div>
<div class="ContentPasted0">>>                ret = intel_context_migrate_clear(to_gt(i915)->migrate.context, deps,</div>
<div class="ContentPasted0">>> -                                               dst_st->sgl, dst_level,</div>
<div class="ContentPasted0">>> +                                               dst_st->sgl,</div>
<div class="ContentPasted0">>> +                                               i915_gem_get_pat_index(i915, dst_level),</div>
<div class="ContentPasted0">>>                                                  i915_ttm_gtt_binds_lmem(dst_mem),</div>
<div class="ContentPasted0">>>                                                  0, &rq);</div>
<div class="ContentPasted0">>>        } else {</div>
<div class="ContentPasted0">>> @@ -228,9 +229,10 @@ static struct dma_fence *i915_ttm_accel_move(struct ttm_buffer_object *bo,</div>
<div class="ContentPasted0">>>                intel_engine_pm_get(to_gt(i915)->migrate.context->engine);</div>
<div class="ContentPasted0">>>                ret = intel_context_migrate_copy(to_gt(i915)->migrate.context,</div>
<div class="ContentPasted0">>>                                                 deps, src_rsgt->table.sgl,</div>
<div class="ContentPasted0">>> -                                              src_level,</div>
<div class="ContentPasted0">>> +                                              i915_gem_get_pat_index(i915, src_level),</div>
<div class="ContentPasted0">>>                                                 i915_ttm_gtt_binds_lmem(bo->resource),</div>
<div class="ContentPasted0">>> -                                              dst_st->sgl, dst_level,</div>
<div class="ContentPasted0">>> +                                              dst_st->sgl,</div>
<div class="ContentPasted0">>> +                                              i915_gem_get_pat_index(i915, dst_level),</div>
<div class="ContentPasted0">>>                                                 i915_ttm_gtt_binds_lmem(dst_mem),</div>
<div class="ContentPasted0">>>                                                 &rq);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c</div>
<div class="ContentPasted0">>> index d1057574e966..df6c9a84252c 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c</div>
<div class="ContentPasted0">>> @@ -354,7 +354,7 @@ fake_huge_pages_object(struct drm_i915_private *i915, u64 size, bool single)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        obj->write_domain = I915_GEM_DOMAIN_CPU;</div>
<div class="ContentPasted0">>>        obj->read_domains = I915_GEM_DOMAIN_CPU;</div>
<div class="ContentPasted0">>> -     obj->cache_level = I915_CACHE_NONE;</div>
<div class="ContentPasted0">>> +     obj->pat_index = i915_gem_get_pat_index(i915, I915_CACHE_NONE);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        return obj;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_migrate.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_migrate.c</div>
<div class="ContentPasted0">>> index fe6c37fd7859..a93a90b15907 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_migrate.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_migrate.c</div>
<div class="ContentPasted0">>> @@ -219,7 +219,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,</div>
<div class="ContentPasted0">>>                        continue;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                err = intel_migrate_clear(&gt->migrate, &ww, deps,</div>
<div class="ContentPasted0">>> -                                       obj->mm.pages->sgl, obj->cache_level,</div>
<div class="ContentPasted0">>> +                                       obj->mm.pages->sgl, obj->pat_index,</div>
<div class="ContentPasted0">>>                                          i915_gem_object_is_lmem(obj),</div>
<div class="ContentPasted0">>>                                          0xdeadbeaf, &rq);</div>
<div class="ContentPasted0">>>                if (rq) {</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c</div>
<div class="ContentPasted0">>> index 56279908ed30..a93d8f9f8bc1 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c</div>
<div class="ContentPasted0">>> @@ -1222,7 +1222,7 @@ static int __igt_mmap_migrate(struct intel_memory_region **placements,</div>
<div class="ContentPasted0">>>        }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        err = intel_context_migrate_clear(to_gt(i915)->migrate.context, NULL,</div>
<div class="ContentPasted0">>> -                                       obj->mm.pages->sgl, obj->cache_level,</div>
<div class="ContentPasted0">>> +                                       obj->mm.pages->sgl, obj->pat_index,</div>
<div class="ContentPasted0">>>                                          i915_gem_object_is_lmem(obj),</div>
<div class="ContentPasted0">>>                                          expand32(POISON_INUSE), &rq);</div>
<div class="ContentPasted0">>>        i915_gem_object_unpin_pages(obj);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/gen6_ppgtt.c b/drivers/gpu/drm/i915/gt/gen6_ppgtt.c</div>
<div class="ContentPasted0">>> index 5aaacc53fa4c..c2bdc133c89a 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/gen6_ppgtt.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/gen6_ppgtt.c</div>
<div class="ContentPasted0">>> @@ -109,7 +109,7 @@ static void gen6_ppgtt_clear_range(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                      struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                                   enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                                   unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                      u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);</div>
<div class="ContentPasted0">>> @@ -117,7 +117,7 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>        unsigned int first_entry = vma_res->start / I915_GTT_PAGE_SIZE;</div>
<div class="ContentPasted0">>>        unsigned int act_pt = first_entry / GEN6_PTES;</div>
<div class="ContentPasted0">>>        unsigned int act_pte = first_entry % GEN6_PTES;</div>
<div class="ContentPasted0">>> -     const u32 pte_encode = vm->pte_encode(0, cache_level, flags);</div>
<div class="ContentPasted0">>> +     const u32 pte_encode = vm->pte_encode(0, pat_index, flags);</div>
<div class="ContentPasted0">>>        struct sgt_dma iter = sgt_dma(vma_res);</div>
<div class="ContentPasted0">>>        gen6_pte_t *vaddr;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -227,7 +227,9 @@ static int gen6_ppgtt_init_scratch(struct gen6_ppgtt *ppgtt)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        vm->scratch[0]->encode =</div>
<div class="ContentPasted0">>>                vm->pte_encode(px_dma(vm->scratch[0]),</div>
<div class="ContentPasted0">>> -                            I915_CACHE_NONE, PTE_READ_ONLY);</div>
<div class="ContentPasted0">>> +                            i915_gem_get_pat_index(vm->i915,</div>
<div class="ContentPasted0">>> +                                                   I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                            PTE_READ_ONLY);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        vm->scratch[1] = vm->alloc_pt_dma(vm, I915_GTT_PAGE_SIZE_4K);</div>
<div class="ContentPasted0">>>        if (IS_ERR(vm->scratch[1])) {</div>
<div class="ContentPasted0">>> @@ -278,7 +280,7 @@ static void gen6_ppgtt_cleanup(struct i915_address_space *vm)</div>
<div class="ContentPasted0">>>   static void pd_vma_bind(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                        struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                        struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                     enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                     unsigned int pat_index,</div>
<div class="ContentPasted0">>>                        u32 unused)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/gen8_ppgtt.c b/drivers/gpu/drm/i915/gt/gen8_ppgtt.c</div>
<div class="ContentPasted0">>> index bb6998d67133..f948d33e5ec5 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/gen8_ppgtt.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/gen8_ppgtt.c</div>
<div class="ContentPasted0">>> @@ -29,7 +29,7 @@ static u64 gen8_pde_encode(const dma_addr_t addr,</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static u64 gen8_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>> -                        enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                        unsigned int pat_index,</div>
<div class="ContentPasted0">>>                           u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        gen8_pte_t pte = addr | GEN8_PAGE_PRESENT | GEN8_PAGE_RW;</div>
<div class="ContentPasted0">>> @@ -40,7 +40,12 @@ static u64 gen8_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>>        if (flags & PTE_LM)</div>
<div class="ContentPasted0">>>                pte |= GEN12_PPGTT_PTE_LM;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     switch (level) {</div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * For pre-gen12 platforms pat_index is the same as enum</div>
<div class="ContentPasted0">>> +      * i915_cache_level, so the switch-case here is still valid.</div>
<div class="ContentPasted0">>> +      * See translation table defined by LEGACY_CACHELEVEL.</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>> +     switch (pat_index) {</div>
<div class="ContentPasted0">>>        case I915_CACHE_NONE:</div>
<div class="ContentPasted0">>>                pte |= PPAT_UNCACHED;</div>
<div class="ContentPasted0">>>                break;</div>
<div class="ContentPasted0">>> @@ -55,9 +60,9 @@ static u64 gen8_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>>        return pte;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -static u64 mtl_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>> -                       enum i915_cache_level level,</div>
<div class="ContentPasted0">>> -                       u32 flags)</div>
<div class="ContentPasted0">>> +static u64 gen12_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>> +                         unsigned int pat_index,</div>
<div class="ContentPasted0">>> +                         u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        gen8_pte_t pte = addr | GEN8_PAGE_PRESENT | GEN8_PAGE_RW;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -67,24 +72,17 @@ static u64 mtl_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>>        if (flags & PTE_LM)</div>
<div class="ContentPasted0">>>                pte |= GEN12_PPGTT_PTE_LM;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     switch (level) {</div>
<div class="ContentPasted0">>> -     case I915_CACHE_NONE:</div>
<div class="ContentPasted0">>> -             pte |= GEN12_PPGTT_PTE_PAT1;</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -     case I915_CACHE_LLC:</div>
<div class="ContentPasted0">>> -     case I915_CACHE_L3_LLC:</div>
<div class="ContentPasted0">>> -             pte |= GEN12_PPGTT_PTE_PAT0 | GEN12_PPGTT_PTE_PAT1;</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -     case I915_CACHE_WT:</div>
<div class="ContentPasted0">>> +     if (pat_index & BIT(0))</div>
<div class="ContentPasted0">>>                pte |= GEN12_PPGTT_PTE_PAT0;</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -     default:</div>
<div class="ContentPasted0">>> -             /* This should never happen. Added to deal with the compile</div>
<div class="ContentPasted0">>> -              * error due to the addition of I915_MAX_CACHE_LEVEL. Will</div>
<div class="ContentPasted0">>> -              * be removed by the pat_index patch.</div>
<div class="ContentPasted0">>> -              */</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -     }</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     if (pat_index & BIT(1))</div>
<div class="ContentPasted0">>> +             pte |= GEN12_PPGTT_PTE_PAT1;</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     if (pat_index & BIT(2))</div>
<div class="ContentPasted0">>> +             pte |= GEN12_PPGTT_PTE_PAT2;</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     if (pat_index & BIT(3))</div>
<div class="ContentPasted0">>> +             pte |= MTL_PPGTT_PTE_PAT3;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        return pte;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -457,11 +455,11 @@ gen8_ppgtt_insert_pte(struct i915_ppgtt *ppgtt,</div>
<div class="ContentPasted0">>>                      struct i915_page_directory *pdp,</div>
<div class="ContentPasted0">>>                      struct sgt_dma *iter,</div>
<div class="ContentPasted0">>>                      u64 idx,</div>
<div class="ContentPasted0">>> -                   enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                   unsigned int pat_index,</div>
<div class="ContentPasted0">>>                      u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_page_directory *pd;</div>
<div class="ContentPasted0">>> -     const gen8_pte_t pte_encode = ppgtt->vm.pte_encode(0, cache_level, flags);</div>
<div class="ContentPasted0">>> +     const gen8_pte_t pte_encode = ppgtt->vm.pte_encode(0, pat_index, flags);</div>
<div class="ContentPasted0">>>        gen8_pte_t *vaddr;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        pd = i915_pd_entry(pdp, gen8_pd_index(idx, 2));</div>
<div class="ContentPasted0">>> @@ -504,10 +502,10 @@ static void</div>
<div class="ContentPasted0">>>   xehpsdv_ppgtt_insert_huge(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                          struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>>                          struct sgt_dma *iter,</div>
<div class="ContentPasted0">>> -                       enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                       unsigned int pat_index,</div>
<div class="ContentPasted0">>>                          u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> -     const gen8_pte_t pte_encode = vm->pte_encode(0, cache_level, flags);</div>
<div class="ContentPasted0">>> +     const gen8_pte_t pte_encode = vm->pte_encode(0, pat_index, flags);</div>
<div class="ContentPasted0">>>        unsigned int rem = sg_dma_len(iter->sg);</div>
<div class="ContentPasted0">>>        u64 start = vma_res->start;</div>
<div class="ContentPasted0">>>        u64 end = start + vma_res->vma_size;</div>
<div class="ContentPasted0">>> @@ -612,10 +610,10 @@ xehpsdv_ppgtt_insert_huge(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>   static void gen8_ppgtt_insert_huge(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                   struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>>                                   struct sgt_dma *iter,</div>
<div class="ContentPasted0">>> -                                enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                                unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                   u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> -     const gen8_pte_t pte_encode = vm->pte_encode(0, cache_level, flags);</div>
<div class="ContentPasted0">>> +     const gen8_pte_t pte_encode = vm->pte_encode(0, pat_index, flags);</div>
<div class="ContentPasted0">>>        unsigned int rem = sg_dma_len(iter->sg);</div>
<div class="ContentPasted0">>>        u64 start = vma_res->start;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -735,7 +733,7 @@ static void gen8_ppgtt_insert_huge(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void gen8_ppgtt_insert(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                              struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                           enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                           unsigned int pat_index,</div>
<div class="ContentPasted0">>>                              u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_ppgtt * const ppgtt = i915_vm_to_ppgtt(vm);</div>
<div class="ContentPasted0">>> @@ -743,9 +741,9 @@ static void gen8_ppgtt_insert(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        if (vma_res->bi.page_sizes.sg > I915_GTT_PAGE_SIZE) {</div>
<div class="ContentPasted0">>>                if (GRAPHICS_VER_FULL(vm->i915) >= IP_VER(12, 50))</div>
<div class="ContentPasted0">>> -                     xehpsdv_ppgtt_insert_huge(vm, vma_res, &iter, cache_level, flags);</div>
<div class="ContentPasted0">>> +                     xehpsdv_ppgtt_insert_huge(vm, vma_res, &iter, pat_index, flags);</div>
<div class="ContentPasted0">>>                else</div>
<div class="ContentPasted0">>> -                     gen8_ppgtt_insert_huge(vm, vma_res, &iter, cache_level, flags);</div>
<div class="ContentPasted0">>> +                     gen8_ppgtt_insert_huge(vm, vma_res, &iter, pat_index, flags);</div>
<div class="ContentPasted0">>>        } else  {</div>
<div class="ContentPasted0">>>                u64 idx = vma_res->start >> GEN8_PTE_SHIFT;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -754,7 +752,7 @@ static void gen8_ppgtt_insert(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                gen8_pdp_for_page_index(vm, idx);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                        idx = gen8_ppgtt_insert_pte(ppgtt, pdp, &iter, idx,</div>
<div class="ContentPasted0">>> -                                                 cache_level, flags);</div>
<div class="ContentPasted0">>> +                                                 pat_index, flags);</div>
<div class="ContentPasted0">>>                } while (idx);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                vma_res->page_sizes_gtt = I915_GTT_PAGE_SIZE;</div>
<div class="ContentPasted0">>> @@ -764,7 +762,7 @@ static void gen8_ppgtt_insert(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>   static void gen8_ppgtt_insert_entry(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                    dma_addr_t addr,</div>
<div class="ContentPasted0">>>                                    u64 offset,</div>
<div class="ContentPasted0">>> -                                 enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                                 unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                    u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        u64 idx = offset >> GEN8_PTE_SHIFT;</div>
<div class="ContentPasted0">>> @@ -778,14 +776,14 @@ static void gen8_ppgtt_insert_entry(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>        GEM_BUG_ON(pt->is_compact);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        vaddr = px_vaddr(pt);</div>
<div class="ContentPasted0">>> -     vaddr[gen8_pd_index(idx, 0)] = vm->pte_encode(addr, level, flags);</div>
<div class="ContentPasted0">>> +     vaddr[gen8_pd_index(idx, 0)] = vm->pte_encode(addr, pat_index, flags);</div>
<div class="ContentPasted0">>>        drm_clflush_virt_range(&vaddr[gen8_pd_index(idx, 0)], sizeof(*vaddr));</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void __xehpsdv_ppgtt_insert_entry_lm(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                            dma_addr_t addr,</div>
<div class="ContentPasted0">>>                                            u64 offset,</div>
<div class="ContentPasted0">>> -                                         enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                                         unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                            u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        u64 idx = offset >> GEN8_PTE_SHIFT;</div>
<div class="ContentPasted0">>> @@ -808,20 +806,20 @@ static void __xehpsdv_ppgtt_insert_entry_lm(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>        }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        vaddr = px_vaddr(pt);</div>
<div class="ContentPasted0">>> -     vaddr[gen8_pd_index(idx, 0) / 16] = vm->pte_encode(addr, level, flags);</div>
<div class="ContentPasted0">>> +     vaddr[gen8_pd_index(idx, 0) / 16] = vm->pte_encode(addr, pat_index, flags);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void xehpsdv_ppgtt_insert_entry(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                       dma_addr_t addr,</div>
<div class="ContentPasted0">>>                                       u64 offset,</div>
<div class="ContentPasted0">>> -                                    enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                                    unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                       u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        if (flags & PTE_LM)</div>
<div class="ContentPasted0">>>                return __xehpsdv_ppgtt_insert_entry_lm(vm, addr, offset,</div>
<div class="ContentPasted0">>> -                                                    level, flags);</div>
<div class="ContentPasted0">>> +                                                    pat_index, flags);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     return gen8_ppgtt_insert_entry(vm, addr, offset, level, flags);</div>
<div class="ContentPasted0">>> +     return gen8_ppgtt_insert_entry(vm, addr, offset, pat_index, flags);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static int gen8_init_scratch(struct i915_address_space *vm)</div>
<div class="ContentPasted0">>> @@ -856,7 +854,9 @@ static int gen8_init_scratch(struct i915_address_space *vm)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        vm->scratch[0]->encode =</div>
<div class="ContentPasted0">>>                vm->pte_encode(px_dma(vm->scratch[0]),</div>
<div class="ContentPasted0">>> -                            I915_CACHE_NONE, pte_flags);</div>
<div class="ContentPasted0">>> +                            i915_gem_get_pat_index(vm->i915,</div>
<div class="ContentPasted0">>> +                                                   I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                            pte_flags);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        for (i = 1; i <= vm->top; i++) {</div>
<div class="ContentPasted0">>>                struct drm_i915_gem_object *obj;</div>
<div class="ContentPasted0">>> @@ -998,8 +998,8 @@ struct i915_ppgtt *gen8_ppgtt_create(struct intel_gt *gt,</div>
<div class="ContentPasted0">>>         */</div>
<div class="ContentPasted0">>>        ppgtt->vm.alloc_scratch_dma = alloc_pt_dma;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70))</div>
<div class="ContentPasted0">>> -             ppgtt->vm.pte_encode = mtl_pte_encode;</div>
<div class="ContentPasted0">>> +     if (GRAPHICS_VER(gt->i915) >= 12)</div>
<div class="ContentPasted0">>> +             ppgtt->vm.pte_encode = gen12_pte_encode;</div>
<div class="ContentPasted0">>>        else</div>
<div class="ContentPasted0">>>                ppgtt->vm.pte_encode = gen8_pte_encode;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/gen8_ppgtt.h b/drivers/gpu/drm/i915/gt/gen8_ppgtt.h</div>
<div class="ContentPasted0">>> index f541d19264b4..19c635441642 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/gen8_ppgtt.h</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/gen8_ppgtt.h</div>
<div class="ContentPasted0">>> @@ -10,13 +10,12 @@</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   struct i915_address_space;</div>
<div class="ContentPasted0">>>   struct intel_gt;</div>
<div class="ContentPasted0">>> -enum i915_cache_level;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   struct i915_ppgtt *gen8_ppgtt_create(struct intel_gt *gt,</div>
<div class="ContentPasted0">>>                                     unsigned long lmem_pt_obj_flags);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   u64 gen8_ggtt_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>> -                      enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                      unsigned int pat_index,</div>
<div class="ContentPasted0">>>                         u32 flags);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   #endif</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c</div>
<div class="ContentPasted0">>> index c8390d03fce2..2a7942fac798 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/intel_ggtt.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c</div>
<div class="ContentPasted0">>> @@ -221,7 +221,7 @@ static void guc_ggtt_invalidate(struct i915_ggtt *ggtt)</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static u64 mtl_ggtt_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>> -                            enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                            unsigned int pat_index,</div>
<div class="ContentPasted0">>>                               u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        gen8_pte_t pte = addr | GEN8_PAGE_PRESENT;</div>
<div class="ContentPasted0">>> @@ -231,30 +231,17 @@ static u64 mtl_ggtt_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>>        if (flags & PTE_LM)</div>
<div class="ContentPasted0">>>                pte |= GEN12_GGTT_PTE_LM;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     switch (level) {</div>
<div class="ContentPasted0">>> -     case I915_CACHE_NONE:</div>
<div class="ContentPasted0">>> -             pte |= MTL_GGTT_PTE_PAT1;</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -     case I915_CACHE_LLC:</div>
<div class="ContentPasted0">>> -     case I915_CACHE_L3_LLC:</div>
<div class="ContentPasted0">>> -             pte |= MTL_GGTT_PTE_PAT0 | MTL_GGTT_PTE_PAT1;</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -     case I915_CACHE_WT:</div>
<div class="ContentPasted0">>> +     if (pat_index & BIT(0))</div>
<div class="ContentPasted0">>>                pte |= MTL_GGTT_PTE_PAT0;</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -     default:</div>
<div class="ContentPasted0">>> -             /* This should never happen. Added to deal with the compile</div>
<div class="ContentPasted0">>> -              * error due to the addition of I915_MAX_CACHE_LEVEL. Will</div>
<div class="ContentPasted0">>> -              * be removed by the pat_index patch.</div>
<div class="ContentPasted0">>> -              */</div>
<div class="ContentPasted0">>> -             break;</div>
<div class="ContentPasted0">>> -     }</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     if (pat_index & BIT(1))</div>
<div class="ContentPasted0">>> +             pte |= MTL_GGTT_PTE_PAT1;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        return pte;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   u64 gen8_ggtt_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>> -                      enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                      unsigned int pat_index,</div>
<div class="ContentPasted0">>>                         u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        gen8_pte_t pte = addr | GEN8_PAGE_PRESENT;</div>
<div class="ContentPasted0">>> @@ -273,25 +260,25 @@ static void gen8_set_pte(void __iomem *addr, gen8_pte_t pte)</div>
<div class="ContentPasted0">>>   static void gen8_ggtt_insert_page(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                  dma_addr_t addr,</div>
<div class="ContentPasted0">>>                                  u64 offset,</div>
<div class="ContentPasted0">>> -                               enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                               unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                  u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);</div>
<div class="ContentPasted0">>>        gen8_pte_t __iomem *pte =</div>
<div class="ContentPasted0">>>                (gen8_pte_t __iomem *)ggtt->gsm + offset / I915_GTT_PAGE_SIZE;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     gen8_set_pte(pte, ggtt->vm.pte_encode(addr, level, flags));</div>
<div class="ContentPasted0">>> +     gen8_set_pte(pte, ggtt->vm.pte_encode(addr, pat_index, flags));</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        ggtt->invalidate(ggtt);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void gen8_ggtt_insert_entries(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                     struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                                  enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                                  unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                     u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);</div>
<div class="ContentPasted0">>> -     const gen8_pte_t pte_encode = ggtt->vm.pte_encode(0, level, flags);</div>
<div class="ContentPasted0">>> +     const gen8_pte_t pte_encode = ggtt->vm.pte_encode(0, pat_index, flags);</div>
<div class="ContentPasted0">>>        gen8_pte_t __iomem *gte;</div>
<div class="ContentPasted0">>>        gen8_pte_t __iomem *end;</div>
<div class="ContentPasted0">>>        struct sgt_iter iter;</div>
<div class="ContentPasted0">>> @@ -348,14 +335,14 @@ static void gen8_ggtt_clear_range(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>   static void gen6_ggtt_insert_page(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                  dma_addr_t addr,</div>
<div class="ContentPasted0">>>                                  u64 offset,</div>
<div class="ContentPasted0">>> -                               enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                               unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                  u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);</div>
<div class="ContentPasted0">>>        gen6_pte_t __iomem *pte =</div>
<div class="ContentPasted0">>>                (gen6_pte_t __iomem *)ggtt->gsm + offset / I915_GTT_PAGE_SIZE;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     iowrite32(vm->pte_encode(addr, level, flags), pte);</div>
<div class="ContentPasted0">>> +     iowrite32(vm->pte_encode(addr, pat_index, flags), pte);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        ggtt->invalidate(ggtt);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -368,7 +355,7 @@ static void gen6_ggtt_insert_page(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>    */</div>
<div class="ContentPasted0">>>   static void gen6_ggtt_insert_entries(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                     struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                                  enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                                  unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                     u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);</div>
<div class="ContentPasted0">>> @@ -385,7 +372,7 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                iowrite32(vm->scratch[0]->encode, gte++);</div>
<div class="ContentPasted0">>>        end += (vma_res->node_size + vma_res->guard) / I915_GTT_PAGE_SIZE;</div>
<div class="ContentPasted0">>>        for_each_sgt_daddr(addr, iter, vma_res->bi.pages)</div>
<div class="ContentPasted0">>> -             iowrite32(vm->pte_encode(addr, level, flags), gte++);</div>
<div class="ContentPasted0">>> +             iowrite32(vm->pte_encode(addr, pat_index, flags), gte++);</div>
<div class="ContentPasted0">>>        GEM_BUG_ON(gte > end);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        /* Fill the allocated but "unused" space beyond the end of the buffer */</div>
<div class="ContentPasted0">>> @@ -420,14 +407,15 @@ struct insert_page {</div>
<div class="ContentPasted0">>>        struct i915_address_space *vm;</div>
<div class="ContentPasted0">>>        dma_addr_t addr;</div>
<div class="ContentPasted0">>>        u64 offset;</div>
<div class="ContentPasted0">>> -     enum i915_cache_level level;</div>
<div class="ContentPasted0">>> +     unsigned int pat_index;</div>
<div class="ContentPasted0">>>   };</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static int bxt_vtd_ggtt_insert_page__cb(void *_arg)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct insert_page *arg = _arg;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     gen8_ggtt_insert_page(arg->vm, arg->addr, arg->offset, arg->level, 0);</div>
<div class="ContentPasted0">>> +     gen8_ggtt_insert_page(arg->vm, arg->addr, arg->offset,</div>
<div class="ContentPasted0">>> +                           arg->pat_index, 0);</div>
<div class="ContentPasted0">>>        bxt_vtd_ggtt_wa(arg->vm);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        return 0;</div>
<div class="ContentPasted0">>> @@ -436,10 +424,10 @@ static int bxt_vtd_ggtt_insert_page__cb(void *_arg)</div>
<div class="ContentPasted0">>>   static void bxt_vtd_ggtt_insert_page__BKL(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                          dma_addr_t addr,</div>
<div class="ContentPasted0">>>                                          u64 offset,</div>
<div class="ContentPasted0">>> -                                       enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                                       unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                          u32 unused)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> -     struct insert_page arg = { vm, addr, offset, level };</div>
<div class="ContentPasted0">>> +     struct insert_page arg = { vm, addr, offset, pat_index };</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        stop_machine(bxt_vtd_ggtt_insert_page__cb, &arg, NULL);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -447,7 +435,7 @@ static void bxt_vtd_ggtt_insert_page__BKL(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>   struct insert_entries {</div>
<div class="ContentPasted0">>>        struct i915_address_space *vm;</div>
<div class="ContentPasted0">>>        struct i915_vma_resource *vma_res;</div>
<div class="ContentPasted0">>> -     enum i915_cache_level level;</div>
<div class="ContentPasted0">>> +     unsigned int pat_index;</div>
<div class="ContentPasted0">>>        u32 flags;</div>
<div class="ContentPasted0">>>   };</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -455,7 +443,8 @@ static int bxt_vtd_ggtt_insert_entries__cb(void *_arg)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct insert_entries *arg = _arg;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     gen8_ggtt_insert_entries(arg->vm, arg->vma_res, arg->level, arg->flags);</div>
<div class="ContentPasted0">>> +     gen8_ggtt_insert_entries(arg->vm, arg->vma_res,</div>
<div class="ContentPasted0">>> +                              arg->pat_index, arg->flags);</div>
<div class="ContentPasted0">>>        bxt_vtd_ggtt_wa(arg->vm);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        return 0;</div>
<div class="ContentPasted0">>> @@ -463,10 +452,10 @@ static int bxt_vtd_ggtt_insert_entries__cb(void *_arg)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void bxt_vtd_ggtt_insert_entries__BKL(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                             struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                                          enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                                          unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                             u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> -     struct insert_entries arg = { vm, vma_res, level, flags };</div>
<div class="ContentPasted0">>> +     struct insert_entries arg = { vm, vma_res, pat_index, flags };</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        stop_machine(bxt_vtd_ggtt_insert_entries__cb, &arg, NULL);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -495,7 +484,7 @@ static void gen6_ggtt_clear_range(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>   void intel_ggtt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                         struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                         struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                      enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                      unsigned int pat_index,</div>
<div class="ContentPasted0">>>                         u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        u32 pte_flags;</div>
<div class="ContentPasted0">>> @@ -512,7 +501,7 @@ void intel_ggtt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>        if (vma_res->bi.lmem)</div>
<div class="ContentPasted0">>>                pte_flags |= PTE_LM;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     vm->insert_entries(vm, vma_res, cache_level, pte_flags);</div>
<div class="ContentPasted0">>> +     vm->insert_entries(vm, vma_res, pat_index, pte_flags);</div>
<div class="ContentPasted0">>>        vma_res->page_sizes_gtt = I915_GTT_PAGE_SIZE;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -661,7 +650,7 @@ static int init_ggtt(struct i915_ggtt *ggtt)</div>
<div class="ContentPasted0">>>   static void aliasing_gtt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                  struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                                  struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                               enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                               unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                  u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        u32 pte_flags;</div>
<div class="ContentPasted0">>> @@ -673,10 +662,10 @@ static void aliasing_gtt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        if (flags & I915_VMA_LOCAL_BIND)</div>
<div class="ContentPasted0">>>                ppgtt_bind_vma(&i915_vm_to_ggtt(vm)->alias->vm,</div>
<div class="ContentPasted0">>> -                            stash, vma_res, cache_level, flags);</div>
<div class="ContentPasted0">>> +                            stash, vma_res, pat_index, flags);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        if (flags & I915_VMA_GLOBAL_BIND)</div>
<div class="ContentPasted0">>> -             vm->insert_entries(vm, vma_res, cache_level, pte_flags);</div>
<div class="ContentPasted0">>> +             vm->insert_entries(vm, vma_res, pat_index, pte_flags);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        vma_res->bound_flags |= flags;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -933,7 +922,9 @@ static int ggtt_probe_common(struct i915_ggtt *ggtt, u64 size)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        ggtt->vm.scratch[0]->encode =</div>
<div class="ContentPasted0">>>                ggtt->vm.pte_encode(px_dma(ggtt->vm.scratch[0]),</div>
<div class="ContentPasted0">>> -                                 I915_CACHE_NONE, pte_flags);</div>
<div class="ContentPasted0">>> +                                 i915_gem_get_pat_index(i915,</div>
<div class="ContentPasted0">>> +                                                        I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                 pte_flags);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        return 0;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -1022,6 +1013,11 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)</div>
<div class="ContentPasted0">>>        return ggtt_probe_common(ggtt, size);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> +/*</div>
<div class="ContentPasted0">>> + * For pre-gen8 platforms pat_index is the same as enum i915_cache_level,</div>
<div class="ContentPasted0">>> + * so these PTE encode functions are left with using cache_level.</div>
<div class="ContentPasted0">>> + * See translation table LEGACY_CACHELEVEL.</div>
<div class="ContentPasted0">>> + */</div>
<div class="ContentPasted0">>>   static u64 snb_pte_encode(dma_addr_t addr,</div>
<div class="ContentPasted0">>>                          enum i915_cache_level level,</div>
<div class="ContentPasted0">>>                          u32 flags)</div>
<div class="ContentPasted0">>> @@ -1302,7 +1298,9 @@ bool i915_ggtt_resume_vm(struct i915_address_space *vm)</div>
<div class="ContentPasted0">>>                 */</div>
<div class="ContentPasted0">>>                vma->resource->bound_flags = 0;</div>
<div class="ContentPasted0">>>                vma->ops->bind_vma(vm, NULL, vma->resource,</div>
<div class="ContentPasted0">>> -                                obj ? obj->cache_level : 0,</div>
<div class="ContentPasted0">>> +                                obj ? obj->pat_index :</div>
<div class="ContentPasted0">>> +                                      i915_gem_get_pat_index(vm->i915,</div>
<div class="ContentPasted0">>> +                                                             I915_CACHE_NONE),</div>
<div class="ContentPasted0">>>                                   was_bound);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                if (obj) { /* only used during resume => exclusive access */</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h b/drivers/gpu/drm/i915/gt/intel_gtt.h</div>
<div class="ContentPasted0">>> index 9aff343beaa8..4d6296cdbcfd 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/intel_gtt.h</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/intel_gtt.h</div>
<div class="ContentPasted0">>> @@ -163,8 +163,6 @@ typedef u64 gen8_pte_t;</div>
<div class="ContentPasted0">>>   #define MTL_3_COH_2W        REG_FIELD_PREP(MTL_PAT_INDEX_COH_MODE_MASK, 3)</div>
<div class="ContentPasted0">>>   #define MTL_2_COH_1W        REG_FIELD_PREP(MTL_PAT_INDEX_COH_MODE_MASK, 2)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -enum i915_cache_level;</div>
<div class="ContentPasted0">>> -</div>
<div class="ContentPasted0">>>   struct drm_i915_gem_object;</div>
<div class="ContentPasted0">>>   struct i915_fence_reg;</div>
<div class="ContentPasted0">>>   struct i915_vma;</div>
<div class="ContentPasted0">>> @@ -232,7 +230,7 @@ struct i915_vma_ops {</div>
<div class="ContentPasted0">>>        void (*bind_vma)(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                         struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                         struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                      enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                      unsigned int pat_index,</div>
<div class="ContentPasted0">>>                         u32 flags);</div>
<div class="ContentPasted0">>>        /*</div>
<div class="ContentPasted0">>>         * Unmap an object from an address space. This usually consists of</div>
<div class="ContentPasted0">>> @@ -304,7 +302,7 @@ struct i915_address_space {</div>
<div class="ContentPasted0">>>                (*alloc_scratch_dma)(struct i915_address_space *vm, int sz);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        u64 (*pte_encode)(dma_addr_t addr,</div>
<div class="ContentPasted0">>> -                       enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                       unsigned int pat_index,</div>
<div class="ContentPasted0">>>                          u32 flags); /* Create a valid PTE */</div>
<div class="ContentPasted0">>>   #define PTE_READ_ONLY       BIT(0)</div>
<div class="ContentPasted0">>>   #define PTE_LM              BIT(1)</div>
<div class="ContentPasted0">>> @@ -319,20 +317,20 @@ struct i915_address_space {</div>
<div class="ContentPasted0">>>        void (*insert_page)(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                            dma_addr_t addr,</div>
<div class="ContentPasted0">>>                            u64 offset,</div>
<div class="ContentPasted0">>> -                         enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                         unsigned int pat_index,</div>
<div class="ContentPasted0">>>                            u32 flags);</div>
<div class="ContentPasted0">>>        void (*insert_entries)(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                               struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                            enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                            unsigned int pat_index,</div>
<div class="ContentPasted0">>>                               u32 flags);</div>
<div class="ContentPasted0">>>        void (*raw_insert_page)(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                dma_addr_t addr,</div>
<div class="ContentPasted0">>>                                u64 offset,</div>
<div class="ContentPasted0">>> -                             enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                             unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                u32 flags);</div>
<div class="ContentPasted0">>>        void (*raw_insert_entries)(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                   struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                                enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                                unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                   u32 flags);</div>
<div class="ContentPasted0">>>        void (*cleanup)(struct i915_address_space *vm);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -579,7 +577,7 @@ void ppgtt_init(struct i915_ppgtt *ppgtt, struct intel_gt *gt,</div>
<div class="ContentPasted0">>>   void intel_ggtt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                         struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                         struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                      enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                      unsigned int pat_index,</div>
<div class="ContentPasted0">>>                         u32 flags);</div>
<div class="ContentPasted0">>>   void intel_ggtt_unbind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                           struct i915_vma_resource *vma_res);</div>
<div class="ContentPasted0">>> @@ -657,7 +655,7 @@ void gen6_ggtt_invalidate(struct i915_ggtt *ggtt);</div>
<div class="ContentPasted0">>>   void ppgtt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                    struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                    struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                 enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                 unsigned int pat_index,</div>
<div class="ContentPasted0">>>                    u32 flags);</div>
<div class="ContentPasted0">>>   void ppgtt_unbind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                      struct i915_vma_resource *vma_res);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/intel_migrate.c b/drivers/gpu/drm/i915/gt/intel_migrate.c</div>
<div class="ContentPasted0">>> index e0998879a0e1..6023288b0e2d 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/intel_migrate.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/intel_migrate.c</div>
<div class="ContentPasted0">>> @@ -45,7 +45,9 @@ static void xehpsdv_toggle_pdes(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>         * Insert a dummy PTE into every PT that will map to LMEM to ensure</div>
<div class="ContentPasted0">>>         * we have a correctly setup PDE structure for later use.</div>
<div class="ContentPasted0">>>         */</div>
<div class="ContentPasted0">>> -     vm->insert_page(vm, 0, d->offset, I915_CACHE_NONE, PTE_LM);</div>
<div class="ContentPasted0">>> +     vm->insert_page(vm, 0, d->offset,</div>
<div class="ContentPasted0">>> +                     i915_gem_get_pat_index(vm->i915, I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                     PTE_LM);</div>
<div class="ContentPasted0">>>        GEM_BUG_ON(!pt->is_compact);</div>
<div class="ContentPasted0">>>        d->offset += SZ_2M;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -63,7 +65,9 @@ static void xehpsdv_insert_pte(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>         * alignment is 64K underneath for the pt, and we are careful</div>
<div class="ContentPasted0">>>         * not to access the space in the void.</div>
<div class="ContentPasted0">>>         */</div>
<div class="ContentPasted0">>> -     vm->insert_page(vm, px_dma(pt), d->offset, I915_CACHE_NONE, PTE_LM);</div>
<div class="ContentPasted0">>> +     vm->insert_page(vm, px_dma(pt), d->offset,</div>
<div class="ContentPasted0">>> +                     i915_gem_get_pat_index(vm->i915, I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                     PTE_LM);</div>
<div class="ContentPasted0">>>        d->offset += SZ_64K;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -73,7 +77,8 @@ static void insert_pte(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct insert_pte_data *d = data;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     vm->insert_page(vm, px_dma(pt), d->offset, I915_CACHE_NONE,</div>
<div class="ContentPasted0">>> +     vm->insert_page(vm, px_dma(pt), d->offset,</div>
<div class="ContentPasted0">>> +                     i915_gem_get_pat_index(vm->i915, I915_CACHE_NONE),</div>
<div class="ContentPasted0">>>                        i915_gem_object_is_lmem(pt->base) ? PTE_LM : 0);</div>
<div class="ContentPasted0">>>        d->offset += PAGE_SIZE;</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -356,13 +361,13 @@ static int max_pte_pkt_size(struct i915_request *rq, int pkt)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static int emit_pte(struct i915_request *rq,</div>
<div class="ContentPasted0">>>                    struct sgt_dma *it,</div>
<div class="ContentPasted0">>> -                 enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                 unsigned int pat_index,</div>
<div class="ContentPasted0">>>                    bool is_lmem,</div>
<div class="ContentPasted0">>>                    u64 offset,</div>
<div class="ContentPasted0">>>                    int length)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        bool has_64K_pages = HAS_64K_PAGES(rq->engine->i915);</div>
<div class="ContentPasted0">>> -     const u64 encode = rq->context->vm->pte_encode(0, cache_level,</div>
<div class="ContentPasted0">>> +     const u64 encode = rq->context->vm->pte_encode(0, pat_index,</div>
<div class="ContentPasted0">>>                                                       is_lmem ? PTE_LM : 0);</div>
<div class="ContentPasted0">>>        struct intel_ring *ring = rq->ring;</div>
<div class="ContentPasted0">>>        int pkt, dword_length;</div>
<div class="ContentPasted0">>> @@ -673,17 +678,17 @@ int</div>
<div class="ContentPasted0">>>   intel_context_migrate_copy(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                           const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                           struct scatterlist *src,</div>
<div class="ContentPasted0">>> -                        enum i915_cache_level src_cache_level,</div>
<div class="ContentPasted0">>> +                        unsigned int src_pat_index,</div>
<div class="ContentPasted0">>>                           bool src_is_lmem,</div>
<div class="ContentPasted0">>>                           struct scatterlist *dst,</div>
<div class="ContentPasted0">>> -                        enum i915_cache_level dst_cache_level,</div>
<div class="ContentPasted0">>> +                        unsigned int dst_pat_index,</div>
<div class="ContentPasted0">>>                           bool dst_is_lmem,</div>
<div class="ContentPasted0">>>                           struct i915_request **out)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        struct sgt_dma it_src = sg_sgt(src), it_dst = sg_sgt(dst), it_ccs;</div>
<div class="ContentPasted0">>>        struct drm_i915_private *i915 = ce->engine->i915;</div>
<div class="ContentPasted0">>>        u64 ccs_bytes_to_cpy = 0, bytes_to_cpy;</div>
<div class="ContentPasted0">>> -     enum i915_cache_level ccs_cache_level;</div>
<div class="ContentPasted0">>> +     unsigned int ccs_pat_index;</div>
<div class="ContentPasted0">>>        u32 src_offset, dst_offset;</div>
<div class="ContentPasted0">>>        u8 src_access, dst_access;</div>
<div class="ContentPasted0">>>        struct i915_request *rq;</div>
<div class="ContentPasted0">>> @@ -707,12 +712,12 @@ intel_context_migrate_copy(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                dst_sz = scatter_list_length(dst);</div>
<div class="ContentPasted0">>>                if (src_is_lmem) {</div>
<div class="ContentPasted0">>>                        it_ccs = it_dst;</div>
<div class="ContentPasted0">>> -                     ccs_cache_level = dst_cache_level;</div>
<div class="ContentPasted0">>> +                     ccs_pat_index = dst_pat_index;</div>
<div class="ContentPasted0">>>                        ccs_is_src = false;</div>
<div class="ContentPasted0">>>                } else if (dst_is_lmem) {</div>
<div class="ContentPasted0">>>                        bytes_to_cpy = dst_sz;</div>
<div class="ContentPasted0">>>                        it_ccs = it_src;</div>
<div class="ContentPasted0">>> -                     ccs_cache_level = src_cache_level;</div>
<div class="ContentPasted0">>> +                     ccs_pat_index = src_pat_index;</div>
<div class="ContentPasted0">>>                        ccs_is_src = true;</div>
<div class="ContentPasted0">>>                }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -773,7 +778,7 @@ intel_context_migrate_copy(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                src_sz = calculate_chunk_sz(i915, src_is_lmem,</div>
<div class="ContentPasted0">>>                                            bytes_to_cpy, ccs_bytes_to_cpy);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -             len = emit_pte(rq, &it_src, src_cache_level, src_is_lmem,</div>
<div class="ContentPasted0">>> +             len = emit_pte(rq, &it_src, src_pat_index, src_is_lmem,</div>
<div class="ContentPasted0">>>                               src_offset, src_sz);</div>
<div class="ContentPasted0">>>                if (!len) {</div>
<div class="ContentPasted0">>>                        err = -EINVAL;</div>
<div class="ContentPasted0">>> @@ -784,7 +789,7 @@ intel_context_migrate_copy(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                        goto out_rq;</div>
<div class="ContentPasted0">>>                }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -             err = emit_pte(rq, &it_dst, dst_cache_level, dst_is_lmem,</div>
<div class="ContentPasted0">>> +             err = emit_pte(rq, &it_dst, dst_pat_index, dst_is_lmem,</div>
<div class="ContentPasted0">>>                               dst_offset, len);</div>
<div class="ContentPasted0">>>                if (err < 0)</div>
<div class="ContentPasted0">>>                        goto out_rq;</div>
<div class="ContentPasted0">>> @@ -811,7 +816,7 @@ intel_context_migrate_copy(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                                goto out_rq;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                        ccs_sz = GET_CCS_BYTES(i915, len);</div>
<div class="ContentPasted0">>> -                     err = emit_pte(rq, &it_ccs, ccs_cache_level, false,</div>
<div class="ContentPasted0">>> +                     err = emit_pte(rq, &it_ccs, ccs_pat_index, false,</div>
<div class="ContentPasted0">>>                                       ccs_is_src ? src_offset : dst_offset,</div>
<div class="ContentPasted0">>>                                       ccs_sz);</div>
<div class="ContentPasted0">>>                        if (err < 0)</div>
<div class="ContentPasted0">>> @@ -979,7 +984,7 @@ int</div>
<div class="ContentPasted0">>>   intel_context_migrate_clear(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                            const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                            struct scatterlist *sg,</div>
<div class="ContentPasted0">>> -                         enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                         unsigned int pat_index,</div>
<div class="ContentPasted0">>>                            bool is_lmem,</div>
<div class="ContentPasted0">>>                            u32 value,</div>
<div class="ContentPasted0">>>                            struct i915_request **out)</div>
<div class="ContentPasted0">>> @@ -1027,7 +1032,7 @@ intel_context_migrate_clear(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                if (err)</div>
<div class="ContentPasted0">>>                        goto out_rq;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -             len = emit_pte(rq, &it, cache_level, is_lmem, offset, CHUNK_SZ);</div>
<div class="ContentPasted0">>> +             len = emit_pte(rq, &it, pat_index, is_lmem, offset, CHUNK_SZ);</div>
<div class="ContentPasted0">>>                if (len <= 0) {</div>
<div class="ContentPasted0">>>                        err = len;</div>
<div class="ContentPasted0">>>                        goto out_rq;</div>
<div class="ContentPasted0">>> @@ -1074,10 +1079,10 @@ int intel_migrate_copy(struct intel_migrate *m,</div>
<div class="ContentPasted0">>>                       struct i915_gem_ww_ctx *ww,</div>
<div class="ContentPasted0">>>                       const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                       struct scatterlist *src,</div>
<div class="ContentPasted0">>> -                    enum i915_cache_level src_cache_level,</div>
<div class="ContentPasted0">>> +                    unsigned int src_pat_index,</div>
<div class="ContentPasted0">>>                       bool src_is_lmem,</div>
<div class="ContentPasted0">>>                       struct scatterlist *dst,</div>
<div class="ContentPasted0">>> -                    enum i915_cache_level dst_cache_level,</div>
<div class="ContentPasted0">>> +                    unsigned int dst_pat_index,</div>
<div class="ContentPasted0">>>                       bool dst_is_lmem,</div>
<div class="ContentPasted0">>>                       struct i915_request **out)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> @@ -1098,8 +1103,8 @@ int intel_migrate_copy(struct intel_migrate *m,</div>
<div class="ContentPasted0">>>                goto out;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        err = intel_context_migrate_copy(ce, deps,</div>
<div class="ContentPasted0">>> -                                      src, src_cache_level, src_is_lmem,</div>
<div class="ContentPasted0">>> -                                      dst, dst_cache_level, dst_is_lmem,</div>
<div class="ContentPasted0">>> +                                      src, src_pat_index, src_is_lmem,</div>
<div class="ContentPasted0">>> +                                      dst, dst_pat_index, dst_is_lmem,</div>
<div class="ContentPasted0">>>                                         out);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        intel_context_unpin(ce);</div>
<div class="ContentPasted0">>> @@ -1113,7 +1118,7 @@ intel_migrate_clear(struct intel_migrate *m,</div>
<div class="ContentPasted0">>>                    struct i915_gem_ww_ctx *ww,</div>
<div class="ContentPasted0">>>                    const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                    struct scatterlist *sg,</div>
<div class="ContentPasted0">>> -                 enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                 unsigned int pat_index,</div>
<div class="ContentPasted0">>>                    bool is_lmem,</div>
<div class="ContentPasted0">>>                    u32 value,</div>
<div class="ContentPasted0">>>                    struct i915_request **out)</div>
<div class="ContentPasted0">>> @@ -1134,7 +1139,7 @@ intel_migrate_clear(struct intel_migrate *m,</div>
<div class="ContentPasted0">>>        if (err)</div>
<div class="ContentPasted0">>>                goto out;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     err = intel_context_migrate_clear(ce, deps, sg, cache_level,</div>
<div class="ContentPasted0">>> +     err = intel_context_migrate_clear(ce, deps, sg, pat_index,</div>
<div class="ContentPasted0">>>                                          is_lmem, value, out);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        intel_context_unpin(ce);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/intel_migrate.h b/drivers/gpu/drm/i915/gt/intel_migrate.h</div>
<div class="ContentPasted0">>> index ccc677ec4aa3..11fc09a00c4b 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/intel_migrate.h</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/intel_migrate.h</div>
<div class="ContentPasted0">>> @@ -16,7 +16,6 @@ struct i915_request;</div>
<div class="ContentPasted0">>>   struct i915_gem_ww_ctx;</div>
<div class="ContentPasted0">>>   struct intel_gt;</div>
<div class="ContentPasted0">>>   struct scatterlist;</div>
<div class="ContentPasted0">>> -enum i915_cache_level;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   int intel_migrate_init(struct intel_migrate *m, struct intel_gt *gt);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -26,20 +25,20 @@ int intel_migrate_copy(struct intel_migrate *m,</div>
<div class="ContentPasted0">>>                       struct i915_gem_ww_ctx *ww,</div>
<div class="ContentPasted0">>>                       const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                       struct scatterlist *src,</div>
<div class="ContentPasted0">>> -                    enum i915_cache_level src_cache_level,</div>
<div class="ContentPasted0">>> +                    unsigned int src_pat_index,</div>
<div class="ContentPasted0">>>                       bool src_is_lmem,</div>
<div class="ContentPasted0">>>                       struct scatterlist *dst,</div>
<div class="ContentPasted0">>> -                    enum i915_cache_level dst_cache_level,</div>
<div class="ContentPasted0">>> +                    unsigned int dst_pat_index,</div>
<div class="ContentPasted0">>>                       bool dst_is_lmem,</div>
<div class="ContentPasted0">>>                       struct i915_request **out);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   int intel_context_migrate_copy(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                               const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                               struct scatterlist *src,</div>
<div class="ContentPasted0">>> -                            enum i915_cache_level src_cache_level,</div>
<div class="ContentPasted0">>> +                            unsigned int src_pat_index,</div>
<div class="ContentPasted0">>>                               bool src_is_lmem,</div>
<div class="ContentPasted0">>>                               struct scatterlist *dst,</div>
<div class="ContentPasted0">>> -                            enum i915_cache_level dst_cache_level,</div>
<div class="ContentPasted0">>> +                            unsigned int dst_pat_index,</div>
<div class="ContentPasted0">>>                               bool dst_is_lmem,</div>
<div class="ContentPasted0">>>                               struct i915_request **out);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -48,7 +47,7 @@ intel_migrate_clear(struct intel_migrate *m,</div>
<div class="ContentPasted0">>>                    struct i915_gem_ww_ctx *ww,</div>
<div class="ContentPasted0">>>                    const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                    struct scatterlist *sg,</div>
<div class="ContentPasted0">>> -                 enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                 unsigned int pat_index,</div>
<div class="ContentPasted0">>>                    bool is_lmem,</div>
<div class="ContentPasted0">>>                    u32 value,</div>
<div class="ContentPasted0">>>                    struct i915_request **out);</div>
<div class="ContentPasted0">>> @@ -56,7 +55,7 @@ int</div>
<div class="ContentPasted0">>>   intel_context_migrate_clear(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                            const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                            struct scatterlist *sg,</div>
<div class="ContentPasted0">>> -                         enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                         unsigned int pat_index,</div>
<div class="ContentPasted0">>>                            bool is_lmem,</div>
<div class="ContentPasted0">>>                            u32 value,</div>
<div class="ContentPasted0">>>                            struct i915_request **out);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c b/drivers/gpu/drm/i915/gt/intel_ppgtt.c</div>
<div class="ContentPasted0">>> index 7ecfa672f738..436756bfbb1a 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c</div>
<div class="ContentPasted0">>> @@ -181,7 +181,7 @@ struct i915_ppgtt *i915_ppgtt_create(struct intel_gt *gt,</div>
<div class="ContentPasted0">>>   void ppgtt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                    struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                    struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                 enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                 unsigned int pat_index,</div>
<div class="ContentPasted0">>>                    u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        u32 pte_flags;</div>
<div class="ContentPasted0">>> @@ -199,7 +199,7 @@ void ppgtt_bind_vma(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>        if (vma_res->bi.lmem)</div>
<div class="ContentPasted0">>>                pte_flags |= PTE_LM;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     vm->insert_entries(vm, vma_res, cache_level, pte_flags);</div>
<div class="ContentPasted0">>> +     vm->insert_entries(vm, vma_res, pat_index, pte_flags);</div>
<div class="ContentPasted0">>>        wmb();</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/selftest_migrate.c b/drivers/gpu/drm/i915/gt/selftest_migrate.c</div>
<div class="ContentPasted0">>> index e677f2da093d..3def5ca72dec 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/selftest_migrate.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/selftest_migrate.c</div>
<div class="ContentPasted0">>> @@ -137,7 +137,7 @@ static int copy(struct intel_migrate *migrate,</div>
<div class="ContentPasted0">>>   static int intel_context_copy_ccs(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                                  const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                                  struct scatterlist *sg,</div>
<div class="ContentPasted0">>> -                               enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                               unsigned int pat_index,</div>
<div class="ContentPasted0">>>                                  bool write_to_ccs,</div>
<div class="ContentPasted0">>>                                  struct i915_request **out)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> @@ -185,7 +185,7 @@ static int intel_context_copy_ccs(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                if (err)</div>
<div class="ContentPasted0">>>                        goto out_rq;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -             len = emit_pte(rq, &it, cache_level, true, offset, CHUNK_SZ);</div>
<div class="ContentPasted0">>> +             len = emit_pte(rq, &it, pat_index, true, offset, CHUNK_SZ);</div>
<div class="ContentPasted0">>>                if (len <= 0) {</div>
<div class="ContentPasted0">>>                        err = len;</div>
<div class="ContentPasted0">>>                        goto out_rq;</div>
<div class="ContentPasted0">>> @@ -223,7 +223,7 @@ intel_migrate_ccs_copy(struct intel_migrate *m,</div>
<div class="ContentPasted0">>>                       struct i915_gem_ww_ctx *ww,</div>
<div class="ContentPasted0">>>                       const struct i915_deps *deps,</div>
<div class="ContentPasted0">>>                       struct scatterlist *sg,</div>
<div class="ContentPasted0">>> -                    enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                    unsigned int pat_index,</div>
<div class="ContentPasted0">>>                       bool write_to_ccs,</div>
<div class="ContentPasted0">>>                       struct i915_request **out)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> @@ -243,7 +243,7 @@ intel_migrate_ccs_copy(struct intel_migrate *m,</div>
<div class="ContentPasted0">>>        if (err)</div>
<div class="ContentPasted0">>>                goto out;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -     err = intel_context_copy_ccs(ce, deps, sg, cache_level,</div>
<div class="ContentPasted0">>> +     err = intel_context_copy_ccs(ce, deps, sg, pat_index,</div>
<div class="ContentPasted0">>>                                     write_to_ccs, out);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        intel_context_unpin(ce);</div>
<div class="ContentPasted0">>> @@ -300,7 +300,7 @@ static int clear(struct intel_migrate *migrate,</div>
<div class="ContentPasted0">>>                        /* Write the obj data into ccs surface */</div>
<div class="ContentPasted0">>>                        err = intel_migrate_ccs_copy(migrate, &ww, NULL,</div>
<div class="ContentPasted0">>>                                                     obj->mm.pages->sgl,</div>
<div class="ContentPasted0">>> -                                                  obj->cache_level,</div>
<div class="ContentPasted0">>> +                                                  obj->pat_index,</div>
<div class="ContentPasted0">>>                                                     true, &rq);</div>
<div class="ContentPasted0">>>                        if (rq && !err) {</div>
<div class="ContentPasted0">>>                                if (i915_request_wait(rq, 0, HZ) < 0) {</div>
<div class="ContentPasted0">>> @@ -351,7 +351,7 @@ static int clear(struct intel_migrate *migrate,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                        err = intel_migrate_ccs_copy(migrate, &ww, NULL,</div>
<div class="ContentPasted0">>>                                                     obj->mm.pages->sgl,</div>
<div class="ContentPasted0">>> -                                                  obj->cache_level,</div>
<div class="ContentPasted0">>> +                                                  obj->pat_index,</div>
<div class="ContentPasted0">>>                                                     false, &rq);</div>
<div class="ContentPasted0">>>                        if (rq && !err) {</div>
<div class="ContentPasted0">>>                                if (i915_request_wait(rq, 0, HZ) < 0) {</div>
<div class="ContentPasted0">>> @@ -414,9 +414,9 @@ static int __migrate_copy(struct intel_migrate *migrate,</div>
<div class="ContentPasted0">>>                          struct i915_request **out)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        return intel_migrate_copy(migrate, ww, NULL,</div>
<div class="ContentPasted0">>> -                               src->mm.pages->sgl, src->cache_level,</div>
<div class="ContentPasted0">>> +                               src->mm.pages->sgl, src->pat_index,</div>
<div class="ContentPasted0">>>                                  i915_gem_object_is_lmem(src),</div>
<div class="ContentPasted0">>> -                               dst->mm.pages->sgl, dst->cache_level,</div>
<div class="ContentPasted0">>> +                               dst->mm.pages->sgl, dst->pat_index,</div>
<div class="ContentPasted0">>>                                  i915_gem_object_is_lmem(dst),</div>
<div class="ContentPasted0">>>                                  out);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -428,9 +428,9 @@ static int __global_copy(struct intel_migrate *migrate,</div>
<div class="ContentPasted0">>>                         struct i915_request **out)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        return intel_context_migrate_copy(migrate->context, NULL,</div>
<div class="ContentPasted0">>> -                                       src->mm.pages->sgl, src->cache_level,</div>
<div class="ContentPasted0">>> +                                       src->mm.pages->sgl, src->pat_index,</div>
<div class="ContentPasted0">>>                                          i915_gem_object_is_lmem(src),</div>
<div class="ContentPasted0">>> -                                       dst->mm.pages->sgl, dst->cache_level,</div>
<div class="ContentPasted0">>> +                                       dst->mm.pages->sgl, dst->pat_index,</div>
<div class="ContentPasted0">>>                                          i915_gem_object_is_lmem(dst),</div>
<div class="ContentPasted0">>>                                          out);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -455,7 +455,7 @@ static int __migrate_clear(struct intel_migrate *migrate,</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        return intel_migrate_clear(migrate, ww, NULL,</div>
<div class="ContentPasted0">>>                                   obj->mm.pages->sgl,</div>
<div class="ContentPasted0">>> -                                obj->cache_level,</div>
<div class="ContentPasted0">>> +                                obj->pat_index,</div>
<div class="ContentPasted0">>>                                   i915_gem_object_is_lmem(obj),</div>
<div class="ContentPasted0">>>                                   value, out);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -468,7 +468,7 @@ static int __global_clear(struct intel_migrate *migrate,</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        return intel_context_migrate_clear(migrate->context, NULL,</div>
<div class="ContentPasted0">>>                                           obj->mm.pages->sgl,</div>
<div class="ContentPasted0">>> -                                        obj->cache_level,</div>
<div class="ContentPasted0">>> +                                        obj->pat_index,</div>
<div class="ContentPasted0">>>                                           i915_gem_object_is_lmem(obj),</div>
<div class="ContentPasted0">>>                                           value, out);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>> @@ -648,7 +648,7 @@ static int live_emit_pte_full_ring(void *arg)</div>
<div class="ContentPasted0">>>         */</div>
<div class="ContentPasted0">>>        pr_info("%s emite_pte ring space=%u\n", __func__, rq->ring->space);</div>
<div class="ContentPasted0">>>        it = sg_sgt(obj->mm.pages->sgl);</div>
<div class="ContentPasted0">>> -     len = emit_pte(rq, &it, obj->cache_level, false, 0, CHUNK_SZ);</div>
<div class="ContentPasted0">>> +     len = emit_pte(rq, &it, obj->pat_index, false, 0, CHUNK_SZ);</div>
<div class="ContentPasted0">>>        if (!len) {</div>
<div class="ContentPasted0">>>                err = -EINVAL;</div>
<div class="ContentPasted0">>>                goto out_rq;</div>
<div class="ContentPasted0">>> @@ -844,7 +844,7 @@ static int wrap_ktime_compare(const void *A, const void *B)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static int __perf_clear_blt(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                            struct scatterlist *sg,</div>
<div class="ContentPasted0">>> -                         enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                         unsigned int pat_index,</div>
<div class="ContentPasted0">>>                            bool is_lmem,</div>
<div class="ContentPasted0">>>                            size_t sz)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> @@ -858,7 +858,7 @@ static int __perf_clear_blt(struct intel_context *ce,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                t0 = ktime_get();</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -             err = intel_context_migrate_clear(ce, NULL, sg, cache_level,</div>
<div class="ContentPasted0">>> +             err = intel_context_migrate_clear(ce, NULL, sg, pat_index,</div>
<div class="ContentPasted0">>>                                                  is_lmem, 0, &rq);</div>
<div class="ContentPasted0">>>                if (rq) {</div>
<div class="ContentPasted0">>>                        if (i915_request_wait(rq, 0, MAX_SCHEDULE_TIMEOUT) < 0)</div>
<div class="ContentPasted0">>> @@ -904,7 +904,8 @@ static int perf_clear_blt(void *arg)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                err = __perf_clear_blt(gt->migrate.context,</div>
<div class="ContentPasted0">>>                                       dst->mm.pages->sgl,</div>
<div class="ContentPasted0">>> -                                    I915_CACHE_NONE,</div>
<div class="ContentPasted0">>> +                                    i915_gem_get_pat_index(gt->i915,</div>
<div class="ContentPasted0">>> +                                                           I915_CACHE_NONE),</div>
<div class="ContentPasted0">>>                                       i915_gem_object_is_lmem(dst),</div>
<div class="ContentPasted0">>>                                       sizes[i]);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -919,10 +920,10 @@ static int perf_clear_blt(void *arg)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static int __perf_copy_blt(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                           struct scatterlist *src,</div>
<div class="ContentPasted0">>> -                        enum i915_cache_level src_cache_level,</div>
<div class="ContentPasted0">>> +                        unsigned int src_pat_index,</div>
<div class="ContentPasted0">>>                           bool src_is_lmem,</div>
<div class="ContentPasted0">>>                           struct scatterlist *dst,</div>
<div class="ContentPasted0">>> -                        enum i915_cache_level dst_cache_level,</div>
<div class="ContentPasted0">>> +                        unsigned int dst_pat_index,</div>
<div class="ContentPasted0">>>                           bool dst_is_lmem,</div>
<div class="ContentPasted0">>>                           size_t sz)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> @@ -937,9 +938,9 @@ static int __perf_copy_blt(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                t0 = ktime_get();</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                err = intel_context_migrate_copy(ce, NULL,</div>
<div class="ContentPasted0">>> -                                              src, src_cache_level,</div>
<div class="ContentPasted0">>> +                                              src, src_pat_index,</div>
<div class="ContentPasted0">>>                                                 src_is_lmem,</div>
<div class="ContentPasted0">>> -                                              dst, dst_cache_level,</div>
<div class="ContentPasted0">>> +                                              dst, dst_pat_index,</div>
<div class="ContentPasted0">>>                                                 dst_is_lmem,</div>
<div class="ContentPasted0">>>                                                 &rq);</div>
<div class="ContentPasted0">>>                if (rq) {</div>
<div class="ContentPasted0">>> @@ -994,10 +995,12 @@ static int perf_copy_blt(void *arg)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                err = __perf_copy_blt(gt->migrate.context,</div>
<div class="ContentPasted0">>>                                      src->mm.pages->sgl,</div>
<div class="ContentPasted0">>> -                                   I915_CACHE_NONE,</div>
<div class="ContentPasted0">>> +                                   i915_gem_get_pat_index(gt->i915,</div>
<div class="ContentPasted0">>> +                                                          I915_CACHE_NONE),</div>
<div class="ContentPasted0">>>                                      i915_gem_object_is_lmem(src),</div>
<div class="ContentPasted0">>>                                      dst->mm.pages->sgl,</div>
<div class="ContentPasted0">>> -                                   I915_CACHE_NONE,</div>
<div class="ContentPasted0">>> +                                   i915_gem_get_pat_index(gt->i915,</div>
<div class="ContentPasted0">>> +                                                          I915_CACHE_NONE),</div>
<div class="ContentPasted0">>>                                      i915_gem_object_is_lmem(dst),</div>
<div class="ContentPasted0">>>                                      sz);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c b/drivers/gpu/drm/i915/gt/selftest_reset.c</div>
<div class="ContentPasted0">>> index a9e0a91bc0e0..79aa6ac66ad2 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/selftest_reset.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/selftest_reset.c</div>
<div class="ContentPasted0">>> @@ -86,7 +86,9 @@ __igt_reset_stolen(struct intel_gt *gt,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                ggtt->vm.insert_page(&ggtt->vm, dma,</div>
<div class="ContentPasted0">>>                                     ggtt->error_capture.start,</div>
<div class="ContentPasted0">>> -                                  I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                  i915_gem_get_pat_index(gt->i915,</div>
<div class="ContentPasted0">>> +                                                         I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                  0);</div>
<div class="ContentPasted0">>>                mb();</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                s = io_mapping_map_wc(&ggtt->iomap,</div>
<div class="ContentPasted0">>> @@ -127,7 +129,9 @@ __igt_reset_stolen(struct intel_gt *gt,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                ggtt->vm.insert_page(&ggtt->vm, dma,</div>
<div class="ContentPasted0">>>                                     ggtt->error_capture.start,</div>
<div class="ContentPasted0">>> -                                  I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                  i915_gem_get_pat_index(gt->i915,</div>
<div class="ContentPasted0">>> +                                                         I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                  0);</div>
<div class="ContentPasted0">>>                mb();</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                s = io_mapping_map_wc(&ggtt->iomap,</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/selftest_timeline.c b/drivers/gpu/drm/i915/gt/selftest_timeline.c</div>
<div class="ContentPasted0">>> index 9f536c251179..39c3ec12df1a 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/selftest_timeline.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/selftest_timeline.c</div>
<div class="ContentPasted0">>> @@ -836,7 +836,7 @@ static int setup_watcher(struct hwsp_watcher *w, struct intel_gt *gt,</div>
<div class="ContentPasted0">>>                return PTR_ERR(obj);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        /* keep the same cache settings as timeline */</div>
<div class="ContentPasted0">>> -     i915_gem_object_set_cache_coherency(obj, tl->hwsp_ggtt->obj->cache_level);</div>
<div class="ContentPasted0">>> +     i915_gem_object_set_pat_index(obj, tl->hwsp_ggtt->obj->pat_index);</div>
<div class="ContentPasted0">>>        w->map = i915_gem_object_pin_map_unlocked(obj,</div>
<div class="ContentPasted0">>>                                                  page_unmask_bits(tl->hwsp_ggtt->obj->mm.mapping));</div>
<div class="ContentPasted0">>>        if (IS_ERR(w->map)) {</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/selftest_tlb.c b/drivers/gpu/drm/i915/gt/selftest_tlb.c</div>
<div class="ContentPasted0">>> index e6cac1f15d6e..4493c8518e91 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/selftest_tlb.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/selftest_tlb.c</div>
<div class="ContentPasted0">>> @@ -36,6 +36,8 @@ pte_tlbinv(struct intel_context *ce,</div>
<div class="ContentPasted0">>>           u64 length,</div>
<div class="ContentPasted0">>>           struct rnd_state *prng)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> +     const unsigned int pat_index =</div>
<div class="ContentPasted0">>> +             i915_gem_get_pat_index(ce->vm->i915, I915_CACHE_NONE);</div>
<div class="ContentPasted0">>>        struct drm_i915_gem_object *batch;</div>
<div class="ContentPasted0">>>        struct drm_mm_node vb_node;</div>
<div class="ContentPasted0">>>        struct i915_request *rq;</div>
<div class="ContentPasted0">>> @@ -155,7 +157,7 @@ pte_tlbinv(struct intel_context *ce,</div>
<div class="ContentPasted0">>>                /* Flip the PTE between A and B */</div>
<div class="ContentPasted0">>>                if (i915_gem_object_is_lmem(vb->obj))</div>
<div class="ContentPasted0">>>                        pte_flags |= PTE_LM;</div>
<div class="ContentPasted0">>> -             ce->vm->insert_entries(ce->vm, &vb_res, 0, pte_flags);</div>
<div class="ContentPasted0">>> +             ce->vm->insert_entries(ce->vm, &vb_res, pat_index, pte_flags);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                /* Flush the PTE update to concurrent HW */</div>
<div class="ContentPasted0">>>                tlbinv(ce->vm, addr & -length, length);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c</div>
<div class="ContentPasted0">>> index 4ec7df9ed5ff..e34c79120090 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c</div>
<div class="ContentPasted0">>> @@ -957,9 +957,15 @@ static void uc_fw_bind_ggtt(struct intel_uc_fw *uc_fw)</div>
<div class="ContentPasted0">>>                pte_flags |= PTE_LM;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        if (ggtt->vm.raw_insert_entries)</div>
<div class="ContentPasted0">>> -             ggtt->vm.raw_insert_entries(&ggtt->vm, dummy, I915_CACHE_NONE, pte_flags);</div>
<div class="ContentPasted0">>> +             ggtt->vm.raw_insert_entries(&ggtt->vm, dummy,</div>
<div class="ContentPasted0">>> +                                         i915_gem_get_pat_index(ggtt->vm.i915,</div>
<div class="ContentPasted0">>> +                                                                I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                         pte_flags);</div>
<div class="ContentPasted0">>>        else</div>
<div class="ContentPasted0">>> -             ggtt->vm.insert_entries(&ggtt->vm, dummy, I915_CACHE_NONE, pte_flags);</div>
<div class="ContentPasted0">>> +             ggtt->vm.insert_entries(&ggtt->vm, dummy,</div>
<div class="ContentPasted0">>> +                                     i915_gem_get_pat_index(ggtt->vm.i915,</div>
<div class="ContentPasted0">>> +                                                            I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                     pte_flags);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void uc_fw_unbind_ggtt(struct intel_uc_fw *uc_fw)</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c</div>
<div class="ContentPasted0">>> index 41389a32e998..76ccd4e03e31 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/i915_debugfs.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/i915_debugfs.c</div>
<div class="ContentPasted0">>> @@ -139,21 +139,54 @@ static const char *stringify_vma_type(const struct i915_vma *vma)</div>
<div class="ContentPasted0">>>        return "ppgtt";</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -static const char *i915_cache_level_str(struct drm_i915_private *i915, int type)</div>
<div class="ContentPasted0">>> -{</div>
<div class="ContentPasted0">>> -     switch (type) {</div>
<div class="ContentPasted0">>> -     case I915_CACHE_NONE: return " uncached";</div>
<div class="ContentPasted0">>> -     case I915_CACHE_LLC: return HAS_LLC(i915) ? " LLC" : " snooped";</div>
<div class="ContentPasted0">>> -     case I915_CACHE_L3_LLC: return " L3+LLC";</div>
<div class="ContentPasted0">>> -     case I915_CACHE_WT: return " WT";</div>
<div class="ContentPasted0">>> -     default: return "";</div>
<div class="ContentPasted0">>> +static const char *i915_cache_level_str(struct drm_i915_gem_object *obj)</div>
<div class="ContentPasted0">>> +{</div>
<div class="ContentPasted0">>> +     struct drm_i915_private *i915 = obj_to_i915(obj);</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>> +     if (IS_METEORLAKE(i915)) {</div>
<div class="ContentPasted0">>> +             switch (obj->pat_index) {</div>
<div class="ContentPasted0">>> +             case 0: return " WB";</div>
<div class="ContentPasted0">>> +             case 1: return " WT";</div>
<div class="ContentPasted0">>> +             case 2: return " UC";</div>
<div class="ContentPasted0">>> +             case 3: return " WB (1-Way Coh)";</div>
<div class="ContentPasted0">>> +             case 4: return " WB (2-Way Coh)";</div>
<div class="ContentPasted0">>> +             default: return " not defined";</div>
<div class="ContentPasted0">>> +             }</div>
<div class="ContentPasted0">>> +     } else if (IS_PONTEVECCHIO(i915)) {</div>
<div class="ContentPasted0">>> +             switch (obj->pat_index) {</div>
<div class="ContentPasted0">>> +             case 0: return " UC";</div>
<div class="ContentPasted0">>> +             case 1: return " WC";</div>
<div class="ContentPasted0">>> +             case 2: return " WT";</div>
<div class="ContentPasted0">>> +             case 3: return " WB";</div>
<div class="ContentPasted0">>> +             case 4: return " WT (CLOS1)";</div>
<div class="ContentPasted0">>> +             case 5: return " WB (CLOS1)";</div>
<div class="ContentPasted0">>> +             case 6: return " WT (CLOS2)";</div>
<div class="ContentPasted0">>> +             case 7: return " WT (CLOS2)";</div>
<div class="ContentPasted0">>> +             default: return " not defined";</div>
<div class="ContentPasted0">>> +             }</div>
<div class="ContentPasted0">>> +     } else if (GRAPHICS_VER(i915) >= 12) {</div>
<div class="ContentPasted0">>> +             switch (obj->pat_index) {</div>
<div class="ContentPasted0">>> +             case 0: return " WB";</div>
<div class="ContentPasted0">>> +             case 1: return " WC";</div>
<div class="ContentPasted0">>> +             case 2: return " WT";</div>
<div class="ContentPasted0">>> +             case 3: return " UC";</div>
<div class="ContentPasted0">>> +             default: return " not defined";</div>
<div class="ContentPasted0">>> +             }</div>
<div class="ContentPasted0">>> +     } else {</div>
<div class="ContentPasted0">>> +             switch (obj->pat_index) {</div>
<div class="ContentPasted0">>> +             case 0: return " UC";</div>
<div class="ContentPasted0">>> +             case 1: return HAS_LLC(i915) ?</div>
<div class="ContentPasted0">>> +                            " LLC" : " snooped";</div>
<div class="ContentPasted0">>> +             case 2: return " L3+LLC";</div>
<div class="ContentPasted0">>> +             case 3: return " WT";</div>
<div class="ContentPasted0">>> +             default: return " not defined";</div>
<div class="ContentPasted0">>> +             }</div>
<div class="ContentPasted0">>>        }</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   void</div>
<div class="ContentPasted0">>>   i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>> -     struct drm_i915_private *dev_priv = to_i915(obj->base.dev);</div>
<div class="ContentPasted0">>>        struct i915_vma *vma;</div>
<div class="ContentPasted0">>>        int pin_count = 0;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -165,7 +198,7 @@ i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)</div>
<div class="ContentPasted0">>>                   obj->base.size / 1024,</div>
<div class="ContentPasted0">>>                   obj->read_domains,</div>
<div class="ContentPasted0">>>                   obj->write_domain,</div>
<div class="ContentPasted0">>> -                i915_cache_level_str(dev_priv, obj->cache_level),</div>
<div class="ContentPasted0">>> +                i915_cache_level_str(obj),</div>
<div class="ContentPasted0">>>                   obj->mm.dirty ? " dirty" : "",</div>
<div class="ContentPasted0">>>                   obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : "");</div>
<div class="ContentPasted0">>>        if (obj->base.name)</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c</div>
<div class="ContentPasted0">>> index 0a78bdbd36b1..38933c00f705 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/i915_gem.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/i915_gem.c</div>
<div class="ContentPasted0">>> @@ -420,8 +420,11 @@ i915_gem_gtt_pread(struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>>                page_length = remain < page_length ? remain : page_length;</div>
<div class="ContentPasted0">>>                if (drm_mm_node_allocated(&node)) {</div>
<div class="ContentPasted0">>>                        ggtt->vm.insert_page(&ggtt->vm,</div>
<div class="ContentPasted0">>> -                                          i915_gem_object_get_dma_address(obj, offset >> PAGE_SHIFT),</div>
<div class="ContentPasted0">>> -                                          node.start, I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                          i915_gem_object_get_dma_address(obj,</div>
<div class="ContentPasted0">>> +                                                                          offset >> PAGE_SHIFT),</div>
<div class="ContentPasted0">>> +                                          node.start,</div>
<div class="ContentPasted0">>> +                                          i915_gem_get_pat_index(i915,</div>
<div class="ContentPasted0">>> +                                                                 I915_CACHE_NONE), 0);</div>
<div class="ContentPasted0">>>                } else {</div>
<div class="ContentPasted0">>>                        page_base += offset & PAGE_MASK;</div>
<div class="ContentPasted0">>>                }</div>
<div class="ContentPasted0">>> @@ -598,8 +601,11 @@ i915_gem_gtt_pwrite_fast(struct drm_i915_gem_object *obj,</div>
<div class="ContentPasted0">>>                        /* flush the write before we modify the GGTT */</div>
<div class="ContentPasted0">>>                        intel_gt_flush_ggtt_writes(ggtt->vm.gt);</div>
<div class="ContentPasted0">>>                        ggtt->vm.insert_page(&ggtt->vm,</div>
<div class="ContentPasted0">>> -                                          i915_gem_object_get_dma_address(obj, offset >> PAGE_SHIFT),</div>
<div class="ContentPasted0">>> -                                          node.start, I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                          i915_gem_object_get_dma_address(obj,</div>
<div class="ContentPasted0">>> +                                                                          offset >> PAGE_SHIFT),</div>
<div class="ContentPasted0">>> +                                          node.start,</div>
<div class="ContentPasted0">>> +                                          i915_gem_get_pat_index(i915,</div>
<div class="ContentPasted0">>> +                                                                 I915_CACHE_NONE), 0);</div>
<div class="ContentPasted0">>>                        wmb(); /* flush modifications to the GGTT (insert_page) */</div>
<div class="ContentPasted0">>>                } else {</div>
<div class="ContentPasted0">>>                        page_base += offset & PAGE_MASK;</div>
<div class="ContentPasted0">>> @@ -1142,6 +1148,19 @@ int i915_gem_init(struct drm_i915_private *dev_priv)</div>
<div class="ContentPasted0">>>        unsigned int i;</div>
<div class="ContentPasted0">>>        int ret;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> +     /*</div>
<div class="ContentPasted0">>> +      * In the proccess of replacing cache_level with pat_index a tricky</div>
<div class="ContentPasted0">>> +      * dependency is created on the definition of the enum i915_cache_level.</div>
<div class="ContentPasted0">>> +      * in case this enum is changed, PTE encode would be broken.</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">>_I_n</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Sorry, what does this mean?</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">>> +      * Add a WARNING here. And remove when we completely quit using this</div>
<div class="ContentPasted0">>> +      * enum</div>
<div class="ContentPasted0">>> +      */</div>
<div class="ContentPasted0">>> +     WARN_ON_ONCE(I915_CACHE_NONE != 0 ||</div>
<div class="ContentPasted0">>> +                  I915_CACHE_LLC != 1 ||</div>
<div class="ContentPasted0">>> +                  I915_CACHE_L3_LLC != 2 ||</div>
<div class="ContentPasted0">>> +                  I915_CACHE_WT != 3 ||</div>
<div class="ContentPasted0">>> +                  I915_MAX_CACHE_LEVEL != 4);</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">> I thought BUILD_BUG_ON would be better.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Of course, don't know what I was thinking, updated in v8.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">>> +</div>
<div class="ContentPasted0">>>        /* We need to fallback to 4K pages if host doesn't support huge gtt. */</div>
<div class="ContentPasted0">>>        if (intel_vgpu_active(dev_priv) && !intel_vgpu_has_huge_gtt(dev_priv))</div>
<div class="ContentPasted0">>>                RUNTIME_INFO(dev_priv)->page_sizes = I915_GTT_PAGE_SIZE_4K;</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c</div>
<div class="ContentPasted0">>> index 8ffdd7f47e93..566536499954 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/i915_gpu_error.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c</div>
<div class="ContentPasted0">>> @@ -1122,10 +1122,14 @@ i915_vma_coredump_create(const struct intel_gt *gt,</div>
<div class="ContentPasted0">>>                        mutex_lock(&ggtt->error_mutex);</div>
<div class="ContentPasted0">>>                        if (ggtt->vm.raw_insert_page)</div>
<div class="ContentPasted0">>>                                ggtt->vm.raw_insert_page(&ggtt->vm, dma, slot,</div>
<div class="ContentPasted0">>> -                                                      I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                                      i915_gem_get_pat_index(gt->i915,</div>
<div class="ContentPasted0">>> +                                                                             I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                                      0);</div>
<div class="ContentPasted0">>>                        else</div>
<div class="ContentPasted0">>>                                ggtt->vm.insert_page(&ggtt->vm, dma, slot,</div>
<div class="ContentPasted0">>> -                                                  I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                                  i915_gem_get_pat_index(gt->i915,</div>
<div class="ContentPasted0">>> +                                                                         I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                                  0);</div>
<div class="ContentPasted0">>>                        mb();</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                        s = io_mapping_map_wc(&ggtt->iomap, slot, PAGE_SIZE);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c</div>
<div class="ContentPasted0">>> index 20a44788999e..a814775a363d 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/i915_vma.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/i915_vma.c</div>
<div class="ContentPasted0">>> @@ -315,7 +315,7 @@ struct i915_vma_work {</div>
<div class="ContentPasted0">>>        struct i915_vma_resource *vma_res;</div>
<div class="ContentPasted0">>>        struct drm_i915_gem_object *obj;</div>
<div class="ContentPasted0">>>        struct i915_sw_dma_fence_cb cb;</div>
<div class="ContentPasted0">>> -     enum i915_cache_level cache_level;</div>
<div class="ContentPasted0">>> +     unsigned int pat_index;</div>
<div class="ContentPasted0">>>        unsigned int flags;</div>
<div class="ContentPasted0">>>   };</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -334,7 +334,7 @@ static void __vma_bind(struct dma_fence_work *work)</div>
<div class="ContentPasted0">>>                return;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        vma_res->ops->bind_vma(vma_res->vm, &vw->stash,</div>
<div class="ContentPasted0">>> -                            vma_res, vw->cache_level, vw->flags);</div>
<div class="ContentPasted0">>> +                            vma_res, vw->pat_index, vw->flags);</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void __vma_release(struct dma_fence_work *work)</div>
<div class="ContentPasted0">>> @@ -426,7 +426,7 @@ i915_vma_resource_init_from_vma(struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>>   /**</div>
<div class="ContentPasted0">>>    * i915_vma_bind - Sets up PTEs for an VMA in it's corresponding address space.</div>
<div class="ContentPasted0">>>    * @vma: VMA to map</div>
<div class="ContentPasted0">>> - * @cache_level: mapping cache level</div>
<div class="ContentPasted0">>> + * @pat_index: PAT index to set in PTE</div>
<div class="ContentPasted0">>>    * @flags: flags like global or local mapping</div>
<div class="ContentPasted0">>>    * @work: preallocated worker for allocating and binding the PTE</div>
<div class="ContentPasted0">>>    * @vma_res: pointer to a preallocated vma resource. The resource is either</div>
<div class="ContentPasted0">>> @@ -437,7 +437,7 @@ i915_vma_resource_init_from_vma(struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>>    * Note that DMA addresses are also the only part of the SG table we care about.</div>
<div class="ContentPasted0">>>    */</div>
<div class="ContentPasted0">>>   int i915_vma_bind(struct i915_vma *vma,</div>
<div class="ContentPasted0">>> -               enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +               unsigned int pat_index,</div>
<div class="ContentPasted0">>>                  u32 flags,</div>
<div class="ContentPasted0">>>                  struct i915_vma_work *work,</div>
<div class="ContentPasted0">>>                  struct i915_vma_resource *vma_res)</div>
<div class="ContentPasted0">>> @@ -507,7 +507,7 @@ int i915_vma_bind(struct i915_vma *vma,</div>
<div class="ContentPasted0">>>                struct dma_fence *prev;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                work->vma_res = i915_vma_resource_get(vma->resource);</div>
<div class="ContentPasted0">>> -             work->cache_level = cache_level;</div>
<div class="ContentPasted0">>> +             work->pat_index = pat_index;</div>
<div class="ContentPasted0">>>                work->flags = bind_flags;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                /*</div>
<div class="ContentPasted0">>> @@ -537,7 +537,7 @@ int i915_vma_bind(struct i915_vma *vma,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                        return ret;</div>
<div class="ContentPasted0">>>                }</div>
<div class="ContentPasted0">>> -             vma->ops->bind_vma(vma->vm, NULL, vma->resource, cache_level,</div>
<div class="ContentPasted0">>> +             vma->ops->bind_vma(vma->vm, NULL, vma->resource, pat_index,</div>
<div class="ContentPasted0">>>                                   bind_flags);</div>
<div class="ContentPasted0">>>        }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -814,7 +814,7 @@ i915_vma_insert(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,</div>
<div class="ContentPasted0">>>        color = 0;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        if (i915_vm_has_cache_coloring(vma->vm))</div>
<div class="ContentPasted0">>> -             color = vma->obj->cache_level;</div>
<div class="ContentPasted0">>> +             color = vma->obj->pat_index;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        if (flags & PIN_OFFSET_FIXED) {</div>
<div class="ContentPasted0">>>                u64 offset = flags & PIN_OFFSET_MASK;</div>
<div class="ContentPasted0">>> @@ -1518,7 +1518,7 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        GEM_BUG_ON(!vma->pages);</div>
<div class="ContentPasted0">>>        err = i915_vma_bind(vma,</div>
<div class="ContentPasted0">>> -                         vma->obj->cache_level,</div>
<div class="ContentPasted0">>> +                         vma->obj->pat_index,</div>
<div class="ContentPasted0">>>                            flags, work, vma_res);</div>
<div class="ContentPasted0">>>        vma_res = NULL;</div>
<div class="ContentPasted0">>>        if (err)</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h</div>
<div class="ContentPasted0">>> index 38c8c66ed724..9a9729205d5b 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/i915_vma.h</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/i915_vma.h</div>
<div class="ContentPasted0">>> @@ -250,7 +250,7 @@ i915_vma_compare(struct i915_vma *vma,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   struct i915_vma_work *i915_vma_work(void);</div>
<div class="ContentPasted0">>>   int i915_vma_bind(struct i915_vma *vma,</div>
<div class="ContentPasted0">>> -               enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +               unsigned int pat_index,</div>
<div class="ContentPasted0">>>                  u32 flags,</div>
<div class="ContentPasted0">>>                  struct i915_vma_work *work,</div>
<div class="ContentPasted0">>>                  struct i915_vma_resource *vma_res);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/i915_vma_types.h b/drivers/gpu/drm/i915/i915_vma_types.h</div>
<div class="ContentPasted0">>> index 77fda2244d16..64472b7f0e77 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/i915_vma_types.h</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/i915_vma_types.h</div>
<div class="ContentPasted0">>> @@ -32,8 +32,6 @@</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   #include "gem/i915_gem_object_types.h"</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -enum i915_cache_level;</div>
<div class="ContentPasted0">>> -</div>
<div class="ContentPasted0">>>   /**</div>
<div class="ContentPasted0">>>    * DOC: Global GTT views</div>
<div class="ContentPasted0">>>    *</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem.c b/drivers/gpu/drm/i915/selftests/i915_gem.c</div>
<div class="ContentPasted0">>> index d91d0ade8abd..61da4ed9d521 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/selftests/i915_gem.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/selftests/i915_gem.c</div>
<div class="ContentPasted0">>> @@ -57,7 +57,10 @@ static void trash_stolen(struct drm_i915_private *i915)</div>
<div class="ContentPasted0">>>                u32 __iomem *s;</div>
<div class="ContentPasted0">>>                int x;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> -             ggtt->vm.insert_page(&ggtt->vm, dma, slot, I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +             ggtt->vm.insert_page(&ggtt->vm, dma, slot,</div>
<div class="ContentPasted0">>> +                                  i915_gem_get_pat_index(i915,</div>
<div class="ContentPasted0">>> +                                                         I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                  0);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                s = io_mapping_map_atomic_wc(&ggtt->iomap, slot);</div>
<div class="ContentPasted0">>>                for (x = 0; x < PAGE_SIZE / sizeof(u32); x++) {</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c</div>
<div class="ContentPasted0">>> index f68ef4074088..f8fe3681c3dc 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c</div>
<div class="ContentPasted0">>> @@ -246,7 +246,7 @@ static int igt_evict_for_cache_color(void *arg)</div>
<div class="ContentPasted0">>>        struct drm_mm_node target = {</div>
<div class="ContentPasted0">>>                .start = I915_GTT_PAGE_SIZE * 2,</div>
<div class="ContentPasted0">>>                .size = I915_GTT_PAGE_SIZE,</div>
<div class="ContentPasted0">>> -             .color = I915_CACHE_LLC,</div>
<div class="ContentPasted0">>> +             .color = i915_gem_get_pat_index(gt->i915, I915_CACHE_LLC),</div>
<div class="ContentPasted0">>>        };</div>
<div class="ContentPasted0">>>        struct drm_i915_gem_object *obj;</div>
<div class="ContentPasted0">>>        struct i915_vma *vma;</div>
<div class="ContentPasted0">>> @@ -309,7 +309,7 @@ static int igt_evict_for_cache_color(void *arg)</div>
<div class="ContentPasted0">>>        /* Attempt to remove the first *pinned* vma, by removing the (empty)</div>
<div class="ContentPasted0">>>         * neighbour -- this should fail.</div>
<div class="ContentPasted0">>>         */</div>
<div class="ContentPasted0">>> -     target.color = I915_CACHE_L3_LLC;</div>
<div class="ContentPasted0">>> +     target.color = i915_gem_get_pat_index(gt->i915, I915_CACHE_L3_LLC);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        mutex_lock(&ggtt->vm.mutex);</div>
<div class="ContentPasted0">>>        err = i915_gem_evict_for_node(&ggtt->vm, NULL, &target, 0);</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c</div>
<div class="ContentPasted0">>> index 154801f1c468..36940ef10108 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c</div>
<div class="ContentPasted0">>> @@ -135,7 +135,7 @@ fake_dma_object(struct drm_i915_private *i915, u64 size)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        obj->write_domain = I915_GEM_DOMAIN_CPU;</div>
<div class="ContentPasted0">>>        obj->read_domains = I915_GEM_DOMAIN_CPU;</div>
<div class="ContentPasted0">>> -     obj->cache_level = I915_CACHE_NONE;</div>
<div class="ContentPasted0">>> +     obj->pat_index = i915_gem_get_pat_index(i915, I915_CACHE_NONE);</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        /* Preallocate the "backing storage" */</div>
<div class="ContentPasted0">>>        if (i915_gem_object_pin_pages_unlocked(obj))</div>
<div class="ContentPasted0">>> @@ -359,7 +359,9 @@ static int lowlevel_hole(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                        with_intel_runtime_pm(vm->gt->uncore->rpm, wakeref)</div>
<div class="ContentPasted0">>>                          vm->insert_entries(vm, mock_vma_res,</div>
<div class="ContentPasted0">>> -                                                I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                          i915_gem_get_pat_index(vm->i915,</div>
<div class="ContentPasted0">>> +                                                                 I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                          0);</div>
<div class="ContentPasted0">>>                }</div>
<div class="ContentPasted0">>>                count = n;</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>> @@ -1377,7 +1379,10 @@ static int igt_ggtt_page(void *arg)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>                ggtt->vm.insert_page(&ggtt->vm,</div>
<div class="ContentPasted0">>>                                     i915_gem_object_get_dma_address(obj, 0),</div>
<div class="ContentPasted0">>> -                                  offset, I915_CACHE_NONE, 0);</div>
<div class="ContentPasted0">>> +                                  offset,</div>
<div class="ContentPasted0">>> +                                  i915_gem_get_pat_index(i915,</div>
<div class="ContentPasted0">>> +                                                         I915_CACHE_NONE),</div>
<div class="ContentPasted0">>> +                                  0);</div>
<div class="ContentPasted0">>>        }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        order = i915_random_order(count, &prng);</div>
<div class="ContentPasted0">>> @@ -1510,7 +1515,7 @@ static int reserve_gtt_with_resource(struct i915_vma *vma, u64 offset)</div>
<div class="ContentPasted0">>>        mutex_lock(&vm->mutex);</div>
<div class="ContentPasted0">>>        err = i915_gem_gtt_reserve(vm, NULL, &vma->node, obj->base.size,</div>
<div class="ContentPasted0">>>                                   offset,</div>
<div class="ContentPasted0">>> -                                obj->cache_level,</div>
<div class="ContentPasted0">>> +                                obj->pat_index,</div>
<div class="ContentPasted0">>>                                   0);</div>
<div class="ContentPasted0">>>        if (!err) {</div>
<div class="ContentPasted0">>>                i915_vma_resource_init_from_vma(vma_res, vma);</div>
<div class="ContentPasted0">>> @@ -1690,7 +1695,7 @@ static int insert_gtt_with_resource(struct i915_vma *vma)</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>        mutex_lock(&vm->mutex);</div>
<div class="ContentPasted0">>>        err = i915_gem_gtt_insert(vm, NULL, &vma->node, obj->base.size, 0,</div>
<div class="ContentPasted0">>> -                               obj->cache_level, 0, vm->total, 0);</div>
<div class="ContentPasted0">>> +                               obj->pat_index, 0, vm->total, 0);</div>
<div class="ContentPasted0">>>        if (!err) {</div>
<div class="ContentPasted0">>>                i915_vma_resource_init_from_vma(vma_res, vma);</div>
<div class="ContentPasted0">>>                vma->resource = vma_res;</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c</div>
<div class="ContentPasted0">>> index 3b18e5905c86..d985d9bae2e8 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c</div>
<div class="ContentPasted0">>> @@ -1070,7 +1070,9 @@ static int igt_lmem_write_cpu(void *arg)</div>
<div class="ContentPasted0">>>        /* Put the pages into a known state -- from the gpu for added fun */</div>
<div class="ContentPasted0">>>        intel_engine_pm_get(engine);</div>
<div class="ContentPasted0">>>        err = intel_context_migrate_clear(engine->gt->migrate.context, NULL,</div>
<div class="ContentPasted0">>> -                                       obj->mm.pages->sgl, I915_CACHE_NONE,</div>
<div class="ContentPasted0">>> +                                       obj->mm.pages->sgl,</div>
<div class="ContentPasted0">>> +                                       i915_gem_get_pat_index(i915,</div>
<div class="ContentPasted0">>> +                                                              I915_CACHE_NONE),</div>
<div class="ContentPasted0">>>                                          true, 0xdeadbeaf, &rq);</div>
<div class="ContentPasted0">>>        if (rq) {</div>
<div class="ContentPasted0">>>                dma_resv_add_fence(obj->base.resv, &rq->fence,</div>
<div class="ContentPasted0">>> diff --git a/drivers/gpu/drm/i915/selftests/mock_gtt.c b/drivers/gpu/drm/i915/selftests/mock_gtt.c</div>
<div class="ContentPasted0">>> index ece97e4faacb..a516c0aa88fd 100644</div>
<div class="ContentPasted0">>> --- a/drivers/gpu/drm/i915/selftests/mock_gtt.c</div>
<div class="ContentPasted0">>> +++ b/drivers/gpu/drm/i915/selftests/mock_gtt.c</div>
<div class="ContentPasted0">>> @@ -27,21 +27,21 @@</div>
<div class="ContentPasted0">>>   static void mock_insert_page(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                             dma_addr_t addr,</div>
<div class="ContentPasted0">>>                             u64 offset,</div>
<div class="ContentPasted0">>> -                          enum i915_cache_level level,</div>
<div class="ContentPasted0">>> +                          unsigned int pat_index,</div>
<div class="ContentPasted0">>>                             u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void mock_insert_entries(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                                struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                             enum i915_cache_level level, u32 flags)</div>
<div class="ContentPasted0">>> +                             unsigned int pat_index, u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">>>  </div>
<div class="ContentPasted0">>>   static void mock_bind_ppgtt(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                            struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                            struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                         enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                         unsigned int pat_index,</div>
<div class="ContentPasted0">>>                            u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>        GEM_BUG_ON(flags & I915_VMA_GLOBAL_BIND);</div>
<div class="ContentPasted0">>> @@ -94,7 +94,7 @@ struct i915_ppgtt *mock_ppgtt(struct drm_i915_private *i915, const char *name)</div>
<div class="ContentPasted0">>>   static void mock_bind_ggtt(struct i915_address_space *vm,</div>
<div class="ContentPasted0">>>                           struct i915_vm_pt_stash *stash,</div>
<div class="ContentPasted0">>>                           struct i915_vma_resource *vma_res,</div>
<div class="ContentPasted0">>> -                        enum i915_cache_level cache_level,</div>
<div class="ContentPasted0">>> +                        unsigned int pat_index,</div>
<div class="ContentPasted0">>>                           u32 flags)</div>
<div class="ContentPasted0">>>   {</div>
<div class="ContentPasted0">>>   }</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">> With a pinky promise to improve this all in the near future I won't</div>
<div class="ContentPasted0">> grumble to loudly. :) I haven't read all the details, I leave that to</div>
<div class="ContentPasted0">> other reviewers, and also assuming some final tweaks as indicated above</div>
<div class="ContentPasted0">> please.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Thanks for all the suggestions, really appreciated.</div>
<div class="ContentPasted0">May I add your Acked-by?</div>
<div><br class="ContentPasted0">
</div>
<div>-Fei</div>
<div><br>
</div>
<div class="ContentPasted0">> Regards,</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">> Tvrtko</div>
<br>
</div>
</body>
</html>