Skip to contentSkip to conversation

drm/i915/mtl: Media GT and Render GT share common GGTT

PATCH Superseded Aravind Iddamsetty 4 participants 10 messages Oct 31, 2022 – Nov 9, 2022

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/mtl: Media GT and Render GT share common GGTT

On XE_LPM+ platforms the media engines are carved out into a separate GT but have a common GGTMMADR address range which essentially makes the GGTT address space to be shared between media and render GT.

BSPEC: 63834

---
 drivers/gpu/drm/i915/gt/intel_ggtt.c      | 49 +++++++++++-------
 drivers/gpu/drm/i915/gt/intel_gt.c        | 15 +++++-
 drivers/gpu/drm/i915/gt/intel_gt_types.h  |  3 ++
 drivers/gpu/drm/i915/gt/intel_gtt.h       |  3 ++
 drivers/gpu/drm/i915/i915_driver.c        | 19 +++++--
 drivers/gpu/drm/i915/i915_gem_evict.c     | 63 +++++++++++++++++------
 drivers/gpu/drm/i915/i915_vma.c           |  5 +-
 drivers/gpu/drm/i915/selftests/i915_gem.c |  2 +
 drivers/gpu/drm/i915/selftests/mock_gtt.c |  1 +
 9 files changed, 115 insertions(+), 45 deletions(-)
drivers/gpu/drm/i915/gt/intel_ggtt.c +29 -20
index 2518cebbf931..f5c2f3c58627 100644
@@ -196,10 +196,13 @@ void i915_ggtt_suspend_vm(struct i915_address_space *vm)
 
 void i915_ggtt_suspend(struct i915_ggtt *ggtt)
 {
+	struct intel_gt *gt;
+
 	i915_ggtt_suspend_vm(&ggtt->vm);
 	ggtt->invalidate(ggtt);
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 }
 
 void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)
@@ -214,27 +217,36 @@ void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)
 
 static void gen8_ggtt_invalidate(struct i915_ggtt *ggtt)
 {
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
+	struct intel_uncore *uncore;
+	struct intel_gt *gt;
 
-	/*
-	 * Note that as an uncached mmio write, this will flush the
-	 * WCB of the writes into the GGTT before it triggers the invalidate.
-	 */
-	intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link) {
+		uncore = gt->uncore;
+		/*
+		 * Note that as an uncached mmio write, this will flush the
+		 * WCB of the writes into the GGTT before it triggers the invalidate.
+		 */
+		intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
+	}
 }
 
 static void guc_ggtt_invalidate(struct i915_ggtt *ggtt)
 {
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
 	struct drm_i915_private *i915 = ggtt->vm.i915;
 
 	gen8_ggtt_invalidate(ggtt);
 
-	if (GRAPHICS_VER(i915) >= 12)
-		intel_uncore_write_fw(uncore, GEN12_GUC_TLB_INV_CR,
-				      GEN12_GUC_TLB_INV_CR_INVALIDATE);
-	else
-		intel_uncore_write_fw(uncore, GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	if (GRAPHICS_VER(i915) >= 12) {
+		struct intel_gt *gt;
+
+		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+			intel_uncore_write_fw(gt->uncore,
+					      GEN12_GUC_TLB_INV_CR,
+					      GEN12_GUC_TLB_INV_CR_INVALIDATE);
+	} else {
+		intel_uncore_write_fw(ggtt->vm.gt->uncore,
+				      GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	}
 }
 
 u64 gen8_ggtt_pte_encode(dma_addr_t addr,
@@ -986,8 +998,6 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 
 	ggtt->vm.pte_encode = gen8_ggtt_pte_encode;
 
-	setup_private_pat(ggtt->vm.gt);
-
 	return ggtt_probe_common(ggtt, size);
 }
 
@@ -1186,7 +1196,7 @@ static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct intel_gt *gt)
 		(u64)ggtt->mappable_end >> 20);
 	drm_dbg(&i915->drm, "DSM size = %lluM\n",
 		(u64)resource_size(&intel_graphics_stolen_res) >> 20);
-
+	INIT_LIST_HEAD(&ggtt->gt_list);
 	return 0;
 }
 
@@ -1296,9 +1306,11 @@ bool i915_ggtt_resume_vm(struct i915_address_space *vm)
 
 void i915_ggtt_resume(struct i915_ggtt *ggtt)
 {
+	struct intel_gt *gt;
 	bool flush;
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 
 	flush = i915_ggtt_resume_vm(&ggtt->vm);
 
@@ -1307,9 +1319,6 @@ void i915_ggtt_resume(struct i915_ggtt *ggtt)
 	if (flush)
 		wbinvd_on_all_cpus();
 
-	if (GRAPHICS_VER(ggtt->vm.i915) >= 8)
-		setup_private_pat(ggtt->vm.gt);
-
 	intel_ggtt_restore_fences(ggtt);
 }
 
drivers/gpu/drm/i915/gt/intel_gt.c +13 -2
index 2e796ffad911..d72efb74563a 100644
@@ -110,9 +110,17 @@ static int intel_gt_probe_lmem(struct intel_gt *gt)
 
 int intel_gt_assign_ggtt(struct intel_gt *gt)
 {
-	gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
+	/* Media GT shares primary GT's GGTT */
+	if (gt->type == GT_MEDIA) {
+		gt->ggtt = to_gt(gt->i915)->ggtt;
+	} else {
+		gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
+		if (!gt->ggtt)
+			return -ENOMEM;
+	}
 
-	return gt->ggtt ? 0 : -ENOMEM;
+	list_add_tail(&gt->ggtt_link, &gt->ggtt->gt_list);
+	return 0;
 }
 
 int intel_gt_init_mmio(struct intel_gt *gt)
@@ -965,6 +973,9 @@ int intel_gt_tiles_init(struct drm_i915_private *i915)
 	int ret;
 
 	for_each_gt(gt, i915, id) {
+		if (GRAPHICS_VER(i915) >= 8)
+			setup_private_pat(gt);
+
 		ret = intel_gt_probe_lmem(gt);
 		if (ret)
 			return ret;
drivers/gpu/drm/i915/gt/intel_gt_types.h +3 -0
index 6f686a4244f0..aee37e9e79b0 100644
@@ -292,6 +292,9 @@ struct intel_gt {
 	struct kobject *sysfs_defaults;
 
 	struct i915_perf_gt perf;
+
+	/** link: &ggtt.gt_list */
+	struct list_head ggtt_link;
 };
 
 struct intel_gt_definition {
drivers/gpu/drm/i915/gt/intel_gtt.h +3 -0
index 4d75ba4bb41d..cb1272702a1a 100644
@@ -390,6 +390,9 @@ struct i915_ggtt {
 	struct mutex error_mutex;
 	struct drm_mm_node error_capture;
 	struct drm_mm_node uc_fw;
+
+	/** List of GTs mapping this GGTT */
+	struct list_head gt_list;
 };
 
 struct i915_ppgtt {
drivers/gpu/drm/i915/i915_driver.c +14 -5
index c3d43f9b1e45..6b973182ddcc 100644
@@ -577,7 +577,8 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 {
 	struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
 	struct pci_dev *root_pdev;
-	int ret;
+	struct intel_gt *gt;
+	int ret, i;
 
 	if (i915_inject_probe_failure(dev_priv))
 		return -ENODEV;
@@ -614,9 +615,11 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 
 	i915_perf_init(dev_priv);
 
-	ret = intel_gt_assign_ggtt(to_gt(dev_priv));
-	if (ret)
-		goto err_perf;
+	for_each_gt(gt, dev_priv, i) {
+		ret = intel_gt_assign_ggtt(gt);
+		if (ret)
+			goto err_perf;
+	}
 
 	ret = i915_ggtt_probe_hw(dev_priv);
 	if (ret)
@@ -1318,7 +1321,8 @@ int i915_driver_suspend_switcheroo(struct drm_i915_private *i915,
 static int i915_drm_resume(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	int ret;
+	struct intel_gt *gt;
+	int ret, i;
 
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -1333,6 +1337,11 @@ static int i915_drm_resume(struct drm_device *dev)
 		drm_err(&dev_priv->drm, "failed to re-enable GGTT\n");
 
 	i915_ggtt_resume(to_gt(dev_priv)->ggtt);
+
+	for_each_gt(gt, dev_priv, i)
+		if (GRAPHICS_VER(gt->i915) >= 8)
+			setup_private_pat(gt);
+
 	/* Must be called after GGTT is resumed. */
 	intel_dpt_resume(dev_priv);
 
drivers/gpu/drm/i915/i915_gem_evict.c +46 -17

100 lines not on this page · raw message

drivers/gpu/drm/i915/i915_vma.c +4 -1
index c39488eb9eeb..24cbee3c1ce5 100644
@@ -1542,6 +1542,8 @@ static int __i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 			   u32 align, unsigned int flags)
 {
 	struct i915_address_space *vm = vma->vm;
+	struct intel_gt *gt;
+	struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
 	int err;
 
 	do {
@@ -1557,7 +1559,8 @@ static int __i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 		}
 
 		/* Unlike i915_vma_pin, we don't take no for an answer! */
-		flush_idle_contexts(vm->gt);
+		list_for_each_entry_rcu(gt, &ggtt->gt_list, ggtt_link)
+			flush_idle_contexts(gt);
 		if (mutex_lock_interruptible(&vm->mutex) == 0) {
 			/*
 			 * We pass NULL ww here, as we don't want to unbind
drivers/gpu/drm/i915/selftests/i915_gem.c +2 -0
index e5dd82e7e480..2535b9684bd1 100644
@@ -127,6 +127,8 @@ static void igt_pm_resume(struct drm_i915_private *i915)
 	 */
 	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 		i915_ggtt_resume(to_gt(i915)->ggtt);
+		if (GRAPHICS_VER(i915) >= 8)
+			setup_private_pat(to_gt(i915));
 		i915_gem_resume(i915);
 	}
 }
drivers/gpu/drm/i915/selftests/mock_gtt.c +1 -0
index 568840e7ca66..b519d271f4fe 100644
@@ -127,6 +127,7 @@ void mock_init_ggtt(struct intel_gt *gt)
 	ggtt->vm.vma_ops.bind_vma    = mock_bind_ggtt;
 	ggtt->vm.vma_ops.unbind_vma  = mock_unbind_ggtt;
 
+	INIT_LIST_HEAD(&ggtt->gt_list);
 	i915_address_space_init(&ggtt->vm, VM_CLASS_GGTT);
 }
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Aravind Iddamsetty

On XE_LPM+ platforms the media engines are carved out into a separate GT but have a common GGTMMADR address range which essentially makes the GGTT address space to be shared between media and render GT.

While this is all true, I feel like this description is lacking a bit of explanation for why/how that translates into the code changes below. For example you should elaborate on the areas this impacts, such as the need to invalidate both GTs' TLBs, retire requests for both GTs, etc.

Also, the movement of the PAT setup should be noted and explained as well since it differs from how you approached the other changes here.

Quoted 46 lines

BSPEC: 63834

---
 drivers/gpu/drm/i915/gt/intel_ggtt.c      | 49 +++++++++++-------
 drivers/gpu/drm/i915/gt/intel_gt.c        | 15 +++++-
 drivers/gpu/drm/i915/gt/intel_gt_types.h  |  3 ++
 drivers/gpu/drm/i915/gt/intel_gtt.h       |  3 ++
 drivers/gpu/drm/i915/i915_driver.c        | 19 +++++--
 drivers/gpu/drm/i915/i915_gem_evict.c     | 63 +++++++++++++++++------
 drivers/gpu/drm/i915/i915_vma.c           |  5 +-
 drivers/gpu/drm/i915/selftests/i915_gem.c |  2 +
 drivers/gpu/drm/i915/selftests/mock_gtt.c |  1 +
 9 files changed, 115 insertions(+), 45 deletions(-)
drivers/gpu/drm/i915/gt/intel_ggtt.c +6 -4
index 2518cebbf931..f5c2f3c58627 100644
@@ -196,10 +196,13 @@ void i915_ggtt_suspend_vm(struct i915_address_space *vm)
 
 void i915_ggtt_suspend(struct i915_ggtt *ggtt)
 {
+	struct intel_gt *gt;
+
 	i915_ggtt_suspend_vm(&ggtt->vm);
 	ggtt->invalidate(ggtt);
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 }
 
 void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)
@@ -214,27 +217,36 @@ void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)
 
 static void gen8_ggtt_invalidate(struct i915_ggtt *ggtt)
 {
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
+	struct intel_uncore *uncore;
+	struct intel_gt *gt;
 
-	/*
-	 * Note that as an uncached mmio write, this will flush the

drivers/gpu/drm/i915/gt/intel_ggtt.c void gen6_ggtt_invalidate(struct i915_ggtt *ggtt) · line 229

Quoted 10 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +7 -3
-	 * WCB of the writes into the GGTT before it triggers the invalidate.
-	 */
-	intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link) {
+		uncore = gt->uncore;
+		/*
+		 * Note that as an uncached mmio write, this will flush the
+		 * WCB of the writes into the GGTT before it triggers the invalidate.
+		 */
+		intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);

This isn't a GT register, so writing it for each GT doesn't do anything different than just writing it once. But actually it doesn't look like this is even a register we should be writing to anymore since Xe_HP. The GFX_FLSH_CNTL register no longer lives here.

Quoted 95 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +16 -13
+	}
 }
 
 static void guc_ggtt_invalidate(struct i915_ggtt *ggtt)
 {
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
 	struct drm_i915_private *i915 = ggtt->vm.i915;
 
 	gen8_ggtt_invalidate(ggtt);
 
-	if (GRAPHICS_VER(i915) >= 12)
-		intel_uncore_write_fw(uncore, GEN12_GUC_TLB_INV_CR,
-				      GEN12_GUC_TLB_INV_CR_INVALIDATE);
-	else
-		intel_uncore_write_fw(uncore, GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	if (GRAPHICS_VER(i915) >= 12) {
+		struct intel_gt *gt;
+
+		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+			intel_uncore_write_fw(gt->uncore,
+					      GEN12_GUC_TLB_INV_CR,
+					      GEN12_GUC_TLB_INV_CR_INVALIDATE);
+	} else {
+		intel_uncore_write_fw(ggtt->vm.gt->uncore,
+				      GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	}
 }
 
 u64 gen8_ggtt_pte_encode(dma_addr_t addr,
@@ -986,8 +998,6 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 
 	ggtt->vm.pte_encode = gen8_ggtt_pte_encode;
 
-	setup_private_pat(ggtt->vm.gt);
-
 	return ggtt_probe_common(ggtt, size);
 }
 
@@ -1186,7 +1196,7 @@ static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct intel_gt *gt)
 		(u64)ggtt->mappable_end >> 20);
 	drm_dbg(&i915->drm, "DSM size = %lluM\n",
 		(u64)resource_size(&intel_graphics_stolen_res) >> 20);
