All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs
@ 2019-06-11 17:27 Mika Kuoppala
  2019-06-11 17:27 ` [PATCH 2/9] drm/i915/gtt: Use a common type for page directories Mika Kuoppala
                   ` (12 more replies)
  0 siblings, 13 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-06-11 17:27 UTC (permalink / raw)
  To: intel-gfx

We set them to scratch right after allocation so prevent
useless zeroing before.

v2: atomic_t

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index e70675bfb51d..07f86d474fa2 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -687,7 +687,7 @@ static struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
 {
 	struct i915_page_directory *pd;
 
-	pd = kzalloc(sizeof(*pd), I915_GFP_ALLOW_FAIL);
+	pd = kmalloc(sizeof(*pd), I915_GFP_ALLOW_FAIL);
 	if (unlikely(!pd))
 		return ERR_PTR(-ENOMEM);
 
@@ -747,7 +747,7 @@ alloc_pdp(struct i915_address_space *vm)
 
 	GEM_BUG_ON(!i915_vm_is_4lvl(vm));
 
-	pdp = kzalloc(sizeof(*pdp), GFP_KERNEL);
+	pdp = kmalloc(sizeof(*pdp), GFP_KERNEL);
 	if (!pdp)
 		return ERR_PTR(-ENOMEM);
 
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/9] drm/i915/gtt: Use a common type for page directories
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
@ 2019-06-11 17:27 ` Mika Kuoppala
  2019-06-11 19:41   ` Chris Wilson
  2019-06-11 19:43   ` Chris Wilson
  2019-06-11 17:27 ` [PATCH 3/9] drm/i915/gtt: Introduce init_pd_with_page Mika Kuoppala
                   ` (11 subsequent siblings)
  12 siblings, 2 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-06-11 17:27 UTC (permalink / raw)
  To: intel-gfx

All page directories are identical in function, only the position in the
hierarchy differ. Use same base type for directory functionality.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Matthew Auld <matthew.william.auld@gmail.com>
Cc: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c |   2 +-
 drivers/gpu/drm/i915/gt/intel_lrc_reg.h     |   2 +-
 drivers/gpu/drm/i915/gt/intel_ringbuffer.c  |   2 +-
 drivers/gpu/drm/i915/gvt/scheduler.c        |  30 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c         | 349 ++++++++++----------
 drivers/gpu/drm/i915/i915_gem_gtt.h         |  64 ++--
 6 files changed, 234 insertions(+), 215 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index c86ca9f21532..dbab0ab1cef1 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1038,7 +1038,7 @@ static int emit_ppgtt_update(struct i915_request *rq, void *data)
 
 	if (i915_vm_is_4lvl(vm)) {
 		struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
-		const dma_addr_t pd_daddr = px_dma(&ppgtt->pml4);
+		const dma_addr_t pd_daddr = px_dma(ppgtt->pd);
 
 		cs = intel_ring_begin(rq, 6);
 		if (IS_ERR(cs))
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
index 5ef932d810a7..6bf34738b4e5 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
+++ b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
@@ -55,7 +55,7 @@
 
 #define ASSIGN_CTX_PML4(ppgtt, reg_state) do { \
 	u32 *reg_state__ = (reg_state); \
-	const u64 addr__ = px_dma(&ppgtt->pml4); \
+	const u64 addr__ = px_dma(ppgtt->pd); \
 	(reg_state__)[CTX_PDP0_UDW + 1] = upper_32_bits(addr__); \
 	(reg_state__)[CTX_PDP0_LDW + 1] = lower_32_bits(addr__); \
 } while (0)
diff --git a/drivers/gpu/drm/i915/gt/intel_ringbuffer.c b/drivers/gpu/drm/i915/gt/intel_ringbuffer.c
index c834d016c965..3b857994943c 100644
--- a/drivers/gpu/drm/i915/gt/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/gt/intel_ringbuffer.c
@@ -1523,7 +1523,7 @@ static int load_pd_dir(struct i915_request *rq, const struct i915_ppgtt *ppgtt)
 
 	*cs++ = MI_LOAD_REGISTER_IMM(1);
 	*cs++ = i915_mmio_reg_offset(RING_PP_DIR_BASE(engine->mmio_base));
-	*cs++ = ppgtt->pd.base.ggtt_offset << 10;
+	*cs++ = ppgtt->pd->base.ggtt_offset << 10;
 
 	intel_ring_advance(rq, cs);
 
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index e301efb18d45..f1e1261ac3db 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -375,11 +375,13 @@ static int set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload,
 		return -EINVAL;
 
 	if (mm->ppgtt_mm.root_entry_type == GTT_TYPE_PPGTT_ROOT_L4_ENTRY) {
-		px_dma(&ppgtt->pml4) = mm->ppgtt_mm.shadow_pdps[0];
+		px_dma(ppgtt->pd) = mm->ppgtt_mm.shadow_pdps[0];
 	} else {
 		for (i = 0; i < GVT_RING_CTX_NR_PDPS; i++) {
-			px_dma(ppgtt->pdp.page_directory[i]) =
-				mm->ppgtt_mm.shadow_pdps[i];
+			struct i915_page_directory * const pd =
+				i915_pd_entry(ppgtt->pd, i);
+
+			px_dma(pd) = mm->ppgtt_mm.shadow_pdps[i];
 		}
 	}
 
@@ -1128,11 +1130,14 @@ i915_context_ppgtt_root_restore(struct intel_vgpu_submission *s,
 	int i;
 
 	if (i915_vm_is_4lvl(&ppgtt->vm)) {
-		px_dma(&ppgtt->pml4) = s->i915_context_pml4;
+		px_dma(ppgtt->pd) = s->i915_context_pml4;
 	} else {
-		for (i = 0; i < GEN8_3LVL_PDPES; i++)
-			px_dma(ppgtt->pdp.page_directory[i]) =
-				s->i915_context_pdps[i];
+		for (i = 0; i < GEN8_3LVL_PDPES; i++) {
+			struct i915_page_directory * const pd =
+				i915_pd_entry(ppgtt->pd, i);
+
+			px_dma(pd) = s->i915_context_pdps[i];
+		}
 	}
 }
 
@@ -1186,11 +1191,14 @@ i915_context_ppgtt_root_save(struct intel_vgpu_submission *s,
 	int i;
 
 	if (i915_vm_is_4lvl(&ppgtt->vm)) {
-		s->i915_context_pml4 = px_dma(&ppgtt->pml4);
+		s->i915_context_pml4 = px_dma(ppgtt->pd);
 	} else {
-		for (i = 0; i < GEN8_3LVL_PDPES; i++)
-			s->i915_context_pdps[i] =
-				px_dma(ppgtt->pdp.page_directory[i]);
+		for (i = 0; i < GEN8_3LVL_PDPES; i++) {
+			struct i915_page_directory * const pd =
+				i915_pd_entry(ppgtt->pd, i);
+
+			s->i915_context_pdps[i] = px_dma(pd);
+		}
 	}
 }
 
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 07f86d474fa2..9a1f956a817a 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -661,7 +661,8 @@ static struct i915_page_table *alloc_pt(struct i915_address_space *vm)
 		return ERR_PTR(-ENOMEM);
 	}
 
-	atomic_set(&pt->used_ptes, 0);
+	atomic_set(&pt->used, 0);
+
 	return pt;
 }
 
@@ -683,11 +684,28 @@ static void gen6_initialize_pt(struct i915_address_space *vm,
 	fill32_px(vm, pt, vm->scratch_pte);
 }
 
+static struct i915_page_directory *__alloc_pd(const unsigned int entries)
+{
+	struct i915_page_directory *pd;
+
+	pd = kmalloc(sizeof(*pd) +
+		     entries * sizeof(pd->entry[0]), I915_GFP_ALLOW_FAIL);
+
+	if (unlikely(!pd))
+		return NULL;
+
+	memset(&pd->base, 0, sizeof(pd->base));
+	atomic_set(&pd->used, 0);
+	spin_lock_init(&pd->lock);
+
+	return pd;
+}
+
 static struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
 {
 	struct i915_page_directory *pd;
 
-	pd = kmalloc(sizeof(*pd), I915_GFP_ALLOW_FAIL);
+	pd = __alloc_pd(512);
 	if (unlikely(!pd))
 		return ERR_PTR(-ENOMEM);
 
@@ -696,8 +714,6 @@ static struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
 		return ERR_PTR(-ENOMEM);
 	}
 
-	atomic_set(&pd->used_pdes, 0);
-	spin_lock_init(&pd->lock);
 	return pd;
 }
 
@@ -713,88 +729,56 @@ static void gen8_initialize_pd(struct i915_address_space *vm,
 {
 	fill_px(vm, pd,
 		gen8_pde_encode(px_dma(vm->scratch_pt), I915_CACHE_LLC));
-	memset_p((void **)pd->page_table, vm->scratch_pt, I915_PDES);
+	memset_p(pd->entry, vm->scratch_pt, I915_PDES);
 }
 
-static int __pdp_init(struct i915_address_space *vm,
-		      struct i915_page_directory_pointer *pdp)
+static struct i915_page_directory *alloc_pdp(struct i915_address_space *vm)
 {
-	const unsigned int pdpes = i915_pdpes_per_pdp(vm);
+	struct i915_page_directory *pdp;
 
-	pdp->page_directory = kmalloc_array(pdpes, sizeof(*pdp->page_directory),
-					    I915_GFP_ALLOW_FAIL);
-	if (unlikely(!pdp->page_directory))
-		return -ENOMEM;
-
-	memset_p((void **)pdp->page_directory, vm->scratch_pd, pdpes);
-
-	atomic_set(&pdp->used_pdpes, 0);
-	spin_lock_init(&pdp->lock);
-	return 0;
-}
-
-static void __pdp_fini(struct i915_page_directory_pointer *pdp)
-{
-	kfree(pdp->page_directory);
-	pdp->page_directory = NULL;
-}
-
-static struct i915_page_directory_pointer *
-alloc_pdp(struct i915_address_space *vm)
-{
-	struct i915_page_directory_pointer *pdp;
-	int ret = -ENOMEM;
-
-	GEM_BUG_ON(!i915_vm_is_4lvl(vm));
-
-	pdp = kmalloc(sizeof(*pdp), GFP_KERNEL);
+	pdp = __alloc_pd(i915_pdpes_per_pdp(vm));
 	if (!pdp)
 		return ERR_PTR(-ENOMEM);
 
-	ret = __pdp_init(vm, pdp);
-	if (ret)
-		goto fail_bitmap;
-
-	ret = setup_px(vm, pdp);
-	if (ret)
-		goto fail_page_m;
+	if (i915_vm_is_4lvl(vm)) {
+		if (unlikely(setup_px(vm, pdp))) {
+			kfree(pdp);
+			return ERR_PTR(-ENOMEM);
+		}
+	}
 
 	return pdp;
-
-fail_page_m:
-	__pdp_fini(pdp);
-fail_bitmap:
-	kfree(pdp);
-
-	return ERR_PTR(ret);
 }
 
 static void free_pdp(struct i915_address_space *vm,
-		     struct i915_page_directory_pointer *pdp)
+		     struct i915_page_directory *pdp)
 {
-	__pdp_fini(pdp);
-
-	if (!i915_vm_is_4lvl(vm))
-		return;
+	if (i915_vm_is_4lvl(vm))
+		cleanup_px(vm, pdp);
 
-	cleanup_px(vm, pdp);
 	kfree(pdp);
 }
 
-static void gen8_initialize_pdp(struct i915_address_space *vm,
-				struct i915_page_directory_pointer *pdp)
+static void gen8_initialize_4lvl_pdp(struct i915_address_space *vm,
+				     struct i915_page_directory *pdp)
 {
 	fill_px(vm, pdp,
 		gen8_pdpe_encode(px_dma(vm->scratch_pd), I915_CACHE_LLC));
+	memset_p(pdp->entry, vm->scratch_pd, 512);
+}
+
+static void gen8_initialize_3lvl_pdp(struct i915_address_space *vm,
+				     struct i915_page_directory *pdp)
+{
+	memset_p(pdp->entry, vm->scratch_pd, GEN8_3LVL_PDPES);
 }
 
 static void gen8_initialize_pml4(struct i915_address_space *vm,
-				 struct i915_pml4 *pml4)
+				 struct i915_page_directory *pml4)
 {
 	fill_px(vm, pml4,
 		gen8_pml4e_encode(px_dma(vm->scratch_pdp), I915_CACHE_LLC));
-	memset_p((void **)pml4->pdps, vm->scratch_pdp, GEN8_PML4ES_PER_PML4);
-	spin_lock_init(&pml4->lock);
+	memset_p(pml4->entry, vm->scratch_pdp, GEN8_PML4ES_PER_PML4);
 }
 
 /*
@@ -822,8 +806,8 @@ static bool gen8_ppgtt_clear_pt(const struct i915_address_space *vm,
 	memset64(vaddr + gen8_pte_index(start), vm->scratch_pte, num_entries);
 	kunmap_atomic(vaddr);
 
-	GEM_BUG_ON(num_entries > atomic_read(&pt->used_ptes));
-	return !atomic_sub_return(num_entries, &pt->used_ptes);
+	GEM_BUG_ON(num_entries > atomic_read(&pt->used));
+	return !atomic_sub_return(num_entries, &pt->used);
 }
 
 static void gen8_ppgtt_set_pde(struct i915_address_space *vm,
@@ -854,12 +838,12 @@ static bool gen8_ppgtt_clear_pd(struct i915_address_space *vm,
 			continue;
 
 		spin_lock(&pd->lock);
-		if (!atomic_read(&pt->used_ptes)) {
+		if (!atomic_read(&pt->used)) {
 			gen8_ppgtt_set_pde(vm, pd, vm->scratch_pt, pde);
-			pd->page_table[pde] = vm->scratch_pt;
+			pd->entry[pde] = vm->scratch_pt;
 
-			GEM_BUG_ON(!atomic_read(&pd->used_pdes));
-			atomic_dec(&pd->used_pdes);
+			GEM_BUG_ON(!atomic_read(&pd->used));
+			atomic_dec(&pd->used);
 			free = true;
 		}
 		spin_unlock(&pd->lock);
@@ -867,11 +851,11 @@ static bool gen8_ppgtt_clear_pd(struct i915_address_space *vm,
 			free_pt(vm, pt);
 	}
 
-	return !atomic_read(&pd->used_pdes);
+	return !atomic_read(&pd->used);
 }
 
 static void gen8_ppgtt_set_pdpe(struct i915_address_space *vm,
-				struct i915_page_directory_pointer *pdp,
+				struct i915_page_directory *pdp,
 				struct i915_page_directory *pd,
 				unsigned int pdpe)
 {
@@ -889,7 +873,7 @@ static void gen8_ppgtt_set_pdpe(struct i915_address_space *vm,
  * Caller can use the return value to update higher-level entries
  */
 static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
-				 struct i915_page_directory_pointer *pdp,
+				 struct i915_page_directory * const pdp,
 				 u64 start, u64 length)
 {
 	struct i915_page_directory *pd;
@@ -904,12 +888,12 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
 			continue;
 
 		spin_lock(&pdp->lock);
-		if (!atomic_read(&pd->used_pdes)) {
+		if (!atomic_read(&pd->used)) {
 			gen8_ppgtt_set_pdpe(vm, pdp, vm->scratch_pd, pdpe);
-			pdp->page_directory[pdpe] = vm->scratch_pd;
+			pdp->entry[pdpe] = vm->scratch_pd;
 
-			GEM_BUG_ON(!atomic_read(&pdp->used_pdpes));
-			atomic_dec(&pdp->used_pdpes);
+			GEM_BUG_ON(!atomic_read(&pdp->used));
+			atomic_dec(&pdp->used);
 			free = true;
 		}
 		spin_unlock(&pdp->lock);
@@ -917,17 +901,17 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
 			free_pd(vm, pd);
 	}
 
-	return !atomic_read(&pdp->used_pdpes);
+	return !atomic_read(&pdp->used);
 }
 
 static void gen8_ppgtt_clear_3lvl(struct i915_address_space *vm,
 				  u64 start, u64 length)
 {
-	gen8_ppgtt_clear_pdp(vm, &i915_vm_to_ppgtt(vm)->pdp, start, length);
+	gen8_ppgtt_clear_pdp(vm, i915_vm_to_ppgtt(vm)->pd, start, length);
 }
 
-static void gen8_ppgtt_set_pml4e(struct i915_pml4 *pml4,
-				 struct i915_page_directory_pointer *pdp,
+static void gen8_ppgtt_set_pml4e(struct i915_page_directory *pml4,
+				 struct i915_page_directory *pdp,
 				 unsigned int pml4e)
 {
 	gen8_ppgtt_pml4e_t *vaddr;
@@ -945,8 +929,8 @@ static void gen8_ppgtt_clear_4lvl(struct i915_address_space *vm,
 				  u64 start, u64 length)
 {
 	struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
-	struct i915_pml4 *pml4 = &ppgtt->pml4;
-	struct i915_page_directory_pointer *pdp;
+	struct i915_page_directory * const pml4 = ppgtt->pd;
+	struct i915_page_directory *pdp;
 	unsigned int pml4e;
 
 	GEM_BUG_ON(!i915_vm_is_4lvl(vm));
@@ -959,9 +943,9 @@ static void gen8_ppgtt_clear_4lvl(struct i915_address_space *vm,
 			continue;
 
 		spin_lock(&pml4->lock);
-		if (!atomic_read(&pdp->used_pdpes)) {
+		if (!atomic_read(&pdp->used)) {
 			gen8_ppgtt_set_pml4e(pml4, vm->scratch_pdp, pml4e);
-			pml4->pdps[pml4e] = vm->scratch_pdp;
+			pml4->entry[pml4e] = vm->scratch_pdp;
 			free = true;
 		}
 		spin_unlock(&pml4->lock);
@@ -998,7 +982,7 @@ static __always_inline struct gen8_insert_pte gen8_insert_pte(u64 start)
 
 static __always_inline bool
 gen8_ppgtt_insert_pte_entries(struct i915_ppgtt *ppgtt,
-			      struct i915_page_directory_pointer *pdp,
+			      struct i915_page_directory *pdp,
 			      struct sgt_dma *iter,
 			      struct gen8_insert_pte *idx,
 			      enum i915_cache_level cache_level,
@@ -1010,8 +994,8 @@ gen8_ppgtt_insert_pte_entries(struct i915_ppgtt *ppgtt,
 	bool ret;
 
 	GEM_BUG_ON(idx->pdpe >= i915_pdpes_per_pdp(&ppgtt->vm));
-	pd = pdp->page_directory[idx->pdpe];
-	vaddr = kmap_atomic_px(pd->page_table[idx->pde]);
+	pd = i915_pd_entry(pdp, idx->pdpe);
+	vaddr = kmap_atomic_px(i915_pt_entry(pd, idx->pde));
 	do {
 		vaddr[idx->pte] = pte_encode | iter->dma;
 
@@ -1041,11 +1025,11 @@ gen8_ppgtt_insert_pte_entries(struct i915_ppgtt *ppgtt,
 				}
 
 				GEM_BUG_ON(idx->pdpe >= i915_pdpes_per_pdp(&ppgtt->vm));
-				pd = pdp->page_directory[idx->pdpe];
+				pd = pdp->entry[idx->pdpe];
 			}
 
 			kunmap_atomic(vaddr);
-			vaddr = kmap_atomic_px(pd->page_table[idx->pde]);
+			vaddr = kmap_atomic_px(i915_pt_entry(pd, idx->pde));
 		}
 	} while (1);
 	kunmap_atomic(vaddr);
@@ -1062,14 +1046,14 @@ static void gen8_ppgtt_insert_3lvl(struct i915_address_space *vm,
 	struct sgt_dma iter = sgt_dma(vma);
 	struct gen8_insert_pte idx = gen8_insert_pte(vma->node.start);
 
-	gen8_ppgtt_insert_pte_entries(ppgtt, &ppgtt->pdp, &iter, &idx,
+	gen8_ppgtt_insert_pte_entries(ppgtt, ppgtt->pd, &iter, &idx,
 				      cache_level, flags);
 
 	vma->page_sizes.gtt = I915_GTT_PAGE_SIZE;
 }
 
 static void gen8_ppgtt_insert_huge_entries(struct i915_vma *vma,
-					   struct i915_page_directory_pointer **pdps,
+					   struct i915_page_directory *pml4,
 					   struct sgt_dma *iter,
 					   enum i915_cache_level cache_level,
 					   u32 flags)
@@ -1080,8 +1064,9 @@ static void gen8_ppgtt_insert_huge_entries(struct i915_vma *vma,
 
 	do {
 		struct gen8_insert_pte idx = gen8_insert_pte(start);
-		struct i915_page_directory_pointer *pdp = pdps[idx.pml4e];
-		struct i915_page_directory *pd = pdp->page_directory[idx.pdpe];
+		struct i915_page_directory *pdp =
+			i915_pdp_entry(pml4, idx.pml4e);
+		struct i915_page_directory *pd = i915_pd_entry(pdp, idx.pdpe);
 		unsigned int page_size;
 		bool maybe_64K = false;
 		gen8_pte_t encode = pte_encode;
@@ -1099,7 +1084,7 @@ static void gen8_ppgtt_insert_huge_entries(struct i915_vma *vma,
 
 			vaddr = kmap_atomic_px(pd);
 		} else {
-			struct i915_page_table *pt = pd->page_table[idx.pde];
+			struct i915_page_table *pt = i915_pt_entry(pd, idx.pde);
 
 			index = idx.pte;
 			max = GEN8_PTES;
@@ -1174,7 +1159,8 @@ static void gen8_ppgtt_insert_huge_entries(struct i915_vma *vma,
 				u16 i;
 
 				encode = vma->vm->scratch_pte;
-				vaddr = kmap_atomic_px(pd->page_table[idx.pde]);
+				vaddr = kmap_atomic_px(i915_pt_entry(pd,
+								     idx.pde));
 
 				for (i = 1; i < index; i += 16)
 					memset64(vaddr + i, encode, 15);
@@ -1194,15 +1180,16 @@ static void gen8_ppgtt_insert_4lvl(struct i915_address_space *vm,
 {
 	struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
 	struct sgt_dma iter = sgt_dma(vma);
-	struct i915_page_directory_pointer **pdps = ppgtt->pml4.pdps;
+	struct i915_page_directory * const pml4 = ppgtt->pd;
 
 	if (vma->page_sizes.sg > I915_GTT_PAGE_SIZE) {
-		gen8_ppgtt_insert_huge_entries(vma, pdps, &iter, cache_level,
+		gen8_ppgtt_insert_huge_entries(vma, pml4, &iter, cache_level,
 					       flags);
 	} else {
 		struct gen8_insert_pte idx = gen8_insert_pte(vma->node.start);
 
-		while (gen8_ppgtt_insert_pte_entries(ppgtt, pdps[idx.pml4e++],
+		while (gen8_ppgtt_insert_pte_entries(ppgtt,
+						     i915_pdp_entry(pml4, idx.pml4e++),
 						     &iter, &idx, cache_level,
 						     flags))
 			GEM_BUG_ON(idx.pml4e >= GEN8_PML4ES_PER_PML4);
@@ -1217,8 +1204,8 @@ static void gen8_free_page_tables(struct i915_address_space *vm,
 	int i;
 
 	for (i = 0; i < I915_PDES; i++) {
-		if (pd->page_table[i] != vm->scratch_pt)
-			free_pt(vm, pd->page_table[i]);
+		if (pd->entry[i] != vm->scratch_pt)
+			free_pt(vm, pd->entry[i]);
 	}
 }
 
@@ -1277,7 +1264,7 @@ static int gen8_init_scratch(struct i915_address_space *vm)
 	gen8_initialize_pt(vm, vm->scratch_pt);
 	gen8_initialize_pd(vm, vm->scratch_pd);
 	if (i915_vm_is_4lvl(vm))
-		gen8_initialize_pdp(vm, vm->scratch_pdp);
+		gen8_initialize_4lvl_pdp(vm, vm->scratch_pdp);
 
 	return 0;
 
@@ -1299,7 +1286,7 @@ static int gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create)
 	int i;
 
 	if (i915_vm_is_4lvl(vm)) {
-		const u64 daddr = px_dma(&ppgtt->pml4);
+		const u64 daddr = px_dma(ppgtt->pd);
 
 		I915_WRITE(vgtif_reg(pdp[0].lo), lower_32_bits(daddr));
 		I915_WRITE(vgtif_reg(pdp[0].hi), upper_32_bits(daddr));
@@ -1336,17 +1323,17 @@ static void gen8_free_scratch(struct i915_address_space *vm)
 }
 
 static void gen8_ppgtt_cleanup_3lvl(struct i915_address_space *vm,
-				    struct i915_page_directory_pointer *pdp)
+				    struct i915_page_directory *pdp)
 {
 	const unsigned int pdpes = i915_pdpes_per_pdp(vm);
 	int i;
 
 	for (i = 0; i < pdpes; i++) {
-		if (pdp->page_directory[i] == vm->scratch_pd)
+		if (pdp->entry[i] == vm->scratch_pd)
 			continue;
 
-		gen8_free_page_tables(vm, pdp->page_directory[i]);
-		free_pd(vm, pdp->page_directory[i]);
+		gen8_free_page_tables(vm, pdp->entry[i]);
+		free_pd(vm, pdp->entry[i]);
 	}
 
 	free_pdp(vm, pdp);
@@ -1354,16 +1341,19 @@ static void gen8_ppgtt_cleanup_3lvl(struct i915_address_space *vm,
 
 static void gen8_ppgtt_cleanup_4lvl(struct i915_ppgtt *ppgtt)
 {
+	struct i915_page_directory * const pml4 = ppgtt->pd;
 	int i;
 
 	for (i = 0; i < GEN8_PML4ES_PER_PML4; i++) {
-		if (ppgtt->pml4.pdps[i] == ppgtt->vm.scratch_pdp)
+		struct i915_page_directory *pdp = i915_pdp_entry(pml4, i);
+
+		if (pdp == ppgtt->vm.scratch_pdp)
 			continue;
 
-		gen8_ppgtt_cleanup_3lvl(&ppgtt->vm, ppgtt->pml4.pdps[i]);
+		gen8_ppgtt_cleanup_3lvl(&ppgtt->vm, pdp);
 	}
 
-	cleanup_px(&ppgtt->vm, &ppgtt->pml4);
+	cleanup_px(&ppgtt->vm, pml4);
 }
 
 static void gen8_ppgtt_cleanup(struct i915_address_space *vm)
@@ -1377,7 +1367,7 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm)
 	if (i915_vm_is_4lvl(vm))
 		gen8_ppgtt_cleanup_4lvl(ppgtt);
 	else
-		gen8_ppgtt_cleanup_3lvl(&ppgtt->vm, &ppgtt->pdp);
+		gen8_ppgtt_cleanup_3lvl(&ppgtt->vm, ppgtt->pd);
 
 	gen8_free_scratch(vm);
 }
@@ -1406,10 +1396,10 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
 			if (count < GEN8_PTES || intel_vgpu_active(vm->i915))
 				gen8_initialize_pt(vm, pt);
 
-			old = cmpxchg(&pd->page_table[pde], vm->scratch_pt, pt);
+			old = cmpxchg(&pd->entry[pde], vm->scratch_pt, pt);
 			if (old == vm->scratch_pt) {
 				gen8_ppgtt_set_pde(vm, pd, pt, pde);
-				atomic_inc(&pd->used_pdes);
+				atomic_inc(&pd->used);
 			} else {
 				free_pt(vm, pt);
 				pt = old;
@@ -1418,7 +1408,7 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
 			spin_lock(&pd->lock);
 		}
 
-		atomic_add(count, &pt->used_ptes);
+		atomic_add(count, &pt->used);
 	}
 	spin_unlock(&pd->lock);
 
@@ -1430,7 +1420,7 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
 }
 
 static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
-				struct i915_page_directory_pointer *pdp,
+				struct i915_page_directory *pdp,
 				u64 start, u64 length)
 {
 	struct i915_page_directory *pd;
@@ -1451,11 +1441,10 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 
 			gen8_initialize_pd(vm, pd);
 
-			old = cmpxchg(&pdp->page_directory[pdpe],
-				      vm->scratch_pd, pd);
+			old = cmpxchg(&pdp->entry[pdpe], vm->scratch_pd, pd);
 			if (old == vm->scratch_pd) {
 				gen8_ppgtt_set_pdpe(vm, pdp, pd, pdpe);
-				atomic_inc(&pdp->used_pdpes);
+				atomic_inc(&pdp->used);
 			} else {
 				free_pd(vm, pd);
 				pd = old;
@@ -1463,7 +1452,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 
 			spin_lock(&pdp->lock);
 		}
-		atomic_inc(&pd->used_pdes);
+		atomic_inc(&pd->used);
 		spin_unlock(&pdp->lock);
 
 		ret = gen8_ppgtt_alloc_pd(vm, pd, start, length);
@@ -1471,7 +1460,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 			goto unwind_pd;
 
 		spin_lock(&pdp->lock);
-		atomic_dec(&pd->used_pdes);
+		atomic_dec(&pd->used);
 	}
 	spin_unlock(&pdp->lock);
 
@@ -1479,10 +1468,10 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 
 unwind_pd:
 	spin_lock(&pdp->lock);
-	if (atomic_dec_and_test(&pd->used_pdes)) {
+	if (atomic_dec_and_test(&pd->used)) {
 		gen8_ppgtt_set_pdpe(vm, pdp, vm->scratch_pd, pdpe);
-		GEM_BUG_ON(!atomic_read(&pdp->used_pdpes));
-		atomic_dec(&pdp->used_pdpes);
+		GEM_BUG_ON(!atomic_read(&pdp->used));
+		atomic_dec(&pdp->used);
 		free_pd(vm, pd);
 	}
 	spin_unlock(&pdp->lock);
@@ -1495,23 +1484,24 @@ static int gen8_ppgtt_alloc_3lvl(struct i915_address_space *vm,
 				 u64 start, u64 length)
 {
 	return gen8_ppgtt_alloc_pdp(vm,
-				    &i915_vm_to_ppgtt(vm)->pdp, start, length);
+				    i915_vm_to_ppgtt(vm)->pd, start, length);
 }
 
 static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 				 u64 start, u64 length)
 {
 	struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
-	struct i915_pml4 *pml4 = &ppgtt->pml4;
-	struct i915_page_directory_pointer *pdp;
+	struct i915_page_directory * const pml4 = ppgtt->pd;
+	struct i915_page_directory *pdp;
 	u64 from = start;
 	u32 pml4e;
 	int ret;
 
 	spin_lock(&pml4->lock);
 	gen8_for_each_pml4e(pdp, pml4, start, length, pml4e) {
+
 		if (pdp == vm->scratch_pdp) {
-			struct i915_page_directory_pointer *old;
+			struct i915_page_directory *old;
 
 			spin_unlock(&pml4->lock);
 
@@ -1519,9 +1509,9 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 			if (IS_ERR(pdp))
 				goto unwind;
 
-			gen8_initialize_pdp(vm, pdp);
+			gen8_initialize_4lvl_pdp(vm, pdp);
 
-			old = cmpxchg(&pml4->pdps[pml4e], vm->scratch_pdp, pdp);
+			old = cmpxchg(&pml4->entry[pml4e], vm->scratch_pdp, pdp);
 			if (old == vm->scratch_pdp) {
 				gen8_ppgtt_set_pml4e(pml4, pdp, pml4e);
 			} else {
@@ -1531,7 +1521,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 
 			spin_lock(&pml4->lock);
 		}
-		atomic_inc(&pdp->used_pdpes);
+		atomic_inc(&pdp->used);
 		spin_unlock(&pml4->lock);
 
 		ret = gen8_ppgtt_alloc_pdp(vm, pdp, start, length);
@@ -1539,7 +1529,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 			goto unwind_pdp;
 
 		spin_lock(&pml4->lock);
-		atomic_dec(&pdp->used_pdpes);
+		atomic_dec(&pdp->used);
 	}
 	spin_unlock(&pml4->lock);
 
@@ -1547,7 +1537,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 
 unwind_pdp:
 	spin_lock(&pml4->lock);
-	if (atomic_dec_and_test(&pdp->used_pdpes)) {
+	if (atomic_dec_and_test(&pdp->used)) {
 		gen8_ppgtt_set_pml4e(pml4, vm->scratch_pdp, pml4e);
 		free_pdp(vm, pdp);
 	}
@@ -1560,7 +1550,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 {
 	struct i915_address_space *vm = &ppgtt->vm;
-	struct i915_page_directory_pointer *pdp = &ppgtt->pdp;
+	struct i915_page_directory *pdp = ppgtt->pd;
 	struct i915_page_directory *pd;
 	u64 start = 0, length = ppgtt->vm.total;
 	u64 from = start;
@@ -1573,10 +1563,12 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 
 		gen8_initialize_pd(vm, pd);
 		gen8_ppgtt_set_pdpe(vm, pdp, pd, pdpe);
-		atomic_inc(&pdp->used_pdpes);
+
+		atomic_inc(&pdp->used);
 	}
 
-	atomic_inc(&pdp->used_pdpes); /* never remove */
+	atomic_inc(&pdp->used); /* never remove */
+
 	return 0;
 
 unwind:
@@ -1585,7 +1577,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 		gen8_ppgtt_set_pdpe(vm, pdp, vm->scratch_pd, pdpe);
 		free_pd(vm, pd);
 	}
-	atomic_set(&pdp->used_pdpes, 0);
+	atomic_set(&pdp->used, 0);
 	return -ENOMEM;
 }
 
@@ -1640,27 +1632,25 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
 	if (err)
 		goto err_free;
 
-	if (i915_vm_is_4lvl(&ppgtt->vm)) {
-		err = setup_px(&ppgtt->vm, &ppgtt->pml4);
-		if (err)
-			goto err_scratch;
+	ppgtt->pd = alloc_pdp(&ppgtt->vm);
+	if (IS_ERR(ppgtt->pd)) {
+		err = PTR_ERR(ppgtt->pd);
+		goto err_scratch;
+	}
 
-		gen8_initialize_pml4(&ppgtt->vm, &ppgtt->pml4);
+	if (i915_vm_is_4lvl(&ppgtt->vm)) {
+		gen8_initialize_pml4(&ppgtt->vm, ppgtt->pd);
 
 		ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc_4lvl;
 		ppgtt->vm.insert_entries = gen8_ppgtt_insert_4lvl;
 		ppgtt->vm.clear_range = gen8_ppgtt_clear_4lvl;
 	} else {
-		err = __pdp_init(&ppgtt->vm, &ppgtt->pdp);
-		if (err)
-			goto err_scratch;
+		gen8_initialize_3lvl_pdp(&ppgtt->vm, ppgtt->pd);
 
 		if (intel_vgpu_active(i915)) {
 			err = gen8_preallocate_top_level_pdp(ppgtt);
-			if (err) {
-				__pdp_fini(&ppgtt->pdp);
-				goto err_scratch;
-			}
+			if (err)
+				goto err_pdp;
 		}
 
 		ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc_3lvl;
@@ -1675,6 +1665,8 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
 
 	return ppgtt;
 
+err_pdp:
+	free_pdp(&ppgtt->vm, ppgtt->pd);
 err_scratch:
 	gen8_free_scratch(&ppgtt->vm);
 err_free:
@@ -1740,15 +1732,16 @@ static void gen6_ppgtt_enable(struct drm_i915_private *dev_priv)
 static void gen6_ppgtt_clear_range(struct i915_address_space *vm,
 				   u64 start, u64 length)
 {
-	struct gen6_ppgtt *ppgtt = to_gen6_ppgtt(i915_vm_to_ppgtt(vm));
-	unsigned int first_entry = start / I915_GTT_PAGE_SIZE;
+	struct gen6_ppgtt * const ppgtt = to_gen6_ppgtt(i915_vm_to_ppgtt(vm));
+	const unsigned int first_entry = start / I915_GTT_PAGE_SIZE;
+	const gen6_pte_t scratch_pte = vm->scratch_pte;
 	unsigned int pde = first_entry / GEN6_PTES;
 	unsigned int pte = first_entry % GEN6_PTES;
 	unsigned int num_entries = length / I915_GTT_PAGE_SIZE;
-	const gen6_pte_t scratch_pte = vm->scratch_pte;
 
 	while (num_entries) {
-		struct i915_page_table *pt = ppgtt->base.pd.page_table[pde++];
+		struct i915_page_table * const pt =
+			i915_pt_entry(ppgtt->base.pd, pde++);
 		const unsigned int count = min(num_entries, GEN6_PTES - pte);
 		gen6_pte_t *vaddr;
 
@@ -1756,8 +1749,8 @@ static void gen6_ppgtt_clear_range(struct i915_address_space *vm,
 
 		num_entries -= count;
 
-		GEM_BUG_ON(count > atomic_read(&pt->used_ptes));
-		if (!atomic_sub_return(count, &pt->used_ptes))
+		GEM_BUG_ON(count > atomic_read(&pt->used));
+		if (!atomic_sub_return(count, &pt->used))
 			ppgtt->scan_for_unused_pt = true;
 
 		/*
@@ -1781,6 +1774,7 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,
 				      u32 flags)
 {
 	struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
+	struct i915_page_directory * const pd = ppgtt->pd;
 	unsigned first_entry = vma->node.start / I915_GTT_PAGE_SIZE;
 	unsigned act_pt = first_entry / GEN6_PTES;
 	unsigned act_pte = first_entry % GEN6_PTES;
@@ -1788,9 +1782,9 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,
 	struct sgt_dma iter = sgt_dma(vma);
 	gen6_pte_t *vaddr;
 
-	GEM_BUG_ON(ppgtt->pd.page_table[act_pt] == vm->scratch_pt);
+	GEM_BUG_ON(i915_pt_entry(pd, act_pt) == vm->scratch_pt);
 
-	vaddr = kmap_atomic_px(ppgtt->pd.page_table[act_pt]);
+	vaddr = kmap_atomic_px(i915_pt_entry(pd, act_pt));
 	do {
 		vaddr[act_pte] = pte_encode | GEN6_PTE_ADDR_ENCODE(iter.dma);
 
@@ -1806,7 +1800,7 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,
 
 		if (++act_pte == GEN6_PTES) {
 			kunmap_atomic(vaddr);
-			vaddr = kmap_atomic_px(ppgtt->pd.page_table[++act_pt]);
+			vaddr = kmap_atomic_px(i915_pt_entry(pd, ++act_pt));
 			act_pte = 0;
 		}
 	} while (1);
@@ -1819,6 +1813,7 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
 			       u64 start, u64 length)
 {
 	struct gen6_ppgtt *ppgtt = to_gen6_ppgtt(i915_vm_to_ppgtt(vm));
+	struct i915_page_directory * const pd = ppgtt->base.pd;
 	struct i915_page_table *pt;
 	intel_wakeref_t wakeref;
 	u64 from = start;
@@ -1827,14 +1822,14 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
 
 	wakeref = intel_runtime_pm_get(vm->i915);
 
-	spin_lock(&ppgtt->base.pd.lock);
-	gen6_for_each_pde(pt, &ppgtt->base.pd, start, length, pde) {
+	spin_lock(&pd->lock);
+	gen6_for_each_pde(pt, pd, start, length, pde) {
 		const unsigned int count = gen6_pte_count(start, length);
 
 		if (pt == vm->scratch_pt) {
 			struct i915_page_table *old;
 
-			spin_unlock(&ppgtt->base.pd.lock);
+			spin_unlock(&pd->lock);
 
 			pt = alloc_pt(vm);
 			if (IS_ERR(pt))
@@ -1842,10 +1837,8 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
 
 			gen6_initialize_pt(vm, pt);
 
-			old = cmpxchg(&ppgtt->base.pd.page_table[pde],
-				      vm->scratch_pt, pt);
+			old = cmpxchg(&pd->entry[pde], vm->scratch_pt, pt);
 			if (old == vm->scratch_pt) {
-				ppgtt->base.pd.page_table[pde] = pt;
 				if (i915_vma_is_bound(ppgtt->vma,
 						      I915_VMA_GLOBAL_BIND)) {
 					gen6_write_pde(ppgtt, pde, pt);
@@ -1856,12 +1849,12 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
 				pt = old;
 			}
 
-			spin_lock(&ppgtt->base.pd.lock);
+			spin_lock(&pd->lock);
 		}
 
-		atomic_add(count, &pt->used_ptes);
+		atomic_add(count, &pt->used);
 	}
-	spin_unlock(&ppgtt->base.pd.lock);
+	spin_unlock(&pd->lock);
 
 	if (flush) {
 		mark_tlbs_dirty(&ppgtt->base);
@@ -1881,6 +1874,7 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
 static int gen6_ppgtt_init_scratch(struct gen6_ppgtt *ppgtt)
 {
 	struct i915_address_space * const vm = &ppgtt->base.vm;
+	struct i915_page_directory * const pd = ppgtt->base.pd;
 	struct i915_page_table *unused;
 	u32 pde;
 	int ret;
@@ -1900,9 +1894,9 @@ static int gen6_ppgtt_init_scratch(struct gen6_ppgtt *ppgtt)
 	}
 
 	gen6_initialize_pt(vm, vm->scratch_pt);
-	gen6_for_all_pdes(unused, &ppgtt->base.pd, pde)
-		ppgtt->base.pd.page_table[pde] = vm->scratch_pt;
-	spin_lock_init(&ppgtt->base.pd.lock);
+
+	gen6_for_all_pdes(unused, pd, pde)
+		pd->entry[pde] = vm->scratch_pt;
 
 	return 0;
 }
@@ -1915,10 +1909,11 @@ static void gen6_ppgtt_free_scratch(struct i915_address_space *vm)
 
 static void gen6_ppgtt_free_pd(struct gen6_ppgtt *ppgtt)
 {
+	struct i915_page_directory * const pd = ppgtt->base.pd;
 	struct i915_page_table *pt;
 	u32 pde;
 
-	gen6_for_all_pdes(pt, &ppgtt->base.pd, pde)
+	gen6_for_all_pdes(pt, pd, pde)
 		if (pt != ppgtt->base.vm.scratch_pt)
 			free_pt(&ppgtt->base.vm, pt);
 }
@@ -1982,6 +1977,7 @@ static void gen6_ppgtt_cleanup(struct i915_address_space *vm)
 
 	gen6_ppgtt_free_pd(ppgtt);
 	gen6_ppgtt_free_scratch(vm);
+	kfree(ppgtt->base.pd);
 }
 
 static int pd_vma_set_pages(struct i915_vma *vma)
@@ -2007,10 +2003,10 @@ static int pd_vma_bind(struct i915_vma *vma,
 	struct i915_page_table *pt;
 	unsigned int pde;
 
-	ppgtt->base.pd.base.ggtt_offset = ggtt_offset * sizeof(gen6_pte_t);
+	ppgtt->base.pd->base.ggtt_offset = ggtt_offset * sizeof(gen6_pte_t);
 	ppgtt->pd_addr = (gen6_pte_t __iomem *)ggtt->gsm + ggtt_offset;
 
-	gen6_for_all_pdes(pt, &ppgtt->base.pd, pde)
+	gen6_for_all_pdes(pt, ppgtt->base.pd, pde)
 		gen6_write_pde(ppgtt, pde, pt);
 
 	mark_tlbs_dirty(&ppgtt->base);
@@ -2022,6 +2018,7 @@ static int pd_vma_bind(struct i915_vma *vma,
 static void pd_vma_unbind(struct i915_vma *vma)
 {
 	struct gen6_ppgtt *ppgtt = vma->private;
+	struct i915_page_directory * const pd = ppgtt->base.pd;
 	struct i915_page_table * const scratch_pt = ppgtt->base.vm.scratch_pt;
 	struct i915_page_table *pt;
 	unsigned int pde;
@@ -2030,12 +2027,12 @@ static void pd_vma_unbind(struct i915_vma *vma)
 		return;
 
 	/* Free all no longer used page tables */
-	gen6_for_all_pdes(pt, &ppgtt->base.pd, pde) {
-		if (atomic_read(&pt->used_ptes) || pt == scratch_pt)
+	gen6_for_all_pdes(pt, ppgtt->base.pd, pde) {
+		if (atomic_read(&pt->used) || pt == scratch_pt)
 			continue;
 
 		free_pt(&ppgtt->base.vm, pt);
-		ppgtt->base.pd.page_table[pde] = scratch_pt;
+		pd->entry[pde] = scratch_pt;
 	}
 
 	ppgtt->scan_for_unused_pt = false;
@@ -2164,9 +2161,15 @@ static struct i915_ppgtt *gen6_ppgtt_create(struct drm_i915_private *i915)
 		goto err_free;
 	}
 
+	ppgtt->base.pd = __alloc_pd(512);
+	if (!ppgtt->base.pd) {
+		err = -ENOMEM;
+		goto err_work;
+	}
+
 	err = gen6_ppgtt_init_scratch(ppgtt);
 	if (err)
-		goto err_work;
+		goto err_pd;
 
 	ppgtt->vma = pd_vma_create(ppgtt, GEN6_PD_SIZE);
 	if (IS_ERR(ppgtt->vma)) {
@@ -2178,6 +2181,8 @@ static struct i915_ppgtt *gen6_ppgtt_create(struct drm_i915_private *i915)
 
 err_scratch:
 	gen6_ppgtt_free_scratch(&ppgtt->base.vm);
+err_pd:
+	kfree(ppgtt->base.pd);
 err_work:
 	kfree(ppgtt->work);
 err_free:
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index 89437d0a721c..49f44071def4 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -248,28 +248,14 @@ struct i915_page_dma {
 
 struct i915_page_table {
 	struct i915_page_dma base;
-	atomic_t used_ptes;
+	atomic_t used;
 };
 
 struct i915_page_directory {
 	struct i915_page_dma base;
-
-	struct i915_page_table *page_table[I915_PDES]; /* PDEs */
-	atomic_t used_pdes;
-	spinlock_t lock;
-};
-
-struct i915_page_directory_pointer {
-	struct i915_page_dma base;
-	struct i915_page_directory **page_directory;
-	atomic_t used_pdpes;
-	spinlock_t lock;
-};
-
-struct i915_pml4 {
-	struct i915_page_dma base;
-	struct i915_page_directory_pointer *pdps[GEN8_PML4ES_PER_PML4];
+	atomic_t used;
 	spinlock_t lock;
+	void *entry[0];
 };
 
 struct i915_vma_ops {
@@ -321,7 +307,7 @@ struct i915_address_space {
 	struct i915_page_dma scratch_page;
 	struct i915_page_table *scratch_pt;
 	struct i915_page_directory *scratch_pd;
-	struct i915_page_directory_pointer *scratch_pdp; /* GEN8+ & 48b PPGTT */
+	struct i915_page_directory *scratch_pdp; /* GEN8+ & 48b PPGTT */
 
 	/**
 	 * List of vma currently bound.
@@ -416,11 +402,7 @@ struct i915_ppgtt {
 	struct i915_address_space vm;
 
 	intel_engine_mask_t pd_dirty_engines;
-	union {
-		struct i915_pml4 pml4;		/* GEN8+ & 48b PPGTT */
-		struct i915_page_directory_pointer pdp;	/* GEN8+ */
-		struct i915_page_directory pd;		/* GEN6-7 */
-	};
+	struct i915_page_directory *pd;
 };
 
 struct gen6_ppgtt {
@@ -454,7 +436,7 @@ static inline struct gen6_ppgtt *to_gen6_ppgtt(struct i915_ppgtt *base)
 #define gen6_for_each_pde(pt, pd, start, length, iter)			\
 	for (iter = gen6_pde_index(start);				\
 	     length > 0 && iter < I915_PDES &&				\
-		(pt = (pd)->page_table[iter], true);			\
+		     (pt = i915_pt_entry(pd, iter), true);		\
 	     ({ u32 temp = ALIGN(start+1, 1 << GEN6_PDE_SHIFT);		\
 		    temp = min(temp - start, length);			\
 		    start += temp, length -= temp; }), ++iter)
@@ -462,7 +444,7 @@ static inline struct gen6_ppgtt *to_gen6_ppgtt(struct i915_ppgtt *base)
 #define gen6_for_all_pdes(pt, pd, iter)					\
 	for (iter = 0;							\
 	     iter < I915_PDES &&					\
-		(pt = (pd)->page_table[iter], true);			\
+		     (pt = i915_pt_entry(pd, iter), true);		\
 	     ++iter)
 
 static inline u32 i915_pte_index(u64 address, unsigned int pde_shift)
@@ -521,6 +503,27 @@ i915_pdpes_per_pdp(const struct i915_address_space *vm)
 	return GEN8_3LVL_PDPES;
 }
 
+static inline struct i915_page_table *
+i915_pt_entry(const struct i915_page_directory * const pd,
+	      const unsigned short n)
+{
+	return pd->entry[n];
+}
+
+static inline struct i915_page_directory *
+i915_pd_entry(const struct i915_page_directory * const pdp,
+	      const unsigned short n)
+{
+	return pdp->entry[n];
+}
+
+static inline struct i915_page_directory *
+i915_pdp_entry(const struct i915_page_directory * const pml4,
+	       const unsigned short n)
+{
+	return pml4->entry[n];
+}
+
 /* Equivalent to the gen6 version, For each pde iterates over every pde
  * between from start until start + length. On gen8+ it simply iterates
  * over every page directory entry in a page directory.
@@ -528,7 +531,7 @@ i915_pdpes_per_pdp(const struct i915_address_space *vm)
 #define gen8_for_each_pde(pt, pd, start, length, iter)			\
 	for (iter = gen8_pde_index(start);				\
 	     length > 0 && iter < I915_PDES &&				\
-		(pt = (pd)->page_table[iter], true);			\
+		     (pt = i915_pt_entry(pd, iter), true);		\
 	     ({ u64 temp = ALIGN(start+1, 1 << GEN8_PDE_SHIFT);		\
 		    temp = min(temp - start, length);			\
 		    start += temp, length -= temp; }), ++iter)
@@ -536,7 +539,7 @@ i915_pdpes_per_pdp(const struct i915_address_space *vm)
 #define gen8_for_each_pdpe(pd, pdp, start, length, iter)		\
 	for (iter = gen8_pdpe_index(start);				\
 	     length > 0 && iter < i915_pdpes_per_pdp(vm) &&		\
-		(pd = (pdp)->page_directory[iter], true);		\
+		     (pd = i915_pd_entry(pdp, iter), true);		\
 	     ({ u64 temp = ALIGN(start+1, 1 << GEN8_PDPE_SHIFT);	\
 		    temp = min(temp - start, length);			\
 		    start += temp, length -= temp; }), ++iter)
@@ -544,7 +547,7 @@ i915_pdpes_per_pdp(const struct i915_address_space *vm)
 #define gen8_for_each_pml4e(pdp, pml4, start, length, iter)		\
 	for (iter = gen8_pml4e_index(start);				\
 	     length > 0 && iter < GEN8_PML4ES_PER_PML4 &&		\
-		(pdp = (pml4)->pdps[iter], true);			\
+		     (pdp = i915_pdp_entry(pml4, iter), true);		\
 	     ({ u64 temp = ALIGN(start+1, 1ULL << GEN8_PML4E_SHIFT);	\
 		    temp = min(temp - start, length);			\
 		    start += temp, length -= temp; }), ++iter)
@@ -577,7 +580,10 @@ static inline u64 gen8_pte_count(u64 address, u64 length)
 static inline dma_addr_t
 i915_page_dir_dma_addr(const struct i915_ppgtt *ppgtt, const unsigned int n)
 {
-	return px_dma(ppgtt->pdp.page_directory[n]);
+	struct i915_page_directory *pd;
+
+	pd = i915_pdp_entry(ppgtt->pd, n);
+	return px_dma(pd);
 }
 
 static inline struct i915_ggtt *
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/9] drm/i915/gtt: Introduce init_pd_with_page
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
  2019-06-11 17:27 ` [PATCH 2/9] drm/i915/gtt: Use a common type for page directories Mika Kuoppala
