drm/i915: Allow user to set cache at BO creation
v2 cover drm/i915: Allow user to set cache at BO creation
From: Fei Yang <[email protected]>
The first three patches in this series are taken from
https://patchwork.freedesktop.org/series/116868/
These patches are included here because the last patch has dependency on the pat_index refactor.
This series is focusing on uAPI changes,
1. end support for set caching ioctl [PATCH 4/5]
2. add set_pat extension for gem_create [PATCH 5/5]
v2: drop one patch that was merged separately
341ad0e8e254 drm/i915/mtl: Add PTE encode function
Fei Yang (5):
drm/i915: preparation for using PAT index drm/i915: use pat_index instead of cache_level drm/i915: make sure correct pte encode is used drm/i915/mtl: end support for set caching ioctl drm/i915: Allow user to set cache at BO creation
drivers/gpu/drm/i915/display/intel_dpt.c | 12 +-- drivers/gpu/drm/i915/gem/i915_gem_create.c | 36 +++++++++ drivers/gpu/drm/i915/gem/i915_gem_domain.c | 30 +++---- .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 10 ++- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 3 +- drivers/gpu/drm/i915/gem/i915_gem_object.c | 67 +++++++++++++++- drivers/gpu/drm/i915/gem/i915_gem_object.h | 8 ++ .../gpu/drm/i915/gem/i915_gem_object_types.h | 26 +++++- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 9 ++- drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 2 - drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 16 ++-- .../gpu/drm/i915/gem/selftests/huge_pages.c | 2 +- .../drm/i915/gem/selftests/i915_gem_migrate.c | 2 +- .../drm/i915/gem/selftests/i915_gem_mman.c | 2 +- drivers/gpu/drm/i915/gt/gen6_ppgtt.c | 10 ++- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 73 +++++++++-------- drivers/gpu/drm/i915/gt/gen8_ppgtt.h | 3 +- drivers/gpu/drm/i915/gt/intel_ggtt.c | 76 +++++++++--------- drivers/gpu/drm/i915/gt/intel_gtt.h | 20 +++-- drivers/gpu/drm/i915/gt/intel_migrate.c | 47 ++++++----- drivers/gpu/drm/i915/gt/intel_migrate.h | 13 ++- drivers/gpu/drm/i915/gt/intel_ppgtt.c | 6 +- drivers/gpu/drm/i915/gt/selftest_migrate.c | 47 +++++------ drivers/gpu/drm/i915/gt/selftest_reset.c | 8 +- drivers/gpu/drm/i915/gt/selftest_timeline.c | 2 +- drivers/gpu/drm/i915/gt/selftest_tlb.c | 4 +- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 10 ++- drivers/gpu/drm/i915/i915_debugfs.c | 55 ++++++++++--- drivers/gpu/drm/i915/i915_gem.c | 16 +++- drivers/gpu/drm/i915/i915_gpu_error.c | 8 +- drivers/gpu/drm/i915/i915_pci.c | 79 ++++++++++++++++--- drivers/gpu/drm/i915/i915_vma.c | 16 ++-- drivers/gpu/drm/i915/i915_vma.h | 2 +- drivers/gpu/drm/i915/i915_vma_types.h | 2 - drivers/gpu/drm/i915/intel_device_info.h | 5 ++ drivers/gpu/drm/i915/selftests/i915_gem.c | 5 +- .../gpu/drm/i915/selftests/i915_gem_evict.c | 4 +- drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 15 ++-- .../drm/i915/selftests/intel_memory_region.c | 4 +- .../gpu/drm/i915/selftests/mock_gem_device.c | 9 +++ drivers/gpu/drm/i915/selftests/mock_gtt.c | 8 +- include/uapi/drm/i915_drm.h | 36 +++++++++ tools/include/uapi/drm/i915_drm.h | 36 +++++++++ 44 files changed, 605 insertions(+), 243 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/5 drm/i915: preparation for using PAT index
From: Fei Yang <[email protected]>
This patch is a preparation for replacing enum i915_cache_level with PAT index. Caching policy for buffer objects is set through the PAT index in PTE, the old i915_cache_level is not sufficient to represent all caching modes supported by the hardware.
Preparing the transition by adding some platform dependent data structures and helper functions to translate the cache_level to pat_index.
cachelevel_to_pat: a platform dependent array mapping cache_level to
pat_index.
max_pat_index: the maximum PAT index recommended in hardware specification
Needed for validating the PAT index passed in from user space.
i915_gem_get_pat_index: function to convert cache_level to PAT index.
obj_to_i915(obj): macro moved to header file for wider usage.
I915_MAX_CACHE_LEVEL: upper bound of i915_cache_level for the
convenience of coding.
--- drivers/gpu/drm/i915/gem/i915_gem_object.c | 9 +++ drivers/gpu/drm/i915/gem/i915_gem_object.h | 4 + .../gpu/drm/i915/gem/i915_gem_object_types.h | 1 + drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 2 - drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 6 ++ drivers/gpu/drm/i915/gt/intel_ggtt.c | 6 ++ drivers/gpu/drm/i915/i915_pci.c | 79 ++++++++++++++++--- drivers/gpu/drm/i915/intel_device_info.h | 5 ++ .../gpu/drm/i915/selftests/mock_gem_device.c | 9 +++ 9 files changed, 110 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +9 -0
@@ -45,6 +45,15 @@ static struct kmem_cache *slab_objects;static const struct drm_gem_object_funcs i915_gem_object_funcs; +unsigned int i915_gem_get_pat_index (struct drm_i915_private *i915, +enum i915_cache_level level) +{ +if (drm_WARN_ON (&i915->drm, level >=I915_MAX_CACHE_LEVEL )) +return 0 ; + +return INTEL_INFO (i915)->cachelevel_to_pat[level]; +} +struct drm_i915_gem_object *i915_gem_object_alloc (void ) {struct drm_i915_gem_object *obj;
drivers/gpu/drm/i915/gem/i915_gem_object.h +4 -0
@@ -20,6 +20,8 @@enum intel_region_id ; +#define obj_to_i915 (obj__) to_i915((obj__)->base.dev) +static inline bool i915_gem_object_size_2big (u64 size) {struct drm_i915_gem_object *obj;
@@ -30,6 +32,8 @@ static inline bool i915_gem_object_size_2big(u64 size)return false; } +unsigned int i915_gem_get_pat_index (struct drm_i915_private *i915, +enum i915_cache_level level);void i915_gem_init__objects (struct drm_i915_private *i915);void i915_objects_module_exit (void );
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +1 -0
@@ -194,6 +194,7 @@ enum i915_cache_level {* engine. */ I915_CACHE_WT , + I915_MAX_CACHE_LEVEL, }; enum i915_map_type {
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +0 -2
@@ -460,8 +460,6 @@ void i915_gem_shrinker_taints_mutex(struct drm_i915_private *i915,fs_reclaim_release (GFP_KERNEL ); } -#define obj_to_i915 (obj__) to_i915((obj__)->base.dev) -/** * i915_gem_object_make_unshrinkable - Hide the object from the shrinker. By * default all object types that support shrinking(see IS_SHRINKABLE), will also
drivers/gpu/drm/i915/gt/gen8_ppgtt.c +6 -0
@@ -78,6 +78,12 @@ static u64 mtl_pte_encode(dma_addr_t addr,case I915_CACHE_WT : pte |=GEN12_PPGTT_PTE_PAT0 ;break ; +default : +/* This should never happen. Added to deal with the compile +* error due to the addition of I915_MAX_CACHE_LEVEL. Will +* be removed by the pat_index patch. +*/ +break ; }return pte;
drivers/gpu/drm/i915/gt/intel_ggtt.c +6 -0
@@ -242,6 +242,12 @@ static u64 mtl_ggtt_pte_encode(dma_addr_t addr,case I915_CACHE_WT : pte |=MTL_GGTT_PTE_PAT0 ;break ; +default : +/* This should never happen. Added to deal with the compile +* error due to the addition of I915_MAX_CACHE_LEVEL. Will +* be removed by the pat_index patch. +*/ +break ; }return pte;
drivers/gpu/drm/i915/i915_pci.c +70 -9
239 lines not on this page · raw message
drivers/gpu/drm/i915/intel_device_info.h +5 -0
@@ -35,6 +35,8 @@#include "gt/intel_context_types.h" #include "gt/intel_sseu.h" +#include "gem/i915_gem_object_types.h" +struct drm_printer ;struct drm_i915_private ;struct intel_gt_definition ;
@@ -308,6 +310,9 @@ struct intel_device_info {* Initial runtime info. Do not access outside of i915_driver_create(). */ const struct intel_runtime_info __runtime; + +u32 cachelevel_to_pat[I915_MAX_CACHE_LEVEL ]; +u32 max_pat_index; };struct intel_driver_caps {
drivers/gpu/drm/i915/selftests/mock_gem_device.c +9 -0
@@ -123,7 +123,9 @@ struct drm_i915_private *mock_gem_device(void)static struct dev_iommu fake_iommu = { .priv = (void *)-1 };#endif struct drm_i915_private *i915; +struct intel_device_info *i915_info;struct pci_dev *pdev; +unsigned int i;int ret; pdev =kzalloc (sizeof (*pdev),GFP_KERNEL );
@@ -180,6 +182,13 @@ struct drm_i915_private *mock_gem_device(void)I915_GTT_PAGE_SIZE_2M ;RUNTIME_INFO (i915)->memory_regions =REGION_SMEM ; + +/* simply use legacy cache level for mock device */ + i915_info = (struct intel_device_info *)INTEL_INFO (i915); + i915_info->max_pat_index =3 ; +for (i =0 ; i <I915_MAX_CACHE_LEVEL ; i++) + i915_info->cachelevel_to_pat[i] = i; +intel_memory_regions_hw_probe (i915);spin_lock_init (&i915->gpu_error.lock);
Signature · 1 line
2.25.1
PATCH v2 2/5 drm/i915: use pat_index instead of cache_level
In reply to [email protected]From: Fei Yang <[email protected]>
Currently the KMD is using enum i915_cache_level to set caching policy for buffer objects. This is flaky because the PAT index which really controls the caching behavior in PTE has far more levels than what's defined in the enum. In addition, the PAT index is platform dependent, having to translate between i915_cache_level and PAT index is not reliable, and makes the code more complicated.
From UMD's perspective there is also a necessity to set caching policy for performance fine tuning. It's much easier for the UMD to directly use PAT index because the behavior of each PAT index is clearly defined in Bspec. Having the abstracted i915_cache_level sitting in between would only cause more ambiguity.
For these reasons this patch replaces i915_cache_level with PAT index. Also note, the cache_level is not completely removed yet, because the KMD still has the need of creating buffer objects with simple cache settings such as cached, uncached, or writethrough. For such simple cases, using cache_level would help simplify the code.
--- drivers/gpu/drm/i915/display/intel_dpt.c | 12 +-- drivers/gpu/drm/i915/gem/i915_gem_domain.c | 27 ++---- .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 10 ++- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 3 +- drivers/gpu/drm/i915/gem/i915_gem_object.c | 52 +++++++++++- drivers/gpu/drm/i915/gem/i915_gem_object.h | 4 + .../gpu/drm/i915/gem/i915_gem_object_types.h | 25 +++++- drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 16 ++-- .../gpu/drm/i915/gem/selftests/huge_pages.c | 2 +- .../drm/i915/gem/selftests/i915_gem_migrate.c | 2 +- .../drm/i915/gem/selftests/i915_gem_mman.c | 2 +- drivers/gpu/drm/i915/gt/gen6_ppgtt.c | 10 ++- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 71 ++++++++-------- drivers/gpu/drm/i915/gt/gen8_ppgtt.h | 3 +- drivers/gpu/drm/i915/gt/intel_ggtt.c | 82 +++++++++---------- drivers/gpu/drm/i915/gt/intel_gtt.h | 20 ++--- drivers/gpu/drm/i915/gt/intel_migrate.c | 47 ++++++----- drivers/gpu/drm/i915/gt/intel_migrate.h | 13 ++- drivers/gpu/drm/i915/gt/intel_ppgtt.c | 6 +- drivers/gpu/drm/i915/gt/selftest_migrate.c | 47 ++++++----- drivers/gpu/drm/i915/gt/selftest_reset.c | 8 +- drivers/gpu/drm/i915/gt/selftest_timeline.c | 2 +- drivers/gpu/drm/i915/gt/selftest_tlb.c | 4 +- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 10 ++- drivers/gpu/drm/i915/i915_debugfs.c | 55 ++++++++++--- drivers/gpu/drm/i915/i915_gem.c | 16 +++- drivers/gpu/drm/i915/i915_gpu_error.c | 8 +- drivers/gpu/drm/i915/i915_vma.c | 16 ++-- drivers/gpu/drm/i915/i915_vma.h | 2 +- drivers/gpu/drm/i915/i915_vma_types.h | 2 - drivers/gpu/drm/i915/selftests/i915_gem.c | 5 +- .../gpu/drm/i915/selftests/i915_gem_evict.c | 4 +- drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 15 ++-- .../drm/i915/selftests/intel_memory_region.c | 4 +- drivers/gpu/drm/i915/selftests/mock_gtt.c | 8 +- 36 files changed, 378 insertions(+), 239 deletions(-)
drivers/gpu/drm/i915/display/intel_dpt.c +6 -6
@@ -43,24 +43,24 @@ static void gen8_set_pte(void __iomem *addr, gen8_pte_t pte)static void dpt_insert_page (struct i915_address_space *vm,dma_addr_t addr,u64 offset, -enum i915_cache_level level, +unsigned int pat_index,u32 flags) {struct i915_dpt *dpt =i915_vm_to_dpt (vm);gen8_pte_t __iomem *base = dpt->iomem;gen8_set_pte (base + offset /I915_GTT_PAGE_SIZE , - vm->pte_encode (addr, level, flags)); + vm->pte_encode (addr, pat_index, flags)); }static void dpt_insert_entries (struct i915_address_space *vm,struct i915_vma_resource *vma_res, -enum i915_cache_level level, +unsigned int pat_index,u32 flags) {struct i915_dpt *dpt =i915_vm_to_dpt (vm);gen8_pte_t __iomem *base = dpt->iomem; -const gen8_pte_t pte_encode = vm->pte_encode (0 , level, flags); +const gen8_pte_t pte_encode = vm->pte_encode (0 , pat_index, flags);struct sgt_iter sgt_iter;dma_addr_t addr;int i;
@@ -83,7 +83,7 @@ static void dpt_clear_range(struct i915_address_space *vm,static void dpt_bind_vma (struct i915_address_space *vm,struct i915_vm_pt_stash *stash,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags) {u32 pte_flags;
@@ -98,7 +98,7 @@ static void dpt_bind_vma(struct i915_address_space *vm,if (vma_res->bi.lmem) pte_flags |=PTE_LM ; - vm->insert_entries (vm, vma_res, cache_level, pte_flags); + vm->insert_entries (vm, vma_res, pat_index, pte_flags); vma_res->page_sizes_gtt =I915_GTT_PAGE_SIZE ;
drivers/gpu/drm/i915/gem/i915_gem_domain.c +9 -18
@@ -27,8 +27,8 @@ static bool gpu_write_needs_clflush(struct drm_i915_gem_object *obj)if (IS_DGFX (i915))return false; -return !(obj->cache_level ==I915_CACHE_NONE || - obj->cache_level ==I915_CACHE_WT ); +return !(i915_gem_object_has_cache_level (obj,I915_CACHE_NONE ) || +i915_gem_object_has_cache_level (obj,I915_CACHE_WT )); }bool i915_gem_cpu_write_needs_clflush (struct drm_i915_gem_object *obj)
@@ -267,7 +267,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj, {int ret; -if (obj->cache_level == cache_level) +if (i915_gem_object_has_cache_level (obj, cache_level))return 0 ; ret = i915_gem_object_wait(obj,
@@ -278,10 +278,8 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,return ret;/* Always invalidate stale cachelines */ -if (obj->cache_level != cache_level) { -i915_gem_object_set_cache_coherency (obj, cache_level); - obj->cache_dirty = true; - } +i915_gem_object_set_cache_coherency (obj, cache_level); + obj->cache_dirty = true;/* The cache-level will be applied when each vma is rebound. */ return i915_gem_object_unbind(obj,
@@ -306,20 +304,13 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data, goto out; } -switch (obj->cache_level) { -case I915_CACHE_LLC : -case I915_CACHE_L3_LLC : +if (i915_gem_object_has_cache_level (obj,I915_CACHE_LLC ) || +i915_gem_object_has_cache_level (obj,I915_CACHE_L3_LLC )) args->caching =I915_CACHING_CACHED ; -break ; - -case I915_CACHE_WT : +else if (i915_gem_object_has_cache_level (obj,I915_CACHE_WT )) args->caching =I915_CACHING_DISPLAY ; -break ; - -default : +else args->caching =I915_CACHING_NONE ; -break ; - } out:rcu_read_unlock ();return err;
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +6 -4
@@ -642,7 +642,7 @@ static inline int use_cpu_reloc(const struct reloc_cache *cache,return (cache->has_llc || obj->cache_dirty || - obj->cache_level !=I915_CACHE_NONE ); + !i915_gem_object_has_cache_level (obj,I915_CACHE_NONE )); } static int eb_reserve_vma(struct i915_execbuffer *eb,
@@ -1323,8 +1323,10 @@ static void *reloc_iomap(struct i915_vma *batch, offset = cache->node.start;if (drm_mm_node_allocated (&cache->node)) { ggtt->vm.insert_page (&ggtt->vm, -i915_gem_object_get_dma_address (obj, page), - offset,I915_CACHE_NONE ,0 ); +i915_gem_object_get_dma_address (obj, page), + offset, +i915_gem_get_pat_index (ggtt->vm.i915,I915_CACHE_NONE ), +0 ); }else { offset += page <<PAGE_SHIFT ; }
@@ -1464,7 +1466,7 @@ eb_relocate_entry(struct i915_execbuffer *eb,reloc_cache_unmap (&eb->reloc_cache);mutex_lock (&vma->vm->mutex); err =i915_vma_bind (target->vma, - target->vma->obj->cache_level, + target->vma->obj->pat_index,PIN_GLOBAL ,NULL ,NULL );mutex_unlock (&vma->vm->mutex);reloc_cache_remap (&eb->reloc_cache, ev->vma->obj);
drivers/gpu/drm/i915/gem/i915_gem_mman.c +2 -1
@@ -383,7 +383,8 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf) }/* Access to snoopable pages through the GTT is incoherent. */ -if (obj->cache_level !=I915_CACHE_NONE && !HAS_LLC (i915)) { +if (!(i915_gem_object_has_cache_level (obj,I915_CACHE_NONE ) || +HAS_LLC (i915))) { ret = -EFAULT ; goto err_unpin; }
drivers/gpu/drm/i915/gem/i915_gem_object.c +51 -1
70 lines not on this page · raw message
drivers/gpu/drm/i915/gem/i915_gem_object.h +4 -0
@@ -34,6 +34,8 @@ static inline bool i915_gem_object_size_2big(u64 size)unsigned int i915_gem_get_pat_index (struct drm_i915_private *i915,enum i915_cache_level level); +bool i915_gem_object_has_cache_level (const struct drm_i915_gem_object *obj, +enum i915_cache_level lvl);void i915_gem_init__objects (struct drm_i915_private *i915);void i915_objects_module_exit (void );
@@ -764,6 +766,8 @@ bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object *obj);void i915_gem_object_set_cache_coherency (struct drm_i915_gem_object *obj,unsigned int cache_level); +void i915_gem_object_set_pat_index (struct drm_i915_gem_object *obj, +unsigned int pat_index);bool i915_gem_object_can_bypass_llc (struct drm_i915_gem_object *obj);void i915_gem_object_flush_if_display (struct drm_i915_gem_object *obj);void i915_gem_object_flush_if_display_locked (struct drm_i915_gem_object *obj);
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +22 -3
@@ -195,6 +195,7 @@ enum i915_cache_level {*/ I915_CACHE_WT ,I915_MAX_CACHE_LEVEL , + I915_CACHE_INVAL = I915_MAX_CACHE_LEVEL, }; enum i915_map_type {
@@ -358,10 +359,28 @@ struct drm_i915_gem_object {#define I915_BO_FLAG_STRUCT_PAGE BIT(0)/* Object backed by struct pages */ #define I915_BO_FLAG_IOMEM BIT(1)/* Object backed by IO memory */ /** -* @cache_level: The desired GTT caching level. +* @pat_index: The desired PAT index. +* +* See hardware specification for valid PAT indices for each platform. +* This field used to contain a value of enum i915_cache_level. It's +* changed to an unsigned int because PAT indices are being used by +* both UMD and KMD for caching policy control after GEN12. +* For backward compatibility, this field will continue to contain +* value of i915_cache_level for pre-GEN12 platforms so that the PTE +* encode functions for these legacy platforms can stay the same. +* In the meantime platform specific tables are created to translate +* i915_cache_level into pat index, for more details check the macros +* defined i915/i915_pci.c, e.g. PVC_CACHELEVEL. +*/ + unsigned int pat_index:6; +/** +* @cache_level: Indicate whether pat_index is set by UMD * -* See enum i915_cache_level for possible values, along with what -* each does. +* This used to hold desired GTT caching level, but is now replaced by +* pat_index. It's kept here for KMD to tell whether the pat_index is +* set by UMD or converted from enum i915_cache_level. +* This field should be 0 by default, but I915_CACHE_INVAL if the +* pat_index is set by UMD. */ unsigned int cache_level:3;/**
drivers/gpu/drm/i915/gem/i915_gem_stolen.c +3 -1
@@ -565,7 +565,9 @@ static void dbg_poison(struct i915_ggtt *ggtt, ggtt->vm.insert_page (&ggtt->vm, addr, ggtt->error_capture.start, -I915_CACHE_NONE ,0 ); +i915_gem_get_pat_index (ggtt->vm.i915, +I915_CACHE_NONE ), +0 );mb (); s = io_mapping_map_wc(&ggtt->iomap,
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +9 -7
@@ -214,7 +214,8 @@ static struct dma_fence *i915_ttm_accel_move(struct ttm_buffer_object *bo,intel_engine_pm_get (to_gt (i915)->migrate.context->engine); ret =intel_context_migrate_clear (to_gt (i915)->migrate.context, deps, - dst_st->sgl, dst_level, + dst_st->sgl, +i915_gem_get_pat_index (i915, dst_level),i915_ttm_gtt_binds_lmem (dst_mem),0 , &rq); }else {
@@ -227,12 +228,13 @@ static struct dma_fence *i915_ttm_accel_move(struct ttm_buffer_object *bo, src_level =i915_ttm_cache_level (i915, bo->resource, src_ttm);intel_engine_pm_get (to_gt (i915)->migrate.context->engine); ret =intel_context_migrate_copy (to_gt (i915)->migrate.context, - deps, src_rsgt->table.sgl, - src_level, -i915_ttm_gtt_binds_lmem (bo->resource), - dst_st->sgl, dst_level, -i915_ttm_gtt_binds_lmem (dst_mem), - &rq); + deps, src_rsgt->table.sgl, +i915_gem_get_pat_index (i915, src_level), +i915_ttm_gtt_binds_lmem (bo->resource), + dst_st->sgl, +i915_gem_get_pat_index (i915, dst_level), +i915_ttm_gtt_binds_lmem (dst_mem), + &rq);i915_refct_sgt_put (src_rsgt); }
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
@@ -354,7 +354,7 @@ fake_huge_pages_object(struct drm_i915_private *i915, u64 size, bool single) obj->write_domain =I915_GEM_DOMAIN_CPU ; obj->read_domains =I915_GEM_DOMAIN_CPU ; - obj->cache_level =I915_CACHE_NONE ; + obj->pat_index =i915_gem_get_pat_index (i915,I915_CACHE_NONE );return obj; }
drivers/gpu/drm/i915/gem/selftests/i915_gem_migrate.c +1 -1
@@ -219,7 +219,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,continue ; err =intel_migrate_clear (>->migrate, &ww, deps, - obj->mm.pages->sgl, obj->cache_level, + obj->mm.pages->sgl, obj->pat_index,i915_gem_object_is_lmem (obj),0xdeadbeaf , &rq);if (rq) {
drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c +1 -1
@@ -1222,7 +1222,7 @@ static int __igt_mmap_migrate(struct intel_memory_region **placements, } err =intel_context_migrate_clear (to_gt (i915)->migrate.context,NULL , - obj->mm.pages->sgl, obj->cache_level, + obj->mm.pages->sgl, obj->pat_index,i915_gem_object_is_lmem (obj),expand32 (POISON_INUSE ), &rq);i915_gem_object_unpin_pages (obj);
drivers/gpu/drm/i915/gt/gen6_ppgtt.c +6 -4
@@ -109,7 +109,7 @@ static void gen6_ppgtt_clear_range(struct i915_address_space *vm,static void gen6_ppgtt_insert_entries (struct i915_address_space *vm,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags) {struct i915_ppgtt *ppgtt =i915_vm_to_ppgtt (vm);
@@ -117,7 +117,7 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,unsigned int first_entry = vma_res->start /I915_GTT_PAGE_SIZE ;unsigned int act_pt = first_entry /GEN6_PTES ;unsigned int act_pte = first_entry %GEN6_PTES ; -const u32 pte_encode = vm->pte_encode (0 , cache_level, flags); +const u32 pte_encode = vm->pte_encode (0 , pat_index, flags);struct sgt_dma iter =sgt_dma (vma_res);gen6_pte_t *vaddr;
@@ -227,7 +227,9 @@ static int gen6_ppgtt_init_scratch(struct gen6_ppgtt *ppgtt) vm->scratch[0 ]->encode = vm->pte_encode (px_dma (vm->scratch[0 ]), -I915_CACHE_NONE ,PTE_READ_ONLY ); +i915_gem_get_pat_index (vm->i915, +I915_CACHE_NONE ), +PTE_READ_ONLY ); vm->scratch[1 ] = vm->alloc_pt_dma (vm,I915_GTT_PAGE_SIZE_4K );if (IS_ERR (vm->scratch[1 ])) {
@@ -278,7 +280,7 @@ static void gen6_ppgtt_cleanup(struct i915_address_space *vm)static void pd_vma_bind (struct i915_address_space *vm,struct i915_vm_pt_stash *stash,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 unused) {struct i915_ggtt *ggtt =i915_vm_to_ggtt (vm);
drivers/gpu/drm/i915/gt/gen8_ppgtt.c +34 -37
174 lines not on this page · raw message
drivers/gpu/drm/i915/gt/gen8_ppgtt.h +1 -2
@@ -10,13 +10,12 @@struct i915_address_space ;struct intel_gt ; -enum i915_cache_level ;struct i915_ppgtt *gen8_ppgtt_create (struct intel_gt *gt,unsigned long lmem_pt_obj_flags);u64 gen8_ggtt_pte_encode (dma_addr_t addr, -enum i915_cache_level level, +unsigned int pat_index,u32 flags);#endif
drivers/gpu/drm/i915/gt/intel_ggtt.c +40 -42
229 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_gtt.h +9 -11
@@ -163,8 +163,6 @@ typedef u64 gen8_pte_t;#define MTL_3_COH_2W REG_FIELD_PREP(MTL_PAT_INDEX_COH_MODE_MASK, 3)#define MTL_2_COH_1W REG_FIELD_PREP(MTL_PAT_INDEX_COH_MODE_MASK, 2) -enum i915_cache_level ; -struct drm_i915_gem_object ;struct i915_fence_reg ;struct i915_vma ;
@@ -232,7 +230,7 @@ struct i915_vma_ops {void (*bind_vma)(struct i915_address_space *vm,struct i915_vm_pt_stash *stash,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags);/* * Unmap an object from an address space. This usually consists of
@@ -304,7 +302,7 @@ struct i915_address_space { (*alloc_scratch_dma)(struct i915_address_space *vm, int sz);u64 (*pte_encode)(dma_addr_t addr, -enum i915_cache_level level, +unsigned int pat_index,u32 flags);/* Create a valid PTE */ #define PTE_READ_ONLY BIT(0)#define PTE_LM BIT(1)
@@ -319,20 +317,20 @@ struct i915_address_space {void (*insert_page)(struct i915_address_space *vm,dma_addr_t addr,u64 offset, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags);void (*insert_entries)(struct i915_address_space *vm,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags);void (*raw_insert_page)(struct i915_address_space *vm,dma_addr_t addr,u64 offset, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags);void (*raw_insert_entries)(struct i915_address_space *vm,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags);void (*cleanup)(struct i915_address_space *vm);
@@ -579,7 +577,7 @@ void ppgtt_init(struct i915_ppgtt *ppgtt, struct intel_gt *gt,void intel_ggtt_bind_vma (struct i915_address_space *vm,struct i915_vm_pt_stash *stash,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags);void intel_ggtt_unbind_vma (struct i915_address_space *vm,struct i915_vma_resource *vma_res);
@@ -637,7 +635,7 @@ void __set_pd_entry(struct i915_page_directory * const pd, const unsigned short idx, struct i915_page_table *pt, - u64 (*encode)(const dma_addr_t, const enum i915_cache_level)); + u64 (*encode)(const dma_addr_t, const unsigned int pat_index));#define set_pd_entry (pd, idx, to) \ __set_pd_entry((pd), (idx), px_pt(to), gen8_pde_encode)
@@ -657,7 +655,7 @@ void gen6_ggtt_invalidate(struct i915_ggtt *ggtt);void ppgtt_bind_vma (struct i915_address_space *vm,struct i915_vm_pt_stash *stash,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags);void ppgtt_unbind_vma (struct i915_address_space *vm,struct i915_vma_resource *vma_res);
drivers/gpu/drm/i915/gt/intel_migrate.c +26 -21
156 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_migrate.h +6 -7
@@ -16,7 +16,6 @@ struct i915_request;struct i915_gem_ww_ctx ;struct intel_gt ;struct scatterlist ; -enum i915_cache_level ;int intel_migrate_init (struct intel_migrate *m,struct intel_gt *gt);
@@ -26,20 +25,20 @@ int intel_migrate_copy(struct intel_migrate *m,struct i915_gem_ww_ctx *ww, const struct i915_deps *deps, struct scatterlist *src, - enum i915_cache_level src_cache_level, + unsigned int src_pat_index, bool src_is_lmem, struct scatterlist *dst, - enum i915_cache_level dst_cache_level, + unsigned int dst_pat_index, bool dst_is_lmem, struct i915_request **out);int intel_context_migrate_copy (struct intel_context *ce,const struct i915_deps *deps,struct scatterlist *src, -enum i915_cache_level src_cache_level, +unsigned int src_pat_index,bool src_is_lmem,struct scatterlist *dst, -enum i915_cache_level dst_cache_level, +unsigned int dst_pat_index,bool dst_is_lmem,struct i915_request **out);
@@ -48,7 +47,7 @@ intel_migrate_clear(struct intel_migrate *m,struct i915_gem_ww_ctx *ww, const struct i915_deps *deps, struct scatterlist *sg, - enum i915_cache_level cache_level, + unsigned int pat_index, bool is_lmem, u32 value, struct i915_request **out);
@@ -56,7 +55,7 @@ int intel_context_migrate_clear(struct intel_context *ce, const struct i915_deps *deps, struct scatterlist *sg, - enum i915_cache_level cache_level, + unsigned int pat_index, bool is_lmem, u32 value, struct i915_request **out);
drivers/gpu/drm/i915/gt/intel_ppgtt.c +3 -3
@@ -98,7 +98,7 @@ void __set_pd_entry(struct i915_page_directory * const pd, const unsigned short idx, struct i915_page_table * const to, - u64 (*encode)(const dma_addr_t, const enum i915_cache_level)) + u64 (*encode)(const dma_addr_t, const unsigned int)) { /* Each thread pre-pins the pd, and we may have a thread per pde. */ GEM_BUG_ON(atomic_read(px_used(pd)) > NALLOC * I915_PDES);
@@ -181,7 +181,7 @@ struct i915_ppgtt *i915_ppgtt_create(struct intel_gt *gt,void ppgtt_bind_vma (struct i915_address_space *vm,struct i915_vm_pt_stash *stash,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags) {u32 pte_flags;
@@ -199,7 +199,7 @@ void ppgtt_bind_vma(struct i915_address_space *vm,if (vma_res->bi.lmem) pte_flags |=PTE_LM ; - vm->insert_entries (vm, vma_res, cache_level, pte_flags); + vm->insert_entries (vm, vma_res, pat_index, pte_flags);wmb (); }
drivers/gpu/drm/i915/gt/selftest_migrate.c +25 -22
156 lines not on this page · raw message
drivers/gpu/drm/i915/gt/selftest_reset.c +6 -2
@@ -86,7 +86,9 @@ __igt_reset_stolen(struct intel_gt *gt, ggtt->vm.insert_page (&ggtt->vm, dma, ggtt->error_capture.start, -I915_CACHE_NONE ,0 ); +i915_gem_get_pat_index (gt->i915, +I915_CACHE_NONE ), +0 );mb (); s = io_mapping_map_wc(&ggtt->iomap,
@@ -127,7 +129,9 @@ __igt_reset_stolen(struct intel_gt *gt, ggtt->vm.insert_page (&ggtt->vm, dma, ggtt->error_capture.start, -I915_CACHE_NONE ,0 ); +i915_gem_get_pat_index (gt->i915, +I915_CACHE_NONE ), +0 );mb (); s = io_mapping_map_wc(&ggtt->iomap,
drivers/gpu/drm/i915/gt/selftest_timeline.c +1 -1
@@ -836,7 +836,7 @@ static int setup_watcher(struct hwsp_watcher *w, struct intel_gt *gt,return PTR_ERR (obj);/* keep the same cache settings as timeline */ -i915_gem_object_set_cache_coherency (obj, tl->hwsp_ggtt->obj->cache_level); +i915_gem_object_set_pat_index (obj, tl->hwsp_ggtt->obj->pat_index); w->map =i915_gem_object_pin_map_unlocked (obj,page_unmask_bits (tl->hwsp_ggtt->obj->mm.mapping));if (IS_ERR (w->map)) {
drivers/gpu/drm/i915/gt/selftest_tlb.c +3 -1
@@ -36,6 +36,8 @@ pte_tlbinv(struct intel_context *ce, u64 length, struct rnd_state *prng) { +const unsigned int pat_index = +i915_gem_get_pat_index (ce->vm->i915,I915_CACHE_NONE );struct drm_i915_gem_object *batch;struct drm_mm_node vb_node;struct i915_request *rq;
@@ -155,7 +157,7 @@ pte_tlbinv(struct intel_context *ce,/* Flip the PTE between A and B */ if (i915_gem_object_is_lmem (vb->obj)) pte_flags |=PTE_LM ; - ce->vm->insert_entries (ce->vm, &vb_res,0 , pte_flags); + ce->vm->insert_entries (ce->vm, &vb_res, pat_index, pte_flags);/* Flush the PTE update to concurrent HW */ tlbinv (ce->vm, addr & -length, length);
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +8 -2
@@ -890,9 +890,15 @@ static void uc_fw_bind_ggtt(struct intel_uc_fw *uc_fw) pte_flags |=PTE_LM ;if (ggtt->vm.raw_insert_entries) - ggtt->vm.raw_insert_entries (&ggtt->vm, dummy,I915_CACHE_NONE , pte_flags); + ggtt->vm.raw_insert_entries (&ggtt->vm, dummy, +i915_gem_get_pat_index (ggtt->vm.i915, +I915_CACHE_NONE ), + pte_flags);else - ggtt->vm.insert_entries (&ggtt->vm, dummy,I915_CACHE_NONE , pte_flags); + ggtt->vm.insert_entries (&ggtt->vm, dummy, +i915_gem_get_pat_index (ggtt->vm.i915, +I915_CACHE_NONE ), + pte_flags); }static void uc_fw_unbind_ggtt (struct intel_uc_fw *uc_fw)
drivers/gpu/drm/i915/i915_debugfs.c +45 -10
73 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem.c +12 -4
@@ -420,8 +420,12 @@ i915_gem_gtt_pread(struct drm_i915_gem_object *obj, page_length = remain < page_length ? remain : page_length;if (drm_mm_node_allocated (&node)) { ggtt->vm.insert_page (&ggtt->vm, -i915_gem_object_get_dma_address (obj, offset >>PAGE_SHIFT ), - node.start,I915_CACHE_NONE ,0 ); +i915_gem_object_get_dma_address (obj, + offset >>PAGE_SHIFT ), + node.start, +i915_gem_get_pat_index (i915, +I915_CACHE_NONE ), +0 ); }else { page_base += offset &PAGE_MASK ; }
@@ -598,8 +602,12 @@ i915_gem_gtt_pwrite_fast(struct drm_i915_gem_object *obj,/* flush the write before we modify the GGTT */ intel_gt_flush_ggtt_writes (ggtt->vm.gt); ggtt->vm.insert_page (&ggtt->vm, -i915_gem_object_get_dma_address (obj, offset >>PAGE_SHIFT ), - node.start,I915_CACHE_NONE ,0 ); +i915_gem_object_get_dma_address (obj, + offset >>PAGE_SHIFT ), + node.start, +i915_gem_get_pat_index (i915, +I915_CACHE_NONE ), +0 );wmb ();/* flush modifications to the GGTT (insert_page) */ }else { page_base += offset &PAGE_MASK ;
drivers/gpu/drm/i915/i915_gpu_error.c +6 -2
@@ -1117,10 +1117,14 @@ i915_vma_coredump_create(const struct intel_gt *gt,mutex_lock (&ggtt->error_mutex);if (ggtt->vm.raw_insert_page) ggtt->vm.raw_insert_page (&ggtt->vm, dma, slot, -I915_CACHE_NONE ,0 ); +i915_gem_get_pat_index (gt->i915, +I915_CACHE_NONE ), +0 );else ggtt->vm.insert_page (&ggtt->vm, dma, slot, -I915_CACHE_NONE ,0 ); +i915_gem_get_pat_index (gt->i915, +I915_CACHE_NONE ), +0 );mb (); s =io_mapping_map_wc (&ggtt->iomap, slot,PAGE_SIZE );
drivers/gpu/drm/i915/i915_vma.c +8 -8
@@ -315,7 +315,7 @@ struct i915_vma_work {struct i915_vma_resource *vma_res;struct drm_i915_gem_object *obj;struct i915_sw_dma_fence_cb cb; -enum i915_cache_level cache_level; +unsigned int pat_index;unsigned int flags; };
@@ -334,7 +334,7 @@ static void __vma_bind(struct dma_fence_work *work)return ; vma_res->ops->bind_vma (vma_res->vm, &vw->stash, - vma_res, vw->cache_level, vw->flags); + vma_res, vw->pat_index, vw->flags); }static void __vma_release (struct dma_fence_work *work)
@@ -426,7 +426,7 @@ i915_vma_resource_init_from_vma(struct i915_vma_resource *vma_res,/** * i915_vma_bind - Sets up PTEs for an VMA in it's corresponding address space. * @vma: VMA to map -* @cache_level: mapping cache level +* @pat_index: PAT index to set in PTE * @flags: flags like global or local mapping * @work: preallocated worker for allocating and binding the PTE * @vma_res: pointer to a preallocated vma resource. The resource is either
@@ -437,7 +437,7 @@ i915_vma_resource_init_from_vma(struct i915_vma_resource *vma_res,* Note that DMA addresses are also the only part of the SG table we care about. */ int i915_vma_bind (struct i915_vma *vma, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags,struct i915_vma_work *work,struct i915_vma_resource *vma_res)
@@ -507,7 +507,7 @@ int i915_vma_bind(struct i915_vma *vma,struct dma_fence *prev; work->vma_res =i915_vma_resource_get (vma->resource); - work->cache_level = cache_level; + work->pat_index = pat_index; work->flags = bind_flags;/*
@@ -537,7 +537,7 @@ int i915_vma_bind(struct i915_vma *vma,return ret; } - vma->ops->bind_vma (vma->vm,NULL , vma->resource, cache_level, + vma->ops->bind_vma (vma->vm,NULL , vma->resource, pat_index, bind_flags); }
@@ -814,7 +814,7 @@ i915_vma_insert(struct i915_vma *vma, struct i915_gem_ww_ctx *ww, color =0 ;if (i915_vm_has_cache_coloring (vma->vm)) - color = vma->obj->cache_level; + color = vma->obj->pat_index;if (flags &PIN_OFFSET_FIXED ) {u64 offset = flags &PIN_OFFSET_MASK ;
@@ -1518,7 +1518,7 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,GEM_BUG_ON (!vma->pages); err =i915_vma_bind (vma, - vma->obj->cache_level, + vma->obj->pat_index, flags, work, vma_res); vma_res =NULL ;if (err)
drivers/gpu/drm/i915/i915_vma.h +1 -1
@@ -250,7 +250,7 @@ i915_vma_compare(struct i915_vma *vma,struct i915_vma_work *i915_vma_work (void );int i915_vma_bind (struct i915_vma *vma, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags,struct i915_vma_work *work,struct i915_vma_resource *vma_res);
drivers/gpu/drm/i915/i915_vma_types.h +0 -2
@@ -32,8 +32,6 @@#include "gem/i915_gem_object_types.h" -enum i915_cache_level ; -/** * DOC: Global GTT views *
drivers/gpu/drm/i915/selftests/i915_gem.c +4 -1
@@ -57,7 +57,10 @@ static void trash_stolen(struct drm_i915_private *i915)u32 __iomem *s;int x; - ggtt->vm.insert_page (&ggtt->vm, dma, slot,I915_CACHE_NONE ,0 ); + ggtt->vm.insert_page (&ggtt->vm, dma, slot, +i915_gem_get_pat_index (i915, +I915_CACHE_NONE ), +0 ); s =io_mapping_map_atomic_wc (&ggtt->iomap, slot);for (x =0 ; x <PAGE_SIZE /sizeof (u32); x++) {
drivers/gpu/drm/i915/selftests/i915_gem_evict.c +2 -2
@@ -245,7 +245,7 @@ static int igt_evict_for_cache_color(void *arg)struct drm_mm_node target = { .start =I915_GTT_PAGE_SIZE *2 , .size =I915_GTT_PAGE_SIZE , - .color =I915_CACHE_LLC , + .color =i915_gem_get_pat_index (gt->i915,I915_CACHE_LLC ), };struct drm_i915_gem_object *obj;struct i915_vma *vma;
@@ -308,7 +308,7 @@ static int igt_evict_for_cache_color(void *arg)/* Attempt to remove the first *pinned* vma, by removing the (empty) * neighbour -- this should fail. */ - target.color =I915_CACHE_L3_LLC ; + target.color =i915_gem_get_pat_index (gt->i915,I915_CACHE_L3_LLC );mutex_lock (&ggtt->vm.mutex); err =i915_gem_evict_for_node (&ggtt->vm,NULL , &target,0 );
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +10 -5
@@ -135,7 +135,7 @@ fake_dma_object(struct drm_i915_private *i915, u64 size) obj->write_domain =I915_GEM_DOMAIN_CPU ; obj->read_domains =I915_GEM_DOMAIN_CPU ; - obj->cache_level =I915_CACHE_NONE ; + obj->pat_index =i915_gem_get_pat_index (i915,I915_CACHE_NONE );/* Preallocate the "backing storage" */ if (i915_gem_object_pin_pages_unlocked (obj))
@@ -359,7 +359,9 @@ static int lowlevel_hole(struct i915_address_space *vm,with_intel_runtime_pm (vm->gt->uncore->rpm, wakeref) vm->insert_entries(vm, mock_vma_res, -I915_CACHE_NONE ,0 ); +i915_gem_get_pat_index (vm->i915, +I915_CACHE_NONE ), +0 ); } count = n;
@@ -1377,7 +1379,10 @@ static int igt_ggtt_page(void *arg) ggtt->vm.insert_page (&ggtt->vm,i915_gem_object_get_dma_address (obj,0 ), - offset,I915_CACHE_NONE ,0 ); + offset, +i915_gem_get_pat_index (i915, +I915_CACHE_NONE ), +0 ); } order =i915_random_order (count, &prng);
@@ -1510,7 +1515,7 @@ static int reserve_gtt_with_resource(struct i915_vma *vma, u64 offset)mutex_lock (&vm->mutex); err =i915_gem_gtt_reserve (vm,NULL , &vma->node, obj->base.size, offset, - obj->cache_level, + obj->pat_index,0 );if (!err) {i915_vma_resource_init_from_vma (vma_res, vma);
@@ -1690,7 +1695,7 @@ static int insert_gtt_with_resource(struct i915_vma *vma)mutex_lock (&vm->mutex); err =i915_gem_gtt_insert (vm,NULL , &vma->node, obj->base.size,0 , - obj->cache_level,0 , vm->total,0 ); + obj->pat_index,0 , vm->total,0 );if (!err) {i915_vma_resource_init_from_vma (vma_res, vma); vma->resource = vma_res;
drivers/gpu/drm/i915/selftests/intel_memory_region.c +3 -1
@@ -1070,7 +1070,9 @@ static int igt_lmem_write_cpu(void *arg)/* Put the pages into a known state -- from the gpu for added fun */ intel_engine_pm_get (engine); err =intel_context_migrate_clear (engine->gt->migrate.context,NULL , - obj->mm.pages->sgl,I915_CACHE_NONE , + obj->mm.pages->sgl, +i915_gem_get_pat_index (i915, +I915_CACHE_NONE ), true,0xdeadbeaf , &rq);if (rq) { dma_resv_add_fence(obj->base.resv, &rq->fence,
drivers/gpu/drm/i915/selftests/mock_gtt.c +4 -4
@@ -27,21 +27,21 @@static void mock_insert_page (struct i915_address_space *vm,dma_addr_t addr,u64 offset, -enum i915_cache_level level, +unsigned int pat_index,u32 flags) { }static void mock_insert_entries (struct i915_address_space *vm,struct i915_vma_resource *vma_res, -enum i915_cache_level level,u32 flags) +unsigned int pat_index,u32 flags) { }static void mock_bind_ppgtt (struct i915_address_space *vm,struct i915_vm_pt_stash *stash,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags) {GEM_BUG_ON (flags &I915_VMA_GLOBAL_BIND );
@@ -94,7 +94,7 @@ struct i915_ppgtt *mock_ppgtt(struct drm_i915_private *i915, const char *name)static void mock_bind_ggtt (struct i915_address_space *vm,struct i915_vm_pt_stash *stash,struct i915_vma_resource *vma_res, -enum i915_cache_level cache_level, +unsigned int pat_index,u32 flags) { }
Signature · 1 line
2.25.1
PATCH v2 3/5 drm/i915: make sure correct pte encode is used
In reply to [email protected]From: Fei Yang <[email protected]>
PTE encode is platform dependent. After replacing cache_level with pat_index, the newly introduced mtl_pte_encode is actually generic for all gen12 platforms, thus rename it to gen12_pte_encode and apply it to all gen12 platforms.
--- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/gt/gen8_ppgtt.c +5 -5
@@ -55,9 +55,9 @@ static u64 gen8_pte_encode(dma_addr_t addr,return pte; } -static u64 mtl_pte_encode (dma_addr_t addr, -unsigned int pat_index, -u32 flags) +static u64 gen12_pte_encode (dma_addr_t addr, +unsigned int pat_index, +u32 flags) {gen8_pte_t pte = addr |GEN8_PAGE_PRESENT |GEN8_PAGE_RW ;
@@ -994,8 +994,8 @@ struct i915_ppgtt *gen8_ppgtt_create(struct intel_gt *gt,*/ ppgtt->vm.alloc_scratch_dma = alloc_pt_dma; -if (GRAPHICS_VER_FULL (gt->i915) >=IP_VER (12 ,70 )) - ppgtt->vm.pte_encode = mtl_pte_encode; +if (GRAPHICS_VER (gt->i915) >=12 ) + ppgtt->vm.pte_encode = gen12_pte_encode;else ppgtt->vm.pte_encode = gen8_pte_encode;
Signature · 1 line
2.25.1
PATCH v2 4/5 drm/i915/mtl: end support for set caching ioctl
In reply to [email protected]From: Fei Yang <[email protected]>
The design is to keep Buffer Object's caching policy immutable through out its life cycle. This patch ends the support for set caching ioctl from MTL onward. While doing that we also set BO's to be 1-way coherent at creation time because GPU is no longer automatically snooping CPU cache. For userspace components needing to fine tune the caching policy for BO's, a follow up patch will extend the GEM_CREATE uAPI to allow them specify caching mode at BO creation time.
--- drivers/gpu/drm/i915/gem/i915_gem_domain.c | 3 +++ drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_domain.c +3 -0
@@ -328,6 +328,9 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,if (IS_DGFX (i915))return -ENODEV ; +if (GRAPHICS_VER_FULL (i915) >=IP_VER (12 ,70 )) +return -EOPNOTSUPP ; +switch (args->caching) {case I915_CACHING_NONE : level =I915_CACHE_NONE ;
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +8 -1
@@ -601,7 +601,14 @@ static int shmem_object_init(struct intel_memory_region *mem, obj->write_domain =I915_GEM_DOMAIN_CPU ; obj->read_domains =I915_GEM_DOMAIN_CPU ; -if (HAS_LLC (i915)) +/* +* MTL doesn't snoop CPU cache by default for GPU access (namely +* 1-way coherency). However some UMD's are currently depending on +* that. Make 1-way coherent the default setting for MTL. A follow +* up patch will extend the GEM_CREATE uAPI to allow UMD's specify +* caching mode at BO creation time +*/ +if (HAS_LLC (i915) || (GRAPHICS_VER_FULL (i915) >=IP_VER (12 ,70 )))/* On some devices, we can have the GPU use the LLC (the CPU * cache) for about a 10% performance improvement * compared to uncached. Graphics requests other than
Signature · 1 line
2.25.1
PATCH v2 5/5 drm/i915: Allow user to set cache at BO creation
In reply to [email protected]From: Fei Yang <[email protected]>
To comply with the design that buffer objects shall have immutable cache setting through out their life cycle, {set, get}_caching ioctl's are no longer supported from MTL onward. With that change caching policy can only be set at object creation time. The current code applies a default (platform dependent) cache setting for all objects. However this is not optimal for performance tuning. The patch extends the existing gem_create uAPI to let user set PAT index for the object at creation time.
The new extension is platform independent, so UMD's can switch to using this extension for older platforms as well, while {set, get}_caching are still supported on these legacy paltforms for compatibility reason.
--- drivers/gpu/drm/i915/gem/i915_gem_create.c | 36 ++++++++++++++++++++++ drivers/gpu/drm/i915/gem/i915_gem_object.c | 6 ++++ include/uapi/drm/i915_drm.h | 36 ++++++++++++++++++++++ tools/include/uapi/drm/i915_drm.h | 36 ++++++++++++++++++++++ 4 files changed, 114 insertions(+)
drivers/gpu/drm/i915/gem/i915_gem_create.c +36 -0
@@ -245,6 +245,7 @@ struct create_ext {unsigned int n_placements;unsigned int placement_mask;unsigned long flags; +unsigned int pat_index; }; static void repr_placements(char *buf, size_t size,
@@ -394,11 +395,39 @@ static int ext_set_protected(struct i915_user_extension __user *base, void *datareturn 0 ; } +static int ext_set_pat (struct i915_user_extension __user *base,void *data) +{ +struct create_ext *ext_data = data; +struct drm_i915_private *i915 = ext_data->i915; +struct drm_i915_gem_create_ext_set_pat ext; +unsigned int max_pat_index; + +BUILD_BUG_ON (sizeof (struct drm_i915_gem_create_ext_set_pat ) != + offsetofend(struct drm_i915_gem_create_ext_set_pat, rsvd)); + +if (copy_from_user (&ext, base,sizeof (ext))) +return -EFAULT ; + + max_pat_index =INTEL_INFO (i915)->max_pat_index; + +if (ext.pat_index > max_pat_index) { +drm_dbg (&i915->drm,"PAT index is invalid: %u\n" , + ext.pat_index); +return -EINVAL ; + } + + ext_data->pat_index = ext.pat_index; + +return 0 ; +} +static const i915_user_extension_fn create_extensions[] = { [I915_GEM_CREATE_EXT_MEMORY_REGIONS ] = ext_set_placements, [I915_GEM_CREATE_EXT_PROTECTED_CONTENT ] = ext_set_protected, + [I915_GEM_CREATE_EXT_SET_PAT ] = ext_set_pat, }; +#define PAT_INDEX_NOT_SET 0xffff/** * i915_gem_create_ext_ioctl - Creates a new mm object and returns a handle to it. * @dev: drm device pointer
@@ -418,6 +447,7 @@ i915_gem_create_ext_ioctl(struct drm_device *dev, void *data,if (args->flags & ~I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS )return -EINVAL ; + ext_data.pat_index =PAT_INDEX_NOT_SET ; ret = i915_user_extensions(u64_to_user_ptr(args->extensions), create_extensions, ARRAY_SIZE(create_extensions),
@@ -454,5 +484,11 @@ i915_gem_create_ext_ioctl(struct drm_device *dev, void *data,if (IS_ERR (obj))return PTR_ERR (obj); +if (ext_data.pat_index !=PAT_INDEX_NOT_SET ) { +i915_gem_object_set_pat_index (obj, ext_data.pat_index); +/* Mark pat_index is set by UMD */ + obj->cache_level =I915_CACHE_INVAL ; + } +return i915_gem_publish (obj, file, &args->size, &args->handle); }
drivers/gpu/drm/i915/gem/i915_gem_object.c +6 -0
@@ -209,6 +209,12 @@ bool i915_gem_object_can_bypass_llc(struct drm_i915_gem_object *obj)if (!(obj->flags &I915_BO_ALLOC_USER ))return false; +/* +* Always flush cache for UMD objects at creation time. +*/ +if (obj->cache_level ==I915_CACHE_INVAL ) +return true; +/* * EHL and JSL add the 'Bypass LLC' MOCS entry, which should make it * possible for userspace to bypass the GTT caching bits set by the
include/uapi/drm/i915_drm.h +36 -0
@@ -3630,9 +3630,13 @@ struct drm_i915_gem_create_ext {* * For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see * struct drm_i915_gem_create_ext_protected_content. +* +* For I915_GEM_CREATE_EXT_SET_PAT usage see +* struct drm_i915_gem_create_ext_set_pat. */ #define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0#define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1 +#define I915_GEM_CREATE_EXT_SET_PAT 2__u64 extensions; };
@@ -3747,6 +3751,38 @@ struct drm_i915_gem_create_ext_protected_content {__u32 flags; }; +/** +* struct drm_i915_gem_create_ext_set_pat - The +* I915_GEM_CREATE_EXT_SET_PAT extension. +* +* If this extension is provided, the specified caching policy (PAT index) is +* applied to the buffer object. +* +* Below is an example on how to create an object with specific caching policy: +* +* .. code-block:: C +* +* struct drm_i915_gem_create_ext_set_pat set_pat_ext = { +* .base = { .name = I915_GEM_CREATE_EXT_SET_PAT }, +* .pat_index = 0, +* }; +* struct drm_i915_gem_create_ext create_ext = { +* .size = PAGE_SIZE, +* .extensions = (uintptr_t)&set_pat_ext, +* }; +* +* int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext); +* if (err) ... +*/ +struct drm_i915_gem_create_ext_set_pat { +/** @base: Extension link. See struct i915_user_extension. */ +struct i915_user_extension base; +/** @pat_index: PAT index to be set */ +__u32 pat_index; +/** @rsvd: reserved for future use */ +__u32 rsvd; +}; +/* ID of the protected content session managed by i915 when PXP is active */ #define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf
tools/include/uapi/drm/i915_drm.h +36 -0
@@ -3607,9 +3607,13 @@ struct drm_i915_gem_create_ext {* * For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see * struct drm_i915_gem_create_ext_protected_content. +* +* For I915_GEM_CREATE_EXT_SET_PAT usage see +* struct drm_i915_gem_create_ext_set_pat. */ #define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0#define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1 +#define I915_GEM_CREATE_EXT_SET_PAT 2__u64 extensions; };
@@ -3724,6 +3728,38 @@ struct drm_i915_gem_create_ext_protected_content {__u32 flags; }; +/** +* struct drm_i915_gem_create_ext_set_pat - The +* I915_GEM_CREATE_EXT_SET_PAT extension. +* +* If this extension is provided, the specified caching policy (PAT index) is +* applied to the buffer object. +* +* Below is an example on how to create an object with specific caching policy: +* +* .. code-block:: C +* +* struct drm_i915_gem_create_ext_set_pat set_pat_ext = { +* .base = { .name = I915_GEM_CREATE_EXT_SET_PAT }, +* .pat_index = 0, +* }; +* struct drm_i915_gem_create_ext create_ext = { +* .size = PAGE_SIZE, +* .extensions = (uintptr_t)&set_pat_ext, +* }; +* +* int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext); +* if (err) ... +*/ +struct drm_i915_gem_create_ext_set_pat { +/** @base: Extension link. See struct i915_user_extension. */ +struct i915_user_extension base; +/** @pat_index: PAT index to be set */ +__u32 pat_index; +/** @rsvd: reserved for future use */ +__u32 rsvd; +}; +/* ID of the protected content session managed by i915 when PXP is active */ #define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf
Signature · 1 line
2.25.1
Patchwork
CI[Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915: Allow user to set cache at BO creation (rev2)
In reply to [email protected]== Series Details ==
== Series Details ==
Series: drm/i915: Allow user to set cache at BO creation (rev2)
URL : https://patchwork.freedesktop.org/series/116870/
State : warning
== Summary ==
Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Allow user to set cache at BO creation (rev2)
In reply to [email protected]== Series Details ==
== Series Details ==
Series: drm/i915: Allow user to set cache at BO creation (rev2)
URL : https://patchwork.freedesktop.org/series/116870/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_13062 -> Patchwork_116870v2
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_116870v2 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_116870v2, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_116870v2/index.html
Participating hosts (39 -> 36)
------------------------------
Missing (3): fi-kbl-soraka fi-kbl-x1275 fi-snb-2520m
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_116870v2:
### IGT changes ###
#### Possible regressions ####
* igt@gem_exec_suspend@basic-s3@smem:
- bat-rpls-1: NOTRUN -> [ABORT][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_116870v2/bat-rpls-1/igt@gem_exec_suspend@[email protected]
* igt@i915_suspend@basic-s2idle-without-i915:
- fi-blb-e6850: [PASS][2] -> [ABORT][3]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13062/fi-blb-e6850/igt@[email protected]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_116870v2/fi-blb-e6850/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_116870v2 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_pm_rps@basic-api:
- bat-dg2-11: [PASS][4] -> [FAIL][5] ([i915#8308])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13062/bat-dg2-11/igt@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_116870v2/bat-dg2-11/igt@[email protected]
* igt@i915_selftest@live@slpc:
- bat-rpls-1: NOTRUN -> [FAIL][6] ([i915#6997])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_116870v2/bat-rpls-1/igt@i915_selftest@[email protected]
#### Possible fixes ####
* igt@i915_selftest@live@reset:
- bat-rpls-1: [ABORT][7] ([i915#8384]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13062/bat-rpls-1/igt@i915_selftest@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_116870v2/bat-rpls-1/igt@i915_selftest@[email protected]
#### Warnings ####
* igt@i915_suspend@basic-s3-without-i915:
- fi-tgl-1115g4: [INCOMPLETE][9] ([i915#7443]) -> [INCOMPLETE][10] ([i915#8102])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13062/fi-tgl-1115g4/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_116870v2/fi-tgl-1115g4/igt@[email protected]
* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence:
- bat-dg2-11: [SKIP][11] ([i915#5354]) -> [SKIP][12] ([i915#1845] / [i915#5354])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13062/bat-dg2-11/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_116870v2/bat-dg2-11/igt@[email protected]
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#6997]: https://gitlab.freedesktop.org/drm/intel/issues/6997
[i915#7443]: https://gitlab.freedesktop.org/drm/intel/issues/7443
[i915#8102]: https://gitlab.freedesktop.org/drm/intel/issues/8102
[i915#8308]: https://gitlab.freedesktop.org/drm/intel/issues/8308
[i915#8384]: https://gitlab.freedesktop.org/drm/intel/issues/8384
Build changes
-------------
* Linux: CI_DRM_13062 -> Patchwork_116870v2
CI-20190529: 20190529
CI_DRM_13062: 5a0333cf630a335d7e8f60fd2b8526ed0895900c @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7270: 3bd8bf9bca97bbfb7b4b408f9fccd0cf6f742d4c @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_116870v2: 5a0333cf630a335d7e8f60fd2b8526ed0895900c @ git://anongit.freedesktop.org/gfx-ci/linux
### Linux commits
da316b7babfe drm/i915: Allow user to set cache at BO creation 03842686dd83 drm/i915/mtl: end support for set caching ioctl d5361ff407b4 drm/i915: make sure correct pte encode is used 94f6b6b98c20 drm/i915: use pat_index instead of cache_level d8cf5b99d5a0 drm/i915: preparation for using PAT index
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_116870v2/index.html
Quoted 7 lines · On 26/04/2023 07:24, [email protected] wrote:
From: Fei Yang <[email protected]>
The first three patches in this series are taken from
https://patchwork.freedesktop.org/series/116868/
These patches are included here because the last patch has dependency on thepat_indexrefactor.
Quoted 6 lines
This series is focusing on uAPI changes,
1. end support for set caching ioctl [PATCH 4/5]
2. addset_patextension forgem_create[PATCH 5/5]v2: drop one patch that was merged separately
341ad0e8e254 drm/i915/mtl: Add PTE encode function
Are the re-sends for stabilizing the series, or focusing on merge?
If the latter then opens are:
1) Link to Mesa MR reviewed and ready to merge.
2) IGT reviewed.
3) I raised an open that get/set_caching should not "lie" but return an error if set pat extension has been used. I don't see a good reason not to do that.
+ Joonas on this one.
4) Refactoring as done is not very pretty and I proposed an idea for a nicer approach. Feasible or not, open for discussion.
At a push I can look past that and someone can attempt to tidy the driver later.
But without 1-3 we cannot merge this.
Regards,
Tvrtko
Quoted 54 lines
Fei Yang (5):
drm/i915: preparation for using PAT index drm/i915: usepat_indexinstead ofcache_leveldrm/i915: make sure correct pte encode is used drm/i915/mtl: end support for set caching ioctl drm/i915: Allow user to set cache at BO creationdrivers/gpu/drm/i915/display/intel_dpt.c | 12 +-- drivers/gpu/drm/i915/gem/i915_gem_create.c | 36 +++++++++ drivers/gpu/drm/i915/gem/i915_gem_domain.c | 30 +++---- .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 10 ++- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 3 +- drivers/gpu/drm/i915/gem/i915_gem_object.c | 67 +++++++++++++++- drivers/gpu/drm/i915/gem/i915_gem_object.h | 8 ++ .../gpu/drm/i915/gem/i915_gem_object_types.h | 26 +++++- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 9 ++- drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 2 - drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 16 ++-- .../gpu/drm/i915/gem/selftests/huge_pages.c | 2 +- .../drm/i915/gem/selftests/i915_gem_migrate.c | 2 +- .../drm/i915/gem/selftests/i915_gem_mman.c | 2 +- drivers/gpu/drm/i915/gt/gen6_ppgtt.c | 10 ++- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 73 +++++++++-------- drivers/gpu/drm/i915/gt/gen8_ppgtt.h | 3 +- drivers/gpu/drm/i915/gt/intel_ggtt.c | 76 +++++++++--------- drivers/gpu/drm/i915/gt/intel_gtt.h | 20 +++-- drivers/gpu/drm/i915/gt/intel_migrate.c | 47 ++++++----- drivers/gpu/drm/i915/gt/intel_migrate.h | 13 ++- drivers/gpu/drm/i915/gt/intel_ppgtt.c | 6 +- drivers/gpu/drm/i915/gt/selftest_migrate.c | 47 +++++------ drivers/gpu/drm/i915/gt/selftest_reset.c | 8 +- drivers/gpu/drm/i915/gt/selftest_timeline.c | 2 +- drivers/gpu/drm/i915/gt/selftest_tlb.c | 4 +- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 10 ++- drivers/gpu/drm/i915/i915_debugfs.c | 55 ++++++++++--- drivers/gpu/drm/i915/i915_gem.c | 16 +++- drivers/gpu/drm/i915/i915_gpu_error.c | 8 +- drivers/gpu/drm/i915/i915_pci.c | 79 ++++++++++++++++--- drivers/gpu/drm/i915/i915_vma.c | 16 ++-- drivers/gpu/drm/i915/i915_vma.h | 2 +- drivers/gpu/drm/i915/i915_vma_types.h | 2 - drivers/gpu/drm/i915/intel_device_info.h | 5 ++ drivers/gpu/drm/i915/selftests/i915_gem.c | 5 +- .../gpu/drm/i915/selftests/i915_gem_evict.c | 4 +- drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 15 ++-- .../drm/i915/selftests/intel_memory_region.c | 4 +- .../gpu/drm/i915/selftests/mock_gem_device.c | 9 +++ drivers/gpu/drm/i915/selftests/mock_gtt.c | 8 +- include/uapi/drm/i915_drm.h | 36 +++++++++ tools/include/uapi/drm/i915_drm.h | 36 +++++++++ 44 files changed, 605 insertions(+), 243 deletions(-)
Quoted 8 lines · On 26/04/2023 07:24, [email protected] wrote:
Quoted 7 lines
From: Fei Yang <[email protected]>
The first three patches in this series are taken from
https://patchwork.freedesktop.org/series/116868/
These patches are included here because the last patch has dependency on thepat_indexrefactor.
Quoted 8 lines
Quoted 6 lines
This series is focusing on uAPI changes,
1. end support for set caching ioctl [PATCH 4/5]
2. addset_patextension forgem_create[PATCH 5/5]v2: drop one patch that was merged separately
341ad0e8e254 drm/i915/mtl: Add PTE encode functionAre the re-sends for stabilizing the series, or focusing on merge?
v2 was sent just to drop one of patches that has already been merged.
Quoted 9 lines
If the latter then opens are:
1) Link to Mesa MR reviewed and ready to merge.
2) IGT reviewed.
3) I raised an open that get/set_caching should not "lie" but return an error if set pat extension has been used. I don't see a good reason not to do that.
I don't think it's "lying" to the userspace. the comparison is only valid for objects created by KMD because only such object uses the pat_index from the cachelevel_to_pat table.
Quoted 4 lines
+ Joonas on this one.
4) Refactoring as done is not very pretty and I proposed an idea for a nicer approach. Feasible or not, open for discussion.
Still digesting your proposal. but not sure how would you define things like PAT_UC as that is platform dependent, not a constant.
- Fei
Quoted 8 lines
At a push I can look past that and someone can attempt to tidy the driver later.
But without 1-3 we cannot merge this.
Regards,
Tvrtko
Quoted 25 lines · Fei
Quoted 8 lines · On 26/04/2023 07:24, [email protected] wrote:
Quoted 7 lines
From: Fei Yang <[email protected]>
The first three patches in this series are taken from
https://patchwork.freedesktop.org/series/116868/
These patches are included here because the last patch has dependency on thepat_indexrefactor.Quoted 8 lines
Quoted 6 lines
This series is focusing on uAPI changes,
1. end support for set caching ioctl [PATCH 4/5]
2. addset_patextension forgem_create[PATCH 5/5]v2: drop one patch that was merged separately
341ad0e8e254drm/i915/mtl: Add PTE encode functionAre the re-sends for stabilizing the series, or focusing on merge?
v2 was sent just to drop one of patches that has already been merged.
Quoted 6 lines
If the latter then opens are:
1) Link to Mesa MR reviewed and ready to merge.
2) IGT reviewed.
Quoted 7 lines
Quoted 3 lines
3) I raised an open that get/set_caching should not "lie" but return an error if set pat extension has been used. I don't see a good reason not to do that.
I don't think it's "lying" to the userspace. the comparison is only valid for objects created by KMD because only such object uses the
pat_indexfrom thecachelevel_to_pattable.
Lets double check my understanding is correct. Userspace sequence of operations:
1)
obj = gem_create()+set_pat(PAT_UC)
2a)get_caching(obj)
What gets reported?
2b)set_caching(obj, I915_CACHE_LLC)
What is the return code?
If answer to 2a is I915_CACHING_CACHED and to 2b) success, then please state a good reason why both shouldn't return an error.
Quoted 8 lines
Quoted 5 lines
+ Joonas on this one.
4) Refactoring as done is not very pretty and I proposed an idea for a nicer approach. Feasible or not, open for discussion.
Still digesting your proposal. but not sure how would you define things like
PAT_UCas that is platform dependent, not a constant.
"PAT_UC" in my outline was purely a driver specific value, similarly as I915_CACHE_... are. With the whole point that driver can ask if something is uncached, WT or whatever. Using the platform specific mapping table which converts platform specific obj->pat_index to driver representation of caching modes (PAT_UC etc).
Quite possible I missed some detail, but if I haven't then it could be a neat and lightweight solution.
Regards,
Tvrtko
Quoted 34 lines · Fei
Quoted 25 lines
Quoted 8 lines · On 26/04/2023 07:24, [email protected] wrote:
Quoted 7 lines
From: Fei Yang <[email protected]>
The first three patches in this series are taken from
https://patchwork.freedesktop.org/series/116868/
These patches are included here because the last patch has dependency on thepat_indexrefactor.Quoted 8 lines
Quoted 6 lines
This series is focusing on uAPI changes,
1. end support for set caching ioctl [PATCH 4/5]
2. addset_patextension forgem_create[PATCH 5/5]v2: drop one patch that was merged separately
341ad0e8e254 drm/i915/mtl: Add PTE encode functionAre the re-sends for stabilizing the series, or focusing on merge?
v2 was sent just to drop one of patches that has already been merged.
Quoted 6 lines
If the latter then opens are:
1) Link to Mesa MR reviewed and ready to merge.
2) IGT reviewed.
Quoted 7 lines
Quoted 3 lines
3) I raised an open that get/set_caching should not "lie" but return an error if set pat extension has been used. I don't see a good reason not to do that.
I don't think it's "lying" to the userspace. the comparison is only valid for objects created by KMD because only such object uses the
pat_indexfrom thecachelevel_to_pattable.
Quoted 8 lines
Lets double check my understanding is correct. Userspace sequence of operations:
1)
obj = gem_create()+set_pat(PAT_UC)2a)
get_caching(obj)
What gets reported?
I see your point here. nice catch.
That should be handled by,
if (obj->cachel_level == I915_CACHE_INVAL) /* indicated pat-index is set by userspace */ return -EOPNOTSUPP;
Will update the patch.
Quoted 4 lines
2b)
set_caching(obj, I915_CACHE_LLC)
What is the return code?
This will either return -EOPNOTSUPP, or ignored because set_pat extension was called.
Quoted 7 lines
If answer to 2a is
I915_CACHING_CACHEDand to 2b) success, then please state a good reason why both shouldn't return an error.Quoted 3 lines
Quoted 3 lines
+ Joonas on this one.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
4) Refactoring as done is not very pretty and I proposed an idea for a nicer approach. Feasible or not, open for discussion.
Still digesting your proposal. but not sure how would you define things like
PAT_UCas that is platform dependent, not a constant."
PAT_UC" in my outline was purely a driver specific value, similarly asI915_CACHE_... are.
Okay. Then you were suggesting to add a translation table for pat_index-to-(PAT-UC/WB/WT)? It's going to be a N:1 mapping.
Quoted 4 lines
With the whole point that driver can ask if
something is uncached, WT or whatever. Using the platform specific mapping table which converts platform specificobj->pat_indexto driver representation of caching modes (PAT_UCetc).
Are you suggesting completely remove i915_cache_level and use (PAT-UC/WB/WT) instead? Let's say a KMD object wants to be set as WB, how you get the exact pat_index to use? Note that there are multiple PAT indices having caching mod WB, but they are different, e.g. do you want just WB or WB with 1-way-coherency or WB with 2-way coherency?
Also, in case a checking of pat_index is needed, do we say WB with 1-way-coherency is equal to WB or not?
BTW, isn't PAT-UC/WB/WT the same kind of abstraction as enum i915_cache_level, I'm not sure how that would simplify anything.
Quoted 6 lines
Quite possible I missed some detail, but if I haven't then it could be a neat and lightweight solution.
Regards,
Tvrtko
Quoted 51 lines · Fei
Quoted 24 lines · Fei
Quoted 23 lines
Quoted 8 lines · On 26/04/2023 07:24, [email protected] wrote:
Quoted 7 lines
From: Fei Yang <[email protected]>
The first three patches in this series are taken from
https://patchwork.freedesktop.org/series/116868/
These patches are included here because the last patch has dependency on thepat_indexrefactor.Quoted 8 lines
Quoted 6 lines
This series is focusing on uAPI changes,
1. end support for set caching ioctl [PATCH 4/5]
2. addset_patextension forgem_create[PATCH 5/5]v2: drop one patch that was merged separately
341ad0e8e254drm/i915/mtl: Add PTE encode functionAre the re-sends for stabilizing the series, or focusing on merge?
v2 was sent just to drop one of patches that has already been merged.
Quoted 4 lines
If the latter then opens are:
1) Link to Mesa MR reviewed and ready to merge.
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
2) IGT reviewed.
3) I raised an open that get/set_caching should not "lie" but return an error if set pat extension has been used. I don't see a good reason not to do that.
I don't think it's "lying" to the userspace. the comparison is only
valid
Quoted 11 lines
Quoted 2 lines
for objects created by KMD because only such object uses the
pat_indexfrom thecachelevel_to_pattable.Lets double check my understanding is correct. Userspace sequence of operations:
1)
obj = gem_create()+set_pat(PAT_UC)2a)
get_caching(obj)
What gets reported?I see your point here. nice catch.
That should be handled by,
if (obj->cachel_level==I915_CACHE_INVAL) /* indicated pat-index is set by userspace */ return-EOPNOTSUPP;
Will update the patch.Quoted 1 line
Quoted 5 lines
Quoted 3 lines
2b)
set_caching(obj, I915_CACHE_LLC)
What is the return code?This will either return
-EOPNOTSUPP, or ignored becauseset_patextension was called.
I see that you made it fail instead of fake success in the latest respin and I definitely agree with that.
Quoted 11 lines
Quoted 11 lines
If answer to 2a is
I915_CACHING_CACHEDand to 2b) success, then please state a good reason why both shouldn't return an error.Quoted 6 lines
Quoted 5 lines
+ Joonas on this one.
4) Refactoring as done is not very pretty and I proposed an idea for a nicer approach. Feasible or not, open for discussion.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Still digesting your proposal. but not sure how would you define things like
PAT_UCas that is platform dependent, not a constant."
PAT_UC" in my outline was purely a driver specific value, similarly asI915_CACHE_... are.Okay. Then you were suggesting to add a translation table for pat_index-to-(PAT-UC/WB/WT)? It's going to be a N:1 mapping.
PAT index to a value, probably a bitmask, built out of bits which define caching modes. Like "PAT_WB | PAT_1WAY_COHERENT", or just PAT_WB. Would that approach be enough to express everything?
Quoted 7 lines
Quoted 5 lines
With the whole point that driver can ask if
something is uncached, WT or whatever. Using the platform specific mapping table which converts platform specificobj->pat_indexto driver representation of caching modes (PAT_UCetc).Are you suggesting completely remove
i915_cache_leveland use (PAT-UC/WB/WT) instead?
Not completely but throughout the most internal code paths, which would all just work on PAT index. Basically object always has PAT index set, with a separate boolean saying whether it came from gem_create_ext or set_cache_level.
Quoted 3 lines
Let's say a KMD object wants to be set as WB, how you get the exact
pat_indexto use? Note that there are multiple PAT indices having caching mod WB, but they are different, e.g. do you want just WB or WB with 1-way-coherency or WB with 2-way coherency?
Just use the cache_level to pat_index mapping you added in the series?
Quoted 2 lines
Also, in case a checking of
pat_indexis needed, do we say WB with 1-way-coherency is equal to WB or not?
You mean the call sites where i915 is checking the object caching mode?
We have two call sites which check for !I915_CACHE_NONE. Those would just check if PAT_UC is not set.
Then the one in gpu_write_needs_clflush is checking for neither UC nor WT, which also directly translates.
For the WB case there aren't any callers but if we just checked for "base" PAT_WB bit being set that would work.
So in all cases helper which does "return bits_required | bits_set" seems would work fine.
Quoted 2 lines
BTW, isn't PAT-UC/WB/WT the same kind of abstraction as enum
i915_cache_level, I'm not sure how that would simplify anything.
As I wrote before, I *think* it provides a way of not needing to sprinkle around i915_gem_get_pat_index and a simpler "has_cache_level". Conceptually cache_level->pat_index is done only in gem_create_ext and set_cache_level. Lower level code does not have to consult cache_level at all. And existence of tables simplifies the pretty printing code to a platform agnostic loop.
I *think* at least.. We can leave it all for later. My main concern was that UAPI needs to be clear and solid which it now seems to be.
Regards,
Tvrtko
Quoted 7 lines
Quoted 7 lines
Quite possible I missed some detail, but if I haven't then it could be a neat and lightweight solution.
Regards,
Tvrtko
Quoted 55 lines · Fei
Quoted 54 lines
Quoted 34 lines · Fei
Quoted 25 lines
Quoted 8 lines · On 26/04/2023 07:24, [email protected] wrote:
Quoted 7 lines
From: Fei Yang <[email protected]>
The first three patches in this series are taken from
https://patchwork.freedesktop.org/series/116868/
These patches are included here because the last patch has dependency on thepat_indexrefactor.Quoted 8 lines
Quoted 6 lines
This series is focusing on uAPI changes,
1. end support for set caching ioctl [PATCH 4/5]
2. addset_patextension forgem_create[PATCH 5/5]v2: drop one patch that was merged separately
341ad0e8e254 drm/i915/mtl: Add PTE encode functionAre the re-sends for stabilizing the series, or focusing on merge?
v2 was sent just to drop one of patches that has already been merged.
Quoted 6 lines
If the latter then opens are:
1) Link to Mesa MR reviewed and ready to merge.
2) IGT reviewed.
Quoted 7 lines
Quoted 3 lines
3) I raised an open that get/set_caching should not "lie" but return an error if set pat extension has been used. I don't see a good reason not to do that.
I don't think it's "lying" to the userspace. the comparison is only valid for objects created by KMD because only such object uses the
pat_indexfrom thecachelevel_to_pattable.Quoted 8 lines
Lets double check my understanding is correct. Userspace sequence of operations:
1)
obj = gem_create()+set_pat(PAT_UC)2a)
get_caching(obj)
What gets reported?I see your point here. nice catch.
That should be handled by,
if (obj->cachel_level==I915_CACHE_INVAL) /* indicated pat-index is set by userspace */ return-EOPNOTSUPP;
Will update the patch.Quoted 4 lines
2b)
set_caching(obj, I915_CACHE_LLC)
What is the return code?
Quoted 5 lines
Quoted 2 lines
This will either return
-EOPNOTSUPP, or ignored becauseset_patextension was called.I see that you made it fail instead of fake success in the latest respin and I definitely agree with that.
Thanks for your picky eyes. :)
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
If answer to 2a is
I915_CACHING_CACHEDand to 2b) success, then please state a good reason why both shouldn't return an error.Quoted 8 lines
Quoted 5 lines
+ Joonas on this one.
4) Refactoring as done is not very pretty and I proposed an idea for a nicer approach. Feasible or not, open for discussion.
Still digesting your proposal. but not sure how would you define things like
PAT_UCas that is platform dependent, not a constant."
PAT_UC" in my outline was purely a driver specific value, similarly asI915_CACHE_... are.
Quoted 7 lines
Quoted 3 lines
Okay. Then you were suggesting to add a translation table for pat_index-to-(PAT-UC/WB/WT)?
It's going to be a N:1 mapping.PAT index to a value, probably a bitmask, built out of bits which define caching modes. Like "
PAT_WB|PAT_1WAY_COHERENT", or justPAT_WB. Would that approach be enough to express everything?
I was thinking about dumping the PAT tables from Bspec into struct intel_device_info {}. But that would be only useful to unify all those *_setup_private_ppat() functions in intel_gtt.c. Kernel doesn't really care much about PAT index except making sure the bits are programmed correctly in PTE.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
With the whole point that driver can ask if
something is uncached, WT or whatever. Using the platform specific mapping table which converts platform specificobj->pat_indexto driver representation of caching modes (PAT_UCetc).
Quoted 7 lines
Quoted 2 lines
Are you suggesting completely remove
i915_cache_leveland use (PAT-UC/WB/WT) instead?Not completely but throughout the most internal code paths, which would all just work on PAT index. Basically object always has PAT index set, with a separate boolean saying whether it came from
gem_create_extorset_cache_level.
What's in my mind as an improvement is to completely remove i915_cache_level. KMD is supposed to abstract the hardware, but in this case, since the desgin is that UMDs understand PAT index (and MOCS as well), having an abstraction in between would only introduce ambiguity and complexity.
Also kernel doesn't need to play with all available PAT indices, so it should be okay to add i915->pat_{uc|wb|wt} and initialize them with proper indices respectively. That takes care of the PAT checking as well wherever it's needed, like "if (pat_index == i915->pat_uc)"
Quoted 34 lines
Quoted 4 lines
Let's say a KMD object wants to be set as WB, how you get the exact
pat_indexto use? Note that there are multiple PAT indices having caching mod WB, but they are different, e.g. do you want just WB or WB with 1-way-coherency or WB with 2-way coherency?Just use the
cache_leveltopat_indexmapping you added in the series?Quoted 2 lines
Also, in case a checking of
pat_indexis needed, do we say WB with 1-way-coherency is equal to WB or not?You mean the call sites where i915 is checking the object caching mode? We have two call sites which check for !I915_CACHE_NONE. Those would just check if
PAT_UCis not set.Then the one in
gpu_write_needs_clflushis checking for neither UC nor WT, which also directly translates.For the WB case there aren't any callers but if we just checked for "base"
PAT_WBbit being set that would work.So in all cases helper which does "return
bits_required|bits_set" seems would work fine.Quoted 3 lines
BTW, isn't PAT-UC/WB/WT the same kind of abstraction as enum
i915_cache_level, I'm not
sure how that would simplify anything.As I wrote before, I *think* it provides a way of not needing to sprinkle around
i915_gem_get_pat_indexand a simpler "has_cache_level". Conceptuallycache_level->pat_indexis done only ingem_create_extandset_cache_level. Lower level code does not have to consultcache_levelat all. And existence of tables simplifies the pretty printing code to a platform agnostic loop.
Quoted 2 lines
I *think* at least.. We can leave it all for later. My main concern was that UAPI needs to be clear and solid which it now seems to be.
I'm hesitant to do all that I said above in one shot. But I think completely removing enum i915_cache_level is what to do next.
-Fei
Quoted 7 lines
Regards,
Tvrtko
Quoted 3 lines
Quoted 3 lines
Quite possible I missed some detail, but if I haven't then it could be a neat and lightweight solution.