-
+	INIT_LIST_HEAD(&ggtt->gt_list);
 	return 0;
 }
 
@@ -1296,9 +1306,11 @@ bool i915_ggtt_resume_vm(struct i915_address_space *vm)
 
 void i915_ggtt_resume(struct i915_ggtt *ggtt)
 {
+	struct intel_gt *gt;
 	bool flush;
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 
 	flush = i915_ggtt_resume_vm(&ggtt->vm);
 
@@ -1307,9 +1319,6 @@ void i915_ggtt_resume(struct i915_ggtt *ggtt)
 	if (flush)
 		wbinvd_on_all_cpus();
 
-	if (GRAPHICS_VER(ggtt->vm.i915) >= 8)
-		setup_private_pat(ggtt->vm.gt);
-
 	intel_ggtt_restore_fences(ggtt);
 }
 
drivers/gpu/drm/i915/gt/intel_gt.c +10 -2
index 2e796ffad911..d72efb74563a 100644
@@ -110,9 +110,17 @@ static int intel_gt_probe_lmem(struct intel_gt *gt)
 
 int intel_gt_assign_ggtt(struct intel_gt *gt)
 {
-	gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
+	/* Media GT shares primary GT's GGTT */
+	if (gt->type == GT_MEDIA) {
+		gt->ggtt = to_gt(gt->i915)->ggtt;
+	} else {
+		gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
+		if (!gt->ggtt)
+			return -ENOMEM;
+	}
 
-	return gt->ggtt ? 0 : -ENOMEM;
+	list_add_tail(&gt->ggtt_link, &gt->ggtt->gt_list);
+	return 0;
 }
 
 int intel_gt_init_mmio(struct intel_gt *gt)

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_tiles_init(struct drm_i915_private *i915) · line 978