@ 2019-06-11 17:27 ` Mika Kuoppala
  2019-06-11 19:45   ` Chris Wilson
  2019-06-11 17:27 ` [PATCH 4/9] drm/i915/gtt: Introduce init_pd Mika Kuoppala
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 20+ messages in thread
From: Mika Kuoppala @ 2019-06-11 17:27 UTC (permalink / raw)
  To: intel-gfx

We set the page directory entries to point into a page table.
There is no gen specifics in here so make it simple and
obvious.

Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 9a1f956a817a..9d87f0fb5b16 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -724,12 +724,12 @@ static void free_pd(struct i915_address_space *vm,
 	kfree(pd);
 }
 
-static void gen8_initialize_pd(struct i915_address_space *vm,
-			       struct i915_page_directory *pd)
+static void init_pd_with_page(struct i915_address_space *vm,
+			      struct i915_page_directory * const pd,
+			      struct i915_page_table *pt)
 {
-	fill_px(vm, pd,
-		gen8_pde_encode(px_dma(vm->scratch_pt), I915_CACHE_LLC));
-	memset_p(pd->entry, vm->scratch_pt, I915_PDES);
+	fill_px(vm, pd, gen8_pde_encode(px_dma(pt), I915_CACHE_LLC));
+	memset_p(pd->entry, pt, 512);
 }
 
 static struct i915_page_directory *alloc_pdp(struct i915_address_space *vm)
@@ -1262,7 +1262,7 @@ static int gen8_init_scratch(struct i915_address_space *vm)
 	}
 
 	gen8_initialize_pt(vm, vm->scratch_pt);
-	gen8_initialize_pd(vm, vm->scratch_pd);
+	init_pd_with_page(vm, vm->scratch_pd, vm->scratch_pt);
 	if (i915_vm_is_4lvl(vm))
 		gen8_initialize_4lvl_pdp(vm, vm->scratch_pdp);
 
@@ -1439,7 +1439,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 			if (IS_ERR(pd))
 				goto unwind;
 
-			gen8_initialize_pd(vm, pd);
+			init_pd_with_page(vm, pd, vm->scratch_pt);
 
 			old = cmpxchg(&pdp->entry[pdpe], vm->scratch_pd, pd);
 			if (old == vm->scratch_pd) {
@@ -1561,7 +1561,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 		if (IS_ERR(pd))
 			goto unwind;
 
-		gen8_initialize_pd(vm, pd);
+		init_pd_with_page(vm, pd, vm->scratch_pt);
 		gen8_ppgtt_set_pdpe(vm, pdp, pd, pdpe);
 
 		atomic_inc(&pdp->used);
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/9] drm/i915/gtt: Introduce init_pd
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
  2019-06-11 17:27 ` [PATCH 2/9] drm/i915/gtt: Use a common type for page directories Mika Kuoppala
  2019-06-11 17:27 ` [PATCH 3/9] drm/i915/gtt: Introduce init_pd_with_page Mika Kuoppala
@ 2019-06-11 17:27 ` Mika Kuoppala
  2019-06-11 17:27 ` [PATCH 5/9] drm/i915/gtt: Generalize alloc_pd Mika Kuoppala
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-06-11 17:27 UTC (permalink / raw)
  To: intel-gfx

All page directories, excluding last level, are initialized with
pointer to next level page directories. Make common function for it.

Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 37 +++++++++++------------------
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 9d87f0fb5b16..73aaf9481dab 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -759,26 +759,12 @@ static void free_pdp(struct i915_address_space *vm,
 	kfree(pdp);
 }
 
-static void gen8_initialize_4lvl_pdp(struct i915_address_space *vm,
-				     struct i915_page_directory *pdp)
+static void init_pd(struct i915_address_space *vm,
+		    struct i915_page_directory * const pd,
+		    struct i915_page_directory * const to)
 {
-	fill_px(vm, pdp,
-		gen8_pdpe_encode(px_dma(vm->scratch_pd), I915_CACHE_LLC));
-	memset_p(pdp->entry, vm->scratch_pd, 512);
-}
-
-static void gen8_initialize_3lvl_pdp(struct i915_address_space *vm,
-				     struct i915_page_directory *pdp)
-{
-	memset_p(pdp->entry, vm->scratch_pd, GEN8_3LVL_PDPES);
-}
-
-static void gen8_initialize_pml4(struct i915_address_space *vm,
-				 struct i915_page_directory *pml4)
-{
-	fill_px(vm, pml4,
-		gen8_pml4e_encode(px_dma(vm->scratch_pdp), I915_CACHE_LLC));
-	memset_p(pml4->entry, vm->scratch_pdp, GEN8_PML4ES_PER_PML4);
+	fill_px(vm, pd, gen8_pdpe_encode(px_dma(to), I915_CACHE_LLC));
+	memset_p(pd->entry, to, 512);
 }
 
 /*
@@ -1264,7 +1250,7 @@ static int gen8_init_scratch(struct i915_address_space *vm)
 	gen8_initialize_pt(vm, vm->scratch_pt);
 	init_pd_with_page(vm, vm->scratch_pd, vm->scratch_pt);
 	if (i915_vm_is_4lvl(vm))
-		gen8_initialize_4lvl_pdp(vm, vm->scratch_pdp);
+		init_pd(vm, vm->scratch_pdp, vm->scratch_pd);
 
 	return 0;
 
@@ -1509,7 +1495,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 			if (IS_ERR(pdp))
 				goto unwind;
 
-			gen8_initialize_4lvl_pdp(vm, pdp);
+			init_pd(vm, pdp, vm->scratch_pd);
 
 			old = cmpxchg(&pml4->entry[pml4e], vm->scratch_pdp, pdp);
 			if (old == vm->scratch_pdp) {
@@ -1639,13 +1625,18 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
 	}
 
 	if (i915_vm_is_4lvl(&ppgtt->vm)) {
-		gen8_initialize_pml4(&ppgtt->vm, ppgtt->pd);
+		init_pd(&ppgtt->vm, ppgtt->pd, ppgtt->vm.scratch_pdp);
 
 		ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc_4lvl;
 		ppgtt->vm.insert_entries = gen8_ppgtt_insert_4lvl;
 		ppgtt->vm.clear_range = gen8_ppgtt_clear_4lvl;
 	} else {
-		gen8_initialize_3lvl_pdp(&ppgtt->vm, ppgtt->pd);
+		/*
+		 * We don't need to setup dma for top level pdp, only
+		 * for entries. So point entries to scratch.
+		 */
+		memset_p(ppgtt->pd->entry, ppgtt->vm.scratch_pd,
+			 GEN8_3LVL_PDPES);
 
 		if (intel_vgpu_active(i915)) {
 			err = gen8_preallocate_top_level_pdp(ppgtt);
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 5/9] drm/i915/gtt: Generalize alloc_pd
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (2 preceding siblings ...)
  2019-06-11 17:27 ` [PATCH 4/9] drm/i915/gtt: Introduce init_pd Mika Kuoppala
