]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915/gtt: add xehpsdv_ppgtt_insert_entry
authorMatthew Auld <matthew.auld@intel.com>
Fri, 18 Feb 2022 18:47:47 +0000 (00:17 +0530)
committerLucas De Marchi <lucas.demarchi@intel.com>
Sun, 20 Feb 2022 06:26:46 +0000 (22:26 -0800)
If this is LMEM then we get a 32 entry PT, with each PTE pointing to
some 64K block of memory, otherwise it's just the usual 512 entry PT.
This very much assumes the caller knows what they are doing.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220218184752.7524-11-ramalingam.c@intel.com
drivers/gpu/drm/i915/gt/gen8_ppgtt.c

index 62471730266c6b10557bfa3492d11fd45d305ed3..f574da00eff144159a1bbc05ef5196c5a9019fa1 100644 (file)
@@ -715,13 +715,56 @@ static void gen8_ppgtt_insert_entry(struct i915_address_space *vm,
                gen8_pdp_for_page_index(vm, idx);
        struct i915_page_directory *pd =
                i915_pd_entry(pdp, gen8_pd_index(idx, 2));
+       struct i915_page_table *pt = i915_pt_entry(pd, gen8_pd_index(idx, 1));
        gen8_pte_t *vaddr;
 
-       vaddr = px_vaddr(i915_pt_entry(pd, gen8_pd_index(idx, 1)));
+       GEM_BUG_ON(pt->is_compact);
+
+       vaddr = px_vaddr(pt);
        vaddr[gen8_pd_index(idx, 0)] = gen8_pte_encode(addr, level, flags);
        clflush_cache_range(&vaddr[gen8_pd_index(idx, 0)], sizeof(*vaddr));
 }
 
+static void __xehpsdv_ppgtt_insert_entry_lm(struct i915_address_space *vm,
+                                           dma_addr_t addr,
+                                           u64 offset,
+                                           enum i915_cache_level level,
+                                           u32 flags)
+{
+       u64 idx = offset >> GEN8_PTE_SHIFT;
+       struct i915_page_directory * const pdp =
+               gen8_pdp_for_page_index(vm, idx);
+       struct i915_page_directory *pd =
+               i915_pd_entry(pdp, gen8_pd_index(idx, 2));
+       struct i915_page_table *pt = i915_pt_entry(pd, gen8_pd_index(idx, 1));
+       gen8_pte_t *vaddr;
+
+       GEM_BUG_ON(!IS_ALIGNED(addr, SZ_64K));
+       GEM_BUG_ON(!IS_ALIGNED(offset, SZ_64K));
+
+       if (!pt->is_compact) {
+               vaddr = px_vaddr(pd);
+               vaddr[gen8_pd_index(idx, 1)] |= GEN12_PDE_64K;
+               pt->is_compact = true;
+       }
+
+       vaddr = px_vaddr(pt);
+       vaddr[gen8_pd_index(idx, 0) / 16] = gen8_pte_encode(addr, level, flags);
+}
+
+static void xehpsdv_ppgtt_insert_entry(struct i915_address_space *vm,
+                                      dma_addr_t addr,
+                                      u64 offset,
+                                      enum i915_cache_level level,
+                                      u32 flags)
+{
+       if (flags & PTE_LM)
+               return __xehpsdv_ppgtt_insert_entry_lm(vm, addr, offset,
+                                                      level, flags);
+
+       return gen8_ppgtt_insert_entry(vm, addr, offset, level, flags);
+}
+
 static int gen8_init_scratch(struct i915_address_space *vm)
 {
        u32 pte_flags;
@@ -921,7 +964,10 @@ struct i915_ppgtt *gen8_ppgtt_create(struct intel_gt *gt,
 
        ppgtt->vm.bind_async_flags = I915_VMA_LOCAL_BIND;
        ppgtt->vm.insert_entries = gen8_ppgtt_insert;
-       ppgtt->vm.insert_page = gen8_ppgtt_insert_entry;
+       if (HAS_64K_PAGES(gt->i915))
+               ppgtt->vm.insert_page = xehpsdv_ppgtt_insert_entry;
+       else
+               ppgtt->vm.insert_page = gen8_ppgtt_insert_entry;
        ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc;
        ppgtt->vm.clear_range = gen8_ppgtt_clear;
        ppgtt->vm.foreach = gen8_ppgtt_foreach;