Skip to contentSkip to conversation

drm/i915/display: Check GGTT to determine phys_base

PATCH Superseded Paz Zcharya 3 participants 3 messages Nov 30, 2023 – Dec 5, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/display: Check GGTT to determine phys_base

There was an assumption that for iGPU there should be a 1:1 mapping of GGTT to physical address pointing to actual framebuffer. This assumption is not valid anymore for MTL.
Fix that by checking GGTT to determine the phys address.

The following algorithm for phys_base should be valid for all platforms:
1. Find pte
2. if(IS_DGFX(i915) && pte & GEN12_GGTT_PTE_LM) mem = i915->mm.regions[INTEL_REGION_LMEM_0] else mem = i915->mm.stolen_region
3. phys_base = (pte & I915_GTT_PAGE_MASK) - mem->region.start;

- On older platforms, stolen_region points to system memory, starting at 0
- on DG2, it uses lmem region which starts at 0 as well
- on MTL, stolen_region points to stolen-local which starts at 0x800000

---

 .../drm/i915/display/intel_plane_initial.c    | 45 +++++++++----------
 1 file changed, 22 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/display/intel_plane_initial.c +22 -23
index a55c09cbd0e4..c4bf02ea966c 100644
@@ -51,6 +51,8 @@ initial_plane_vma(struct drm_i915_private *i915,
 	struct intel_memory_region *mem;
 	struct drm_i915_gem_object *obj;
 	struct i915_vma *vma;
+	gen8_pte_t __iomem *gte = to_gt(i915)->ggtt->gsm;
+	gen8_pte_t pte;
 	resource_size_t phys_base;
 	u32 base, size;
 	u64 pinctl;
@@ -59,44 +61,41 @@ initial_plane_vma(struct drm_i915_private *i915,
 		return NULL;
 
 	base = round_down(plane_config->base, I915_GTT_MIN_ALIGNMENT);
-	if (IS_DGFX(i915)) {
-		gen8_pte_t __iomem *gte = to_gt(i915)->ggtt->gsm;
-		gen8_pte_t pte;
+	gte += base / I915_GTT_PAGE_SIZE;
 
-		gte += base / I915_GTT_PAGE_SIZE;
+	pte = ioread64(gte);
 
-		pte = ioread64(gte);
+	if (IS_DGFX(i915)) {
 		if (!(pte & GEN12_GGTT_PTE_LM)) {
 			drm_err(&i915->drm,
 				"Initial plane programming missing PTE_LM bit\n");
 			return NULL;
 		}
-
-		phys_base = pte & I915_GTT_PAGE_MASK;
 		mem = i915->mm.regions[INTEL_REGION_LMEM_0];
-
-		/*
-		 * We don't currently expect this to ever be placed in the
-		 * stolen portion.
-		 */
-		if (phys_base >= resource_size(&mem->region)) {
-			drm_err(&i915->drm,
-				"Initial plane programming using invalid range, phys_base=%pa\n",
-				&phys_base);
-			return NULL;
-		}
-
-		drm_dbg(&i915->drm,
-			"Using phys_base=%pa, based on initial plane programming\n",
-			&phys_base);
 	} else {
-		phys_base = base;
 		mem = i915->mm.stolen_region;
 	}
 
+	phys_base = (pte & I915_GTT_PAGE_MASK) - mem->region.start;
+
 	if (!mem)
 		return NULL;
 
+	/*
+	 * We don't currently expect this to ever be placed in the
+	 * stolen portion.
+	 */
+	if (phys_base >= resource_size(&mem->region)) {
+		drm_err(&i915->drm,
+			"Initial plane programming using invalid range, phys_base=%pa\n",
+			&phys_base);
+		return NULL;
+	}
+
+	drm_dbg(&i915->drm,
+		"Using phys_base=%pa, based on initial plane programming\n",
+		&phys_base);
+
 	size = round_up(plane_config->base + plane_config->size,
 			mem->min_page_size);
 	size -= base;
Signature · 1 line
2.43.0.rc1.413.gea7ed67945-goog
#1 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/display: Check GGTT to determine phys_base

== Series Details ==

== Series Details ==

Series: drm/i915/display: Check GGTT to determine phys_base
URL : https://patchwork.freedesktop.org/series/127130/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13956 -> Patchwork_127130v1
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_127130v1, please notify your bug team ([email protected]) 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_127130v1/index.html

Participating hosts (39 -> 37)
------------------------------

Missing (2): fi-snb-2520m fi-pnv-d510

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_module_load@load:
- fi-ivb-3770: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13956/fi-ivb-3770/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127130v1/fi-ivb-3770/igt@[email protected]
- bat-mtlp-8: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13956/bat-mtlp-8/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127130v1/bat-mtlp-8/igt@[email protected]

* igt@i915_selftest@live@workarounds:
- bat-rpls-1: [PASS][5] -> [INCOMPLETE][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13956/bat-rpls-1/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127130v1/bat-rpls-1/igt@i915_selftest@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_lmem_swapping@basic:
- fi-apl-guc: NOTRUN -> [SKIP][7] ([fdo#109271] / [i915#4613]) +3 other tests skip
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127130v1/fi-apl-guc/igt@[email protected]

* igt@i915_selftest@live@gt_heartbeat:
- fi-apl-guc: NOTRUN -> [DMESG-FAIL][8] ([i915#5334])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127130v1/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html

* igt@i915_suspend@basic-s3-without-i915:
- bat-jsl-3: [PASS][9] -> [FAIL][10] ([fdo#103375])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13956/bat-jsl-3/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127130v1/bat-jsl-3/igt@[email protected]

* igt@kms_hdmi_inject@inject-audio:
- fi-kbl-guc: [PASS][11] -> [FAIL][12] ([IGT#3])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13956/fi-kbl-guc/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127130v1/fi-kbl-guc/igt@[email protected]

#### Possible fixes ####

* igt@core_hotunplug@unbind-rebind:
- fi-apl-guc: [ABORT][13] ([i915#8213] / [i915#8668]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13956/fi-apl-guc/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127130v1/fi-apl-guc/igt@[email protected]

[IGT#3]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/3
[fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#8213]: https://gitlab.freedesktop.org/drm/intel/issues/8213
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668

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

* Linux: CI_DRM_13956 -> Patchwork_127130v1

CI-20190529: 20190529
CI_DRM_13956: b59a0a6520764f36a79ba6b4c590e243ac6b913d @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7612: b5c47966901ee1060bcb9d4bccdd3ccec9651ef4 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_127130v1: b59a0a6520764f36a79ba6b4c590e243ac6b913d @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

ae964dda09d2 drm/i915/display: Check GGTT to determine phys_base

== Logs ==

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

#2 lore raw
In reply to Paz Zcharya
Quoted 11 lines · Paz Zcharya

There was an assumption that for iGPU there should be a 1:1 mapping of GGTT to physical address pointing to actual framebuffer. This assumption is not valid anymore for MTL.
Fix that by checking GGTT to determine the phys address.

The following algorithm for phys_base should be valid for all platforms:
1. Find pte
2. if(IS_DGFX(i915) && pte & GEN12_GGTT_PTE_LM) mem = i915->mm.regions[INTEL_REGION_LMEM_0] else mem = i915->mm.stolen_region
3. phys_base = (pte & I915_GTT_PAGE_MASK) - mem->region.start;

Quoted 5 lines

- On older platforms, stolen_region points to system memory, starting at 0
- on DG2, it uses lmem region which starts at 0 as well
- on MTL, stolen_region points to stolen-local which starts at 0x800000

I was waiting for CI with my comments, but without success.
For some reason it didn't run, that's pity next time you can trigger it manually via patchwork.

Quoted 10 lines

---

  .../drm/i915/display/intel_plane_initial.c    | 45 +++++++++----------
  1 file changed, 22 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/display/intel_plane_initial.c +0 -0
index a55c09cbd0e4..c4bf02ea966c 100644

drivers/gpu/drm/i915/display/intel_plane_initial.c initial_plane_vma(struct drm_i915_private *i915, · line 54

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_plane_initial.c +1 -0
@@ -51,6 +51,8 @@ initial_plane_vma(struct drm_i915_private *i915,
  	struct intel_memory_region *mem;
  	struct drm_i915_gem_object *obj;
  	struct i915_vma *vma;
+	gen8_pte_t __iomem *gte = to_gt(i915)->ggtt->gsm;

I have realized this will work only for gen8+. Older gens uses 32bit gen6_pte_t. So another 'if' is necessary. Then in case of older platforms IMO one can use pte = base;
with comment that it is 1:1 mapping.

Regards
Andrzej

Quoted 69 lines
drivers/gpu/drm/i915/display/intel_plane_initial.c +21 -23
+	gen8_pte_t pte;
  	resource_size_t phys_base;
  	u32 base, size;
  	u64 pinctl;
@@ -59,44 +61,41 @@ initial_plane_vma(struct drm_i915_private *i915,
  		return NULL;
 
  	base = round_down(plane_config->base, I915_GTT_MIN_ALIGNMENT);
-	if (IS_DGFX(i915)) {
-		gen8_pte_t __iomem *gte = to_gt(i915)->ggtt->gsm;
-		gen8_pte_t pte;
+	gte += base / I915_GTT_PAGE_SIZE;
 
-		gte += base / I915_GTT_PAGE_SIZE;
+	pte = ioread64(gte);
 
-		pte = ioread64(gte);
+	if (IS_DGFX(i915)) {
  		if (!(pte & GEN12_GGTT_PTE_LM)) {
  			drm_err(&i915->drm,
  				"Initial plane programming missing PTE_LM bit\n");
  			return NULL;
  		}
-
-		phys_base = pte & I915_GTT_PAGE_MASK;
  		mem = i915->mm.regions[INTEL_REGION_LMEM_0];
-
-		/*
-		 * We don't currently expect this to ever be placed in the
-		 * stolen portion.
-		 */
-		if (phys_base >= resource_size(&mem->region)) {
-			drm_err(&i915->drm,
-				"Initial plane programming using invalid range, phys_base=%pa\n",
-				&phys_base);
-			return NULL;
-		}
-
-		drm_dbg(&i915->drm,
-			"Using phys_base=%pa, based on initial plane programming\n",
-			&phys_base);
  	} else {
-		phys_base = base;
  		mem = i915->mm.stolen_region;
  	}
 
+	phys_base = (pte & I915_GTT_PAGE_MASK) - mem->region.start;
+
  	if (!mem)
  		return NULL;
 
+	/*
+	 * We don't currently expect this to ever be placed in the
+	 * stolen portion.
+	 */
+	if (phys_base >= resource_size(&mem->region)) {
+		drm_err(&i915->drm,
+			"Initial plane programming using invalid range, phys_base=%pa\n",
+			&phys_base);
+		return NULL;
+	}
+
+	drm_dbg(&i915->drm,
+		"Using phys_base=%pa, based on initial plane programming\n",
+		&phys_base);
+
  	size = round_up(plane_config->base + plane_config->size,
  			mem->min_page_size);
  	size -= base;