@ 2019-06-11 17:27 ` Mika Kuoppala
  2019-06-11 17:27 ` [PATCH 6/9] drm/i915/gtt: pde entry encoding is identical Mika Kuoppala
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-06-11 17:27 UTC (permalink / raw)
  To: intel-gfx

Allocate all page directory variants with alloc_pd. As
the lvl3 and lvl4 variants differ in manipulation, we
need to check for existence of backing phys page before accessing
it.

Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 100 ++++++++++++----------------
 1 file changed, 42 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 73aaf9481dab..bbcf3be28e19 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -717,10 +717,17 @@ static struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
 	return pd;
 }
 
+static inline bool pd_has_phys_page(const struct i915_page_directory * const pd)
+{
+	return pd->base.page;
+}
+
 static void free_pd(struct i915_address_space *vm,
 		    struct i915_page_directory *pd)
 {
-	cleanup_px(vm, pd);
+	if (likely(pd_has_phys_page(pd)))
+		cleanup_px(vm, pd);
+
 	kfree(pd);
 }
 
@@ -732,37 +739,12 @@ static void init_pd_with_page(struct i915_address_space *vm,
 	memset_p(pd->entry, pt, 512);
 }
 
-static struct i915_page_directory *alloc_pdp(struct i915_address_space *vm)
-{
-	struct i915_page_directory *pdp;
-
-	pdp = __alloc_pd(i915_pdpes_per_pdp(vm));
-	if (!pdp)
-		return ERR_PTR(-ENOMEM);
-
-	if (i915_vm_is_4lvl(vm)) {
-		if (unlikely(setup_px(vm, pdp))) {
-			kfree(pdp);
-			return ERR_PTR(-ENOMEM);
-		}
-	}
-
-	return pdp;
-}
-
-static void free_pdp(struct i915_address_space *vm,
-		     struct i915_page_directory *pdp)
-{
-	if (i915_vm_is_4lvl(vm))
-		cleanup_px(vm, pdp);
-
-	kfree(pdp);
-}
-
 static void init_pd(struct i915_address_space *vm,
 		    struct i915_page_directory * const pd,
 		    struct i915_page_directory * const to)
 {
+	GEM_DEBUG_BUG_ON(!pd_has_phys_page(pd));
+
 	fill_px(vm, pd, gen8_pdpe_encode(px_dma(to), I915_CACHE_LLC));
 	memset_p(pd->entry, to, 512);
 }
@@ -840,14 +822,13 @@ static bool gen8_ppgtt_clear_pd(struct i915_address_space *vm,
 	return !atomic_read(&pd->used);
 }
 
