Skip to content

Commit 5f97816

Browse files
michaelonchromelucasdemarchi
authored andcommitted
drm/i915: Introduce new macros for i915 PTE
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 <[email protected]> Reviewed-by: Lucas De Marchi <[email protected]> [ Move defines together with other GEN8 defines ] Signed-off-by: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 8722ded commit 5f97816

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

drivers/gpu/drm/i915/gt/gen8_ppgtt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
static u64 gen8_pde_encode(const dma_addr_t addr,
1919
const enum i915_cache_level level)
2020
{
21-
u64 pde = addr | _PAGE_PRESENT | _PAGE_RW;
21+
u64 pde = addr | GEN8_PAGE_PRESENT | GEN8_PAGE_RW;
2222

2323
if (level != I915_CACHE_NONE)
2424
pde |= PPAT_CACHED_PDE;
@@ -32,10 +32,10 @@ static u64 gen8_pte_encode(dma_addr_t addr,
3232
enum i915_cache_level level,
3333
u32 flags)
3434
{
35-
gen8_pte_t pte = addr | _PAGE_PRESENT | _PAGE_RW;
35+
gen8_pte_t pte = addr | GEN8_PAGE_PRESENT | GEN8_PAGE_RW;
3636

3737
if (unlikely(flags & PTE_READ_ONLY))
38-
pte &= ~_PAGE_RW;
38+
pte &= ~GEN8_PAGE_RW;
3939

4040
if (flags & PTE_LM)
4141
pte |= GEN12_PPGTT_PTE_LM;

drivers/gpu/drm/i915/gt/intel_ggtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ u64 gen8_ggtt_pte_encode(dma_addr_t addr,
192192
enum i915_cache_level level,
193193
u32 flags)
194194
{
195-
gen8_pte_t pte = addr | _PAGE_PRESENT;
195+
gen8_pte_t pte = addr | GEN8_PAGE_PRESENT;
196196

197197
if (flags & PTE_LM)
198198
pte |= GEN12_GGTT_PTE_LM;

drivers/gpu/drm/i915/gt/intel_gtt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ typedef u64 gen8_pte_t;
135135
#define GEN8_PPAT_ELLC_OVERRIDE (0<<2)
136136
#define GEN8_PPAT(i, x) ((u64)(x) << ((i) * 8))
137137

138+
#define GEN8_PAGE_PRESENT BIT_ULL(0)
139+
#define GEN8_PAGE_RW BIT_ULL(1)
140+
138141
#define GEN8_PDE_IPS_64K BIT(11)
139142
#define GEN8_PDE_PS_2M BIT(7)
140143

drivers/gpu/drm/i915/gvt/gtt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,17 +446,17 @@ static bool gen8_gtt_test_present(struct intel_gvt_gtt_entry *e)
446446
|| e->type == GTT_TYPE_PPGTT_ROOT_L4_ENTRY)
447447
return (e->val64 != 0);
448448
else
449-
return (e->val64 & _PAGE_PRESENT);
449+
return (e->val64 & GEN8_PAGE_PRESENT);
450450
}
451451

452452
static void gtt_entry_clear_present(struct intel_gvt_gtt_entry *e)
453453
{
454-
e->val64 &= ~_PAGE_PRESENT;
454+
e->val64 &= ~GEN8_PAGE_PRESENT;
455455
}
456456

457457
static void gtt_entry_set_present(struct intel_gvt_gtt_entry *e)
458458
{
459-
e->val64 |= _PAGE_PRESENT;
459+
e->val64 |= GEN8_PAGE_PRESENT;
460460
}
461461

462462
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,
24392439
/* The entry parameters like present/writeable/cache type
24402440
* set to the same as i915's scratch page tree.
24412441
*/
2442-
se.val64 |= _PAGE_PRESENT | _PAGE_RW;
2442+
se.val64 |= GEN8_PAGE_PRESENT | GEN8_PAGE_RW;
24432443
if (type == GTT_TYPE_PPGTT_PDE_PT)
24442444
se.val64 |= PPAT_CACHED;
24452445

@@ -2896,15 +2896,15 @@ void intel_gvt_restore_ggtt(struct intel_gvt *gvt)
28962896
offset = vgpu_aperture_gmadr_base(vgpu) >> PAGE_SHIFT;
28972897
for (idx = 0; idx < num_low; idx++) {
28982898
pte = mm->ggtt_mm.host_ggtt_aperture[idx];
2899-
if (pte & _PAGE_PRESENT)
2899+
if (pte & GEN8_PAGE_PRESENT)
29002900
write_pte64(vgpu->gvt->gt->ggtt, offset + idx, pte);
29012901
}
29022902

29032903
num_hi = vgpu_hidden_sz(vgpu) >> PAGE_SHIFT;
29042904
offset = vgpu_hidden_gmadr_base(vgpu) >> PAGE_SHIFT;
29052905
for (idx = 0; idx < num_hi; idx++) {
29062906
pte = mm->ggtt_mm.host_ggtt_hidden[idx];
2907-
if (pte & _PAGE_PRESENT)
2907+
if (pte & GEN8_PAGE_PRESENT)
29082908
write_pte64(vgpu->gvt->gt->ggtt, offset + idx, pte);
29092909
}
29102910
}

0 commit comments

Comments
 (0)