]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Introduce new macros for i915 PTE
authorMichael Cheng <michael.cheng@intel.com>
Mon, 6 Dec 2021 21:52:45 +0000 (13:52 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 7 Dec 2021 06:21:03 +0000 (22:21 -0800)
Certain functions within i915 uses macros that are defined for
specific architectures by the mmu, such as _PAGE_RW and _PAGE_PRESENT
(Some architectures don't even have these macros defined, like ARM64).

Instead of re-using bits defined for the CPU, we should use bits
defined for i915. This patch introduces two new 64 bit macros,
GEN8_PAGE_PRESENT and GEN8_PAGE_RW, to check for bits 0 and 1 and, to
replace all occurrences of _PAGE_RW and _PAGE_PRESENT within i915.

v2(Michael Cheng): Use GEN8_ instead of I915_

Signed-off-by: Michael Cheng <michael.cheng@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
[ Move defines together with other GEN8 defines ]
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211206215245.513677-2-michael.cheng@intel.com
drivers/gpu/drm/i915/gt/gen8_ppgtt.c
drivers/gpu/drm/i915/gt/intel_ggtt.c
drivers/gpu/drm/i915/gt/intel_gtt.h
drivers/gpu/drm/i915/gvt/gtt.c

index 9966e9dc5218c2db2b00acec7028731d2c5f99b4..95c02096a61bb62743c7dc928b082d90fe61019e 100644 (file)
@@ -18,7 +18,7 @@
 static u64 gen8_pde_encode(const dma_addr_t addr,
                           const enum i915_cache_level level)
 {
-       u64 pde = addr | _PAGE_PRESENT | _PAGE_RW;
+       u64 pde = addr | GEN8_PAGE_PRESENT | GEN8_PAGE_RW;
 
        if (level != I915_CACHE_NONE)
                pde |= PPAT_CACHED_PDE;
@@ -32,10 +32,10 @@ static u64 gen8_pte_encode(dma_addr_t addr,
                           enum i915_cache_level level,
                           u32 flags)
 {
-       gen8_pte_t pte = addr | _PAGE_PRESENT | _PAGE_RW;
+       gen8_pte_t pte = addr | GEN8_PAGE_PRESENT | GEN8_PAGE_RW;
 
        if (unlikely(flags & PTE_READ_ONLY))
-               pte &= ~_PAGE_RW;
+               pte &= ~GEN8_PAGE_RW;
 
        if (flags & PTE_LM)
                pte |= GEN12_PPGTT_PTE_LM;
index b943f202e35acecf404a4e7d0a85f967d88e2678..7a85d658b08d43472331715ba36243bc93e19a09 100644 (file)
@@ -192,7 +192,7 @@ u64 gen8_ggtt_pte_encode(dma_addr_t addr,
                         enum i915_cache_level level,
                         u32 flags)
 {
-       gen8_pte_t pte = addr | _PAGE_PRESENT;
+       gen8_pte_t pte = addr | GEN8_PAGE_PRESENT;
 
        if (flags & PTE_LM)
                pte |= GEN12_GGTT_PTE_LM;
index bc675026335991e0ac86bb17c44fa1df5f409fdf..d8377ed59636fc7ad335c65efe867afcd66f12ca 100644 (file)
@@ -135,6 +135,9 @@ typedef u64 gen8_pte_t;
 #define GEN8_PPAT_ELLC_OVERRIDE                (0<<2)
 #define GEN8_PPAT(i, x)                        ((u64)(x) << ((i) * 8))
 
+#define GEN8_PAGE_PRESENT              BIT_ULL(0)
+#define GEN8_PAGE_RW                   BIT_ULL(1)
+
 #define GEN8_PDE_IPS_64K BIT(11)
 #define GEN8_PDE_PS_2M   BIT(7)
 
index 53d0cb3275398c6e023ccdaaaec4b1dddd6e2b29..99d1781fa5f0c1dc054032793d62b89f09dcaacc 100644 (file)
@@ -446,17 +446,17 @@ static bool gen8_gtt_test_present(struct intel_gvt_gtt_entry *e)
                        || e->type == GTT_TYPE_PPGTT_ROOT_L4_ENTRY)
                return (e->val64 != 0);
        else
-               return (e->val64 & _PAGE_PRESENT);
+               return (e->val64 & GEN8_PAGE_PRESENT);
 }
 
 static void gtt_entry_clear_present(struct intel_gvt_gtt_entry *e)
 {
-       e->val64 &= ~_PAGE_PRESENT;
+       e->val64 &= ~GEN8_PAGE_PRESENT;
 }
 
 static void gtt_entry_set_present(struct intel_gvt_gtt_entry *e)
 {
-       e->val64 |= _PAGE_PRESENT;
+       e->val64 |= GEN8_PAGE_PRESENT;
 }
 
 static bool gen8_gtt_test_64k_splited(struct intel_gvt_gtt_entry *e)
@@ -2439,7 +2439,7 @@ static int alloc_scratch_pages(struct intel_vgpu *vgpu,
                /* The entry parameters like present/writeable/cache type
                 * set to the same as i915's scratch page tree.
                 */
-               se.val64 |= _PAGE_PRESENT | _PAGE_RW;
+               se.val64 |= GEN8_PAGE_PRESENT | GEN8_PAGE_RW;
                if (type == GTT_TYPE_PPGTT_PDE_PT)
                        se.val64 |= PPAT_CACHED;
 
@@ -2896,7 +2896,7 @@ void intel_gvt_restore_ggtt(struct intel_gvt *gvt)
                offset = vgpu_aperture_gmadr_base(vgpu) >> PAGE_SHIFT;
                for (idx = 0; idx < num_low; idx++) {
                        pte = mm->ggtt_mm.host_ggtt_aperture[idx];
-                       if (pte & _PAGE_PRESENT)
+                       if (pte & GEN8_PAGE_PRESENT)
                                write_pte64(vgpu->gvt->gt->ggtt, offset + idx, pte);
                }
 
@@ -2904,7 +2904,7 @@ void intel_gvt_restore_ggtt(struct intel_gvt *gvt)
                offset = vgpu_hidden_gmadr_base(vgpu) >> PAGE_SHIFT;
                for (idx = 0; idx < num_hi; idx++) {
                        pte = mm->ggtt_mm.host_ggtt_hidden[idx];
-                       if (pte & _PAGE_PRESENT)
+                       if (pte & GEN8_PAGE_PRESENT)
                                write_pte64(vgpu->gvt->gt->ggtt, offset + idx, pte);
                }
        }