-static void gen8_ppgtt_set_pdpe(struct i915_address_space *vm,
-				struct i915_page_directory *pdp,
+static void gen8_ppgtt_set_pdpe(struct i915_page_directory *pdp,
 				struct i915_page_directory *pd,
 				unsigned int pdpe)
 {
 	gen8_ppgtt_pdpe_t *vaddr;
 
-	if (!i915_vm_is_4lvl(vm))
+	if (!pd_has_phys_page(pdp))
 		return;
 
 	vaddr = kmap_atomic_px(pdp);
@@ -875,7 +856,7 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
 
 		spin_lock(&pdp->lock);
 		if (!atomic_read(&pd->used)) {
-			gen8_ppgtt_set_pdpe(vm, pdp, vm->scratch_pd, pdpe);
+			gen8_ppgtt_set_pdpe(pdp, vm->scratch_pd, pdpe);
 			pdp->entry[pdpe] = vm->scratch_pd;
 
 			GEM_BUG_ON(!atomic_read(&pdp->used));
@@ -936,7 +917,7 @@ static void gen8_ppgtt_clear_4lvl(struct i915_address_space *vm,
 		}
 		spin_unlock(&pml4->lock);
 		if (free)
-			free_pdp(vm, pdp);
+			free_pd(vm, pdp);
 	}
 }
 
@@ -1240,7 +1221,7 @@ static int gen8_init_scratch(struct i915_address_space *vm)
 	}
 
 	if (i915_vm_is_4lvl(vm)) {
-		vm->scratch_pdp = alloc_pdp(vm);
+		vm->scratch_pdp = alloc_pd(vm);
 		if (IS_ERR(vm->scratch_pdp)) {
 			ret = PTR_ERR(vm->scratch_pdp);
 			goto free_pd;
@@ -1302,7 +1283,7 @@ static void gen8_free_scratch(struct i915_address_space *vm)
 		return;
 
 	if (i915_vm_is_4lvl(vm))
-		free_pdp(vm, vm->scratch_pdp);
+		free_pd(vm, vm->scratch_pdp);
 	free_pd(vm, vm->scratch_pd);
 	free_pt(vm, vm->scratch_pt);
 	cleanup_scratch_page(vm);
@@ -1322,7 +1303,7 @@ static void gen8_ppgtt_cleanup_3lvl(struct i915_address_space *vm,
 		free_pd(vm, pdp->entry[i]);
 	}
 
-	free_pdp(vm, pdp);
+	free_pd(vm, pdp);
 }
 
 static void gen8_ppgtt_cleanup_4lvl(struct i915_ppgtt *ppgtt)
@@ -1429,7 +1410,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 
 			old = cmpxchg(&pdp->entry[pdpe], vm->scratch_pd, pd);
 			if (old == vm->scratch_pd) {
-				gen8_ppgtt_set_pdpe(vm, pdp, pd, pdpe);
+				gen8_ppgtt_set_pdpe(pdp, pd, pdpe);
 				atomic_inc(&pdp->used);
 			} else {
 				free_pd(vm, pd);
@@ -1455,7 +1436,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 unwind_pd:
 	spin_lock(&pdp->lock);
 	if (atomic_dec_and_test(&pd->used)) {
-		gen8_ppgtt_set_pdpe(vm, pdp, vm->scratch_pd, pdpe);
+		gen8_ppgtt_set_pdpe(pdp, vm->scratch_pd, pdpe);
 		GEM_BUG_ON(!atomic_read(&pdp->used));
 		atomic_dec(&pdp->used);
 		free_pd(vm, pd);
@@ -1485,13 +1466,12 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 
 	spin_lock(&pml4->lock);
 	gen8_for_each_pml4e(pdp, pml4, start, length, pml4e) {
-
 		if (pdp == vm->scratch_pdp) {
 			struct i915_page_directory *old;
 
 			spin_unlock(&pml4->lock);
 
-			pdp = alloc_pdp(vm);
+			pdp = alloc_pd(vm);
 			if (IS_ERR(pdp))
 				goto unwind;
 
@@ -1501,7 +1481,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 			if (old == vm->scratch_pdp) {
 				gen8_ppgtt_set_pml4e(pml4, pdp, pml4e);
 			} else {
-				free_pdp(vm, pdp);
+				free_pd(vm, pdp);
 				pdp = old;
 			}
 
@@ -1525,7 +1505,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 	spin_lock(&pml4->lock);
 	if (atomic_dec_and_test(&pdp->used)) {
 		gen8_ppgtt_set_pml4e(pml4, vm->scratch_pdp, pml4e);
-		free_pdp(vm, pdp);
+		free_pd(vm, pdp);
 	}
 	spin_unlock(&pml4->lock);
 unwind:
@@ -1548,7 +1528,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 			goto unwind;
 
 		init_pd_with_page(vm, pd, vm->scratch_pt);
-		gen8_ppgtt_set_pdpe(vm, pdp, pd, pdpe);
+		gen8_ppgtt_set_pdpe(pdp, pd, pdpe);
 
 		atomic_inc(&pdp->used);
 	}
@@ -1560,7 +1540,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 unwind:
 	start -= from;
 	gen8_for_each_pdpe(pd, pdp, from, start, pdpe) {
-		gen8_ppgtt_set_pdpe(vm, pdp, vm->scratch_pd, pdpe);
+		gen8_ppgtt_set_pdpe(pdp, vm->scratch_pd, pdpe);
 		free_pd(vm, pd);
 	}
 	atomic_set(&pdp->used, 0);
@@ -1592,7 +1572,7 @@ static void ppgtt_init(struct drm_i915_private *i915,
 static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
 {
 	struct i915_ppgtt *ppgtt;
-	int err;
+	int ret;
 
 	ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
 	if (!ppgtt)
@@ -1614,17 +1594,21 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
 	if (IS_CHERRYVIEW(i915) || IS_BROXTON(i915))
 		ppgtt->vm.pt_kmap_wc = true;
 
-	err = gen8_init_scratch(&ppgtt->vm);
-	if (err)
+	ret = gen8_init_scratch(&ppgtt->vm);
+	if (ret)
 		goto err_free;
 
-	ppgtt->pd = alloc_pdp(&ppgtt->vm);
-	if (IS_ERR(ppgtt->pd)) {
-		err = PTR_ERR(ppgtt->pd);
-		goto err_scratch;
+	ppgtt->pd = __alloc_pd(i915_pdpes_per_pdp(&ppgtt->vm));
+	if (!ppgtt->pd) {
+		ret = -ENOMEM;
+		goto err_free_scratch;
 	}
 
 	if (i915_vm_is_4lvl(&ppgtt->vm)) {
+		ret = setup_px(&ppgtt->vm, ppgtt->pd);
+		if (ret)
+			goto err_free_pdp;
+
 		init_pd(&ppgtt->vm, ppgtt->pd, ppgtt->vm.scratch_pdp);
 
 		ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc_4lvl;
@@ -1639,9 +1623,9 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
 			 GEN8_3LVL_PDPES);
 
 		if (intel_vgpu_active(i915)) {
-			err = gen8_preallocate_top_level_pdp(ppgtt);
-			if (err)
-				goto err_pdp;
+			ret = gen8_preallocate_top_level_pdp(ppgtt);
+			if (ret)
+				goto err_free_pdp;
 		}
 
 		ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc_3lvl;
@@ -1656,13 +1640,13 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
 
 	return ppgtt;
 
-err_pdp:
-	free_pdp(&ppgtt->vm, ppgtt->pd);
-err_scratch:
+err_free_pdp:
+	free_pd(&ppgtt->vm, ppgtt->pd);
+err_free_scratch:
 	gen8_free_scratch(&ppgtt->vm);
 err_free:
 	kfree(ppgtt);
-	return ERR_PTR(err);
+	return ERR_PTR(ret);
 }
 
 /* Write pde (index) from the page directory @pd to the page table @pt */
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 6/9] drm/i915/gtt: pde entry encoding is identical
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (3 preceding siblings ...)
  2019-06-11 17:27 ` [PATCH 5/9] drm/i915/gtt: Generalize alloc_pd Mika Kuoppala
@ 2019-06-11 17:27 ` Mika Kuoppala
  2019-06-11 17:27 ` [PATCH 7/9] drm/i915/gtt: Check for physical page for pd entry always Mika Kuoppala
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-06-11 17:27 UTC (permalink / raw)
  To: intel-gfx

For all page directory entries, the pde encoding is
identical. Don't compilicate call sites with different
versions of doing the same thing.

Only wart that remains is a 4 entry gen8/bsw pdp, for which
we need to check the backing phys page.

Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 111 ++++++++++------------------
 drivers/gpu/drm/i915/i915_gem_gtt.h |   3 -
 2 files changed, 40 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index bbcf3be28e19..815950658b12 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -214,10 +214,10 @@ static u64 gen8_pte_encode(dma_addr_t addr,
 	return pte;
 }
 
-static gen8_pde_t gen8_pde_encode(const dma_addr_t addr,
-				  const enum i915_cache_level level)
+static u64 gen8_pde_encode(const dma_addr_t addr,
+			   const enum i915_cache_level level)
 {
-	gen8_pde_t pde = _PAGE_PRESENT | _PAGE_RW;
+	u64 pde = _PAGE_PRESENT | _PAGE_RW;
 	pde |= addr;
 	if (level != I915_CACHE_NONE)
 		pde |= PPAT_CACHED_PDE;
@@ -226,9 +226,6 @@ static gen8_pde_t gen8_pde_encode(const dma_addr_t addr,
 	return pde;
 }
 
-#define gen8_pdpe_encode gen8_pde_encode
-#define gen8_pml4e_encode gen8_pde_encode
-
 static u64 snb_pte_encode(dma_addr_t addr,
 			  enum i915_cache_level level,
 			  u32 flags)
@@ -731,24 +728,36 @@ static void free_pd(struct i915_address_space *vm,
 	kfree(pd);
 }
 
-static void init_pd_with_page(struct i915_address_space *vm,
-			      struct i915_page_directory * const pd,
-			      struct i915_page_table *pt)
-{
-	fill_px(vm, pd, gen8_pde_encode(px_dma(pt), I915_CACHE_LLC));
-	memset_p(pd->entry, pt, 512);
+#define init_pd(vm, pd, to) {					\
+	GEM_DEBUG_BUG_ON(!pd_has_phys_page(pd));		\
+	fill_px((vm), (pd), gen8_pde_encode(px_dma(to), I915_CACHE_LLC)); \
+	memset_p((pd)->entry, (to), 512);				\
 }
 
-static void init_pd(struct i915_address_space *vm,
-		    struct i915_page_directory * const pd,
-		    struct i915_page_directory * const to)
+static void __set_pd_entry(struct i915_page_directory * const pd,
+			   const unsigned short pde,
+			   const u64 encoded_entry)
 {
-	GEM_DEBUG_BUG_ON(!pd_has_phys_page(pd));
+	u64 *vaddr;
 
-	fill_px(vm, pd, gen8_pdpe_encode(px_dma(to), I915_CACHE_LLC));
-	memset_p(pd->entry, to, 512);
+	vaddr = kmap_atomic(pd->base.page);
+	vaddr[pde] = encoded_entry;
+	kunmap_atomic(vaddr);
 }
 
+#define set_pd_entry(pd, pde, to) ({					\
+	(pd)->entry[(pde)] = (to);					\
+	__set_pd_entry((pd), (pde),					\
+		       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));	\
+})
+
+#define set_pdp_entry(pdp, pdpe, to) ({		\
+	(pdp)->entry[(pdpe)] = (to);		\
+	if (pd_has_phys_page(pdp))					\
+		__set_pd_entry((pdp), (pdpe),				\
+			       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));\
+})
+
 /*
  * PDE TLBs are a pain to invalidate on GEN8+. When we modify
  * the page table structures, we mark them dirty so that
@@ -778,18 +787,6 @@ static bool gen8_ppgtt_clear_pt(const struct i915_address_space *vm,
 	return !atomic_sub_return(num_entries, &pt->used);
 }
 
-static void gen8_ppgtt_set_pde(struct i915_address_space *vm,
-			       struct i915_page_directory *pd,
-			       struct i915_page_table *pt,
-			       unsigned int pde)
-{
-	gen8_pde_t *vaddr;
-
-	vaddr = kmap_atomic_px(pd);
-	vaddr[pde] = gen8_pde_encode(px_dma(pt), I915_CACHE_LLC);
-	kunmap_atomic(vaddr);
-}
-
 static bool gen8_ppgtt_clear_pd(struct i915_address_space *vm,
 				struct i915_page_directory *pd,
 				u64 start, u64 length)
@@ -807,8 +804,7 @@ static bool gen8_ppgtt_clear_pd(struct i915_address_space *vm,
 
 		spin_lock(&pd->lock);
 		if (!atomic_read(&pt->used)) {
-			gen8_ppgtt_set_pde(vm, pd, vm->scratch_pt, pde);
-			pd->entry[pde] = vm->scratch_pt;
+			set_pd_entry(pd, pde, vm->scratch_pt);
 
 			GEM_BUG_ON(!atomic_read(&pd->used));
 			atomic_dec(&pd->used);
@@ -822,20 +818,6 @@ static bool gen8_ppgtt_clear_pd(struct i915_address_space *vm,
 	return !atomic_read(&pd->used);
 }
 
-static void gen8_ppgtt_set_pdpe(struct i915_page_directory *pdp,
-				struct i915_page_directory *pd,
-				unsigned int pdpe)
-{
-	gen8_ppgtt_pdpe_t *vaddr;
-
-	if (!pd_has_phys_page(pdp))
-		return;
-
-	vaddr = kmap_atomic_px(pdp);
-	vaddr[pdpe] = gen8_pdpe_encode(px_dma(pd), I915_CACHE_LLC);
-	kunmap_atomic(vaddr);
-}
-
 /* Removes entries from a single page dir pointer, releasing it if it's empty.
  * Caller can use the return value to update higher-level entries
  */
@@ -856,8 +838,7 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
 
 		spin_lock(&pdp->lock);
 		if (!atomic_read(&pd->used)) {
-			gen8_ppgtt_set_pdpe(pdp, vm->scratch_pd, pdpe);
-			pdp->entry[pdpe] = vm->scratch_pd;
+			set_pdp_entry(pdp, pdpe, vm->scratch_pd);
 
 			GEM_BUG_ON(!atomic_read(&pdp->used));
 			atomic_dec(&pdp->used);
@@ -877,17 +858,6 @@ static void gen8_ppgtt_clear_3lvl(struct i915_address_space *vm,
 	gen8_ppgtt_clear_pdp(vm, i915_vm_to_ppgtt(vm)->pd, start, length);
 }
 
-static void gen8_ppgtt_set_pml4e(struct i915_page_directory *pml4,
-				 struct i915_page_directory *pdp,
-				 unsigned int pml4e)
-{
-	gen8_ppgtt_pml4e_t *vaddr;
-
-	vaddr = kmap_atomic_px(pml4);
-	vaddr[pml4e] = gen8_pml4e_encode(px_dma(pdp), I915_CACHE_LLC);
-	kunmap_atomic(vaddr);
-}
-
 /* Removes entries from a single pml4.
  * This is the top-level structure in 4-level page tables used on gen8+.
  * Empty entries are always scratch pml4e.
@@ -911,8 +881,7 @@ static void gen8_ppgtt_clear_4lvl(struct i915_address_space *vm,
 
 		spin_lock(&pml4->lock);
 		if (!atomic_read(&pdp->used)) {
-			gen8_ppgtt_set_pml4e(pml4, vm->scratch_pdp, pml4e);
-			pml4->entry[pml4e] = vm->scratch_pdp;
+			set_pd_entry(pml4, pml4e, vm->scratch_pdp);
 			free = true;
 		}
 		spin_unlock(&pml4->lock);
@@ -1229,7 +1198,7 @@ static int gen8_init_scratch(struct i915_address_space *vm)
 	}
 
 	gen8_initialize_pt(vm, vm->scratch_pt);
-	init_pd_with_page(vm, vm->scratch_pd, vm->scratch_pt);
+	init_pd(vm, vm->scratch_pd, vm->scratch_pt);
 	if (i915_vm_is_4lvl(vm))
 		init_pd(vm, vm->scratch_pdp, vm->scratch_pd);
 
@@ -1365,7 +1334,7 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
 
 			old = cmpxchg(&pd->entry[pde], vm->scratch_pt, pt);
 			if (old == vm->scratch_pt) {
-				gen8_ppgtt_set_pde(vm, pd, pt, pde);
+				set_pd_entry(pd, pde, pt);
 				atomic_inc(&pd->used);
 			} else {
 				free_pt(vm, pt);
@@ -1406,11 +1375,11 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 			if (IS_ERR(pd))
 				goto unwind;
 
-			init_pd_with_page(vm, pd, vm->scratch_pt);
+			init_pd(vm, pd, vm->scratch_pt);
 
 			old = cmpxchg(&pdp->entry[pdpe], vm->scratch_pd, pd);
 			if (old == vm->scratch_pd) {
-				gen8_ppgtt_set_pdpe(pdp, pd, pdpe);
+				set_pdp_entry(pdp, pdpe, pd);
 				atomic_inc(&pdp->used);
 			} else {
 				free_pd(vm, pd);
@@ -1436,7 +1405,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 unwind_pd:
 	spin_lock(&pdp->lock);
 	if (atomic_dec_and_test(&pd->used)) {
-		gen8_ppgtt_set_pdpe(pdp, vm->scratch_pd, pdpe);
+		set_pdp_entry(pdp, pdpe, vm->scratch_pd);
 		GEM_BUG_ON(!atomic_read(&pdp->used));
 		atomic_dec(&pdp->used);
 		free_pd(vm, pd);
@@ -1479,7 +1448,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 
 			old = cmpxchg(&pml4->entry[pml4e], vm->scratch_pdp, pdp);
 			if (old == vm->scratch_pdp) {
-				gen8_ppgtt_set_pml4e(pml4, pdp, pml4e);
+				set_pd_entry(pml4, pml4e, pdp);
 			} else {
 				free_pd(vm, pdp);
 				pdp = old;
@@ -1504,7 +1473,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 unwind_pdp:
 	spin_lock(&pml4->lock);
 	if (atomic_dec_and_test(&pdp->used)) {
-		gen8_ppgtt_set_pml4e(pml4, vm->scratch_pdp, pml4e);
+		set_pd_entry(pml4, pml4e, vm->scratch_pdp);
 		free_pd(vm, pdp);
 	}
 	spin_unlock(&pml4->lock);
@@ -1527,8 +1496,8 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 		if (IS_ERR(pd))
 			goto unwind;
 
-		init_pd_with_page(vm, pd, vm->scratch_pt);
-		gen8_ppgtt_set_pdpe(pdp, pd, pdpe);
+		init_pd(vm, pd, vm->scratch_pt);
+		set_pdp_entry(pdp, pdpe, pd);
 
 		atomic_inc(&pdp->used);
 	}
@@ -1540,7 +1509,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 unwind:
 	start -= from;
 	gen8_for_each_pdpe(pd, pdp, from, start, pdpe) {
-		gen8_ppgtt_set_pdpe(pdp, vm->scratch_pd, pdpe);
+		set_pdp_entry(pdp, pdpe, vm->scratch_pd);
 		free_pd(vm, pd);
 	}
 	atomic_set(&pdp->used, 0);
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index 49f44071def4..4dfc5783404a 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -67,9 +67,6 @@ struct i915_vma;
 
 typedef u32 gen6_pte_t;
 typedef u64 gen8_pte_t;
-typedef u64 gen8_pde_t;
-typedef u64 gen8_ppgtt_pdpe_t;
-typedef u64 gen8_ppgtt_pml4e_t;
 
 #define ggtt_total_entries(ggtt) ((ggtt)->vm.total >> PAGE_SHIFT)
 
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 7/9] drm/i915/gtt: Check for physical page for pd entry always
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (4 preceding siblings ...)
  2019-06-11 17:27 ` [PATCH 6/9] drm/i915/gtt: pde entry encoding is identical Mika Kuoppala
@ 2019-06-11 17:27 ` Mika Kuoppala
  2019-06-11 17:27 ` [PATCH 8/9] drm/i915/gtt: Make swapping the pd entry generic Mika Kuoppala
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-06-11 17:27 UTC (permalink / raw)
  To: intel-gfx

Check the physical page before writing the entry into
the physical page. This further generalizes the pd so that
manipulation in callsites will be identical, removing the need to
handle pdps differently for gen8.

Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 815950658b12..f1d7874834e2 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -747,17 +747,11 @@ static void __set_pd_entry(struct i915_page_directory * const pd,
 
 #define set_pd_entry(pd, pde, to) ({					\
 	(pd)->entry[(pde)] = (to);					\
-	__set_pd_entry((pd), (pde),					\
+	if (likely(pd_has_phys_page(pd)))				\
+		__set_pd_entry((pd), (pde),				\
 		       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));	\
 })
 
-#define set_pdp_entry(pdp, pdpe, to) ({		\
-	(pdp)->entry[(pdpe)] = (to);		\
-	if (pd_has_phys_page(pdp))					\
-		__set_pd_entry((pdp), (pdpe),				\
-			       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));\
-})
-
 /*
  * PDE TLBs are a pain to invalidate on GEN8+. When we modify
  * the page table structures, we mark them dirty so that
@@ -838,7 +832,7 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
 
 		spin_lock(&pdp->lock);
 		if (!atomic_read(&pd->used)) {
-			set_pdp_entry(pdp, pdpe, vm->scratch_pd);
+			set_pd_entry(pdp, pdpe, vm->scratch_pd);
 
 			GEM_BUG_ON(!atomic_read(&pdp->used));
 			atomic_dec(&pdp->used);
@@ -1379,7 +1373,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 
 			old = cmpxchg(&pdp->entry[pdpe], vm->scratch_pd, pd);
 			if (old == vm->scratch_pd) {
-				set_pdp_entry(pdp, pdpe, pd);
+				set_pd_entry(pdp, pdpe, pd);
 				atomic_inc(&pdp->used);
 			} else {
 				free_pd(vm, pd);
@@ -1405,7 +1399,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 unwind_pd:
 	spin_lock(&pdp->lock);
 	if (atomic_dec_and_test(&pd->used)) {
-		set_pdp_entry(pdp, pdpe, vm->scratch_pd);
+		set_pd_entry(pdp, pdpe, vm->scratch_pd);
 		GEM_BUG_ON(!atomic_read(&pdp->used));
 		atomic_dec(&pdp->used);
 		free_pd(vm, pd);
@@ -1497,7 +1491,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 			goto unwind;
 
 		init_pd(vm, pd, vm->scratch_pt);
-		set_pdp_entry(pdp, pdpe, pd);
+		set_pd_entry(pdp, pdpe, pd);
 
 		atomic_inc(&pdp->used);
 	}
@@ -1509,7 +1503,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
 unwind:
 	start -= from;
 	gen8_for_each_pdpe(pd, pdp, from, start, pdpe) {
-		set_pdp_entry(pdp, pdpe, vm->scratch_pd);
+		set_pd_entry(pdp, pdpe, vm->scratch_pd);
 		free_pd(vm, pd);
 	}
 	atomic_set(&pdp->used, 0);
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 8/9] drm/i915/gtt: Make swapping the pd entry generic
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (5 preceding siblings ...)
  2019-06-11 17:27 ` [PATCH 7/9] drm/i915/gtt: Check for physical page for pd entry always Mika Kuoppala
@ 2019-06-11 17:27 ` Mika Kuoppala
  2019-06-11 19:50   ` Chris Wilson
  2019-06-11 17:27 ` [PATCH 9/9] drm/i915/gtt: Tear down setup and cleanup macros for page dma Mika Kuoppala
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 20+ messages in thread
From: Mika Kuoppala @ 2019-06-11 17:27 UTC (permalink / raw)
  To: intel-gfx

Swapping a pd entry is same across the page directories, if
we succeed we need to increment the count and write the phys page
entry. Make a common function for it.

Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 41 +++++++++++++++++++----------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index f1d7874834e2..9b0d0a077e31 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -752,6 +752,27 @@ static void __set_pd_entry(struct i915_page_directory * const pd,
 		       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));	\
 })
 
+static void *__swap_pd_entry(struct i915_page_directory * const pd,
+			     const unsigned short pde,
+			     void * const old_val,
+			     void * const new_val,
+			     const u64 encoded_entry)
+{
+	void * const old = cmpxchg(&pd->entry[pde], old_val, new_val);
+
+	if (likely(old == old_val)) {
+		atomic_inc(&pd->used);
+		if (likely(pd_has_phys_page(pd)))
+			__set_pd_entry(pd, pde, encoded_entry);
+	}
+
+	return old;
+}
+
+#define swap_pd_entry(pd, pde, old, to) \
+	__swap_pd_entry((pd), (pde), (old), (to), \
+			gen8_pde_encode(px_dma(to), I915_CACHE_LLC))
+
 /*
  * PDE TLBs are a pain to invalidate on GEN8+. When we modify
  * the page table structures, we mark them dirty so that
@@ -1326,11 +1347,8 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
 			if (count < GEN8_PTES || intel_vgpu_active(vm->i915))
 				gen8_initialize_pt(vm, pt);
 
-			old = cmpxchg(&pd->entry[pde], vm->scratch_pt, pt);
-			if (old == vm->scratch_pt) {
-				set_pd_entry(pd, pde, pt);
-				atomic_inc(&pd->used);
-			} else {
+			old = swap_pd_entry(pd, pde, vm->scratch_pt, pt);
+			if (unlikely(old != vm->scratch_pt)) {
 				free_pt(vm, pt);
 				pt = old;
 			}
@@ -1371,11 +1389,8 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 
 			init_pd(vm, pd, vm->scratch_pt);
 
-			old = cmpxchg(&pdp->entry[pdpe], vm->scratch_pd, pd);
-			if (old == vm->scratch_pd) {
-				set_pd_entry(pdp, pdpe, pd);
-				atomic_inc(&pdp->used);
-			} else {
+			old = swap_pd_entry(pdp, pdpe, vm->scratch_pd, pd);
+			if (unlikely(old != vm->scratch_pd)) {
 				free_pd(vm, pd);
 				pd = old;
 			}
@@ -1440,10 +1455,8 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
 
 			init_pd(vm, pdp, vm->scratch_pd);
 
-			old = cmpxchg(&pml4->entry[pml4e], vm->scratch_pdp, pdp);
-			if (old == vm->scratch_pdp) {
-				set_pd_entry(pml4, pml4e, pdp);
-			} else {
+			old = swap_pd_entry(pml4, pml4e, vm->scratch_pdp, pdp);
+			if (unlikely(old != vm->scratch_pdp)) {
 				free_pd(vm, pdp);
 				pdp = old;
 			}
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 9/9] drm/i915/gtt: Tear down setup and cleanup macros for page dma
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (6 preceding siblings ...)
  2019-06-11 17:27 ` [PATCH 8/9] drm/i915/gtt: Make swapping the pd entry generic Mika Kuoppala
@ 2019-06-11 17:27 ` Mika Kuoppala
  2019-06-11 17:53 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs Patchwork
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-06-11 17:27 UTC (permalink / raw)
  To: intel-gfx

We don't use common codepaths to setup and cleanup page
directories vs page tables. So their setup and cleanup macros
are of no use.

Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 9b0d0a077e31..a2022f240fb6 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -550,8 +550,6 @@ static void cleanup_page_dma(struct i915_address_space *vm,
 
 #define kmap_atomic_px(px) kmap_atomic(px_base(px)->page)
 
-#define setup_px(vm, px) setup_page_dma((vm), px_base(px))
-#define cleanup_px(vm, px) cleanup_page_dma((vm), px_base(px))
 #define fill_px(vm, px, v) fill_page_dma((vm), px_base(px), (v))
 #define fill32_px(vm, px, v) fill_page_dma_32((vm), px_base(px), (v))
 
@@ -653,7 +651,7 @@ static struct i915_page_table *alloc_pt(struct i915_address_space *vm)
 	if (unlikely(!pt))
 		return ERR_PTR(-ENOMEM);
 
-	if (unlikely(setup_px(vm, pt))) {
+	if (unlikely(setup_page_dma(vm, &pt->base))) {
 		kfree(pt);
 		return ERR_PTR(-ENOMEM);
 	}
@@ -665,7 +663,7 @@ static struct i915_page_table *alloc_pt(struct i915_address_space *vm)
 
 static void free_pt(struct i915_address_space *vm, struct i915_page_table *pt)
 {
-	cleanup_px(vm, pt);
+	cleanup_page_dma(vm, &pt->base);
 	kfree(pt);
 }
 
@@ -706,7 +704,7 @@ static struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
 	if (unlikely(!pd))
 		return ERR_PTR(-ENOMEM);
 
-	if (unlikely(setup_px(vm, pd))) {
+	if (unlikely(setup_page_dma(vm, &pd->base))) {
 		kfree(pd);
 		return ERR_PTR(-ENOMEM);
 	}
@@ -723,7 +721,7 @@ static void free_pd(struct i915_address_space *vm,
 		    struct i915_page_directory *pd)
 {
 	if (likely(pd_has_phys_page(pd)))
-		cleanup_px(vm, pd);
+		cleanup_page_dma(vm, &pd->base);
 
 	kfree(pd);
 }
@@ -1304,7 +1302,7 @@ static void gen8_ppgtt_cleanup_4lvl(struct i915_ppgtt *ppgtt)
 		gen8_ppgtt_cleanup_3lvl(&ppgtt->vm, pdp);
 	}
 
-	cleanup_px(&ppgtt->vm, pml4);
+	cleanup_page_dma(&ppgtt->vm, &pml4->base);
 }
 
 static void gen8_ppgtt_cleanup(struct i915_address_space *vm)
@@ -1581,7 +1579,7 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
 	}
 
 	if (i915_vm_is_4lvl(&ppgtt->vm)) {
-		ret = setup_px(&ppgtt->vm, ppgtt->pd);
+		ret = setup_page_dma(&ppgtt->vm, &ppgtt->pd->base);
 		if (ret)
 			goto err_free_pdp;
 
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (7 preceding siblings ...)
  2019-06-11 17:27 ` [PATCH 9/9] drm/i915/gtt: Tear down setup and cleanup macros for page dma Mika Kuoppala
@ 2019-06-11 17:53 ` Patchwork
  2019-06-11 17:57 ` ✗ Fi.CI.SPARSE: " Patchwork
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-06-11 17:53 UTC (permalink / raw)
  To: Mika Kuoppala; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs
URL   : https://patchwork.freedesktop.org/series/61914/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
84806e55a140 drm/i915/gtt: No need to zero the table for page dirs
456a07424854 drm/i915/gtt: Use a common type for page directories
-:676: CHECK:BRACES: Blank lines aren't necessary after an open brace '{'
#676: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:1502:
 	gen8_for_each_pml4e(pdp, pml4, start, length, pml4e) {
+

total: 0 errors, 0 warnings, 1 checks, 1049 lines checked
cfdf6893e733 drm/i915/gtt: Introduce init_pd_with_page
c8ec1761dc80 drm/i915/gtt: Introduce init_pd
2e057ea8402b drm/i915/gtt: Generalize alloc_pd
72426989ea08 drm/i915/gtt: pde entry encoding is identical
-:53: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pd' - possible side-effects?
#53: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:731:
+#define init_pd(vm, pd, to) {					\
+	GEM_DEBUG_BUG_ON(!pd_has_phys_page(pd));		\
+	fill_px((vm), (pd), gen8_pde_encode(px_dma(to), I915_CACHE_LLC)); \
+	memset_p((pd)->entry, (to), 512);				\
 }

-:53: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'to' - possible side-effects?
#53: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:731:
+#define init_pd(vm, pd, to) {					\
+	GEM_DEBUG_BUG_ON(!pd_has_phys_page(pd));		\
+	fill_px((vm), (pd), gen8_pde_encode(px_dma(to), I915_CACHE_LLC)); \
+	memset_p((pd)->entry, (to), 512);				\
 }

-:76: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pd' - possible side-effects?
#76: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:748:
+#define set_pd_entry(pd, pde, to) ({					\
+	(pd)->entry[(pde)] = (to);					\
+	__set_pd_entry((pd), (pde),					\
+		       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));	\
+})

-:76: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pde' - possible side-effects?
#76: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:748:
+#define set_pd_entry(pd, pde, to) ({					\
+	(pd)->entry[(pde)] = (to);					\
+	__set_pd_entry((pd), (pde),					\
+		       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));	\
+})

-:76: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'to' - possible side-effects?
#76: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:748:
+#define set_pd_entry(pd, pde, to) ({					\
+	(pd)->entry[(pde)] = (to);					\
+	__set_pd_entry((pd), (pde),					\
+		       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));	\
+})

-:82: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pdp' - possible side-effects?
#82: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:754:
+#define set_pdp_entry(pdp, pdpe, to) ({		\
+	(pdp)->entry[(pdpe)] = (to);		\
+	if (pd_has_phys_page(pdp))					\
+		__set_pd_entry((pdp), (pdpe),				\
+			       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));\
+})

-:82: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pdpe' - possible side-effects?
#82: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:754:
+#define set_pdp_entry(pdp, pdpe, to) ({		\
+	(pdp)->entry[(pdpe)] = (to);		\
+	if (pd_has_phys_page(pdp))					\
+		__set_pd_entry((pdp), (pdpe),				\
+			       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));\
+})

-:82: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'to' - possible side-effects?
#82: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:754:
+#define set_pdp_entry(pdp, pdpe, to) ({		\
+	(pdp)->entry[(pdpe)] = (to);		\
+	if (pd_has_phys_page(pdp))					\
+		__set_pd_entry((pdp), (pdpe),				\
+			       gen8_pde_encode(px_dma(to), I915_CACHE_LLC));\
+})

total: 0 errors, 0 warnings, 8 checks, 232 lines checked
0a1e3ad99009 drm/i915/gtt: Check for physical page for pd entry always
08e4c78a9b99 drm/i915/gtt: Make swapping the pd entry generic
-:37: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'to' - possible side-effects?
#37: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:772:
+#define swap_pd_entry(pd, pde, old, to) \
+	__swap_pd_entry((pd), (pde), (old), (to), \
+			gen8_pde_encode(px_dma(to), I915_CACHE_LLC))

total: 0 errors, 0 warnings, 1 checks, 65 lines checked
393d891d4aec drm/i915/gtt: Tear down setup and cleanup macros for page dma

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* ✗ Fi.CI.SPARSE: warning for series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (8 preceding siblings ...)
  2019-06-11 17:53 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs Patchwork
@ 2019-06-11 17:57 ` Patchwork
  2019-06-11 18:18 ` ✓ Fi.CI.BAT: success " Patchwork
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-06-11 17:57 UTC (permalink / raw)
  To: Mika Kuoppala; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs
URL   : https://patchwork.freedesktop.org/series/61914/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.5.2
Commit: drm/i915/gtt: No need to zero the table for page dirs
Okay!

Commit: drm/i915/gtt: Use a common type for page directories
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1512:9: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1512:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1501:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1501:9: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1752:44: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1752:44: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1831:9: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1831:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1745:44: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1745:44: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1826:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1826:9: warning: expression using sizeof(void)
-./include/linux/slab.h:666:13: error: undefined identifier '__builtin_mul_overflow'
-./include/linux/slab.h:666:13: warning: call with no type!

Commit: drm/i915/gtt: Introduce init_pd_with_page
Okay!

Commit: drm/i915/gtt: Introduce init_pd
Okay!

Commit: drm/i915/gtt: Generalize alloc_pd
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1487:9: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1487:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1468:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1468:9: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1562:9: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1562:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1542:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1542:9: warning: expression using sizeof(void)

Commit: drm/i915/gtt: pde entry encoding is identical
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1542:9: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1542:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1511:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1511:9: warning: expression using sizeof(void)

Commit: drm/i915/gtt: Check for physical page for pd entry always
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1511:9: warning: expression using sizeof(void)
-O:drivers/gpu/drm/i915/i915_gem_gtt.c:1511:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1505:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1505:9: warning: expression using sizeof(void)

Commit: drm/i915/gtt: Make swapping the pd entry generic
Okay!

Commit: drm/i915/gtt: Tear down setup and cleanup macros for page dma
Okay!

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (9 preceding siblings ...)
  2019-06-11 17:57 ` ✗ Fi.CI.SPARSE: " Patchwork
@ 2019-06-11 18:18 ` Patchwork
  2019-06-11 19:37 ` [PATCH 1/9] " Chris Wilson
  2019-06-12 21:32 ` ✗ Fi.CI.IGT: failure for series starting with [1/9] " Patchwork
  12 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-06-11 18:18 UTC (permalink / raw)
  To: Mika Kuoppala; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs
URL   : https://patchwork.freedesktop.org/series/61914/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6240 -> Patchwork_13246
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/

Known issues
------------

  Here are the changes found in Patchwork_13246 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_pm_rpm@basic-pci-d3-state:
    - fi-skl-6600u:       [PASS][1] -> [FAIL][2] ([fdo#107707])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/fi-skl-6600u/igt@i915_pm_rpm@basic-pci-d3-state.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/fi-skl-6600u/igt@i915_pm_rpm@basic-pci-d3-state.html

  * igt@kms_addfb_basic@unused-modifier:
    - fi-icl-u3:          [PASS][3] -> [DMESG-WARN][4] ([fdo#107724]) +1 similar issue
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/fi-icl-u3/igt@kms_addfb_basic@unused-modifier.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/fi-icl-u3/igt@kms_addfb_basic@unused-modifier.html

  * igt@kms_chamelium@hdmi-hpd-fast:
    - fi-kbl-7500u:       [PASS][5] -> [FAIL][6] ([fdo#109485])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html

  * igt@kms_frontbuffer_tracking@basic:
    - fi-hsw-peppy:       [PASS][7] -> [DMESG-WARN][8] ([fdo#102614])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html

  
#### Possible fixes ####

  * igt@gem_ctx_switch@basic-default:
    - {fi-icl-guc}:       [INCOMPLETE][9] ([fdo#107713] / [fdo#108569]) -> [PASS][10]
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/fi-icl-guc/igt@gem_ctx_switch@basic-default.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/fi-icl-guc/igt@gem_ctx_switch@basic-default.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
  [fdo#107707]: https://bugs.freedesktop.org/show_bug.cgi?id=107707
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
  [fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
  [fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485


Participating hosts (52 -> 47)
------------------------------

  Additional (2): fi-byt-j1900 fi-gdg-551 
  Missing    (7): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * Linux: CI_DRM_6240 -> Patchwork_13246

  CI_DRM_6240: 6912995f6dd977863a049005b01c6f197ae9cbdc @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5051: 1f2acef836ffcbf5113df4ade8b587935c7d5868 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_13246: 393d891d4aec953670d456c9a2336a591274cbba @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

393d891d4aec drm/i915/gtt: Tear down setup and cleanup macros for page dma
08e4c78a9b99 drm/i915/gtt: Make swapping the pd entry generic
0a1e3ad99009 drm/i915/gtt: Check for physical page for pd entry always
72426989ea08 drm/i915/gtt: pde entry encoding is identical
2e057ea8402b drm/i915/gtt: Generalize alloc_pd
c8ec1761dc80 drm/i915/gtt: Introduce init_pd
cfdf6893e733 drm/i915/gtt: Introduce init_pd_with_page
456a07424854 drm/i915/gtt: Use a common type for page directories
84806e55a140 drm/i915/gtt: No need to zero the table for page dirs

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (10 preceding siblings ...)
  2019-06-11 18:18 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-06-11 19:37 ` Chris Wilson
  2019-06-12 21:32 ` ✗ Fi.CI.IGT: failure for series starting with [1/9] " Patchwork
  12 siblings, 0 replies; 20+ messages in thread
From: Chris Wilson @ 2019-06-11 19:37 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-06-11 18:27:23)
> We set them to scratch right after allocation so prevent
> useless zeroing before.
> 
> v2: atomic_t
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index e70675bfb51d..07f86d474fa2 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -687,7 +687,7 @@ static struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
>  {
>         struct i915_page_directory *pd;
>  
> -       pd = kzalloc(sizeof(*pd), I915_GFP_ALLOW_FAIL);
> +       pd = kmalloc(sizeof(*pd), I915_GFP_ALLOW_FAIL);
>         if (unlikely(!pd))
>                 return ERR_PTR(-ENOMEM);
>  
> @@ -747,7 +747,7 @@ alloc_pdp(struct i915_address_space *vm)
>  
>         GEM_BUG_ON(!i915_vm_is_4lvl(vm));
>  
> -       pdp = kzalloc(sizeof(*pdp), GFP_KERNEL);
> +       pdp = kmalloc(sizeof(*pdp), GFP_KERNEL);

While you are here, this too can be I915_GFP_ALLOW_FAIL

>         if (!pdp)
>                 return ERR_PTR(-ENOMEM);

Because we immediately propagate the error and can gracefully handle
failures.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/9] drm/i915/gtt: Use a common type for page directories
  2019-06-11 17:27 ` [PATCH 2/9] drm/i915/gtt: Use a common type for page directories Mika Kuoppala
@ 2019-06-11 19:41   ` Chris Wilson
  2019-06-11 19:52     ` Chris Wilson
  2019-06-11 19:43   ` Chris Wilson
  1 sibling, 1 reply; 20+ messages in thread
From: Chris Wilson @ 2019-06-11 19:41 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-06-11 18:27:24)
>  struct i915_page_table {
>         struct i915_page_dma base;
> -       atomic_t used_ptes;
> +       atomic_t used;
>  };
>  
>  struct i915_page_directory {
>         struct i915_page_dma base;
> -
> -       struct i915_page_table *page_table[I915_PDES]; /* PDEs */
> -       atomic_t used_pdes;
> -       spinlock_t lock;
> -};
> -
> -struct i915_page_directory_pointer {
> -       struct i915_page_dma base;
> -       struct i915_page_directory **page_directory;
> -       atomic_t used_pdpes;
> -       spinlock_t lock;
> -};
> -
> -struct i915_pml4 {
> -       struct i915_page_dma base;
> -       struct i915_page_directory_pointer *pdps[GEN8_PML4ES_PER_PML4];
> +       atomic_t used;
>         spinlock_t lock;
> +       void *entry[0];
>  };