Quoted 6 lines
drivers/gpu/drm/i915/gt/intel_gt.c +3 -0
@@ -965,6 +973,9 @@ int intel_gt_tiles_init(struct drm_i915_private *i915)
 	int ret;
 
 	for_each_gt(gt, i915, id) {
+		if (GRAPHICS_VER(i915) >= 8)
+			setup_private_pat(gt);
+

Since the term "tile" is used for PVC-style remote tiles (which we have some framework for, but haven't enabled yet), it seems confusing to have the PAT setup for all GTs (including the standalone media GT) in a function called intel_gt_tiles_init(). Maybe we should also have a prep patch that renames this function if we're going to start doing non-tile things in here too?

Quoted 111 lines
drivers/gpu/drm/i915/gt/intel_gt.c +0 -0
 		ret = intel_gt_probe_lmem(gt);
 		if (ret)
 			return ret;
drivers/gpu/drm/i915/gt/intel_gt_types.h +3 -0
index 6f686a4244f0..aee37e9e79b0 100644
@@ -292,6 +292,9 @@ struct intel_gt {
 	struct kobject *sysfs_defaults;
 
 	struct i915_perf_gt perf;
+
+	/** link: &ggtt.gt_list */
+	struct list_head ggtt_link;
 };
 
 struct intel_gt_definition {
drivers/gpu/drm/i915/gt/intel_gtt.h +3 -0
index 4d75ba4bb41d..cb1272702a1a 100644
@@ -390,6 +390,9 @@ struct i915_ggtt {
 	struct mutex error_mutex;
 	struct drm_mm_node error_capture;
 	struct drm_mm_node uc_fw;
+
+	/** List of GTs mapping this GGTT */
+	struct list_head gt_list;
 };
 
 struct i915_ppgtt {
drivers/gpu/drm/i915/i915_driver.c +14 -5
index c3d43f9b1e45..6b973182ddcc 100644
@@ -577,7 +577,8 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 {
 	struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
 	struct pci_dev *root_pdev;
-	int ret;
+	struct intel_gt *gt;
+	int ret, i;
 
 	if (i915_inject_probe_failure(dev_priv))
 		return -ENODEV;
@@ -614,9 +615,11 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 
 	i915_perf_init(dev_priv);
 
-	ret = intel_gt_assign_ggtt(to_gt(dev_priv));
-	if (ret)
-		goto err_perf;
+	for_each_gt(gt, dev_priv, i) {
+		ret = intel_gt_assign_ggtt(gt);
+		if (ret)
+			goto err_perf;
+	}
 
 	ret = i915_ggtt_probe_hw(dev_priv);
 	if (ret)
@@ -1318,7 +1321,8 @@ int i915_driver_suspend_switcheroo(struct drm_i915_private *i915,
 static int i915_drm_resume(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	int ret;
+	struct intel_gt *gt;
+	int ret, i;
 
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -1333,6 +1337,11 @@ static int i915_drm_resume(struct drm_device *dev)
 		drm_err(&dev_priv->drm, "failed to re-enable GGTT\n");
 
 	i915_ggtt_resume(to_gt(dev_priv)->ggtt);
+
+	for_each_gt(gt, dev_priv, i)
+		if (GRAPHICS_VER(gt->i915) >= 8)
+			setup_private_pat(gt);
+
 	/* Must be called after GGTT is resumed. */
 	intel_dpt_resume(dev_priv);
 
drivers/gpu/drm/i915/i915_gem_evict.c +11 -9
index f025ee4fa526..e9d4352ebfb8 100644
@@ -43,16 +43,30 @@ static bool dying_vma(struct i915_vma *vma)
 	return !kref_read(&vma->obj->base.refcount);
 }
 
-static int ggtt_flush(struct intel_gt *gt)
+static int ggtt_flush(struct i915_address_space *vm)
 {
-	/*
-	 * Not everything in the GGTT is tracked via vma (otherwise we
-	 * could evict as required with minimal stalling) so we are forced
-	 * to idle the GPU and explicitly retire outstanding requests in
-	 * the hopes that we can then remove contexts and the like only
-	 * bound by their active reference.
-	 */
-	return intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT);
+	int ret = 0;
+
+	if (i915_is_ggtt(vm)) {
+		struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
+		struct intel_gt *gt;
+
+		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link) {
+			/*
+			 * Not everything in the GGTT is tracked via vma (otherwise we
+			 * could evict as required with minimal stalling) so we are forced

drivers/gpu/drm/i915/i915_gem_evict.c static bool dying_vma(struct i915_vma *vma) · line 67

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_evict.c +10 -0
+			 * to idle the GPU and explicitly retire outstanding requests in
+			 * the hopes that we can then remove contexts and the like only
+			 * bound by their active reference.
+			 */
+			ret = intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT);
+			if (ret)
+				return ret;
+		}
+	} else {
+		ret = intel_gt_wait_for_idle(vm->gt, MAX_SCHEDULE_TIMEOUT);

This function is only ever got called on the GGTT as far as I can see (which makes sense given that its name starts with 'ggtt'). It's not clear to me why we want to handle PPGTT too now?

Even if this is intentional and correct, it might be best to move this up to a small if statement at the top of the function with a return so that we can eliminate a level of nesting from most of the function.

        if (!i915_is_ggtt(vm)) {
                wait for idle;
                return;
        }

        ...
Quoted 30 lines
drivers/gpu/drm/i915/i915_gem_evict.c +11 -1
+	}
+	return ret;
 }
 
 static bool grab_vma(struct i915_vma *vma, struct i915_gem_ww_ctx *ww)
@@ -149,6 +163,7 @@ i915_gem_evict_something(struct i915_address_space *vm,
 	struct drm_mm_node *node;
 	enum drm_mm_insert_mode mode;
 	struct i915_vma *active;
+	struct intel_gt *gt;
 	int ret;
 
 	lockdep_assert_held(&vm->mutex);
@@ -174,7 +189,14 @@ i915_gem_evict_something(struct i915_address_space *vm,
 				    min_size, alignment, color,
 				    start, end, mode);
 
-	intel_gt_retire_requests(vm->gt);
+	if (i915_is_ggtt(vm)) {
+		struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
+
+		list_for_each_entry_rcu(gt, &ggtt->gt_list, ggtt_link)
+			intel_gt_retire_requests(gt);
+	} else {
+		intel_gt_retire_requests(vm->gt);
+	}
 
 search_again:
 	active = NULL;

drivers/gpu/drm/i915/i915_gem_evict.c i915_gem_evict_something(struct i915_address_space *vm, · line 271

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_evict.c +1 -1
@@ -246,7 +268,7 @@ i915_gem_evict_something(struct i915_address_space *vm,
 	if (I915_SELFTEST_ONLY(igt_evict_ctl.fail_if_busy))
 		return -EBUSY;
 
-	ret = ggtt_flush(vm->gt);
+	ret = ggtt_flush(vm);

As noted above, this call is always done on GGTT (since we checked and returned if it wasn't GGTT just before this point in the function).

Quoted 23 lines
drivers/gpu/drm/i915/i915_gem_evict.c +9 -1
 	if (ret)
 		return ret;
 
@@ -332,7 +354,15 @@ int i915_gem_evict_for_node(struct i915_address_space *vm,
 	 * a stray pin (preventing eviction) that can only be resolved by
 	 * retiring.
 	 */
-	intel_gt_retire_requests(vm->gt);
+	if (i915_is_ggtt(vm)) {
+		struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
+		struct intel_gt *gt;
+
+		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+			intel_gt_retire_requests(gt);
+	} else {
+		intel_gt_retire_requests(vm->gt);
+	}
 
 	if (i915_vm_has_cache_coloring(vm)) {
 		/* Expand search to cover neighbouring guard pages (or lack!) */
@@ -437,11 +467,10 @@ int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww)
 	 * pin themselves inside the global GTT and performing the
 	 * switch otherwise is ineffective.

drivers/gpu/drm/i915/i915_gem_evict.c int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww) · line 473

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_evict.c +4 -5
 	 */
-	if (i915_is_ggtt(vm)) {
-		ret = ggtt_flush(vm->gt);
-		if (ret)
-			return ret;
-	}
+
+	ret = ggtt_flush(vm);
+	if (ret)
+		return ret;

It's not clear to me why we're removing the GGTT check here?

Matt

Quoted 54 lines
drivers/gpu/drm/i915/i915_gem_evict.c +0 -0
 	do {
 		struct i915_vma *vma, *vn;
drivers/gpu/drm/i915/i915_vma.c +4 -1
index c39488eb9eeb..24cbee3c1ce5 100644
@@ -1542,6 +1542,8 @@ static int __i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 			   u32 align, unsigned int flags)
 {
 	struct i915_address_space *vm = vma->vm;
+	struct intel_gt *gt;
+	struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
 	int err;
 
 	do {
@@ -1557,7 +1559,8 @@ static int __i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 		}
 
 		/* Unlike i915_vma_pin, we don't take no for an answer! */
-		flush_idle_contexts(vm->gt);
+		list_for_each_entry_rcu(gt, &ggtt->gt_list, ggtt_link)
+			flush_idle_contexts(gt);
 		if (mutex_lock_interruptible(&vm->mutex) == 0) {
 			/*
 			 * We pass NULL ww here, as we don't want to unbind
drivers/gpu/drm/i915/selftests/i915_gem.c +2 -0
index e5dd82e7e480..2535b9684bd1 100644
@@ -127,6 +127,8 @@ static void igt_pm_resume(struct drm_i915_private *i915)
 	 */
 	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 		i915_ggtt_resume(to_gt(i915)->ggtt);
+		if (GRAPHICS_VER(i915) >= 8)
+			setup_private_pat(to_gt(i915));
 		i915_gem_resume(i915);
 	}
 }
drivers/gpu/drm/i915/selftests/mock_gtt.c +1 -0
index 568840e7ca66..b519d271f4fe 100644
@@ -127,6 +127,7 @@ void mock_init_ggtt(struct intel_gt *gt)
 	ggtt->vm.vma_ops.bind_vma    = mock_bind_ggtt;
 	ggtt->vm.vma_ops.unbind_vma  = mock_unbind_ggtt;
 
+	INIT_LIST_HEAD(&ggtt->gt_list);
 	i915_address_space_init(&ggtt->vm, VM_CLASS_GGTT);
 }
 
Signature · 1 line
2.25.1
Signature · 4 lines
Matt Roper
Graphics Software Engineer
VTT-OSGC Platform Enablement
Intel Corporation
#2 lore raw
Quoted 5 lines · Matt Roper
Quoted 3 lines · Aravind Iddamsetty

On XE_LPM+ platforms the media engines are carved out into a separate GT but have a common GGTMMADR address range which essentially makes the GGTT address space to be shared between media and render GT.

<snip>

Quoted 5 lines
Quoted 5 lines

int intel_gt_init_mmio(struct intel_gt *gt)

(quoted diff) +0 -0
@@ -965,6 +973,9 @@ int intel_gt_tiles_init(struct drm_i915_private *i915)
 	int ret;
 
Quoted 11 lines

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_tiles_init(struct drm_i915_private *i915) · line 978

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.c +3 -0
 	for_each_gt(gt, i915, id) {
+		if (GRAPHICS_VER(i915) >= 8)
+			setup_private_pat(gt);
+

Since the term "tile" is used for PVC-style remote tiles (which we have some framework for, but haven't enabled yet), it seems confusing to have the PAT setup for all GTs (including the standalone media GT) in a function called intel_gt_tiles_init(). Maybe we should also have a prep patch that renames this function if we're going to start doing non-tile things in here too?

But isn't GT and Tile used interchangeably. Also, Could you please elaborate what do you mean by non tile related things here and as i understand PAT are per GT registers and in case of SA Media the gsi_offset get added.

Quoted 4 lines

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_tiles_init(struct drm_i915_private *i915) · line 981

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.c +0 -0
 		ret = intel_gt_probe_lmem(gt);
 		if (ret)
 			return ret;

<snip>

Thanks,
Aravind.

#3 lore raw
Quoted 27 lines · Aravind
Quoted 5 lines · Matt Roper
Quoted 3 lines · Aravind Iddamsetty

On XE_LPM+ platforms the media engines are carved out into a separate GT but have a common GGTMMADR address range which essentially makes the GGTT address space to be shared between media and render GT.

<snip>

Quoted 5 lines
Quoted 5 lines

int intel_gt_init_mmio(struct intel_gt *gt)

(quoted diff) +0 -0
@@ -965,6 +973,9 @@ int intel_gt_tiles_init(struct drm_i915_private *i915)
 	int ret;
 
Quoted 11 lines

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_tiles_init(struct drm_i915_private *i915) · line 978

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.c +3 -0
 	for_each_gt(gt, i915, id) {
+		if (GRAPHICS_VER(i915) >= 8)
+			setup_private_pat(gt);
+

Since the term "tile" is used for PVC-style remote tiles (which we have some framework for, but haven't enabled yet), it seems confusing to have the PAT setup for all GTs (including the standalone media GT) in a function called intel_gt_tiles_init(). Maybe we should also have a prep patch that renames this function if we're going to start doing non-tile things in here too?

Quoted 1 line

But isn't GT and Tile used interchangeably. Also, Could you please

The terminology has been used a bit inconsistently so far, but I think we're trying to standardize on "tile" as referring to the PVC-style combination of "GT + LMEM." So I'd consider MTL's standalone media to be a "GT," but not a "tile" because it isn't paired with its own lmem unit.

Matt

Quoted 11 lines

elaborate what do you mean by non tile related things here and as i understand PAT are per GT registers and in case of SA Media the gsi_offset get added.

Quoted 4 lines

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_tiles_init(struct drm_i915_private *i915) · line 981

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.c +0 -0
 		ret = intel_gt_probe_lmem(gt);
 		if (ret)
 			return ret;

<snip>

Thanks,
Aravind.

Signature · 4 lines
Matt Roper
Graphics Software Engineer
VTT-OSGC Platform Enablement
Intel Corporation
#4 lore raw
In reply to Matt Roper
Quoted 66 lines · Matt Roper
Quoted 3 lines · Aravind Iddamsetty

On XE_LPM+ platforms the media engines are carved out into a separate GT but have a common GGTMMADR address range which essentially makes the GGTT address space to be shared between media and render GT.

While this is all true, I feel like this description is lacking a bit of explanation for why/how that translates into the code changes below. For example you should elaborate on the areas this impacts, such as the need to invalidate both GTs' TLBs, retire requests for both GTs, etc.

Also, the movement of the PAT setup should be noted and explained as well since it differs from how you approached the other changes here.

Quoted 53 lines

BSPEC: 63834

---
 drivers/gpu/drm/i915/gt/intel_ggtt.c      | 49 +++++++++++-------
 drivers/gpu/drm/i915/gt/intel_gt.c        | 15 +++++-
 drivers/gpu/drm/i915/gt/intel_gt_types.h  |  3 ++
 drivers/gpu/drm/i915/gt/intel_gtt.h       |  3 ++
 drivers/gpu/drm/i915/i915_driver.c        | 19 +++++--
 drivers/gpu/drm/i915/i915_gem_evict.c     | 63 +++++++++++++++++------
 drivers/gpu/drm/i915/i915_vma.c           |  5 +-
 drivers/gpu/drm/i915/selftests/i915_gem.c |  2 +
 drivers/gpu/drm/i915/selftests/mock_gtt.c |  1 +
 9 files changed, 115 insertions(+), 45 deletions(-)
drivers/gpu/drm/i915/gt/intel_ggtt.c +10 -7
index 2518cebbf931..f5c2f3c58627 100644
@@ -196,10 +196,13 @@ void i915_ggtt_suspend_vm(struct i915_address_space *vm)
 
 void i915_ggtt_suspend(struct i915_ggtt *ggtt)
 {
+	struct intel_gt *gt;
+
 	i915_ggtt_suspend_vm(&ggtt->vm);
 	ggtt->invalidate(ggtt);
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 }
 
 void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)
@@ -214,27 +217,36 @@ void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)
 
 static void gen8_ggtt_invalidate(struct i915_ggtt *ggtt)
 {
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
+	struct intel_uncore *uncore;
+	struct intel_gt *gt;
 
-	/*
-	 * Note that as an uncached mmio write, this will flush the
-	 * WCB of the writes into the GGTT before it triggers the invalidate.
-	 */
-	intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link) {
+		uncore = gt->uncore;
+		/*
+		 * Note that as an uncached mmio write, this will flush the
Quoted 8 lines

drivers/gpu/drm/i915/gt/intel_ggtt.c void gen6_ggtt_invalidate(struct i915_ggtt *ggtt) · line 229

Quoted 3 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +3 -0
+		 * WCB of the writes into the GGTT before it triggers the invalidate.
+		 */
+		intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);

This isn't a GT register, so writing it for each GT doesn't do anything different than just writing it once. But actually it doesn't look like this is even a register we should be writing to anymore since Xe_HP. The GFX_FLSH_CNTL register no longer lives here.

Ok I'll remove the iteration over gt, also i do not see an equivalent register for Xe_HP, so i'll leave this as it is for now.

Quoted 98 lines
Quoted 98 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +16 -13
+	}
 }
 
 static void guc_ggtt_invalidate(struct i915_ggtt *ggtt)
 {
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
 	struct drm_i915_private *i915 = ggtt->vm.i915;
 
 	gen8_ggtt_invalidate(ggtt);
 
-	if (GRAPHICS_VER(i915) >= 12)
-		intel_uncore_write_fw(uncore, GEN12_GUC_TLB_INV_CR,
-				      GEN12_GUC_TLB_INV_CR_INVALIDATE);
-	else
-		intel_uncore_write_fw(uncore, GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	if (GRAPHICS_VER(i915) >= 12) {
+		struct intel_gt *gt;
+
+		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+			intel_uncore_write_fw(gt->uncore,
+					      GEN12_GUC_TLB_INV_CR,
+					      GEN12_GUC_TLB_INV_CR_INVALIDATE);
+	} else {
+		intel_uncore_write_fw(ggtt->vm.gt->uncore,
+				      GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	}
 }
 
 u64 gen8_ggtt_pte_encode(dma_addr_t addr,
@@ -986,8 +998,6 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 
 	ggtt->vm.pte_encode = gen8_ggtt_pte_encode;
 
-	setup_private_pat(ggtt->vm.gt);
-
 	return ggtt_probe_common(ggtt, size);
 }
 
@@ -1186,7 +1196,7 @@ static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct intel_gt *gt)
 		(u64)ggtt->mappable_end >> 20);
 	drm_dbg(&i915->drm, "DSM size = %lluM\n",
 		(u64)resource_size(&intel_graphics_stolen_res) >> 20);
-
+	INIT_LIST_HEAD(&ggtt->gt_list);
 	return 0;
 }
 
@@ -1296,9 +1306,11 @@ bool i915_ggtt_resume_vm(struct i915_address_space *vm)
 
 void i915_ggtt_resume(struct i915_ggtt *ggtt)
 {
+	struct intel_gt *gt;
 	bool flush;
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 
 	flush = i915_ggtt_resume_vm(&ggtt->vm);
 
@@ -1307,9 +1319,6 @@ void i915_ggtt_resume(struct i915_ggtt *ggtt)
 	if (flush)
 		wbinvd_on_all_cpus();
 
-	if (GRAPHICS_VER(ggtt->vm.i915) >= 8)
-		setup_private_pat(ggtt->vm.gt);
-
 	intel_ggtt_restore_fences(ggtt);
 }
 
drivers/gpu/drm/i915/gt/intel_gt.c +10 -2
index 2e796ffad911..d72efb74563a 100644
@@ -110,9 +110,17 @@ static int intel_gt_probe_lmem(struct intel_gt *gt)
 
 int intel_gt_assign_ggtt(struct intel_gt *gt)
 {
-	gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
+	/* Media GT shares primary GT's GGTT */
+	if (gt->type == GT_MEDIA) {
+		gt->ggtt = to_gt(gt->i915)->ggtt;
+	} else {
+		gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
+		if (!gt->ggtt)
+			return -ENOMEM;
+	}
 
-	return gt->ggtt ? 0 : -ENOMEM;
+	list_add_tail(&gt->ggtt_link, &gt->ggtt->gt_list);
+	return 0;
 }
 
 int intel_gt_init_mmio(struct intel_gt *gt)
@@ -965,6 +973,9 @@ int intel_gt_tiles_init(struct drm_i915_private *i915)
 	int ret;
 
Quoted 11 lines

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_tiles_init(struct drm_i915_private *i915) · line 978

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.c +3 -0
 	for_each_gt(gt, i915, id) {
+		if (GRAPHICS_VER(i915) >= 8)
+			setup_private_pat(gt);
+

Since the term "tile" is used for PVC-style remote tiles (which we have some framework for, but haven't enabled yet), it seems confusing to have the PAT setup for all GTs (including the standalone media GT) in a function called intel_gt_tiles_init(). Maybe we should also have a prep patch that renames this function if we're going to start doing non-tile things in here too?

i'll move this to i915_driver_hw_probe

Quoted 118 lines
Quoted 118 lines
drivers/gpu/drm/i915/gt/intel_gt.c +0 -0
 		ret = intel_gt_probe_lmem(gt);
 		if (ret)
 			return ret;
drivers/gpu/drm/i915/gt/intel_gt_types.h +3 -0
index 6f686a4244f0..aee37e9e79b0 100644
@@ -292,6 +292,9 @@ struct intel_gt {
 	struct kobject *sysfs_defaults;
 
 	struct i915_perf_gt perf;
+
+	/** link: &ggtt.gt_list */
+	struct list_head ggtt_link;
 };
 
 struct intel_gt_definition {
drivers/gpu/drm/i915/gt/intel_gtt.h +3 -0
index 4d75ba4bb41d..cb1272702a1a 100644
@@ -390,6 +390,9 @@ struct i915_ggtt {
 	struct mutex error_mutex;
 	struct drm_mm_node error_capture;
 	struct drm_mm_node uc_fw;
+
+	/** List of GTs mapping this GGTT */
+	struct list_head gt_list;
 };
 
 struct i915_ppgtt {
drivers/gpu/drm/i915/i915_driver.c +14 -5
index c3d43f9b1e45..6b973182ddcc 100644
@@ -577,7 +577,8 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 {
 	struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
 	struct pci_dev *root_pdev;
-	int ret;
+	struct intel_gt *gt;
+	int ret, i;
 
 	if (i915_inject_probe_failure(dev_priv))
 		return -ENODEV;
@@ -614,9 +615,11 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 
 	i915_perf_init(dev_priv);
 
-	ret = intel_gt_assign_ggtt(to_gt(dev_priv));
-	if (ret)
-		goto err_perf;
+	for_each_gt(gt, dev_priv, i) {
+		ret = intel_gt_assign_ggtt(gt);
+		if (ret)
+			goto err_perf;
+	}
 
 	ret = i915_ggtt_probe_hw(dev_priv);
 	if (ret)
@@ -1318,7 +1321,8 @@ int i915_driver_suspend_switcheroo(struct drm_i915_private *i915,
 static int i915_drm_resume(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	int ret;
+	struct intel_gt *gt;
+	int ret, i;
 
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -1333,6 +1337,11 @@ static int i915_drm_resume(struct drm_device *dev)
 		drm_err(&dev_priv->drm, "failed to re-enable GGTT\n");
 
 	i915_ggtt_resume(to_gt(dev_priv)->ggtt);
+
+	for_each_gt(gt, dev_priv, i)
+		if (GRAPHICS_VER(gt->i915) >= 8)
+			setup_private_pat(gt);
+
 	/* Must be called after GGTT is resumed. */
 	intel_dpt_resume(dev_priv);
 
drivers/gpu/drm/i915/i915_gem_evict.c +17 -9
index f025ee4fa526..e9d4352ebfb8 100644
@@ -43,16 +43,30 @@ static bool dying_vma(struct i915_vma *vma)
 	return !kref_read(&vma->obj->base.refcount);
 }
 
-static int ggtt_flush(struct intel_gt *gt)
+static int ggtt_flush(struct i915_address_space *vm)
 {
-	/*
-	 * Not everything in the GGTT is tracked via vma (otherwise we
-	 * could evict as required with minimal stalling) so we are forced
-	 * to idle the GPU and explicitly retire outstanding requests in
-	 * the hopes that we can then remove contexts and the like only
-	 * bound by their active reference.
-	 */
-	return intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT);
+	int ret = 0;
+
+	if (i915_is_ggtt(vm)) {
+		struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
+		struct intel_gt *gt;
+
+		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link) {
+			/*
+			 * Not everything in the GGTT is tracked via vma (otherwise we
+			 * could evict as required with minimal stalling) so we are forced
+			 * to idle the GPU and explicitly retire outstanding requests in
+			 * the hopes that we can then remove contexts and the like only
+			 * bound by their active reference.
+			 */
+			ret = intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT);
+			if (ret)
Quoted 9 lines

drivers/gpu/drm/i915/i915_gem_evict.c static bool dying_vma(struct i915_vma *vma) · line 67

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem_evict.c +4 -0
+				return ret;
+		}
+	} else {
+		ret = intel_gt_wait_for_idle(vm->gt, MAX_SCHEDULE_TIMEOUT);

This function is only ever got called on the GGTT as far as I can see (which makes sense given that its name starts with 'ggtt'). It's not clear to me why we want to handle PPGTT too now?

Thanks for catching this, it is indeed only used for GGTT, so this i915_is_ggtt check is not needed.

Quoted 78 lines

Even if this is intentional and correct, it might be best to move this up to a small if statement at the top of the function with a return so that we can eliminate a level of nesting from most of the function.

        if (!i915_is_ggtt(vm)) {
                wait for idle;
                return;
        }

        ...
Quoted 30 lines
drivers/gpu/drm/i915/i915_gem_evict.c +11 -1
+	}
+	return ret;
 }
 
 static bool grab_vma(struct i915_vma *vma, struct i915_gem_ww_ctx *ww)
@@ -149,6 +163,7 @@ i915_gem_evict_something(struct i915_address_space *vm,
 	struct drm_mm_node *node;
 	enum drm_mm_insert_mode mode;
 	struct i915_vma *active;
+	struct intel_gt *gt;
 	int ret;
 
 	lockdep_assert_held(&vm->mutex);
@@ -174,7 +189,14 @@ i915_gem_evict_something(struct i915_address_space *vm,
 				    min_size, alignment, color,
 				    start, end, mode);
 
-	intel_gt_retire_requests(vm->gt);
+	if (i915_is_ggtt(vm)) {
+		struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
+
+		list_for_each_entry_rcu(gt, &ggtt->gt_list, ggtt_link)
+			intel_gt_retire_requests(gt);
+	} else {
+		intel_gt_retire_requests(vm->gt);
+	}
 
 search_again:
 	active = NULL;

drivers/gpu/drm/i915/i915_gem_evict.c i915_gem_evict_something(struct i915_address_space *vm, · line 271

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_evict.c +1 -1
@@ -246,7 +268,7 @@ i915_gem_evict_something(struct i915_address_space *vm,
 	if (I915_SELFTEST_ONLY(igt_evict_ctl.fail_if_busy))
 		return -EBUSY;
 
-	ret = ggtt_flush(vm->gt);
+	ret = ggtt_flush(vm);

As noted above, this call is always done on GGTT (since we checked and returned if it wasn't GGTT just before this point in the function).

Quoted 27 lines
drivers/gpu/drm/i915/i915_gem_evict.c +9 -4
 	if (ret)
 		return ret;
 
@@ -332,7 +354,15 @@ int i915_gem_evict_for_node(struct i915_address_space *vm,
 	 * a stray pin (preventing eviction) that can only be resolved by
 	 * retiring.
 	 */
-	intel_gt_retire_requests(vm->gt);
+	if (i915_is_ggtt(vm)) {
+		struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
+		struct intel_gt *gt;
+
+		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+			intel_gt_retire_requests(gt);
+	} else {
+		intel_gt_retire_requests(vm->gt);
+	}
 
 	if (i915_vm_has_cache_coloring(vm)) {
 		/* Expand search to cover neighbouring guard pages (or lack!) */
@@ -437,11 +467,10 @@ int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww)
 	 * pin themselves inside the global GTT and performing the
 	 * switch otherwise is ineffective.
 	 */
-	if (i915_is_ggtt(vm)) {
-		ret = ggtt_flush(vm->gt);
-		if (ret)
Quoted 8 lines

drivers/gpu/drm/i915/i915_gem_evict.c int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww) · line 473

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_evict.c +4 -2
-			return ret;
-	}
+
+	ret = ggtt_flush(vm);
+	if (ret)
+		return ret;

It's not clear to me why we're removing the GGTT check here?

with the above change done, this will be restored.

Thanks,
Aravind.

Quoted 59 lines

Matt

Quoted 54 lines
drivers/gpu/drm/i915/i915_gem_evict.c +0 -0
 	do {
 		struct i915_vma *vma, *vn;
drivers/gpu/drm/i915/i915_vma.c +4 -1
index c39488eb9eeb..24cbee3c1ce5 100644
@@ -1542,6 +1542,8 @@ static int __i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 			   u32 align, unsigned int flags)
 {
 	struct i915_address_space *vm = vma->vm;
+	struct intel_gt *gt;
+	struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
 	int err;
 
 	do {
@@ -1557,7 +1559,8 @@ static int __i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 		}
 
 		/* Unlike i915_vma_pin, we don't take no for an answer! */
-		flush_idle_contexts(vm->gt);
+		list_for_each_entry_rcu(gt, &ggtt->gt_list, ggtt_link)
+			flush_idle_contexts(gt);
 		if (mutex_lock_interruptible(&vm->mutex) == 0) {
 			/*
 			 * We pass NULL ww here, as we don't want to unbind
drivers/gpu/drm/i915/selftests/i915_gem.c +2 -0
index e5dd82e7e480..2535b9684bd1 100644
@@ -127,6 +127,8 @@ static void igt_pm_resume(struct drm_i915_private *i915)
 	 */
 	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 		i915_ggtt_resume(to_gt(i915)->ggtt);
+		if (GRAPHICS_VER(i915) >= 8)
+			setup_private_pat(to_gt(i915));
 		i915_gem_resume(i915);
 	}
 }
drivers/gpu/drm/i915/selftests/mock_gtt.c +1 -0
index 568840e7ca66..b519d271f4fe 100644
@@ -127,6 +127,7 @@ void mock_init_ggtt(struct intel_gt *gt)
 	ggtt->vm.vma_ops.bind_vma    = mock_bind_ggtt;
 	ggtt->vm.vma_ops.unbind_vma  = mock_unbind_ggtt;
 
+	INIT_LIST_HEAD(&ggtt->gt_list);
 	i915_address_space_init(&ggtt->vm, VM_CLASS_GGTT);
 }
 
Signature · 1 line
2.25.1
#6 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/mtl: Media GT and Render GT share common GGTT

In reply to Aravind Iddamsetty
== Series Details ==

== Series Details ==

Series: drm/i915/mtl: Media GT and Render GT share common GGTT
URL : https://patchwork.freedesktop.org/series/110321/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_12325 -> Patchwork_110321v1
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_110321v1 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_110321v1, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/index.html

Participating hosts (40 -> 31)
------------------------------

Additional (3): fi-kbl-soraka fi-rkl-11600 fi-tgl-dsi
Missing (12): fi-cml-u2 bat-dg2-8 bat-adlm-1 bat-dg2-9 bat-adlp-6 bat-adlp-4 bat-adln-1 bat-rplp-1 bat-rpls-1 bat-rpls-2 bat-dg2-11 bat-jsl-1

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_module_load@load:
- fi-ilk-650: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-ilk-650/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-ilk-650/igt@[email protected]
- fi-bxt-dsi: [PASS][3] -> [DMESG-WARN][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-bxt-dsi/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bxt-dsi/igt@[email protected]
- fi-blb-e6850: [PASS][5] -> [DMESG-WARN][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-blb-e6850/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-blb-e6850/igt@[email protected]
- fi-rkl-11600: NOTRUN -> [DMESG-WARN][7]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-rkl-11600/igt@[email protected]
- fi-skl-6600u: [PASS][8] -> [INCOMPLETE][9]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-skl-6600u/igt@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-skl-6600u/igt@[email protected]
- fi-icl-u2: [PASS][10] -> [DMESG-WARN][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-icl-u2/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-icl-u2/igt@[email protected]
- fi-apl-guc: [PASS][12] -> [DMESG-WARN][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-apl-guc/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-apl-guc/igt@[email protected]
- fi-bdw-gvtdvm: [PASS][14] -> [DMESG-WARN][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-bdw-gvtdvm/igt@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bdw-gvtdvm/igt@[email protected]
- fi-pnv-d510: [PASS][16] -> [DMESG-WARN][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-pnv-d510/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-pnv-d510/igt@[email protected]
- fi-snb-2520m: [PASS][18] -> [DMESG-WARN][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-snb-2520m/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-snb-2520m/igt@[email protected]
- fi-glk-j4005: [PASS][20] -> [DMESG-WARN][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-glk-j4005/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-glk-j4005/igt@[email protected]
- fi-rkl-guc: [PASS][22] -> [DMESG-WARN][23]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-rkl-guc/igt@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-rkl-guc/igt@[email protected]
- fi-skl-guc: [PASS][24] -> [DMESG-WARN][25]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-skl-guc/igt@[email protected]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-skl-guc/igt@[email protected]
- fi-skl-6700k2: [PASS][26] -> [DMESG-WARN][27]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-skl-6700k2/igt@[email protected]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-skl-6700k2/igt@[email protected]
- fi-kbl-7567u: [PASS][28] -> [DMESG-WARN][29]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-kbl-7567u/igt@[email protected]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-kbl-7567u/igt@[email protected]
- fi-cfl-8700k: [PASS][30] -> [DMESG-WARN][31]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-cfl-8700k/igt@[email protected]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-cfl-8700k/igt@[email protected]
- fi-kbl-8809g: [PASS][32] -> [DMESG-WARN][33]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-kbl-8809g/igt@[email protected]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-kbl-8809g/igt@[email protected]
- fi-elk-e7500: [PASS][34] -> [DMESG-WARN][35]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-elk-e7500/igt@[email protected]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-elk-e7500/igt@[email protected]
- fi-bsw-nick: [PASS][36] -> [DMESG-WARN][37]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-bsw-nick/igt@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bsw-nick/igt@[email protected]
- fi-hsw-g3258: [PASS][38] -> [DMESG-WARN][39]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-hsw-g3258/igt@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-hsw-g3258/igt@[email protected]
- fi-bsw-kefka: [PASS][40] -> [DMESG-WARN][41]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-bsw-kefka/igt@[email protected]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bsw-kefka/igt@[email protected]
- fi-adl-ddr5: [PASS][42] -> [DMESG-WARN][43]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-adl-ddr5/igt@[email protected]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-adl-ddr5/igt@[email protected]
- fi-cfl-guc: [PASS][44] -> [DMESG-WARN][45]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-cfl-guc/igt@[email protected]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-cfl-guc/igt@[email protected]
- fi-bdw-5557u: [PASS][46] -> [DMESG-WARN][47]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-bdw-5557u/igt@[email protected]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bdw-5557u/igt@[email protected]
- fi-hsw-4770: [PASS][48] -> [DMESG-WARN][49]
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-hsw-4770/igt@[email protected]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-hsw-4770/igt@[email protected]
- fi-cfl-8109u: [PASS][50] -> [DMESG-WARN][51]
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-cfl-8109u/igt@[email protected]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-cfl-8109u/igt@[email protected]
- fi-ivb-3770: [PASS][52] -> [DMESG-WARN][53]
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-ivb-3770/igt@[email protected]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-ivb-3770/igt@[email protected]

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@i915_module_load@load:
- {fi-jsl-1}: [PASS][54] -> [DMESG-WARN][55]
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-jsl-1/igt@[email protected]
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-jsl-1/igt@[email protected]
- {fi-ehl-2}: [PASS][56] -> [DMESG-WARN][57]
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12325/fi-ehl-2/igt@[email protected]
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-ehl-2/igt@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@i915_module_load@load:
- fi-kbl-soraka: NOTRUN -> [DMESG-WARN][58] ([i915#1982])
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-kbl-soraka/igt@[email protected]

* igt@runner@aborted:
- fi-hsw-4770: NOTRUN -> [FAIL][59] ([i915#4312] / [i915#5594])
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-hsw-4770/igt@[email protected]
- fi-skl-6700k2: NOTRUN -> [FAIL][60] ([i915#4312])
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-skl-6700k2/igt@[email protected]
- fi-cfl-8109u: NOTRUN -> [FAIL][61] ([i915#4312])
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-cfl-8109u/igt@[email protected]
- fi-ivb-3770: NOTRUN -> [FAIL][62] ([i915#4312])
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-ivb-3770/igt@[email protected]
- fi-elk-e7500: NOTRUN -> [FAIL][63] ([i915#4312])
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-elk-e7500/igt@[email protected]
- fi-ilk-650: NOTRUN -> [FAIL][64] ([i915#4312])
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-ilk-650/igt@[email protected]
- fi-bxt-dsi: NOTRUN -> [FAIL][65] ([i915#4312])
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bxt-dsi/igt@[email protected]
- fi-blb-e6850: NOTRUN -> [FAIL][66] ([i915#4312])
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-blb-e6850/igt@[email protected]
- fi-icl-u2: NOTRUN -> [FAIL][67] ([i915#4312])
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-icl-u2/igt@[email protected]
- fi-apl-guc: NOTRUN -> [FAIL][68] ([i915#4312])
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-apl-guc/igt@[email protected]
- fi-pnv-d510: NOTRUN -> [FAIL][69] ([i915#4312])
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-pnv-d510/igt@[email protected]
- fi-bdw-5557u: NOTRUN -> [FAIL][70] ([i915#4312])
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bdw-5557u/igt@[email protected]
- fi-snb-2520m: NOTRUN -> [FAIL][71] ([i915#4312])
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-snb-2520m/igt@[email protected]
- fi-glk-j4005: NOTRUN -> [FAIL][72] ([i915#4312])
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-glk-j4005/igt@[email protected]
- fi-rkl-guc: NOTRUN -> [FAIL][73] ([i915#4312])
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-rkl-guc/igt@[email protected]
- fi-skl-guc: NOTRUN -> [FAIL][74] ([i915#4312])
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-skl-guc/igt@[email protected]
- fi-kbl-soraka: NOTRUN -> [FAIL][75] ([i915#4312] / [i915#4991])
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-kbl-soraka/igt@[email protected]
- fi-kbl-7567u: NOTRUN -> [FAIL][76] ([i915#4312])
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-kbl-7567u/igt@[email protected]
- fi-cfl-8700k: NOTRUN -> [FAIL][77] ([i915#4312])
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-cfl-8700k/igt@[email protected]
- fi-bsw-nick: NOTRUN -> [FAIL][78] ([i915#4312])
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bsw-nick/igt@[email protected]
- fi-rkl-11600: NOTRUN -> [FAIL][79] ([i915#4312])
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-rkl-11600/igt@[email protected]
- fi-hsw-g3258: NOTRUN -> [FAIL][80] ([i915#4312] / [i915#4991])
[80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-hsw-g3258/igt@[email protected]
- fi-bdw-gvtdvm: NOTRUN -> [FAIL][81] ([i915#4312])
[81]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bdw-gvtdvm/igt@[email protected]
- fi-bsw-kefka: NOTRUN -> [FAIL][82] ([i915#4312])
[82]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-bsw-kefka/igt@[email protected]
- fi-adl-ddr5: NOTRUN -> [FAIL][83] ([i915#4312])
[83]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-adl-ddr5/igt@[email protected]
- fi-cfl-guc: NOTRUN -> [FAIL][84] ([i915#4312])
[84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/fi-cfl-guc/igt@[email protected]

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

[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4991]: https://gitlab.freedesktop.org/drm/intel/issues/4991
[i915#5594]: https://gitlab.freedesktop.org/drm/intel/issues/5594

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

* Linux: CI_DRM_12325 -> Patchwork_110321v1

CI-20190529: 20190529
CI_DRM_12325: 1a90222aa5e5bb86ffcbde5ba9611659a23f0df6 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7032: 372c56225e12578a7a4a6bcc5b79eb40b643fcde @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_110321v1: 1a90222aa5e5bb86ffcbde5ba9611659a23f0df6 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

98facd573422 drm/i915/mtl: Media GT and Render GT share common GGTT

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110321v1/index.html

#7 lore raw
In reply to Aravind Iddamsetty
Quoted 139 lines · Aravind Iddamsetty

On XE_LPM+ platforms the media engines are carved out into a separate GT but have a common GGTMMADR address range which essentially makes the GGTT address space to be shared between media and render GT.

BSPEC: 63834

---

drivers/gpu/drm/i915/gt/intel_ggtt.c      | 49 +++++++++++-------
drivers/gpu/drm/i915/gt/intel_gt.c        | 15 +++++-
drivers/gpu/drm/i915/gt/intel_gt_types.h  |  3 ++
drivers/gpu/drm/i915/gt/intel_gtt.h       |  3 ++
drivers/gpu/drm/i915/i915_driver.c        | 19 +++++--
drivers/gpu/drm/i915/i915_gem_evict.c     | 63 +++++++++++++++++------
drivers/gpu/drm/i915/i915_vma.c           |  5 +-
drivers/gpu/drm/i915/selftests/i915_gem.c |  2 +
drivers/gpu/drm/i915/selftests/mock_gtt.c |  1 +
9 files changed, 115 insertions(+), 45 deletions(-)
drivers/gpu/drm/i915/gt/intel_ggtt.c +29 -20
index 2518cebbf931..f5c2f3c58627 100644
@@ -196,10 +196,13 @@ void i915_ggtt_suspend_vm(struct i915_address_space *vm)
 
 void i915_ggtt_suspend(struct i915_ggtt *ggtt)
 {
+	struct intel_gt *gt;
+
 	i915_ggtt_suspend_vm(&ggtt->vm);
 	ggtt->invalidate(ggtt);
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 }
 
 void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)
@@ -214,27 +217,36 @@ void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)
 
 static void gen8_ggtt_invalidate(struct i915_ggtt *ggtt)
 {
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
+	struct intel_uncore *uncore;
+	struct intel_gt *gt;
 
-	/*
-	 * Note that as an uncached mmio write, this will flush the
-	 * WCB of the writes into the GGTT before it triggers the invalidate.
-	 */
-	intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link) {
+		uncore = gt->uncore;
+		/*
+		 * Note that as an uncached mmio write, this will flush the
+		 * WCB of the writes into the GGTT before it triggers the invalidate.
+		 */
+		intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
+	}
 }
 
 static void guc_ggtt_invalidate(struct i915_ggtt *ggtt)
 {
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
 	struct drm_i915_private *i915 = ggtt->vm.i915;
 
 	gen8_ggtt_invalidate(ggtt);
 
-	if (GRAPHICS_VER(i915) >= 12)
-		intel_uncore_write_fw(uncore, GEN12_GUC_TLB_INV_CR,
-				      GEN12_GUC_TLB_INV_CR_INVALIDATE);
-	else
-		intel_uncore_write_fw(uncore, GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	if (GRAPHICS_VER(i915) >= 12) {
+		struct intel_gt *gt;
+
+		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+			intel_uncore_write_fw(gt->uncore,
+					      GEN12_GUC_TLB_INV_CR,
+					      GEN12_GUC_TLB_INV_CR_INVALIDATE);
+	} else {
+		intel_uncore_write_fw(ggtt->vm.gt->uncore,
+				      GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	}
 }
 
 u64 gen8_ggtt_pte_encode(dma_addr_t addr,
@@ -986,8 +998,6 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 
 	ggtt->vm.pte_encode = gen8_ggtt_pte_encode;
 
-	setup_private_pat(ggtt->vm.gt);
-
 	return ggtt_probe_common(ggtt, size);
 }
 
@@ -1186,7 +1196,7 @@ static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct intel_gt *gt)
 		(u64)ggtt->mappable_end >> 20);
 	drm_dbg(&i915->drm, "DSM size = %lluM\n",
 		(u64)resource_size(&intel_graphics_stolen_res) >> 20);
-
+	INIT_LIST_HEAD(&ggtt->gt_list);
 	return 0;
 }
 
@@ -1296,9 +1306,11 @@ bool i915_ggtt_resume_vm(struct i915_address_space *vm)
 
 void i915_ggtt_resume(struct i915_ggtt *ggtt)
 {
+	struct intel_gt *gt;
 	bool flush;
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 
 	flush = i915_ggtt_resume_vm(&ggtt->vm);
 
@@ -1307,9 +1319,6 @@ void i915_ggtt_resume(struct i915_ggtt *ggtt)
 	if (flush)
 		wbinvd_on_all_cpus();
 
-	if (GRAPHICS_VER(ggtt->vm.i915) >= 8)
-		setup_private_pat(ggtt->vm.gt);
-
 	intel_ggtt_restore_fences(ggtt);
 }
 
drivers/gpu/drm/i915/gt/intel_gt.c +1 -1
index 2e796ffad911..d72efb74563a 100644
@@ -110,9 +110,17 @@ static int intel_gt_probe_lmem(struct intel_gt *gt)
 
 int intel_gt_assign_ggtt(struct intel_gt *gt)
 {
-	gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
+	/* Media GT shares primary GT's GGTT */

drivers/gpu/drm/i915/gt/intel_gt.c static int intel_gt_probe_lmem(struct intel_gt *gt) · line 122

Quoted 10 lines
drivers/gpu/drm/i915/gt/intel_gt.c +8 -1
+	if (gt->type == GT_MEDIA) {
+		gt->ggtt = to_gt(gt->i915)->ggtt;
+	} else {
+		gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
+		if (!gt->ggtt)
+			return -ENOMEM;
+	}
 
-	return gt->ggtt ? 0 : -ENOMEM;
+	list_add_tail(&gt->ggtt_link, &gt->ggtt->gt_list);

I don't think this really works. You're adding to &gt->ggtt->gt_list that you just allocated above. I had this patch applied and noticed this:

[  151.417250] ------------[ cut here ]------------
[  151.417251] list_add corruption. prev is NULL.
[  151.417254] WARNING: CPU: 10 PID: 1780 at lib/list_debug.c:23 __list_add_valid+0x3e/0xb0
[  151.417259] Modules linked in: i915(+) prime_numbers drm_buddy drm_display_helper drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm overlay fuse x86_pkg_temp_thermal coretemp crct10dif_pclmul crc32_pclmul wmi_bmof ghash_clmulni_intel kvm_intel video wmi ip_tables x_tables e1000e igb dca ptp i2c_i801 i2c_smbus pps_core
[  151.417299] CPU: 10 PID: 1780 Comm: modprobe Tainted: G        W          6.0.0 #382
[  151.417302] XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[  151.417304] RIP: 0010:__list_add_valid+0x3e/0xb0
[  151.417307] Code: 75 46 4c 8b 0a 4d 39 c1 75 56 48 39 fa 74 6f 49 39 f9 74 6a b8 01 00 00 00 c3 cc cc cc cc 48 c7 c7 c0 57 5f 82 e8 96 9c 61 00 <0f> 0b 31 c0 c3 cc cc cc cc 48 c7 c7 e8 57 5f 82 e8 81 9c 61 00 0f
[  151.417309] RSP: 0018:ffffc90005787b80 EFLAGS: 00010282
[  151.417313] RAX: 0000000000000000 RBX: ffff8881428fb778 RCX: 0000000000000000
[  151.417315] RDX: 0000000000000001 RSI: ffffffff825e0c4c RDI: 00000000ffffffff
[  151.417316] RBP: ffff88813f6c3828 R08: ffff88849effffe8 R09: 00000000fffdffff
[  151.417318] R10: ffff88849e200000 R11: ffff88849ed00000 R12: 0000000000000000
[  151.417320] R13: ffff8881428fdaa0 R14: ffff88813f6c3f50 R15: ffff8881428fdab0
[  151.417322] FS:  00007fc71052d540(0000) GS:ffff88849f900000(0000) knlGS:0000000000000000
[  151.417325] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  151.417327] CR2: 0000555a8fad6858 CR3: 000000013b7f4006 CR4: 0000000000770ee0
[  151.417329] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  151.417331] DR3: 0000000000000000 DR6: 00000000ffff07f0 DR7: 0000000000000400
[  151.417332] PKRU: 55555554
[  151.417333] Call Trace:
[  151.417335]  <TASK>
[  151.417336]  intel_gt_assign_ggtt+0x42/0xa0 [i915]

I think something like below would do it (untested):

drivers/gpu/drm/i915/gt/intel_ggtt.c +15 -1
index c1e23b4be8ed6..454b668108457 100644
@@ -8,6 +8,7 @@
 #include <linux/types.h>
 #include <linux/stop_machine.h>
 
+#include <drm/drm_managed.h>
 #include <drm/i915_drm.h>
 #include <drm/intel-gtt.h>
 
@@ -1196,7 +1197,7 @@ static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct intel_gt *gt)
 		(u64)ggtt->mappable_end >> 20);
 	drm_dbg(&i915->drm, "DSM size = %lluM\n",
 		(u64)resource_size(&intel_graphics_stolen_res) >> 20);
-	INIT_LIST_HEAD(&ggtt->gt_list);
+
 	return 0;
 }
 
@@ -1218,6 +1219,19 @@ int i915_ggtt_probe_hw(struct drm_i915_private *i915)
 	return 0;
 }
 
+struct i915_ggtt *i915_ggtt_create(struct drm_i915_private *i915)
+{
+	struct i915_ggtt *ggtt;
+
+	ggtt = drmm_kzalloc(&i915->drm, sizeof(*ggtt), GFP_KERNEL);
+	if (!ggtt)
+		return ERR_PTR(-ENOMEM);
+
+	INIT_LIST_HEAD(&ggtt->gt_list);
+
+	return ggtt;
+}
+
 int i915_ggtt_enable_hw(struct drm_i915_private *i915)
 {
 	if (GRAPHICS_VER(i915) < 6)
drivers/gpu/drm/i915/gt/intel_gt.c +4 -3
index 143359acde5a7..ea3b895dbe6b7 100644
@@ -115,12 +115,13 @@ int intel_gt_assign_ggtt(struct intel_gt *gt)
 	if (gt->type == GT_MEDIA) {
 		gt->ggtt = to_gt(gt->i915)->ggtt;
 	} else {
-		gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
-		if (!gt->ggtt)
-			return -ENOMEM;
+		gt->ggtt = i915_ggtt_create(gt->i915);
+		if (IS_ERR(gt->ggtt))
+			return PTR_ERR(gt->ggtt);
 	}
 
 	list_add_tail(&gt->ggtt_link, &gt->ggtt->gt_list);
+
 	return 0;
 }
 
drivers/gpu/drm/i915/gt/intel_gtt.h +1 -0
index cb1272702a1a1..f2a608c182c82 100644
@@ -585,6 +585,7 @@ int i915_ggtt_enable_hw(struct drm_i915_private *i915);
 void i915_ggtt_enable_guc(struct i915_ggtt *ggtt);
 void i915_ggtt_disable_guc(struct i915_ggtt *ggtt);
 int i915_init_ggtt(struct drm_i915_private *i915);
+struct i915_ggtt *i915_ggtt_create(struct drm_i915_private *i915);
 void i915_ggtt_driver_release(struct drm_i915_private *i915);
 void i915_ggtt_driver_late_release(struct drm_i915_private *i915);
 
Signature · 1 line
2.38.1
#8 lore raw

Hi Lucas,

Quoted 242 lines

-----Original Message-----
From: De Marchi, Lucas <[email protected]>
Sent: Friday, November 4, 2022 12:36 PM
To: Iddamsetty, Aravind <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [Intel-gfx] [PATCH] drm/i915/mtl: Media GT and Render GT share common GGTT

Quoted 2 lines · Aravind Iddamsetty

On XE_LPM+ platforms the media engines are carved out into a separate GT but have a common GGTMMADR address range which essentially makes

the

Quoted 41 lines

GGTT address space to be shared between media and render GT.

BSPEC: 63834

---

drivers/gpu/drm/i915/gt/intel_ggtt.c      | 49 +++++++++++-------
drivers/gpu/drm/i915/gt/intel_gt.c        | 15 +++++-
drivers/gpu/drm/i915/gt/intel_gt_types.h  |  3 ++
drivers/gpu/drm/i915/gt/intel_gtt.h       |  3 ++
drivers/gpu/drm/i915/i915_driver.c        | 19 +++++--
drivers/gpu/drm/i915/i915_gem_evict.c     | 63 +++++++++++++++++------
drivers/gpu/drm/i915/i915_vma.c           |  5 +-
drivers/gpu/drm/i915/selftests/i915_gem.c |  2 +
drivers/gpu/drm/i915/selftests/mock_gtt.c |  1 +
9 files changed, 115 insertions(+), 45 deletions(-)
drivers/gpu/drm/i915/gt/intel_ggtt.c +4 -1
index 2518cebbf931..f5c2f3c58627 100644
@@ -196,10 +196,13 @@ void i915_ggtt_suspend_vm(struct
 i915_address_space *vm)
 
 void i915_ggtt_suspend(struct i915_ggtt *ggtt) {
+	struct intel_gt *gt;
+
 	i915_ggtt_suspend_vm(&ggtt->vm);
 	ggtt->invalidate(ggtt);
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 }
 

void gen6_ggtt_invalidate(struct i915_ggtt *ggtt) @@ -214,27 +217,36 @@ void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)

static void gen8_ggtt_invalidate(struct i915_ggtt *ggtt) {

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

Quoted 9 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +2 -6
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
+	struct intel_uncore *uncore;
+	struct intel_gt *gt;
 
-	/*
-	 * Note that as an uncached mmio write, this will flush the
-	 * WCB of the writes into the GGTT before it triggers the invalidate.
-	 */
-	intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6,

GFX_FLSH_CNTL_EN);

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

Quoted 5 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +5 -0
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link) {
+		uncore = gt->uncore;
+		/*
+		 * Note that as an uncached mmio write, this will flush the
+		 * WCB of the writes into the GGTT before it triggers the

invalidate.

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

Quoted 2 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +2 -0
+		 */
+		intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6,

GFX_FLSH_CNTL_EN);

Quoted 9 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +1 -0
+	}

}

static void guc_ggtt_invalidate(struct i915_ggtt *ggtt) {

drivers/gpu/drm/i915/gt/intel_ggtt.c +0 -1
-	struct intel_uncore *uncore = ggtt->vm.gt->uncore;
	struct drm_i915_private *i915 = ggtt->vm.i915;

	gen8_ggtt_invalidate(ggtt);

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

Quoted 5 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +0 -5
-	if (GRAPHICS_VER(i915) >= 12)
-		intel_uncore_write_fw(uncore, GEN12_GUC_TLB_INV_CR,
-				      GEN12_GUC_TLB_INV_CR_INVALIDATE);
-	else
-		intel_uncore_write_fw(uncore, GEN8_GTCR,

GEN8_GTCR_INVALIDATE);

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

Quoted 7 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +7 -0
+	if (GRAPHICS_VER(i915) >= 12) {
+		struct intel_gt *gt;
+
+		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+			intel_uncore_write_fw(gt->uncore,
+					      GEN12_GUC_TLB_INV_CR,
+

GEN12_GUC_TLB_INV_CR_INVALIDATE);

Quoted 7 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +4 -0
+	} else {
+		intel_uncore_write_fw(ggtt->vm.gt->uncore,
+				      GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	}

}

u64 gen8_ggtt_pte_encode(dma_addr_t addr, @@ -986,8 +998,6 @@

static

drivers/gpu/drm/i915/gt/intel_ggtt.c static int ggtt_probe_hw(struct i915_ggtt *ggtt,

Quoted 9 lines

int gen8_gmch_probe(struct i915_ggtt *ggtt)

	ggtt->vm.pte_encode = gen8_ggtt_pte_encode;
drivers/gpu/drm/i915/gt/intel_ggtt.c +0 -2
-	setup_private_pat(ggtt->vm.gt);
-
	return ggtt_probe_common(ggtt, size);  }
drivers/gpu/drm/i915/gt/intel_ggtt.c +0 -0
@@ -1186,7 +1196,7 @@ static int ggtt_probe_hw(struct i915_ggtt *ggtt,

struct intel_gt *gt)

Quoted 37 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +4 -5
 		(u64)ggtt->mappable_end >> 20);
 	drm_dbg(&i915->drm, "DSM size = %lluM\n",
 		(u64)resource_size(&intel_graphics_stolen_res) >> 20);
-
+	INIT_LIST_HEAD(&ggtt->gt_list);
 	return 0;
 }
 
@@ -1296,9 +1306,11 @@ bool i915_ggtt_resume_vm(struct
 i915_address_space *vm)
 
 void i915_ggtt_resume(struct i915_ggtt *ggtt) {
+	struct intel_gt *gt;
 	bool flush;
 
-	intel_gt_check_and_clear_faults(ggtt->vm.gt);
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
+		intel_gt_check_and_clear_faults(gt);
 
 	flush = i915_ggtt_resume_vm(&ggtt->vm);
 
@@ -1307,9 +1319,6 @@ void i915_ggtt_resume(struct i915_ggtt *ggtt)
 	if (flush)
 		wbinvd_on_all_cpus();
 
-	if (GRAPHICS_VER(ggtt->vm.i915) >= 8)
-		setup_private_pat(ggtt->vm.gt);
-
 	intel_ggtt_restore_fences(ggtt);
 }
 
drivers/gpu/drm/i915/gt/intel_gt.c +0 -0
index 2e796ffad911..d72efb74563a 100644

drivers/gpu/drm/i915/gt/intel_gt.c static int intel_gt_probe_lmem(struct intel_gt · line 113

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.c +0 -1
@@ -110,9 +110,17 @@ static int intel_gt_probe_lmem(struct intel_gt
 *gt)
 
 int intel_gt_assign_ggtt(struct intel_gt *gt)  {
-	gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt),

GFP_KERNEL);

drivers/gpu/drm/i915/gt/intel_gt.c static int intel_gt_probe_lmem(struct intel_gt · line 117

Quoted 5 lines
drivers/gpu/drm/i915/gt/intel_gt.c +5 -0
+	/* Media GT shares primary GT's GGTT */
+	if (gt->type == GT_MEDIA) {
+		gt->ggtt = to_gt(gt->i915)->ggtt;
+	} else {
+		gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt),

GFP_KERNEL);

drivers/gpu/drm/i915/gt/intel_gt.c static int intel_gt_probe_lmem(struct intel_gt · line 122

Quoted 6 lines
drivers/gpu/drm/i915/gt/intel_gt.c +4 -1
+		if (!gt->ggtt)
+			return -ENOMEM;
+	}
 
-	return gt->ggtt ? 0 : -ENOMEM;
+	list_add_tail(&gt->ggtt_link, &gt->ggtt->gt_list);

I don't think this really works. You're adding to &gt->ggtt->gt_list that you just allocated above. I had this patch applied and noticed
this:

[  151.417250] ------------[ cut here ]------------ [  151.417251] list_add
corruption. prev is NULL.
[  151.417254] WARNING: CPU: 10 PID: 1780 at lib/list_debug.c:23

__list_add_valid+0x3e/0xb0 [ 151.417259] Modules linked in: i915(+) prime_numbers drm_buddy drm_display_helper drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm overlay fuse x86_pkg_temp_thermal coretemp crct10dif_pclmul crc32_pclmul wmi_bmof ghash_clmulni_intel kvm_intel video wmi ip_tables x_tables e1000e igb dca ptp i2c_i801 i2c_smbus pps_core

[  151.417299] CPU: 10 PID: 1780 Comm: modprobe Tainted: G        W
6.0.0 #382
[  151.417302]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXX
[  151.417304] RIP: 0010:__list_add_valid+0x3e/0xb0 [  151.417307] Code: 75

46 4c 8b 0a 4d 39 c1 75 56 48 39 fa 74 6f 49 39 f9 74 6a b8 01 00 00 00 c3 cc cc cc cc 48 c7 c7 c0 57 5f 82 e8 96 9c 61 00 <0f> 0b 31 c0 c3 cc cc cc cc 48 c7 c7 e8 57 5f 82 e8 81 9c 61 00 0f [ 151.417309] RSP: 0018:ffffc90005787b80 EFLAGS:
00010282 [ 151.417313] RAX: 0000000000000000 RBX: ffff8881428fb778 RCX:
0000000000000000 [ 151.417315] RDX: 0000000000000001 RSI:
ffffffff825e0c4c RDI: 00000000ffffffff [ 151.417316] RBP: ffff88813f6c3828
R08: ffff88849effffe8 R09: 00000000fffdffff [ 151.417318] R10:
ffff88849e200000 R11: ffff88849ed00000 R12: 0000000000000000 [ 151.417320] R13: ffff8881428fdaa0 R14: ffff88813f6c3f50 R15:
ffff8881428fdab0 [ 151.417322] FS: 00007fc71052d540(0000) GS:ffff88849f900000(0000) knlGS:0000000000000000 [ 151.417325] CS: 0010
DS: 0000 ES: 0000 CR0: 0000000080050033 [ 151.417327] CR2:
0000555a8fad6858 CR3: 000000013b7f4006 CR4: 0000000000770ee0 [ 151.417329] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
0000000000000000 [ 151.417331] DR3: 0000000000000000 DR6:
00000000ffff07f0 DR7: 0000000000000400 [ 151.417332] PKRU: 55555554 [ 151.417333] Call Trace:

[  151.417335]  <TASK>
[  151.417336]  intel_gt_assign_ggtt+0x42/0xa0 [i915]

I think something like below would do it (untested):

drivers/gpu/drm/i915/gt/intel_ggtt.c +4 -1
index c1e23b4be8ed6..454b668108457 100644
@@ -8,6 +8,7 @@
  #include <linux/types.h>
  #include <linux/stop_machine.h>
 
+#include <drm/drm_managed.h>
  #include <drm/i915_drm.h>
  #include <drm/intel-gtt.h>
 
@@ -1196,7 +1197,7 @@ static int ggtt_probe_hw(struct i915_ggtt *ggtt,
 struct intel_gt *gt)
  		(u64)ggtt->mappable_end >> 20);
  	drm_dbg(&i915->drm, "DSM size = %lluM\n",
  		(u64)resource_size(&intel_graphics_stolen_res) >> 20);
-	INIT_LIST_HEAD(&ggtt->gt_list);
+
  	return 0;
  }
@@ -1218,6 +1219,19 @@ int i915_ggtt_probe_hw(struct drm_i915_private
 *i915)
  	return 0;
  }
 
+struct i915_ggtt *i915_ggtt_create(struct drm_i915_private *i915) {
+	struct i915_ggtt *ggtt;

drivers/gpu/drm/i915/gt/intel_ggtt.c int i915_ggtt_probe_hw(struct drm_i915_private · line 1234

Quoted 10 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +10 -0
+
+	ggtt = drmm_kzalloc(&i915->drm, sizeof(*ggtt), GFP_KERNEL);
+	if (!ggtt)
+		return ERR_PTR(-ENOMEM);
+
+	INIT_LIST_HEAD(&ggtt->gt_list);
+
+	return ggtt;
+}
+

Thanks for sharing it, I will try it out.

Regards,
Aravind.

Quoted 42 lines
drivers/gpu/drm/i915/gt/intel_ggtt.c +0 -0
  int i915_ggtt_enable_hw(struct drm_i915_private *i915)
  {
  	if (GRAPHICS_VER(i915) < 6)
drivers/gpu/drm/i915/gt/intel_gt.c +4 -3
index 143359acde5a7..ea3b895dbe6b7 100644
@@ -115,12 +115,13 @@ int intel_gt_assign_ggtt(struct intel_gt *gt)
  	if (gt->type == GT_MEDIA) {
  		gt->ggtt = to_gt(gt->i915)->ggtt;
  	} else {
-		gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt),
 GFP_KERNEL);
-		if (!gt->ggtt)
-			return -ENOMEM;
+		gt->ggtt = i915_ggtt_create(gt->i915);
+		if (IS_ERR(gt->ggtt))
+			return PTR_ERR(gt->ggtt);
  	}
 
  	list_add_tail(&gt->ggtt_link, &gt->ggtt->gt_list);
+
  	return 0;
  }
drivers/gpu/drm/i915/gt/intel_gtt.h +1 -1
index cb1272702a1a1..f2a608c182c82 100644
@@ -585,6 +585,7 @@ int i915_ggtt_enable_hw(struct drm_i915_private
 *i915);
  void i915_ggtt_enable_guc(struct i915_ggtt *ggtt);
  void i915_ggtt_disable_guc(struct i915_ggtt *ggtt);
  int i915_init_ggtt(struct drm_i915_private *i915);
+struct i915_ggtt *i915_ggtt_create(struct drm_i915_private *i915);
  void i915_ggtt_driver_release(struct drm_i915_private *i915);
  void i915_ggtt_driver_late_release(struct drm_i915_private *i915);
 
--

2.38.1

#9 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915/mtl: Media GT and Render GT share common GGTT (rev2)

In reply to Aravind Iddamsetty
== Series Details ==

== Series Details ==

Series: drm/i915/mtl: Media GT and Render GT share common GGTT (rev2)
URL : https://patchwork.freedesktop.org/series/110321/
State : failure

== Summary ==

Error: patch https://patchwork.freedesktop.org/api/1.0/series/110321/revisions/2/mbox/ not applied
Applying: drm/i915/mtl: Media GT and Render GT share common GGTT
error: sha1 information is lacking or useless (drivers/gpu/drm/i915/gt/intel_ggtt.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 drm/i915/mtl: Media GT and Render GT share common GGTT
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".