And always (albeit with a single bsw discrepancy) 512. At the very least
you can alias a fixed sized variant over the top to remove the extra
pointer chasing you added.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/9] drm/i915/gtt: Use a common type for page directories
  2019-06-11 17:27 ` [PATCH 2/9] drm/i915/gtt: Use a common type for page directories Mika Kuoppala
  2019-06-11 19:41   ` Chris Wilson
@ 2019-06-11 19:43   ` Chris Wilson
  1 sibling, 0 replies; 20+ messages in thread
From: Chris Wilson @ 2019-06-11 19:43 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-06-11 18:27:24)
> All page directories are identical in function, only the position in the
> hierarchy differ. Use same base type for directory functionality.
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Matthew Auld <matthew.william.auld@gmail.com>
> Cc: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_context.c |   2 +-
>  drivers/gpu/drm/i915/gt/intel_lrc_reg.h     |   2 +-
>  drivers/gpu/drm/i915/gt/intel_ringbuffer.c  |   2 +-
>  drivers/gpu/drm/i915/gvt/scheduler.c        |  30 +-
>  drivers/gpu/drm/i915/i915_gem_gtt.c         | 349 ++++++++++----------
>  drivers/gpu/drm/i915/i915_gem_gtt.h         |  64 ++--
>  6 files changed, 234 insertions(+), 215 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index c86ca9f21532..dbab0ab1cef1 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -1038,7 +1038,7 @@ static int emit_ppgtt_update(struct i915_request *rq, void *data)
>  
>         if (i915_vm_is_4lvl(vm)) {
>                 struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
> -               const dma_addr_t pd_daddr = px_dma(&ppgtt->pml4);
> +               const dma_addr_t pd_daddr = px_dma(ppgtt->pd);
>  
>                 cs = intel_ring_begin(rq, 6);
>                 if (IS_ERR(cs))
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
> index 5ef932d810a7..6bf34738b4e5 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
> @@ -55,7 +55,7 @@
>  
>  #define ASSIGN_CTX_PML4(ppgtt, reg_state) do { \
>         u32 *reg_state__ = (reg_state); \
> -       const u64 addr__ = px_dma(&ppgtt->pml4); \
> +       const u64 addr__ = px_dma(ppgtt->pd); \
>         (reg_state__)[CTX_PDP0_UDW + 1] = upper_32_bits(addr__); \
>         (reg_state__)[CTX_PDP0_LDW + 1] = lower_32_bits(addr__); \
>  } while (0)
> diff --git a/drivers/gpu/drm/i915/gt/intel_ringbuffer.c b/drivers/gpu/drm/i915/gt/intel_ringbuffer.c
> index c834d016c965..3b857994943c 100644
> --- a/drivers/gpu/drm/i915/gt/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/gt/intel_ringbuffer.c
> @@ -1523,7 +1523,7 @@ static int load_pd_dir(struct i915_request *rq, const struct i915_ppgtt *ppgtt)
>  
>         *cs++ = MI_LOAD_REGISTER_IMM(1);
>         *cs++ = i915_mmio_reg_offset(RING_PP_DIR_BASE(engine->mmio_base));
> -       *cs++ = ppgtt->pd.base.ggtt_offset << 10;
> +       *cs++ = ppgtt->pd->base.ggtt_offset << 10;
>  
>         intel_ring_advance(rq, cs);
>  
> diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
> index e301efb18d45..f1e1261ac3db 100644
> --- a/drivers/gpu/drm/i915/gvt/scheduler.c
> +++ b/drivers/gpu/drm/i915/gvt/scheduler.c
> @@ -375,11 +375,13 @@ static int set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload,
>                 return -EINVAL;
>  
>         if (mm->ppgtt_mm.root_entry_type == GTT_TYPE_PPGTT_ROOT_L4_ENTRY) {
> -               px_dma(&ppgtt->pml4) = mm->ppgtt_mm.shadow_pdps[0];
> +               px_dma(ppgtt->pd) = mm->ppgtt_mm.shadow_pdps[0];
>         } else {
>                 for (i = 0; i < GVT_RING_CTX_NR_PDPS; i++) {
> -                       px_dma(ppgtt->pdp.page_directory[i]) =
> -                               mm->ppgtt_mm.shadow_pdps[i];
> +                       struct i915_page_directory * const pd =
> +                               i915_pd_entry(ppgtt->pd, i);
> +
> +                       px_dma(pd) = mm->ppgtt_mm.shadow_pdps[i];
>                 }
>         }
>  
> @@ -1128,11 +1130,14 @@ i915_context_ppgtt_root_restore(struct intel_vgpu_submission *s,
>         int i;
>  
>         if (i915_vm_is_4lvl(&ppgtt->vm)) {
> -               px_dma(&ppgtt->pml4) = s->i915_context_pml4;
> +               px_dma(ppgtt->pd) = s->i915_context_pml4;
>         } else {
> -               for (i = 0; i < GEN8_3LVL_PDPES; i++)
> -                       px_dma(ppgtt->pdp.page_directory[i]) =
> -                               s->i915_context_pdps[i];
> +               for (i = 0; i < GEN8_3LVL_PDPES; i++) {
> +                       struct i915_page_directory * const pd =
> +                               i915_pd_entry(ppgtt->pd, i);
> +
> +                       px_dma(pd) = s->i915_context_pdps[i];
> +               }
>         }
>  }
>  
> @@ -1186,11 +1191,14 @@ i915_context_ppgtt_root_save(struct intel_vgpu_submission *s,
>         int i;
>  
>         if (i915_vm_is_4lvl(&ppgtt->vm)) {
> -               s->i915_context_pml4 = px_dma(&ppgtt->pml4);
> +               s->i915_context_pml4 = px_dma(ppgtt->pd);
>         } else {
> -               for (i = 0; i < GEN8_3LVL_PDPES; i++)
> -                       s->i915_context_pdps[i] =
> -                               px_dma(ppgtt->pdp.page_directory[i]);
> +               for (i = 0; i < GEN8_3LVL_PDPES; i++) {
> +                       struct i915_page_directory * const pd =
> +                               i915_pd_entry(ppgtt->pd, i);
> +
> +                       s->i915_context_pdps[i] = px_dma(pd);
> +               }
>         }
>  }
>  
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 07f86d474fa2..9a1f956a817a 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -661,7 +661,8 @@ static struct i915_page_table *alloc_pt(struct i915_address_space *vm)
>                 return ERR_PTR(-ENOMEM);
>         }
>  
> -       atomic_set(&pt->used_ptes, 0);
> +       atomic_set(&pt->used, 0);
> +
>         return pt;
>  }
>  
> @@ -683,11 +684,28 @@ static void gen6_initialize_pt(struct i915_address_space *vm,
>         fill32_px(vm, pt, vm->scratch_pte);
>  }
>  
> +static struct i915_page_directory *__alloc_pd(const unsigned int entries)
> +{
> +       struct i915_page_directory *pd;
> +
> +       pd = kmalloc(sizeof(*pd) +
> +                    entries * sizeof(pd->entry[0]), I915_GFP_ALLOW_FAIL);
> +
> +       if (unlikely(!pd))
> +               return NULL;
> +
> +       memset(&pd->base, 0, sizeof(pd->base));
> +       atomic_set(&pd->used, 0);
> +       spin_lock_init(&pd->lock);
> +
> +       return pd;
> +}
> +
>  static struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
>  {
>         struct i915_page_directory *pd;
>  
> -       pd = kmalloc(sizeof(*pd), I915_GFP_ALLOW_FAIL);
> +       pd = __alloc_pd(512);
>         if (unlikely(!pd))
>                 return ERR_PTR(-ENOMEM);
>  
> @@ -696,8 +714,6 @@ static struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
>                 return ERR_PTR(-ENOMEM);
>         }
>  
> -       atomic_set(&pd->used_pdes, 0);
> -       spin_lock_init(&pd->lock);
>         return pd;
>  }
>  
> @@ -713,88 +729,56 @@ static void gen8_initialize_pd(struct i915_address_space *vm,
>  {
>         fill_px(vm, pd,
>                 gen8_pde_encode(px_dma(vm->scratch_pt), I915_CACHE_LLC));
> -       memset_p((void **)pd->page_table, vm->scratch_pt, I915_PDES);
> +       memset_p(pd->entry, vm->scratch_pt, I915_PDES);
>  }
>  
> -static int __pdp_init(struct i915_address_space *vm,
> -                     struct i915_page_directory_pointer *pdp)
> +static struct i915_page_directory *alloc_pdp(struct i915_address_space *vm)
>  {
> -       const unsigned int pdpes = i915_pdpes_per_pdp(vm);
> +       struct i915_page_directory *pdp;
>  
> -       pdp->page_directory = kmalloc_array(pdpes, sizeof(*pdp->page_directory),
> -                                           I915_GFP_ALLOW_FAIL);
> -       if (unlikely(!pdp->page_directory))
> -               return -ENOMEM;
> -
> -       memset_p((void **)pdp->page_directory, vm->scratch_pd, pdpes);
> -
> -       atomic_set(&pdp->used_pdpes, 0);
> -       spin_lock_init(&pdp->lock);
> -       return 0;
> -}
> -
> -static void __pdp_fini(struct i915_page_directory_pointer *pdp)
> -{
> -       kfree(pdp->page_directory);
> -       pdp->page_directory = NULL;
> -}
> -
> -static struct i915_page_directory_pointer *
> -alloc_pdp(struct i915_address_space *vm)
> -{
> -       struct i915_page_directory_pointer *pdp;
> -       int ret = -ENOMEM;
> -
> -       GEM_BUG_ON(!i915_vm_is_4lvl(vm));
> -
> -       pdp = kmalloc(sizeof(*pdp), GFP_KERNEL);
> +       pdp = __alloc_pd(i915_pdpes_per_pdp(vm));
>         if (!pdp)
>                 return ERR_PTR(-ENOMEM);
>  
> -       ret = __pdp_init(vm, pdp);
> -       if (ret)
> -               goto fail_bitmap;
> -
> -       ret = setup_px(vm, pdp);
> -       if (ret)
> -               goto fail_page_m;
> +       if (i915_vm_is_4lvl(vm)) {
> +               if (unlikely(setup_px(vm, pdp))) {
> +                       kfree(pdp);
> +                       return ERR_PTR(-ENOMEM);
> +               }
> +       }
>  
>         return pdp;
> -
> -fail_page_m:
> -       __pdp_fini(pdp);
> -fail_bitmap:
> -       kfree(pdp);
> -
> -       return ERR_PTR(ret);
>  }
>  
>  static void free_pdp(struct i915_address_space *vm,
> -                    struct i915_page_directory_pointer *pdp)
> +                    struct i915_page_directory *pdp)
>  {
> -       __pdp_fini(pdp);
> -
> -       if (!i915_vm_is_4lvl(vm))
> -               return;
> +       if (i915_vm_is_4lvl(vm))
> +               cleanup_px(vm, pdp);
>  
> -       cleanup_px(vm, pdp);
>         kfree(pdp);
>  }
>  
> -static void gen8_initialize_pdp(struct i915_address_space *vm,
> -                               struct i915_page_directory_pointer *pdp)
> +static void gen8_initialize_4lvl_pdp(struct i915_address_space *vm,
> +                                    struct i915_page_directory *pdp)
>  {
>         fill_px(vm, pdp,
>                 gen8_pdpe_encode(px_dma(vm->scratch_pd), I915_CACHE_LLC));
> +       memset_p(pdp->entry, vm->scratch_pd, 512);
> +}
> +
> +static void gen8_initialize_3lvl_pdp(struct i915_address_space *vm,
> +                                    struct i915_page_directory *pdp)
> +{
> +       memset_p(pdp->entry, vm->scratch_pd, GEN8_3LVL_PDPES);
>  }
>  
>  static void gen8_initialize_pml4(struct i915_address_space *vm,
> -                                struct i915_pml4 *pml4)
> +                                struct i915_page_directory *pml4)
>  {
>         fill_px(vm, pml4,
>                 gen8_pml4e_encode(px_dma(vm->scratch_pdp), I915_CACHE_LLC));
> -       memset_p((void **)pml4->pdps, vm->scratch_pdp, GEN8_PML4ES_PER_PML4);
> -       spin_lock_init(&pml4->lock);
> +       memset_p(pml4->entry, vm->scratch_pdp, GEN8_PML4ES_PER_PML4);
>  }
>  
>  /*
> @@ -822,8 +806,8 @@ static bool gen8_ppgtt_clear_pt(const struct i915_address_space *vm,
>         memset64(vaddr + gen8_pte_index(start), vm->scratch_pte, num_entries);
>         kunmap_atomic(vaddr);
>  
> -       GEM_BUG_ON(num_entries > atomic_read(&pt->used_ptes));
> -       return !atomic_sub_return(num_entries, &pt->used_ptes);
> +       GEM_BUG_ON(num_entries > atomic_read(&pt->used));
> +       return !atomic_sub_return(num_entries, &pt->used);
>  }
>  
>  static void gen8_ppgtt_set_pde(struct i915_address_space *vm,
> @@ -854,12 +838,12 @@ static bool gen8_ppgtt_clear_pd(struct i915_address_space *vm,
>                         continue;
>  
>                 spin_lock(&pd->lock);
> -               if (!atomic_read(&pt->used_ptes)) {
> +               if (!atomic_read(&pt->used)) {
>                         gen8_ppgtt_set_pde(vm, pd, vm->scratch_pt, pde);
> -                       pd->page_table[pde] = vm->scratch_pt;
> +                       pd->entry[pde] = vm->scratch_pt;
>  
> -                       GEM_BUG_ON(!atomic_read(&pd->used_pdes));
> -                       atomic_dec(&pd->used_pdes);
> +                       GEM_BUG_ON(!atomic_read(&pd->used));
> +                       atomic_dec(&pd->used);
>                         free = true;
>                 }
>                 spin_unlock(&pd->lock);
> @@ -867,11 +851,11 @@ static bool gen8_ppgtt_clear_pd(struct i915_address_space *vm,
>                         free_pt(vm, pt);
>         }
>  
> -       return !atomic_read(&pd->used_pdes);
> +       return !atomic_read(&pd->used);
>  }
>  
>  static void gen8_ppgtt_set_pdpe(struct i915_address_space *vm,
> -                               struct i915_page_directory_pointer *pdp,
> +                               struct i915_page_directory *pdp,
>                                 struct i915_page_directory *pd,
>                                 unsigned int pdpe)
>  {
> @@ -889,7 +873,7 @@ static void gen8_ppgtt_set_pdpe(struct i915_address_space *vm,
>   * Caller can use the return value to update higher-level entries
>   */
>  static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
> -                                struct i915_page_directory_pointer *pdp,
> +                                struct i915_page_directory * const pdp,
>                                  u64 start, u64 length)
>  {
>         struct i915_page_directory *pd;
> @@ -904,12 +888,12 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
>                         continue;
>  
>                 spin_lock(&pdp->lock);
> -               if (!atomic_read(&pd->used_pdes)) {
> +               if (!atomic_read(&pd->used)) {
>                         gen8_ppgtt_set_pdpe(vm, pdp, vm->scratch_pd, pdpe);
> -                       pdp->page_directory[pdpe] = vm->scratch_pd;
> +                       pdp->entry[pdpe] = vm->scratch_pd;
>  
> -                       GEM_BUG_ON(!atomic_read(&pdp->used_pdpes));
> -                       atomic_dec(&pdp->used_pdpes);
> +                       GEM_BUG_ON(!atomic_read(&pdp->used));
> +                       atomic_dec(&pdp->used);
>                         free = true;
>                 }
>                 spin_unlock(&pdp->lock);
> @@ -917,17 +901,17 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
>                         free_pd(vm, pd);
>         }
>  
> -       return !atomic_read(&pdp->used_pdpes);
> +       return !atomic_read(&pdp->used);
>  }
>  
>  static void gen8_ppgtt_clear_3lvl(struct i915_address_space *vm,
>                                   u64 start, u64 length)
>  {
> -       gen8_ppgtt_clear_pdp(vm, &i915_vm_to_ppgtt(vm)->pdp, start, length);
> +       gen8_ppgtt_clear_pdp(vm, i915_vm_to_ppgtt(vm)->pd, start, length);
>  }
>  
> -static void gen8_ppgtt_set_pml4e(struct i915_pml4 *pml4,
> -                                struct i915_page_directory_pointer *pdp,
> +static void gen8_ppgtt_set_pml4e(struct i915_page_directory *pml4,
> +                                struct i915_page_directory *pdp,
>                                  unsigned int pml4e)
>  {
>         gen8_ppgtt_pml4e_t *vaddr;
> @@ -945,8 +929,8 @@ static void gen8_ppgtt_clear_4lvl(struct i915_address_space *vm,
>                                   u64 start, u64 length)
>  {
>         struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
> -       struct i915_pml4 *pml4 = &ppgtt->pml4;
> -       struct i915_page_directory_pointer *pdp;
> +       struct i915_page_directory * const pml4 = ppgtt->pd;
> +       struct i915_page_directory *pdp;
>         unsigned int pml4e;
>  
>         GEM_BUG_ON(!i915_vm_is_4lvl(vm));
> @@ -959,9 +943,9 @@ static void gen8_ppgtt_clear_4lvl(struct i915_address_space *vm,
>                         continue;
>  
>                 spin_lock(&pml4->lock);
> -               if (!atomic_read(&pdp->used_pdpes)) {
> +               if (!atomic_read(&pdp->used)) {
>                         gen8_ppgtt_set_pml4e(pml4, vm->scratch_pdp, pml4e);
> -                       pml4->pdps[pml4e] = vm->scratch_pdp;
> +                       pml4->entry[pml4e] = vm->scratch_pdp;
>                         free = true;
>                 }
>                 spin_unlock(&pml4->lock);
> @@ -998,7 +982,7 @@ static __always_inline struct gen8_insert_pte gen8_insert_pte(u64 start)
>  
>  static __always_inline bool
>  gen8_ppgtt_insert_pte_entries(struct i915_ppgtt *ppgtt,
> -                             struct i915_page_directory_pointer *pdp,
> +                             struct i915_page_directory *pdp,
>                               struct sgt_dma *iter,
>                               struct gen8_insert_pte *idx,
>                               enum i915_cache_level cache_level,
> @@ -1010,8 +994,8 @@ gen8_ppgtt_insert_pte_entries(struct i915_ppgtt *ppgtt,
>         bool ret;
>  
>         GEM_BUG_ON(idx->pdpe >= i915_pdpes_per_pdp(&ppgtt->vm));
> -       pd = pdp->page_directory[idx->pdpe];
> -       vaddr = kmap_atomic_px(pd->page_table[idx->pde]);
> +       pd = i915_pd_entry(pdp, idx->pdpe);
> +       vaddr = kmap_atomic_px(i915_pt_entry(pd, idx->pde));
>         do {
>                 vaddr[idx->pte] = pte_encode | iter->dma;
>  
> @@ -1041,11 +1025,11 @@ gen8_ppgtt_insert_pte_entries(struct i915_ppgtt *ppgtt,
>                                 }
>  
>                                 GEM_BUG_ON(idx->pdpe >= i915_pdpes_per_pdp(&ppgtt->vm));
> -                               pd = pdp->page_directory[idx->pdpe];
> +                               pd = pdp->entry[idx->pdpe];
>                         }
>  
>                         kunmap_atomic(vaddr);
> -                       vaddr = kmap_atomic_px(pd->page_table[idx->pde]);
> +                       vaddr = kmap_atomic_px(i915_pt_entry(pd, idx->pde));
>                 }
>         } while (1);
>         kunmap_atomic(vaddr);
> @@ -1062,14 +1046,14 @@ static void gen8_ppgtt_insert_3lvl(struct i915_address_space *vm,
>         struct sgt_dma iter = sgt_dma(vma);
>         struct gen8_insert_pte idx = gen8_insert_pte(vma->node.start);
>  
> -       gen8_ppgtt_insert_pte_entries(ppgtt, &ppgtt->pdp, &iter, &idx,
> +       gen8_ppgtt_insert_pte_entries(ppgtt, ppgtt->pd, &iter, &idx,
>                                       cache_level, flags);
>  
>         vma->page_sizes.gtt = I915_GTT_PAGE_SIZE;
>  }
>  
>  static void gen8_ppgtt_insert_huge_entries(struct i915_vma *vma,
> -                                          struct i915_page_directory_pointer **pdps,
> +                                          struct i915_page_directory *pml4,
>                                            struct sgt_dma *iter,
>                                            enum i915_cache_level cache_level,
>                                            u32 flags)
> @@ -1080,8 +1064,9 @@ static void gen8_ppgtt_insert_huge_entries(struct i915_vma *vma,
>  
>         do {
>                 struct gen8_insert_pte idx = gen8_insert_pte(start);
> -               struct i915_page_directory_pointer *pdp = pdps[idx.pml4e];
> -               struct i915_page_directory *pd = pdp->page_directory[idx.pdpe];
> +               struct i915_page_directory *pdp =
> +                       i915_pdp_entry(pml4, idx.pml4e);
> +               struct i915_page_directory *pd = i915_pd_entry(pdp, idx.pdpe);
>                 unsigned int page_size;
>                 bool maybe_64K = false;
>                 gen8_pte_t encode = pte_encode;
> @@ -1099,7 +1084,7 @@ static void gen8_ppgtt_insert_huge_entries(struct i915_vma *vma,
>  
>                         vaddr = kmap_atomic_px(pd);
>                 } else {
> -                       struct i915_page_table *pt = pd->page_table[idx.pde];
> +                       struct i915_page_table *pt = i915_pt_entry(pd, idx.pde);
>  
>                         index = idx.pte;
>                         max = GEN8_PTES;
> @@ -1174,7 +1159,8 @@ static void gen8_ppgtt_insert_huge_entries(struct i915_vma *vma,
>                                 u16 i;
>  
>                                 encode = vma->vm->scratch_pte;
> -                               vaddr = kmap_atomic_px(pd->page_table[idx.pde]);
> +                               vaddr = kmap_atomic_px(i915_pt_entry(pd,
> +                                                                    idx.pde));
>  
>                                 for (i = 1; i < index; i += 16)
>                                         memset64(vaddr + i, encode, 15);
> @@ -1194,15 +1180,16 @@ static void gen8_ppgtt_insert_4lvl(struct i915_address_space *vm,
>  {
>         struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
>         struct sgt_dma iter = sgt_dma(vma);
> -       struct i915_page_directory_pointer **pdps = ppgtt->pml4.pdps;
> +       struct i915_page_directory * const pml4 = ppgtt->pd;
>  
>         if (vma->page_sizes.sg > I915_GTT_PAGE_SIZE) {
> -               gen8_ppgtt_insert_huge_entries(vma, pdps, &iter, cache_level,
> +               gen8_ppgtt_insert_huge_entries(vma, pml4, &iter, cache_level,
>                                                flags);
>         } else {
>                 struct gen8_insert_pte idx = gen8_insert_pte(vma->node.start);
>  
> -               while (gen8_ppgtt_insert_pte_entries(ppgtt, pdps[idx.pml4e++],
> +               while (gen8_ppgtt_insert_pte_entries(ppgtt,
> +                                                    i915_pdp_entry(pml4, idx.pml4e++),
>                                                      &iter, &idx, cache_level,
>                                                      flags))
>                         GEM_BUG_ON(idx.pml4e >= GEN8_PML4ES_PER_PML4);
> @@ -1217,8 +1204,8 @@ static void gen8_free_page_tables(struct i915_address_space *vm,
>         int i;
>  
>         for (i = 0; i < I915_PDES; i++) {
> -               if (pd->page_table[i] != vm->scratch_pt)
> -                       free_pt(vm, pd->page_table[i]);
> +               if (pd->entry[i] != vm->scratch_pt)
> +                       free_pt(vm, pd->entry[i]);
>         }
>  }
>  
> @@ -1277,7 +1264,7 @@ static int gen8_init_scratch(struct i915_address_space *vm)
>         gen8_initialize_pt(vm, vm->scratch_pt);
>         gen8_initialize_pd(vm, vm->scratch_pd);
>         if (i915_vm_is_4lvl(vm))
> -               gen8_initialize_pdp(vm, vm->scratch_pdp);
> +               gen8_initialize_4lvl_pdp(vm, vm->scratch_pdp);
>  
>         return 0;
>  
> @@ -1299,7 +1286,7 @@ static int gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create)
>         int i;
>  
>         if (i915_vm_is_4lvl(vm)) {
> -               const u64 daddr = px_dma(&ppgtt->pml4);
> +               const u64 daddr = px_dma(ppgtt->pd);
>  
>                 I915_WRITE(vgtif_reg(pdp[0].lo), lower_32_bits(daddr));
>                 I915_WRITE(vgtif_reg(pdp[0].hi), upper_32_bits(daddr));
> @@ -1336,17 +1323,17 @@ static void gen8_free_scratch(struct i915_address_space *vm)
>  }
>  
>  static void gen8_ppgtt_cleanup_3lvl(struct i915_address_space *vm,
> -                                   struct i915_page_directory_pointer *pdp)
> +                                   struct i915_page_directory *pdp)
>  {
>         const unsigned int pdpes = i915_pdpes_per_pdp(vm);
>         int i;
>  
>         for (i = 0; i < pdpes; i++) {
> -               if (pdp->page_directory[i] == vm->scratch_pd)
> +               if (pdp->entry[i] == vm->scratch_pd)
>                         continue;
>  
> -               gen8_free_page_tables(vm, pdp->page_directory[i]);
> -               free_pd(vm, pdp->page_directory[i]);
> +               gen8_free_page_tables(vm, pdp->entry[i]);
> +               free_pd(vm, pdp->entry[i]);
>         }
>  
>         free_pdp(vm, pdp);
> @@ -1354,16 +1341,19 @@ static void gen8_ppgtt_cleanup_3lvl(struct i915_address_space *vm,
>  
>  static void gen8_ppgtt_cleanup_4lvl(struct i915_ppgtt *ppgtt)
>  {
> +       struct i915_page_directory * const pml4 = ppgtt->pd;
>         int i;
>  
>         for (i = 0; i < GEN8_PML4ES_PER_PML4; i++) {
> -               if (ppgtt->pml4.pdps[i] == ppgtt->vm.scratch_pdp)
> +               struct i915_page_directory *pdp = i915_pdp_entry(pml4, i);
> +
> +               if (pdp == ppgtt->vm.scratch_pdp)
>                         continue;
>  
> -               gen8_ppgtt_cleanup_3lvl(&ppgtt->vm, ppgtt->pml4.pdps[i]);
> +               gen8_ppgtt_cleanup_3lvl(&ppgtt->vm, pdp);
>         }
>  
> -       cleanup_px(&ppgtt->vm, &ppgtt->pml4);
> +       cleanup_px(&ppgtt->vm, pml4);
>  }
>  
>  static void gen8_ppgtt_cleanup(struct i915_address_space *vm)
> @@ -1377,7 +1367,7 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm)
>         if (i915_vm_is_4lvl(vm))
>                 gen8_ppgtt_cleanup_4lvl(ppgtt);
>         else
> -               gen8_ppgtt_cleanup_3lvl(&ppgtt->vm, &ppgtt->pdp);
> +               gen8_ppgtt_cleanup_3lvl(&ppgtt->vm, ppgtt->pd);
>  
>         gen8_free_scratch(vm);
>  }
> @@ -1406,10 +1396,10 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
>                         if (count < GEN8_PTES || intel_vgpu_active(vm->i915))
>                                 gen8_initialize_pt(vm, pt);
>  
> -                       old = cmpxchg(&pd->page_table[pde], vm->scratch_pt, pt);
> +                       old = cmpxchg(&pd->entry[pde], vm->scratch_pt, pt);
>                         if (old == vm->scratch_pt) {
>                                 gen8_ppgtt_set_pde(vm, pd, pt, pde);
> -                               atomic_inc(&pd->used_pdes);
> +                               atomic_inc(&pd->used);
>                         } else {
>                                 free_pt(vm, pt);
>                                 pt = old;
> @@ -1418,7 +1408,7 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
>                         spin_lock(&pd->lock);
>                 }
>  
> -               atomic_add(count, &pt->used_ptes);
> +               atomic_add(count, &pt->used);
>         }
>         spin_unlock(&pd->lock);
>  
> @@ -1430,7 +1420,7 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
>  }
>  
>  static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
> -                               struct i915_page_directory_pointer *pdp,
> +                               struct i915_page_directory *pdp,
>                                 u64 start, u64 length)
>  {
>         struct i915_page_directory *pd;
> @@ -1451,11 +1441,10 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
>  
>                         gen8_initialize_pd(vm, pd);
>  
> -                       old = cmpxchg(&pdp->page_directory[pdpe],
> -                                     vm->scratch_pd, pd);
> +                       old = cmpxchg(&pdp->entry[pdpe], vm->scratch_pd, pd);
>                         if (old == vm->scratch_pd) {
>                                 gen8_ppgtt_set_pdpe(vm, pdp, pd, pdpe);
> -                               atomic_inc(&pdp->used_pdpes);
> +                               atomic_inc(&pdp->used);
>                         } else {
>                                 free_pd(vm, pd);
>                                 pd = old;
> @@ -1463,7 +1452,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
>  
>                         spin_lock(&pdp->lock);
>                 }
> -               atomic_inc(&pd->used_pdes);
> +               atomic_inc(&pd->used);
>                 spin_unlock(&pdp->lock);
>  
>                 ret = gen8_ppgtt_alloc_pd(vm, pd, start, length);
> @@ -1471,7 +1460,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
>                         goto unwind_pd;
>  
>                 spin_lock(&pdp->lock);
> -               atomic_dec(&pd->used_pdes);
> +               atomic_dec(&pd->used);
>         }
>         spin_unlock(&pdp->lock);
>  
> @@ -1479,10 +1468,10 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
>  
>  unwind_pd:
>         spin_lock(&pdp->lock);
> -       if (atomic_dec_and_test(&pd->used_pdes)) {
> +       if (atomic_dec_and_test(&pd->used)) {
>                 gen8_ppgtt_set_pdpe(vm, pdp, vm->scratch_pd, pdpe);
> -               GEM_BUG_ON(!atomic_read(&pdp->used_pdpes));
> -               atomic_dec(&pdp->used_pdpes);
> +               GEM_BUG_ON(!atomic_read(&pdp->used));
> +               atomic_dec(&pdp->used);
>                 free_pd(vm, pd);
>         }
>         spin_unlock(&pdp->lock);
> @@ -1495,23 +1484,24 @@ static int gen8_ppgtt_alloc_3lvl(struct i915_address_space *vm,
>                                  u64 start, u64 length)
>  {
>         return gen8_ppgtt_alloc_pdp(vm,
> -                                   &i915_vm_to_ppgtt(vm)->pdp, start, length);
> +                                   i915_vm_to_ppgtt(vm)->pd, start, length);
>  }
>  
>  static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
>                                  u64 start, u64 length)
>  {
>         struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
> -       struct i915_pml4 *pml4 = &ppgtt->pml4;
> -       struct i915_page_directory_pointer *pdp;
> +       struct i915_page_directory * const pml4 = ppgtt->pd;
> +       struct i915_page_directory *pdp;
>         u64 from = start;
>         u32 pml4e;
>         int ret;
>  
>         spin_lock(&pml4->lock);
>         gen8_for_each_pml4e(pdp, pml4, start, length, pml4e) {
> +
>                 if (pdp == vm->scratch_pdp) {
> -                       struct i915_page_directory_pointer *old;
> +                       struct i915_page_directory *old;
>  
>                         spin_unlock(&pml4->lock);
>  
> @@ -1519,9 +1509,9 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
>                         if (IS_ERR(pdp))
>                                 goto unwind;
>  
> -                       gen8_initialize_pdp(vm, pdp);
> +                       gen8_initialize_4lvl_pdp(vm, pdp);
>  
> -                       old = cmpxchg(&pml4->pdps[pml4e], vm->scratch_pdp, pdp);
> +                       old = cmpxchg(&pml4->entry[pml4e], vm->scratch_pdp, pdp);
>                         if (old == vm->scratch_pdp) {
>                                 gen8_ppgtt_set_pml4e(pml4, pdp, pml4e);
>                         } else {
> @@ -1531,7 +1521,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
>  
>                         spin_lock(&pml4->lock);
>                 }
> -               atomic_inc(&pdp->used_pdpes);
> +               atomic_inc(&pdp->used);
>                 spin_unlock(&pml4->lock);
>  
>                 ret = gen8_ppgtt_alloc_pdp(vm, pdp, start, length);
> @@ -1539,7 +1529,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
>                         goto unwind_pdp;
>  
>                 spin_lock(&pml4->lock);
> -               atomic_dec(&pdp->used_pdpes);
> +               atomic_dec(&pdp->used);
>         }
>         spin_unlock(&pml4->lock);
>  
> @@ -1547,7 +1537,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
>  
>  unwind_pdp:
>         spin_lock(&pml4->lock);
> -       if (atomic_dec_and_test(&pdp->used_pdpes)) {
> +       if (atomic_dec_and_test(&pdp->used)) {
>                 gen8_ppgtt_set_pml4e(pml4, vm->scratch_pdp, pml4e);
>                 free_pdp(vm, pdp);
>         }
> @@ -1560,7 +1550,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
>  static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
>  {
>         struct i915_address_space *vm = &ppgtt->vm;
> -       struct i915_page_directory_pointer *pdp = &ppgtt->pdp;
> +       struct i915_page_directory *pdp = ppgtt->pd;
>         struct i915_page_directory *pd;
>         u64 start = 0, length = ppgtt->vm.total;
>         u64 from = start;
> @@ -1573,10 +1563,12 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
>  
>                 gen8_initialize_pd(vm, pd);
>                 gen8_ppgtt_set_pdpe(vm, pdp, pd, pdpe);
> -               atomic_inc(&pdp->used_pdpes);
> +
> +               atomic_inc(&pdp->used);
>         }
>  
> -       atomic_inc(&pdp->used_pdpes); /* never remove */
> +       atomic_inc(&pdp->used); /* never remove */
> +
>         return 0;
>  
>  unwind:
> @@ -1585,7 +1577,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
>                 gen8_ppgtt_set_pdpe(vm, pdp, vm->scratch_pd, pdpe);
>                 free_pd(vm, pd);
>         }
> -       atomic_set(&pdp->used_pdpes, 0);
> +       atomic_set(&pdp->used, 0);
>         return -ENOMEM;
>  }
>  
> @@ -1640,27 +1632,25 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
>         if (err)
>                 goto err_free;
>  
> -       if (i915_vm_is_4lvl(&ppgtt->vm)) {
> -               err = setup_px(&ppgtt->vm, &ppgtt->pml4);
> -               if (err)
> -                       goto err_scratch;
> +       ppgtt->pd = alloc_pdp(&ppgtt->vm);
> +       if (IS_ERR(ppgtt->pd)) {
> +               err = PTR_ERR(ppgtt->pd);
> +               goto err_scratch;
> +       }
>  
> -               gen8_initialize_pml4(&ppgtt->vm, &ppgtt->pml4);
> +       if (i915_vm_is_4lvl(&ppgtt->vm)) {
> +               gen8_initialize_pml4(&ppgtt->vm, ppgtt->pd);
>  
>                 ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc_4lvl;
>                 ppgtt->vm.insert_entries = gen8_ppgtt_insert_4lvl;
>                 ppgtt->vm.clear_range = gen8_ppgtt_clear_4lvl;
>         } else {
> -               err = __pdp_init(&ppgtt->vm, &ppgtt->pdp);
> -               if (err)
> -                       goto err_scratch;
> +               gen8_initialize_3lvl_pdp(&ppgtt->vm, ppgtt->pd);
>  
>                 if (intel_vgpu_active(i915)) {
>                         err = gen8_preallocate_top_level_pdp(ppgtt);
> -                       if (err) {
> -                               __pdp_fini(&ppgtt->pdp);
> -                               goto err_scratch;
> -                       }
> +                       if (err)
> +                               goto err_pdp;
>                 }
>  
>                 ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc_3lvl;
> @@ -1675,6 +1665,8 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
>  
>         return ppgtt;
>  
> +err_pdp:
> +       free_pdp(&ppgtt->vm, ppgtt->pd);
>  err_scratch:
>         gen8_free_scratch(&ppgtt->vm);
>  err_free:
> @@ -1740,15 +1732,16 @@ static void gen6_ppgtt_enable(struct drm_i915_private *dev_priv)
>  static void gen6_ppgtt_clear_range(struct i915_address_space *vm,
>                                    u64 start, u64 length)
>  {
> -       struct gen6_ppgtt *ppgtt = to_gen6_ppgtt(i915_vm_to_ppgtt(vm));
> -       unsigned int first_entry = start / I915_GTT_PAGE_SIZE;
> +       struct gen6_ppgtt * const ppgtt = to_gen6_ppgtt(i915_vm_to_ppgtt(vm));
> +       const unsigned int first_entry = start / I915_GTT_PAGE_SIZE;
> +       const gen6_pte_t scratch_pte = vm->scratch_pte;
>         unsigned int pde = first_entry / GEN6_PTES;
>         unsigned int pte = first_entry % GEN6_PTES;
>         unsigned int num_entries = length / I915_GTT_PAGE_SIZE;
> -       const gen6_pte_t scratch_pte = vm->scratch_pte;
>  
>         while (num_entries) {
> -               struct i915_page_table *pt = ppgtt->base.pd.page_table[pde++];
> +               struct i915_page_table * const pt =
> +                       i915_pt_entry(ppgtt->base.pd, pde++);
>                 const unsigned int count = min(num_entries, GEN6_PTES - pte);
>                 gen6_pte_t *vaddr;
>  
> @@ -1756,8 +1749,8 @@ static void gen6_ppgtt_clear_range(struct i915_address_space *vm,
>  
>                 num_entries -= count;
>  
> -               GEM_BUG_ON(count > atomic_read(&pt->used_ptes));
> -               if (!atomic_sub_return(count, &pt->used_ptes))
> +               GEM_BUG_ON(count > atomic_read(&pt->used));
> +               if (!atomic_sub_return(count, &pt->used))
>                         ppgtt->scan_for_unused_pt = true;
>  
>                 /*
> @@ -1781,6 +1774,7 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,
>                                       u32 flags)
>  {
>         struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
> +       struct i915_page_directory * const pd = ppgtt->pd;
>         unsigned first_entry = vma->node.start / I915_GTT_PAGE_SIZE;
>         unsigned act_pt = first_entry / GEN6_PTES;
>         unsigned act_pte = first_entry % GEN6_PTES;
> @@ -1788,9 +1782,9 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,
>         struct sgt_dma iter = sgt_dma(vma);
>         gen6_pte_t *vaddr;
>  
> -       GEM_BUG_ON(ppgtt->pd.page_table[act_pt] == vm->scratch_pt);
> +       GEM_BUG_ON(i915_pt_entry(pd, act_pt) == vm->scratch_pt);
>  
> -       vaddr = kmap_atomic_px(ppgtt->pd.page_table[act_pt]);
> +       vaddr = kmap_atomic_px(i915_pt_entry(pd, act_pt));
>         do {
>                 vaddr[act_pte] = pte_encode | GEN6_PTE_ADDR_ENCODE(iter.dma);
>  
> @@ -1806,7 +1800,7 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,
>  
>                 if (++act_pte == GEN6_PTES) {
>                         kunmap_atomic(vaddr);
> -                       vaddr = kmap_atomic_px(ppgtt->pd.page_table[++act_pt]);
> +                       vaddr = kmap_atomic_px(i915_pt_entry(pd, ++act_pt));
>                         act_pte = 0;
>                 }
>         } while (1);
> @@ -1819,6 +1813,7 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
>                                u64 start, u64 length)
>  {
>         struct gen6_ppgtt *ppgtt = to_gen6_ppgtt(i915_vm_to_ppgtt(vm));
> +       struct i915_page_directory * const pd = ppgtt->base.pd;
>         struct i915_page_table *pt;
>         intel_wakeref_t wakeref;
>         u64 from = start;
> @@ -1827,14 +1822,14 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
>  
>         wakeref = intel_runtime_pm_get(vm->i915);
>  
> -       spin_lock(&ppgtt->base.pd.lock);
> -       gen6_for_each_pde(pt, &ppgtt->base.pd, start, length, pde) {
> +       spin_lock(&pd->lock);
> +       gen6_for_each_pde(pt, pd, start, length, pde) {
>                 const unsigned int count = gen6_pte_count(start, length);
>  
>                 if (pt == vm->scratch_pt) {
>                         struct i915_page_table *old;
>  
> -                       spin_unlock(&ppgtt->base.pd.lock);
> +                       spin_unlock(&pd->lock);
>  
>                         pt = alloc_pt(vm);
>                         if (IS_ERR(pt))
> @@ -1842,10 +1837,8 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
>  
>                         gen6_initialize_pt(vm, pt);
>  
> -                       old = cmpxchg(&ppgtt->base.pd.page_table[pde],
> -                                     vm->scratch_pt, pt);
> +                       old = cmpxchg(&pd->entry[pde], vm->scratch_pt, pt);
>                         if (old == vm->scratch_pt) {
> -                               ppgtt->base.pd.page_table[pde] = pt;
>                                 if (i915_vma_is_bound(ppgtt->vma,
>                                                       I915_VMA_GLOBAL_BIND)) {
>                                         gen6_write_pde(ppgtt, pde, pt);
> @@ -1856,12 +1849,12 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
>                                 pt = old;
>                         }
>  
> -                       spin_lock(&ppgtt->base.pd.lock);
> +                       spin_lock(&pd->lock);
>                 }
>  
> -               atomic_add(count, &pt->used_ptes);
> +               atomic_add(count, &pt->used);
>         }
> -       spin_unlock(&ppgtt->base.pd.lock);
> +       spin_unlock(&pd->lock);
>  
>         if (flush) {
>                 mark_tlbs_dirty(&ppgtt->base);
> @@ -1881,6 +1874,7 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
>  static int gen6_ppgtt_init_scratch(struct gen6_ppgtt *ppgtt)
>  {
>         struct i915_address_space * const vm = &ppgtt->base.vm;
> +       struct i915_page_directory * const pd = ppgtt->base.pd;
>         struct i915_page_table *unused;
>         u32 pde;
>         int ret;
> @@ -1900,9 +1894,9 @@ static int gen6_ppgtt_init_scratch(struct gen6_ppgtt *ppgtt)
>         }
>  
>         gen6_initialize_pt(vm, vm->scratch_pt);
> -       gen6_for_all_pdes(unused, &ppgtt->base.pd, pde)
> -               ppgtt->base.pd.page_table[pde] = vm->scratch_pt;
> -       spin_lock_init(&ppgtt->base.pd.lock);
> +
> +       gen6_for_all_pdes(unused, pd, pde)
> +               pd->entry[pde] = vm->scratch_pt;
>  
>         return 0;
>  }
> @@ -1915,10 +1909,11 @@ static void gen6_ppgtt_free_scratch(struct i915_address_space *vm)
>  
>  static void gen6_ppgtt_free_pd(struct gen6_ppgtt *ppgtt)
>  {
> +       struct i915_page_directory * const pd = ppgtt->base.pd;
>         struct i915_page_table *pt;
>         u32 pde;
>  
> -       gen6_for_all_pdes(pt, &ppgtt->base.pd, pde)
> +       gen6_for_all_pdes(pt, pd, pde)
>                 if (pt != ppgtt->base.vm.scratch_pt)
>                         free_pt(&ppgtt->base.vm, pt);
>  }
> @@ -1982,6 +1977,7 @@ static void gen6_ppgtt_cleanup(struct i915_address_space *vm)
>  
>         gen6_ppgtt_free_pd(ppgtt);
>         gen6_ppgtt_free_scratch(vm);
> +       kfree(ppgtt->base.pd);
>  }
>  
>  static int pd_vma_set_pages(struct i915_vma *vma)
> @@ -2007,10 +2003,10 @@ static int pd_vma_bind(struct i915_vma *vma,
>         struct i915_page_table *pt;
>         unsigned int pde;
>  
> -       ppgtt->base.pd.base.ggtt_offset = ggtt_offset * sizeof(gen6_pte_t);
> +       ppgtt->base.pd->base.ggtt_offset = ggtt_offset * sizeof(gen6_pte_t);
>         ppgtt->pd_addr = (gen6_pte_t __iomem *)ggtt->gsm + ggtt_offset;
>  
> -       gen6_for_all_pdes(pt, &ppgtt->base.pd, pde)
> +       gen6_for_all_pdes(pt, ppgtt->base.pd, pde)
>                 gen6_write_pde(ppgtt, pde, pt);
>  
>         mark_tlbs_dirty(&ppgtt->base);
> @@ -2022,6 +2018,7 @@ static int pd_vma_bind(struct i915_vma *vma,
>  static void pd_vma_unbind(struct i915_vma *vma)
>  {
>         struct gen6_ppgtt *ppgtt = vma->private;
> +       struct i915_page_directory * const pd = ppgtt->base.pd;
>         struct i915_page_table * const scratch_pt = ppgtt->base.vm.scratch_pt;
>         struct i915_page_table *pt;
>         unsigned int pde;
> @@ -2030,12 +2027,12 @@ static void pd_vma_unbind(struct i915_vma *vma)
>                 return;
>  
>         /* Free all no longer used page tables */
> -       gen6_for_all_pdes(pt, &ppgtt->base.pd, pde) {
> -               if (atomic_read(&pt->used_ptes) || pt == scratch_pt)
> +       gen6_for_all_pdes(pt, ppgtt->base.pd, pde) {
> +               if (atomic_read(&pt->used) || pt == scratch_pt)
>                         continue;
>  
>                 free_pt(&ppgtt->base.vm, pt);
> -               ppgtt->base.pd.page_table[pde] = scratch_pt;
> +               pd->entry[pde] = scratch_pt;
>         }
>  
>         ppgtt->scan_for_unused_pt = false;
> @@ -2164,9 +2161,15 @@ static struct i915_ppgtt *gen6_ppgtt_create(struct drm_i915_private *i915)
>                 goto err_free;
>         }
>  
> +       ppgtt->base.pd = __alloc_pd(512);
> +       if (!ppgtt->base.pd) {
> +               err = -ENOMEM;
> +               goto err_work;
> +       }
> +
>         err = gen6_ppgtt_init_scratch(ppgtt);
>         if (err)
> -               goto err_work;
> +               goto err_pd;
>  
>         ppgtt->vma = pd_vma_create(ppgtt, GEN6_PD_SIZE);
>         if (IS_ERR(ppgtt->vma)) {
> @@ -2178,6 +2181,8 @@ static struct i915_ppgtt *gen6_ppgtt_create(struct drm_i915_private *i915)
>  
>  err_scratch:
>         gen6_ppgtt_free_scratch(&ppgtt->base.vm);
> +err_pd:
> +       kfree(ppgtt->base.pd);
>  err_work:
>         kfree(ppgtt->work);
>  err_free:
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
> index 89437d0a721c..49f44071def4 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.h
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
> @@ -248,28 +248,14 @@ struct i915_page_dma {
>  
>  struct i915_page_table {
>         struct i915_page_dma base;
> -       atomic_t used_ptes;
> +       atomic_t used;
>  };
>  
>  struct i915_page_directory {
>         struct i915_page_dma base;
> -
> -       struct i915_page_table *page_table[I915_PDES]; /* PDEs */
> -       atomic_t used_pdes;
> -       spinlock_t lock;
> -};
> -
> -struct i915_page_directory_pointer {
> -       struct i915_page_dma base;
> -       struct i915_page_directory **page_directory;
> -       atomic_t used_pdpes;
> -       spinlock_t lock;
> -};
> -
> -struct i915_pml4 {
> -       struct i915_page_dma base;
> -       struct i915_page_directory_pointer *pdps[GEN8_PML4ES_PER_PML4];
> +       atomic_t used;
>         spinlock_t lock;
> +       void *entry[0];
>  };

Furthermore, we can say that only two types of pointer could be stored
here. However, unions tend to end up with messy code, so I can
understand if the implicit casts from void end up being neater.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/9] drm/i915/gtt: Introduce init_pd_with_page
  2019-06-11 17:27 ` [PATCH 3/9] drm/i915/gtt: Introduce init_pd_with_page Mika Kuoppala
@ 2019-06-11 19:45   ` Chris Wilson
  0 siblings, 0 replies; 20+ messages in thread
From: Chris Wilson @ 2019-06-11 19:45 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-06-11 18:27:25)
> We set the page directory entries to point into a page table.
> There is no gen specifics in here so make it simple and
> obvious.
> 
> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 9a1f956a817a..9d87f0fb5b16 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -724,12 +724,12 @@ static void free_pd(struct i915_address_space *vm,
>         kfree(pd);
>  }
>  
> -static void gen8_initialize_pd(struct i915_address_space *vm,
> -                              struct i915_page_directory *pd)
> +static void init_pd_with_page(struct i915_address_space *vm,
> +                             struct i915_page_directory * const pd,
> +                             struct i915_page_table *pt)
>  {
> -       fill_px(vm, pd,
> -               gen8_pde_encode(px_dma(vm->scratch_pt), I915_CACHE_LLC));
> -       memset_p(pd->entry, vm->scratch_pt, I915_PDES);
> +       fill_px(vm, pd, gen8_pde_encode(px_dma(pt), I915_CACHE_LLC));

Ahem, the scratch_pte value is known apriori and doesn't need
recomputing?
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 8/9] drm/i915/gtt: Make swapping the pd entry generic
  2019-06-11 17:27 ` [PATCH 8/9] drm/i915/gtt: Make swapping the pd entry generic Mika Kuoppala
@ 2019-06-11 19:50   ` Chris Wilson
  2019-06-11 21:46     ` Chris Wilson
  0 siblings, 1 reply; 20+ messages in thread
From: Chris Wilson @ 2019-06-11 19:50 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-06-11 18:27:30)
> Swapping a pd entry is same across the page directories, if
> we succeed we need to increment the count and write the phys page
> entry. Make a common function for it.
> 
> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 41 +++++++++++++++++++----------
>  1 file changed, 27 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index f1d7874834e2..9b0d0a077e31 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -752,6 +752,27 @@ static void __set_pd_entry(struct i915_page_directory * const pd,
>                        gen8_pde_encode(px_dma(to), I915_CACHE_LLC));    \
>  })
>  
> +static void *__swap_pd_entry(struct i915_page_directory * const pd,
> +                            const unsigned short pde,
> +                            void * const old_val,
> +                            void * const new_val,
> +                            const u64 encoded_entry)

Mark this as inline and pass in the encode function, the compiler should
do the rest.

> +{
> +       void * const old = cmpxchg(&pd->entry[pde], old_val, new_val);
> +
> +       if (likely(old == old_val)) {
> +               atomic_inc(&pd->used);

Hmm, looking at this again, this would be safer if atomic_inc was before
the cmpxchg, with an atomic_dec on the fail path.

> +               if (likely(pd_has_phys_page(pd)))
> +                       __set_pd_entry(pd, pde, encoded_entry);
> +       }
> +
> +       return old;
> +}
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/9] drm/i915/gtt: Use a common type for page directories
  2019-06-11 19:41   ` Chris Wilson
@ 2019-06-11 19:52     ` Chris Wilson
  0 siblings, 0 replies; 20+ messages in thread
From: Chris Wilson @ 2019-06-11 19:52 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Chris Wilson (2019-06-11 20:41:59)
> Quoting Mika Kuoppala (2019-06-11 18:27:24)
> >  struct i915_page_table {
> >         struct i915_page_dma base;
> > -       atomic_t used_ptes;
> > +       atomic_t used;
> >  };
> >  
> >  struct i915_page_directory {
> >         struct i915_page_dma base;
> > -
> > -       struct i915_page_table *page_table[I915_PDES]; /* PDEs */
> > -       atomic_t used_pdes;
> > -       spinlock_t lock;
> > -};
> > -
> > -struct i915_page_directory_pointer {
> > -       struct i915_page_dma base;
> > -       struct i915_page_directory **page_directory;
> > -       atomic_t used_pdpes;
> > -       spinlock_t lock;
> > -};
> > -
> > -struct i915_pml4 {
> > -       struct i915_page_dma base;
> > -       struct i915_page_directory_pointer *pdps[GEN8_PML4ES_PER_PML4];
> > +       atomic_t used;
> >         spinlock_t lock;
> > +       void *entry[0];
> >  };
> 
> And always (albeit with a single bsw discrepancy) 512. At the very least
> you can alias a fixed sized variant over the top to remove the extra
> pointer chasing you added.

I would float your make bsw behave identically patch. In the grand
scheme of things, no one will ever notice that bsw alone saved a couple
of pages per GTT.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 8/9] drm/i915/gtt: Make swapping the pd entry generic
  2019-06-11 19:50   ` Chris Wilson
@ 2019-06-11 21:46     ` Chris Wilson
  0 siblings, 0 replies; 20+ messages in thread
From: Chris Wilson @ 2019-06-11 21:46 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Chris Wilson (2019-06-11 20:50:09)
> Quoting Mika Kuoppala (2019-06-11 18:27:30)
> > Swapping a pd entry is same across the page directories, if
> > we succeed we need to increment the count and write the phys page
> > entry. Make a common function for it.
> > 
> > Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_gem_gtt.c | 41 +++++++++++++++++++----------
> >  1 file changed, 27 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> > index f1d7874834e2..9b0d0a077e31 100644
> > --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> > +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> > @@ -752,6 +752,27 @@ static void __set_pd_entry(struct i915_page_directory * const pd,
> >                        gen8_pde_encode(px_dma(to), I915_CACHE_LLC));    \
> >  })
> >  
> > +static void *__swap_pd_entry(struct i915_page_directory * const pd,
> > +                            const unsigned short pde,
> > +                            void * const old_val,
> > +                            void * const new_val,
> > +                            const u64 encoded_entry)
> 
> Mark this as inline and pass in the encode function, the compiler should
> do the rest.
> 
> > +{
> > +       void * const old = cmpxchg(&pd->entry[pde], old_val, new_val);
> > +
> > +       if (likely(old == old_val)) {
> > +               atomic_inc(&pd->used);
> 
> Hmm, looking at this again, this would be safer if atomic_inc was before
> the cmpxchg, with an atomic_dec on the fail path.

Actually already taken care of, the parent pins the child page directory
before entering.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

* ✗ Fi.CI.IGT: failure for series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs
  2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
                   ` (11 preceding siblings ...)
  2019-06-11 19:37 ` [PATCH 1/9] " Chris Wilson
@ 2019-06-12 21:32 ` Patchwork
  12 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-06-12 21:32 UTC (permalink / raw)
  To: Mika Kuoppala; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs
URL   : https://patchwork.freedesktop.org/series/61914/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_6240_full -> Patchwork_13246_full
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_13246_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_13246_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_13246_full:

### IGT changes ###

#### Possible regressions ####

  * igt@gem_ctx_shared@exec-shared-gtt-blt:
    - shard-apl:          [PASS][1] -> [FAIL][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-apl7/igt@gem_ctx_shared@exec-shared-gtt-blt.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-apl5/igt@gem_ctx_shared@exec-shared-gtt-blt.html

  
Known issues
------------

  Here are the changes found in Patchwork_13246_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_tiled_swapping@non-threaded:
    - shard-iclb:         [PASS][3] -> [FAIL][4] ([fdo#108686])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-iclb6/igt@gem_tiled_swapping@non-threaded.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-iclb4/igt@gem_tiled_swapping@non-threaded.html

  * igt@kms_cursor_crc@pipe-a-cursor-suspend:
    - shard-kbl:          [PASS][5] -> [DMESG-WARN][6] ([fdo#108566])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-kbl4/igt@kms_cursor_crc@pipe-a-cursor-suspend.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-kbl3/igt@kms_cursor_crc@pipe-a-cursor-suspend.html

  * igt@kms_cursor_crc@pipe-c-cursor-128x42-onscreen:
    - shard-skl:          [PASS][7] -> [FAIL][8] ([fdo#103232])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-skl8/igt@kms_cursor_crc@pipe-c-cursor-128x42-onscreen.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-skl7/igt@kms_cursor_crc@pipe-c-cursor-128x42-onscreen.html

  * igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
    - shard-hsw:          [PASS][9] -> [FAIL][10] ([fdo#105767])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-hsw2/igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-hsw4/igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic.html

  * igt@kms_flip@dpms-vs-vblank-race-interruptible:
    - shard-kbl:          [PASS][11] -> [FAIL][12] ([fdo#103060])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-kbl2/igt@kms_flip@dpms-vs-vblank-race-interruptible.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-kbl1/igt@kms_flip@dpms-vs-vblank-race-interruptible.html

  * igt@kms_flip@flip-vs-expired-vblank:
    - shard-skl:          [PASS][13] -> [FAIL][14] ([fdo#105363])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-skl1/igt@kms_flip@flip-vs-expired-vblank.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-skl5/igt@kms_flip@flip-vs-expired-vblank.html

  * igt@kms_frontbuffer_tracking@fbcpsr-1p-pri-indfb-multidraw:
    - shard-iclb:         [PASS][15] -> [FAIL][16] ([fdo#103167]) +1 similar issue
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-iclb3/igt@kms_frontbuffer_tracking@fbcpsr-1p-pri-indfb-multidraw.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-iclb1/igt@kms_frontbuffer_tracking@fbcpsr-1p-pri-indfb-multidraw.html

  * igt@kms_plane_alpha_blend@pipe-a-coverage-7efc:
    - shard-skl:          [PASS][17] -> [FAIL][18] ([fdo#108145])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-skl5/igt@kms_plane_alpha_blend@pipe-a-coverage-7efc.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-skl10/igt@kms_plane_alpha_blend@pipe-a-coverage-7efc.html

  * igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
    - shard-skl:          [PASS][19] -> [FAIL][20] ([fdo#108145] / [fdo#110403])
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-skl8/igt@kms_plane_alpha_blend@pipe-c-coverage-7efc.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-skl7/igt@kms_plane_alpha_blend@pipe-c-coverage-7efc.html

  * igt@kms_psr@psr2_cursor_plane_onoff:
    - shard-iclb:         [PASS][21] -> [SKIP][22] ([fdo#109441])
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-iclb2/igt@kms_psr@psr2_cursor_plane_onoff.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-iclb1/igt@kms_psr@psr2_cursor_plane_onoff.html

  * igt@kms_setmode@basic:
    - shard-kbl:          [PASS][23] -> [FAIL][24] ([fdo#99912])
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-kbl3/igt@kms_setmode@basic.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-kbl3/igt@kms_setmode@basic.html

  * igt@kms_vblank@pipe-a-ts-continuation-suspend:
    - shard-apl:          [PASS][25] -> [DMESG-WARN][26] ([fdo#108566]) +2 similar issues
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-apl4/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-apl4/igt@kms_vblank@pipe-a-ts-continuation-suspend.html

  
#### Possible fixes ####

  * igt@gem_ctx_isolation@vecs0-s3:
    - shard-skl:          [INCOMPLETE][27] ([fdo#104108]) -> [PASS][28]
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-skl6/igt@gem_ctx_isolation@vecs0-s3.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-skl4/igt@gem_ctx_isolation@vecs0-s3.html

  * igt@gem_softpin@noreloc-s3:
    - shard-apl:          [DMESG-WARN][29] ([fdo#108566]) -> [PASS][30] +2 similar issues
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-apl7/igt@gem_softpin@noreloc-s3.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-apl5/igt@gem_softpin@noreloc-s3.html

  * igt@kms_cursor_crc@pipe-a-cursor-128x42-offscreen:
    - shard-skl:          [FAIL][31] ([fdo#103232]) -> [PASS][32] +1 similar issue
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-skl4/igt@kms_cursor_crc@pipe-a-cursor-128x42-offscreen.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-skl3/igt@kms_cursor_crc@pipe-a-cursor-128x42-offscreen.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt:
    - shard-skl:          [FAIL][33] ([fdo#103167]) -> [PASS][34] +1 similar issue
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-skl4/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-skl3/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-shrfb-msflip-blt:
    - shard-iclb:         [FAIL][35] ([fdo#103167]) -> [PASS][36] +3 similar issues
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-iclb6/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-shrfb-msflip-blt.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-iclb3/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-shrfb-msflip-blt.html

  * igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
    - shard-skl:          [FAIL][37] ([fdo#108145]) -> [PASS][38]
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-skl4/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-skl3/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html

  * igt@kms_plane_lowres@pipe-a-tiling-x:
    - shard-iclb:         [FAIL][39] ([fdo#103166]) -> [PASS][40]
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-iclb4/igt@kms_plane_lowres@pipe-a-tiling-x.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-iclb7/igt@kms_plane_lowres@pipe-a-tiling-x.html

  * igt@kms_psr@psr2_sprite_mmap_cpu:
    - shard-iclb:         [SKIP][41] ([fdo#109441]) -> [PASS][42]
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-iclb4/igt@kms_psr@psr2_sprite_mmap_cpu.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-iclb2/igt@kms_psr@psr2_sprite_mmap_cpu.html

  * igt@perf@blocking:
    - shard-skl:          [FAIL][43] ([fdo#110728]) -> [PASS][44]
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6240/shard-skl1/igt@perf@blocking.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/shard-skl5/igt@perf@blocking.html

  
  [fdo#103060]: https://bugs.freedesktop.org/show_bug.cgi?id=103060
  [fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
  [fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
  [fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
  [fdo#105767]: https://bugs.freedesktop.org/show_bug.cgi?id=105767
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [fdo#108686]: https://bugs.freedesktop.org/show_bug.cgi?id=108686
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#110403]: https://bugs.freedesktop.org/show_bug.cgi?id=110403
  [fdo#110728]: https://bugs.freedesktop.org/show_bug.cgi?id=110728
  [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912


Participating hosts (11 -> 10)
------------------------------

  Missing    (1): pig-snb-2600 


Build changes
-------------

  * Linux: CI_DRM_6240 -> Patchwork_13246

  CI_DRM_6240: 6912995f6dd977863a049005b01c6f197ae9cbdc @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5051: 1f2acef836ffcbf5113df4ade8b587935c7d5868 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_13246: 393d891d4aec953670d456c9a2336a591274cbba @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13246/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-06-12 21:32 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-11 17:27 [PATCH 1/9] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
2019-06-11 17:27 ` [PATCH 2/9] drm/i915/gtt: Use a common type for page directories Mika Kuoppala
2019-06-11 19:41   ` Chris Wilson
2019-06-11 19:52     ` Chris Wilson
2019-06-11 19:43   ` Chris Wilson
2019-06-11 17:27 ` [PATCH 3/9] drm/i915/gtt: Introduce init_pd_with_page Mika Kuoppala
2019-06-11 19:45   ` Chris Wilson
2019-06-11 17:27 ` [PATCH 4/9] drm/i915/gtt: Introduce init_pd Mika Kuoppala
2019-06-11 17:27 ` [PATCH 5/9] drm/i915/gtt: Generalize alloc_pd Mika Kuoppala
2019-06-11 17:27 ` [PATCH 6/9] drm/i915/gtt: pde entry encoding is identical Mika Kuoppala
2019-06-11 17:27 ` [PATCH 7/9] drm/i915/gtt: Check for physical page for pd entry always Mika Kuoppala
2019-06-11 17:27 ` [PATCH 8/9] drm/i915/gtt: Make swapping the pd entry generic Mika Kuoppala
2019-06-11 19:50   ` Chris Wilson
2019-06-11 21:46     ` Chris Wilson
2019-06-11 17:27 ` [PATCH 9/9] drm/i915/gtt: Tear down setup and cleanup macros for page dma Mika Kuoppala
2019-06-11 17:53 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/9] drm/i915/gtt: No need to zero the table for page dirs Patchwork
2019-06-11 17:57 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-06-11 18:18 ` ✓ Fi.CI.BAT: success " Patchwork
2019-06-11 19:37 ` [PATCH 1/9] " Chris Wilson
2019-06-12 21:32 ` ✗ Fi.CI.IGT: failure for series starting with [1/9] " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.