Skip to contentSkip to conversation

drm/i915: Make i915_coherent_map_type GT-centric

PATCH In review Jonathan Cavitt 5 participants 10 messages Jul 21, 2023 – Jul 25, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/i915: Make i915_coherent_map_type GT-centric

Refactor i915_coherent_map_type to be GT-centric rather than device-centric. Each GT may require different coherency handling due to hardware workarounds.

---
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c        |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_object.h           |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c            |  6 +++---
 .../gpu/drm/i915/gem/selftests/i915_gem_migrate.c    | 12 ++++++------
 drivers/gpu/drm/i915/gt/intel_engine_pm.c            |  2 +-
 drivers/gpu/drm/i915/gt/intel_gt.c                   |  2 +-
 drivers/gpu/drm/i915/gt/intel_gtt.c                  |  4 ++--
 drivers/gpu/drm/i915/gt/intel_lrc.c                  |  2 +-
 drivers/gpu/drm/i915/gt/intel_ring.c                 |  2 +-
 drivers/gpu/drm/i915/gt/selftest_context.c           |  2 +-
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c         |  4 ++--
 drivers/gpu/drm/i915/gt/selftest_lrc.c               |  2 +-
 drivers/gpu/drm/i915/gt/shmem_utils.c                |  6 +++---
 drivers/gpu/drm/i915/gt/shmem_utils.h                |  4 +++-
 drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c            |  3 +--
 drivers/gpu/drm/i915/gt/uc/intel_guc.c               |  2 +-
 drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c            |  3 +--
 drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c             |  2 +-
 drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.c           |  2 +-
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c             |  2 +-
 drivers/gpu/drm/i915/selftests/igt_spinner.c         |  2 +-
 21 files changed, 34 insertions(+), 34 deletions(-)
drivers/gpu/drm/i915/display/intel_hdcp_gsc.c +1 -1
index ad0405375881..71da83f7e98b 100644
@@ -632,7 +632,7 @@ static int intel_hdcp_gsc_initialize_message(struct drm_i915_private *i915,
 		return PTR_ERR(obj);
 	}
 
-	cmd_in = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true));
+	cmd_in = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt, obj, true));
 	if (IS_ERR(cmd_in)) {
 		drm_err(&i915->drm, "Failed to map gsc message page!\n");
 		err = PTR_ERR(cmd_in);
drivers/gpu/drm/i915/gem/i915_gem_object.h +1 -1
index 884a17275b3a..06220494d246 100644
@@ -716,7 +716,7 @@ void *__must_check i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
 void *__must_check i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj,
 						    enum i915_map_type type);
 
-enum i915_map_type i915_coherent_map_type(struct drm_i915_private *i915,
+enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
 					  struct drm_i915_gem_object *obj,
 					  bool always_coherent);
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -3
index 89fc8ea6bcfc..44d93ead96ff 100644
@@ -465,16 +465,16 @@ void *i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj,
 	return ret;
 }
 
-enum i915_map_type i915_coherent_map_type(struct drm_i915_private *i915,
+enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
 					  struct drm_i915_gem_object *obj,
 					  bool always_coherent)
 {
 	/*
 	 * Wa_22016122933: always return I915_MAP_WC for MTL
 	 */
-	if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(i915))
+	if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(gt->i915))
 		return I915_MAP_WC;
-	if (HAS_LLC(i915) || always_coherent)
+	if (HAS_LLC(gt->i915) || always_coherent)
 		return I915_MAP_WB;
 	else
 		return I915_MAP_WC;
drivers/gpu/drm/i915/gem/selftests/i915_gem_migrate.c +6 -6
index a93a90b15907..1ad18a872750 100644
@@ -13,12 +13,12 @@
 #include "selftests/igt_spinner.h"
 
 static int igt_fill_check_buffer(struct drm_i915_gem_object *obj,
+				 struct intel_gt *gt,
 				 bool fill)
 {
-	struct drm_i915_private *i915 = to_i915(obj->base.dev);
 	unsigned int i, count = obj->base.size / sizeof(u32);
 	enum i915_map_type map_type =
-		i915_coherent_map_type(i915, obj, false);
+		i915_coherent_map_type(gt, obj, false);
 	u32 *cur;
 	int err = 0;
 
@@ -66,7 +66,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src,
 		if (err)
 			continue;
 
-		err = igt_fill_check_buffer(obj, true);
+		err = igt_fill_check_buffer(obj, gt, true);
 		if (err)
 			continue;
 
@@ -86,7 +86,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src,
 		if (err)
 			continue;
 
-		err = igt_fill_check_buffer(obj, false);
+		err = igt_fill_check_buffer(obj, gt, false);
 	}
 	i915_gem_object_put(obj);
 
@@ -233,7 +233,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,
 			continue;
 
 		if (!vma) {
-			err = igt_fill_check_buffer(obj, true);
+			err = igt_fill_check_buffer(obj, gt, true);
 			if (err)
 				continue;
 		}
@@ -276,7 +276,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,
 		if (err)
 			goto out_unlock;
 	} else {
-		err = igt_fill_check_buffer(obj, false);
+		err = igt_fill_check_buffer(obj, gt, false);
 	}
 
 out_unlock:
drivers/gpu/drm/i915/gt/intel_engine_pm.c +1 -1
index 21af0ec52223..4cc9c5b8d28e 100644
@@ -39,7 +39,7 @@ static void dbg_poison_ce(struct intel_context *ce)
 
 	if (ce->state) {
 		struct drm_i915_gem_object *obj = ce->state->obj;
-		int type = i915_coherent_map_type(ce->engine->i915, obj, true);
+		int type = i915_coherent_map_type(ce->engine->gt, obj, true);
 		void *map;
 
 		if (!i915_gem_object_trylock(obj, NULL))
drivers/gpu/drm/i915/gt/intel_gt.c +1 -1
index 9f64d61dd5fc..aaa282b0725a 100644
@@ -591,7 +591,7 @@ static int __engines_record_defaults(struct intel_gt *gt)
 			continue;
 
 		/* Keep a copy of the state's backing pages; free the obj */
-		state = shmem_create_from_object(rq->context->state->obj);
+		state = shmem_create_from_object(rq->context->state->obj, gt);
 		if (IS_ERR(state)) {
 			err = PTR_ERR(state);
 			goto out;
drivers/gpu/drm/i915/gt/intel_gtt.c +2 -2
index 731d9f2bbc56..48f3a30dbc99 100644
@@ -89,7 +89,7 @@ int map_pt_dma(struct i915_address_space *vm, struct drm_i915_gem_object *obj)
 	enum i915_map_type type;
 	void *vaddr;
 
-	type = i915_coherent_map_type(vm->i915, obj, true);
+	type = i915_coherent_map_type(vm->gt, obj, true);
 	vaddr = i915_gem_object_pin_map_unlocked(obj, type);
 	if (IS_ERR(vaddr))
 		return PTR_ERR(vaddr);
@@ -103,7 +103,7 @@ int map_pt_dma_locked(struct i915_address_space *vm, struct drm_i915_gem_object
 	enum i915_map_type type;
 	void *vaddr;
 
-	type = i915_coherent_map_type(vm->i915, obj, true);
+	type = i915_coherent_map_type(vm->gt, obj, true);
 	vaddr = i915_gem_object_pin_map(obj, type);
 	if (IS_ERR(vaddr))
 		return PTR_ERR(vaddr);
drivers/gpu/drm/i915/gt/intel_lrc.c +1 -1
index 1b710102390b..c45e6d8cbaac 100644
@@ -1191,7 +1191,7 @@ lrc_pre_pin(struct intel_context *ce,
 	GEM_BUG_ON(!i915_vma_is_pinned(ce->state));
 
 	*vaddr = i915_gem_object_pin_map(ce->state->obj,
-					 i915_coherent_map_type(ce->engine->i915,
+					 i915_coherent_map_type(ce->engine->gt,
 								ce->state->obj,
 								false) |
 					 I915_MAP_OVERRIDE);
drivers/gpu/drm/i915/gt/intel_ring.c +1 -1
index fb99143be98e..a058532cc1b8 100644
@@ -56,7 +56,7 @@ int intel_ring_pin(struct intel_ring *ring, struct i915_gem_ww_ctx *ww)
 	if (i915_vma_is_map_and_fenceable(vma) && !HAS_LLC(vma->vm->i915)) {
 		addr = (void __force *)i915_vma_pin_iomap(vma);
 	} else {
-		int type = i915_coherent_map_type(vma->vm->i915, vma->obj, false);
+		int type = i915_coherent_map_type(vma->vm->gt, vma->obj, false);
 
 		addr = i915_gem_object_pin_map(vma->obj, type);
 	}
drivers/gpu/drm/i915/gt/selftest_context.c +1 -1
index 76fbae358072..87fad1bc15a0 100644
@@ -88,7 +88,7 @@ static int __live_context_size(struct intel_engine_cs *engine)
 		goto err;
 
 	vaddr = i915_gem_object_pin_map_unlocked(ce->state->obj,
-						 i915_coherent_map_type(engine->i915,
+						 i915_coherent_map_type(engine->gt,
 									ce->state->obj, false));
 	if (IS_ERR(vaddr)) {
 		err = PTR_ERR(vaddr);
drivers/gpu/drm/i915/gt/selftest_hangcheck.c +2 -2
index 8b0d84f2aad2..fdc0b565ee21 100644
@@ -73,7 +73,7 @@ static int hang_init(struct hang *h, struct intel_gt *gt)
 	h->seqno = memset(vaddr, 0xff, PAGE_SIZE);
 
 	vaddr = i915_gem_object_pin_map_unlocked(h->obj,
-						 i915_coherent_map_type(gt->i915, h->obj, false));
+						 i915_coherent_map_type(gt, h->obj, false));
 	if (IS_ERR(vaddr)) {
 		err = PTR_ERR(vaddr);
 		goto err_unpin_hws;
@@ -119,7 +119,7 @@ hang_create_request(struct hang *h, struct intel_engine_cs *engine)
 		return ERR_CAST(obj);
 	}
 
-	vaddr = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt->i915, obj, false));
+	vaddr = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt, obj, false));
 	if (IS_ERR(vaddr)) {
 		i915_gem_object_put(obj);
 		i915_vm_put(vm);
drivers/gpu/drm/i915/gt/selftest_lrc.c +1 -1
index a78a3d2c2e16..3d1daeac4c0c 100644
@@ -1292,7 +1292,7 @@ static int compare_isolation(struct intel_engine_cs *engine,
 	}
 
 	lrc = i915_gem_object_pin_map_unlocked(ce->state->obj,
-					       i915_coherent_map_type(engine->i915,
+					       i915_coherent_map_type(engine->gt,
 								      ce->state->obj,
 								      false));
 	if (IS_ERR(lrc)) {
drivers/gpu/drm/i915/gt/shmem_utils.c +3 -3
index 449c9ed44382..3f2fea18746d 100644
@@ -31,9 +31,9 @@ struct file *shmem_create_from_data(const char *name, void *data, size_t len)
 	return file;
 }
 
-struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
+struct file *shmem_create_from_object(struct drm_i915_gem_object *obj,
+				      struct intel_gt *gt)
 {
-	struct drm_i915_private *i915 = to_i915(obj->base.dev);
 	enum i915_map_type map_type;
 	struct file *file;
 	void *ptr;
@@ -44,7 +44,7 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
 		return file;
 	}
 
-	map_type = i915_coherent_map_type(i915, obj, true);
+	map_type = i915_coherent_map_type(gt, obj, true);
 	ptr = i915_gem_object_pin_map_unlocked(obj, map_type);
 	if (IS_ERR(ptr))
 		return ERR_CAST(ptr);
drivers/gpu/drm/i915/gt/shmem_utils.h +3 -1
index b2b04d88c6e5..743a56307216 100644
@@ -11,9 +11,11 @@
 struct iosys_map;
 struct drm_i915_gem_object;
 struct file;
+struct intel_gt;
 
 struct file *shmem_create_from_data(const char *name, void *data, size_t len);
-struct file *shmem_create_from_object(struct drm_i915_gem_object *obj);
+struct file *shmem_create_from_object(struct drm_i915_gem_object *obj,
+				      struct intel_gt *gt);
 
 void *shmem_pin_map(struct file *file);
 void shmem_unpin_map(struct file *file, void *ptr);
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c +1 -2
index ab1a456f833d..fb4933543f31 100644
@@ -268,7 +268,6 @@ static int gsc_fw_load(struct intel_gsc_uc *gsc)
 static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
 {
 	struct intel_gt *gt = gsc_uc_to_gt(gsc);
-	struct drm_i915_private *i915 = gt->i915;
 	void *src;
 
 	if (!gsc->local)
@@ -278,7 +277,7 @@ static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
 		return -ENOSPC;
 
 	src = i915_gem_object_pin_map_unlocked(gsc->fw.obj,
-					       i915_coherent_map_type(i915, gsc->fw.obj, true));
+					       i915_coherent_map_type(gt, gsc->fw.obj, true));
 	if (IS_ERR(src))
 		return PTR_ERR(src);
 
drivers/gpu/drm/i915/gt/uc/intel_guc.c +1 -1
index 2eb891b270ae..effb37727093 100644
@@ -792,7 +792,7 @@ int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size,
 		return PTR_ERR(vma);
 
 	vaddr = i915_gem_object_pin_map_unlocked(vma->obj,
-						 i915_coherent_map_type(guc_to_gt(guc)->i915,
+						 i915_coherent_map_type(guc_to_gt(guc),
 									vma->obj, true));
 	if (IS_ERR(vaddr)) {
 		i915_vma_unpin_and_release(&vma, 0);
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +1 -2
index 48f506a26e6d..ca95ddadc3a8 100644
@@ -27,7 +27,6 @@ struct mtl_huc_auth_msg_out {
 int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc)
 {
 	struct intel_gt *gt = huc_to_gt(huc);
-	struct drm_i915_private *i915 = gt->i915;
 	struct drm_i915_gem_object *obj;
 	struct mtl_huc_auth_msg_in *msg_in;
 	struct mtl_huc_auth_msg_out *msg_out;
@@ -43,7 +42,7 @@ int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc)
 	pkt_offset = i915_ggtt_offset(huc->heci_pkt);
 
 	pkt_vaddr = i915_gem_object_pin_map_unlocked(obj,
-						     i915_coherent_map_type(i915, obj, true));
+						     i915_coherent_map_type(gt, obj, true));
 	if (IS_ERR(pkt_vaddr))
 		return PTR_ERR(pkt_vaddr);
 
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1 -1
index 7aadad5639c3..4f316f010b55 100644
@@ -1213,7 +1213,7 @@ static int uc_fw_rsa_data_create(struct intel_uc_fw *uc_fw)
 		return PTR_ERR(vma);
 
 	vaddr = i915_gem_object_pin_map_unlocked(vma->obj,
-						 i915_coherent_map_type(gt->i915, vma->obj, true));
+						 i915_coherent_map_type(gt, vma->obj, true));
 	if (IS_ERR(vaddr)) {
 		i915_vma_unpin_and_release(&vma, 0);
 		err = PTR_ERR(vaddr);
drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.c +1 -1
index c7df47364013..8b5d3d129881 100644
@@ -336,7 +336,7 @@ gsccs_create_buffer(struct intel_gt *gt,
 	}
 
 	/* return a virtual pointer */
-	*map = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true));
+	*map = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt, obj, true));
 	if (IS_ERR(*map)) {
 		drm_err(&i915->drm, "Failed to map gsccs backend %s.\n", bufname);
 		err = PTR_ERR(*map);
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +1 -1
index 1ce07d7e8769..00630a1c8e77 100644
@@ -245,7 +245,7 @@ static int alloc_streaming_command(struct intel_pxp *pxp)
 	}
 
 	/* map the lmem into the virtual memory pointer */
-	cmd = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true));
+	cmd = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(pxp->ctrl_gt, obj, true));
 	if (IS_ERR(cmd)) {
 		drm_err(&i915->drm, "Failed to map gsc message page!\n");
 		err = PTR_ERR(cmd);
drivers/gpu/drm/i915/selftests/igt_spinner.c +1 -1
index 618d9386d554..b09e56427299 100644
@@ -97,7 +97,7 @@ int igt_spinner_pin(struct igt_spinner *spin,
 	if (!spin->batch) {
 		unsigned int mode;
 
-		mode = i915_coherent_map_type(spin->gt->i915, spin->obj, false);
+		mode = i915_coherent_map_type(spin->gt, spin->obj, false);
 		vaddr = igt_spinner_pin_obj(ce, ww, spin->obj, mode, &spin->batch_vma);
 		if (IS_ERR(vaddr))
 			return PTR_ERR(vaddr);
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 drm/i915/gt: Apply workaround 22016122933 correctly

WA_22016122933 was recently applied to all MeteorLake engines, which is simultaneously too broad (should only apply to Media engines) and too specific (should apply to all platforms that use the same media engine as MeteorLake). Correct this in cases where coherency settings are modified.

There were also two additional places where the workaround was applied unconditionally. The change was confirmed as necessary for all platforms, so the workaround label was removed.

---
 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 5 +++--
 drivers/gpu/drm/i915/gt/intel_gt.h        | 6 ++++++
 drivers/gpu/drm/i915/gt/intel_lrc.c       | 7 ++++---
 drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c | 4 ----
 drivers/gpu/drm/i915/gt/uc/intel_guc.c    | 7 ++++---
 drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 4 ----
 6 files changed, 17 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -2
index 44d93ead96ff..4acdd008d1d3 100644
@@ -470,9 +470,10 @@ enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
 					  bool always_coherent)
 {
 	/*
-	 * Wa_22016122933: always return I915_MAP_WC for MTL
+	 * Wa_22016122933: always return I915_MAP_WC for Media
+	 * version 13.0 when the object is on the Media GT
 	 */
-	if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(gt->i915))
+	if (i915_gem_object_is_lmem(obj) || intel_gt_needs_wa_22016122933(gt))
 		return I915_MAP_WC;
 	if (HAS_LLC(gt->i915) || always_coherent)
 		return I915_MAP_WB;
drivers/gpu/drm/i915/gt/intel_gt.h +6 -0
index d2f4fbde5f9f..4eb41a3b6e8b 100644
@@ -6,6 +6,7 @@
 #ifndef __INTEL_GT__
 #define __INTEL_GT__
 
+#include "i915_drv.h"
 #include "intel_engine_types.h"
 #include "intel_gt_types.h"
 #include "intel_reset.h"
@@ -24,6 +25,11 @@ static inline bool gt_is_root(struct intel_gt *gt)
 	return !gt->info.id;
 }
 
+static inline bool intel_gt_needs_wa_22016122933(struct intel_gt *gt)
+{
+	return MEDIA_VER_FULL(gt->i915) == IP_VER(13, 0) && gt->type == GT_MEDIA;
+}
+
 static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)
 {
 	return container_of(uc, struct intel_gt, uc);
drivers/gpu/drm/i915/gt/intel_lrc.c +4 -3
index c45e6d8cbaac..668ed3fc7076 100644
@@ -1095,10 +1095,11 @@ __lrc_alloc_state(struct intel_context *ce, struct intel_engine_cs *engine)
 	if (IS_ERR(obj)) {
 		obj = i915_gem_object_create_shmem(engine->i915, context_size);
 		/*
-		 * Wa_22016122933: For MTL the shared memory needs to be mapped
-		 * as WC on CPU side and UC (PAT index 2) on GPU side
+		 * Wa_22016122933: For Media version 13.0, all Media GT shared
+		 * memory needs to be mapped as WC on CPU side and UC (PAT
+		 * index 2) on GPU side.
 		 */
-		if (IS_METEORLAKE(engine->i915))
+		if (intel_gt_needs_wa_22016122933(engine->gt))
 			i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
 	}
 	if (IS_ERR(obj))
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c +0 -4
index fb4933543f31..1093b47d3e06 100644
@@ -284,10 +284,6 @@ static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
 	memcpy_toio(gsc->local_vaddr, src, gsc->fw.size);
 	memset_io(gsc->local_vaddr + gsc->fw.size, 0, gsc->local->size - gsc->fw.size);
 
-	/*
-	 * Wa_22016122933: Making sure the data in dst is
-	 * visible to GSC right away
-	 */
 	intel_guc_write_barrier(&gt->uc.guc);
 
 	i915_gem_object_unpin_map(gsc->fw.obj);
drivers/gpu/drm/i915/gt/uc/intel_guc.c +4 -3
index effb37727093..0000846f6029 100644
@@ -745,10 +745,11 @@ struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size)
 		return ERR_CAST(obj);
 
 	/*
-	 * Wa_22016122933: For MTL the shared memory needs to be mapped
-	 * as WC on CPU side and UC (PAT index 2) on GPU side
+	 * Wa_22016122933: For Media version 13.0, all Media GT shared
+	 * memory needs to be mapped as WC on CPU side and UC (PAT
+	 * index 2) on GPU side.
 	 */
-	if (IS_METEORLAKE(gt->i915))
+	if (intel_gt_needs_wa_22016122933(gt))
 		i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
 
 	vma = i915_vma_instance(obj, &gt->ggtt->vm, NULL);
drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c +0 -4
index f28a3a83742d..97eadd08181d 100644
@@ -960,10 +960,6 @@ static int ct_read(struct intel_guc_ct *ct, struct ct_incoming_msg **msg)
 	/* now update descriptor */
 	WRITE_ONCE(desc->head, head);
 
-	/*
-	 * Wa_22016122933: Making sure the head update is
-	 * visible to GuC right away
-	 */
 	intel_guc_write_barrier(ct_to_guc(ct));
 
 	return available - len;
Signature · 1 line
2.25.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [Intel-gfx] [PATCH dii-client 2/2] drm/i915/gt: Apply workaround 22016122933 correctly

Quoted 6 lines

WA_22016122933 was recently applied to all MeteorLake engines, which is simultaneously too broad (should only apply to Media engines) and too specific (should apply to all platforms that use the same media engine as MeteorLake). Correct this in cases where coherency settings are modified.

Quoted 6 lines

There were also two additional places where the workaround was applied unconditionally. The change was confirmed as necessary for all platforms, so the workaround label was removed.

Quoted 119 lines
---
 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 5 +++--
 drivers/gpu/drm/i915/gt/intel_gt.h        | 6 ++++++
 drivers/gpu/drm/i915/gt/intel_lrc.c       | 7 ++++---
 drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c | 4 ----
 drivers/gpu/drm/i915/gt/uc/intel_guc.c    | 7 ++++---
 drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 4 ----
 6 files changed, 17 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -2
index 44d93ead96ff..4acdd008d1d3 100644
@@ -470,9 +470,10 @@ enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
                                        bool always_coherent)
 {
      /*
-      * Wa_22016122933: always return I915_MAP_WC for MTL
+      * Wa_22016122933: always return I915_MAP_WC for Media
+      * version 13.0 when the object is on the Media GT
       */
-     if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(gt->i915))
+     if (i915_gem_object_is_lmem(obj) || intel_gt_needs_wa_22016122933(gt))
              return I915_MAP_WC;
      if (HAS_LLC(gt->i915) || always_coherent)
              return I915_MAP_WB;
drivers/gpu/drm/i915/gt/intel_gt.h +5 -0
index d2f4fbde5f9f..4eb41a3b6e8b 100644
@@ -6,6 +6,7 @@
 #ifndef __INTEL_GT__
 #define __INTEL_GT__
 
+#include "i915_drv.h"
 #include "intel_engine_types.h"
 #include "intel_gt_types.h"
 #include "intel_reset.h"
@@ -24,6 +25,11 @@ static inline bool gt_is_root(struct intel_gt *gt)
      return !gt->info.id;
 }
 
+static inline bool intel_gt_needs_wa_22016122933(struct intel_gt *gt) {
+     return MEDIA_VER_FULL(gt->i915) == IP_VER(13, 0) && gt->type ==
+GT_MEDIA; }
+
 static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)  {
      return container_of(uc, struct intel_gt, uc);
drivers/gpu/drm/i915/gt/intel_lrc.c +4 -3
index c45e6d8cbaac..668ed3fc7076 100644
@@ -1095,10 +1095,11 @@ __lrc_alloc_state(struct intel_context *ce, struct intel_engine_cs *engine)
      if (IS_ERR(obj)) {
              obj = i915_gem_object_create_shmem(engine->i915, context_size);
              /*
-              * Wa_22016122933: For MTL the shared memory needs to be mapped
-              * as WC on CPU side and UC (PAT index 2) on GPU side
+              * Wa_22016122933: For Media version 13.0, all Media GT shared
+              * memory needs to be mapped as WC on CPU side and UC (PAT
+              * index 2) on GPU side.
               */
-             if (IS_METEORLAKE(engine->i915))
+             if (intel_gt_needs_wa_22016122933(engine->gt))
                      i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
      }
      if (IS_ERR(obj))
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c +0 -4
index fb4933543f31..1093b47d3e06 100644
@@ -284,10 +284,6 @@ static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
      memcpy_toio(gsc->local_vaddr, src, gsc->fw.size);
      memset_io(gsc->local_vaddr + gsc->fw.size, 0, gsc->local->size - gsc->fw.size);
 
-     /*
-      * Wa_22016122933: Making sure the data in dst is
-      * visible to GSC right away
-      */
      intel_guc_write_barrier(&gt->uc.guc);
 
      i915_gem_object_unpin_map(gsc->fw.obj);
drivers/gpu/drm/i915/gt/uc/intel_guc.c +4 -3
index effb37727093..0000846f6029 100644
@@ -745,10 +745,11 @@ struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size)
              return ERR_CAST(obj);
 
      /*
-      * Wa_22016122933: For MTL the shared memory needs to be mapped
-      * as WC on CPU side and UC (PAT index 2) on GPU side
+      * Wa_22016122933: For Media version 13.0, all Media GT shared
+      * memory needs to be mapped as WC on CPU side and UC (PAT
+      * index 2) on GPU side.
       */
-     if (IS_METEORLAKE(gt->i915))
+     if (intel_gt_needs_wa_22016122933(gt))
              i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
 
      vma = i915_vma_instance(obj, &gt->ggtt->vm, NULL);
drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c +0 -5
index f28a3a83742d..97eadd08181d 100644
@@ -960,10 +960,6 @@ static int ct_read(struct intel_guc_ct *ct, struct ct_incoming_msg **msg)
      /* now update descriptor */
      WRITE_ONCE(desc->head, head);
 
-     /*
-      * Wa_22016122933: Making sure the head update is
-      * visible to GuC right away
-      */
      intel_guc_write_barrier(ct_to_guc(ct));
 
      return available - len;
--

2.25.1

#3 lore raw

Re: [Intel-gfx] [PATCH dii-client 2/2] drm/i915/gt: Apply workaround 22016122933 correctly

In reply to Jonathan Cavitt
Quoted 51 lines · Jonathan Cavitt

WA_22016122933 was recently applied to all MeteorLake engines, which is simultaneously too broad (should only apply to Media engines) and too specific (should apply to all platforms that use the same media engine as MeteorLake). Correct this in cases where coherency settings are modified.

There were also two additional places where the workaround was applied unconditionally. The change was confirmed as necessary for all platforms, so the workaround label was removed.

---
  drivers/gpu/drm/i915/gem/i915_gem_pages.c | 5 +++--
  drivers/gpu/drm/i915/gt/intel_gt.h        | 6 ++++++
  drivers/gpu/drm/i915/gt/intel_lrc.c       | 7 ++++---
  drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c | 4 ----
  drivers/gpu/drm/i915/gt/uc/intel_guc.c    | 7 ++++---
  drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 4 ----
  6 files changed, 17 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -2
index 44d93ead96ff..4acdd008d1d3 100644
@@ -470,9 +470,10 @@ enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
  					  bool always_coherent)
  {
  	/*
-	 * Wa_22016122933: always return I915_MAP_WC for MTL
+	 * Wa_22016122933: always return I915_MAP_WC for Media
+	 * version 13.0 when the object is on the Media GT
  	 */
-	if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(gt->i915))
+	if (i915_gem_object_is_lmem(obj) || intel_gt_needs_wa_22016122933(gt))
  		return I915_MAP_WC;
  	if (HAS_LLC(gt->i915) || always_coherent)
  		return I915_MAP_WB;
drivers/gpu/drm/i915/gt/intel_gt.h +1 -0
index d2f4fbde5f9f..4eb41a3b6e8b 100644
@@ -6,6 +6,7 @@
  #ifndef __INTEL_GT__
  #define __INTEL_GT__
 
+#include "i915_drv.h"
  #include "intel_engine_types.h"
  #include "intel_gt_types.h"
  #include "intel_reset.h"

drivers/gpu/drm/i915/gt/intel_gt.h static inline bool gt_is_root(struct intel_gt *gt) · line 30

Quoted 6 lines
drivers/gpu/drm/i915/gt/intel_gt.h +3 -0
@@ -24,6 +25,11 @@ static inline bool gt_is_root(struct intel_gt *gt)
  	return !gt->info.id;
  }
 
+static inline bool intel_gt_needs_wa_22016122933(struct intel_gt *gt)
+{
+	return MEDIA_VER_FULL(gt->i915) == IP_VER(13, 0) && gt->type == GT_MEDIA;

Ah this is something Matt was recntly telling me is coming.

Would it make sense to store ipver in the gt? And then we could have:

	return gt->type == GT_MEDIA && gt->info.ipver == IP_VER(13,0);

?

(Give or take the gt->info part, and macro or not.)

Reads a bit better to me to ask the same component about it's type and version.

Regards,

Tvrtko

Quoted 73 lines
drivers/gpu/drm/i915/gt/intel_gt.h +2 -0
+}
+
  static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)
  {
  	return container_of(uc, struct intel_gt, uc);
drivers/gpu/drm/i915/gt/intel_lrc.c +4 -3
index c45e6d8cbaac..668ed3fc7076 100644
@@ -1095,10 +1095,11 @@ __lrc_alloc_state(struct intel_context *ce, struct intel_engine_cs *engine)
  	if (IS_ERR(obj)) {
  		obj = i915_gem_object_create_shmem(engine->i915, context_size);
  		/*
-		 * Wa_22016122933: For MTL the shared memory needs to be mapped
-		 * as WC on CPU side and UC (PAT index 2) on GPU side
+		 * Wa_22016122933: For Media version 13.0, all Media GT shared
+		 * memory needs to be mapped as WC on CPU side and UC (PAT
+		 * index 2) on GPU side.
  		 */
-		if (IS_METEORLAKE(engine->i915))
+		if (intel_gt_needs_wa_22016122933(engine->gt))
  			i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
  	}
  	if (IS_ERR(obj))
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c +0 -4
index fb4933543f31..1093b47d3e06 100644
@@ -284,10 +284,6 @@ static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
  	memcpy_toio(gsc->local_vaddr, src, gsc->fw.size);
  	memset_io(gsc->local_vaddr + gsc->fw.size, 0, gsc->local->size - gsc->fw.size);
 
-	/*
-	 * Wa_22016122933: Making sure the data in dst is
-	 * visible to GSC right away
-	 */
  	intel_guc_write_barrier(&gt->uc.guc);
 
  	i915_gem_object_unpin_map(gsc->fw.obj);
drivers/gpu/drm/i915/gt/uc/intel_guc.c +4 -3
index effb37727093..0000846f6029 100644
@@ -745,10 +745,11 @@ struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size)
  		return ERR_CAST(obj);
 
  	/*
-	 * Wa_22016122933: For MTL the shared memory needs to be mapped
-	 * as WC on CPU side and UC (PAT index 2) on GPU side
+	 * Wa_22016122933: For Media version 13.0, all Media GT shared
+	 * memory needs to be mapped as WC on CPU side and UC (PAT
+	 * index 2) on GPU side.
  	 */
-	if (IS_METEORLAKE(gt->i915))
+	if (intel_gt_needs_wa_22016122933(gt))
  		i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
 
  	vma = i915_vma_instance(obj, &gt->ggtt->vm, NULL);
drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c +0 -4
index f28a3a83742d..97eadd08181d 100644
@@ -960,10 +960,6 @@ static int ct_read(struct intel_guc_ct *ct, struct ct_incoming_msg **msg)
  	/* now update descriptor */
  	WRITE_ONCE(desc->head, head);
 
-	/*
-	 * Wa_22016122933: Making sure the head update is
-	 * visible to GuC right away
-	 */
  	intel_guc_write_barrier(ct_to_guc(ct));
 
  	return available - len;
#4 lore raw

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [dii-client,1/2] drm/i915: Make i915_coherent_map_type GT-centric

In reply to Jonathan Cavitt
== Series Details ==

== Series Details ==

Series: series starting with [dii-client,1/2] drm/i915: Make i915_coherent_map_type GT-centric
URL : https://patchwork.freedesktop.org/series/121133/
State : warning

== Summary ==

Error: dim checkpatch failed
20d96369b3a6 drm/i915: Make i915_coherent_map_type GT-centric -:372: WARNING:LONG_LINE: line length of 101 exceeds 100 columns #372: FILE: drivers/gpu/drm/i915/pxp/intel_pxp_tee.c:248:
+ cmd = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(pxp->ctrl_gt, obj, true));

total: 0 errors, 1 warnings, 0 checks, 262 lines checked c4794405dd4d drm/i915/gt: Apply workaround 22016122933 correctly

#5 lore raw

[Intel-gfx] ✗ Fi.CI.SPARSE: warning for series starting with [dii-client,1/2] drm/i915: Make i915_coherent_map_type GT-centric

In reply to Jonathan Cavitt
== Series Details ==

== Series Details ==

Series: series starting with [dii-client,1/2] drm/i915: Make i915_coherent_map_type GT-centric
URL : https://patchwork.freedesktop.org/series/121133/
State : warning

== Summary ==

Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.

#6 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [dii-client,1/2] drm/i915: Make i915_coherent_map_type GT-centric

In reply to Jonathan Cavitt
== Series Details ==

== Series Details ==

Series: series starting with [dii-client,1/2] drm/i915: Make i915_coherent_map_type GT-centric
URL : https://patchwork.freedesktop.org/series/121133/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13404 -> Patchwork_121133v1
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes introduced in Patchwork_121133v1, 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_121133v1/index.html

Participating hosts (42 -> 42)
------------------------------

No changes in participating hosts

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

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

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_fence@basic-busy@bcs0:
- fi-tgl-1115g4: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/fi-tgl-1115g4/igt@gem_exec_fence@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/fi-tgl-1115g4/igt@gem_exec_fence@[email protected]

* igt@gem_exec_fence@basic-busy@vecs0:
- fi-tgl-1115g4: [PASS][3] -> [DMESG-WARN][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/fi-tgl-1115g4/igt@gem_exec_fence@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/fi-tgl-1115g4/igt@gem_exec_fence@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live@gt_pm:
- bat-rpls-2: [PASS][5] -> [DMESG-FAIL][6] ([i915#4258] / [i915#7913])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/bat-rpls-2/igt@i915_selftest@live@gt_pm.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-rpls-2/igt@i915_selftest@live@gt_pm.html

* igt@i915_selftest@live@migrate:
- bat-dg2-11: [PASS][7] -> [DMESG-WARN][8] ([i915#7699])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/bat-dg2-11/igt@i915_selftest@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-dg2-11/igt@i915_selftest@[email protected]
- bat-atsm-1: [PASS][9] -> [DMESG-FAIL][10] ([i915#7699] / [i915#7913])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/bat-atsm-1/igt@i915_selftest@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-atsm-1/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@requests:
- bat-rpls-1: [PASS][11] -> [ABORT][12] ([i915#4983] / [i915#7911] / [i915#7920])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/bat-rpls-1/igt@i915_selftest@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-rpls-1/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@slpc:
- bat-mtlp-8: [PASS][13] -> [DMESG-WARN][14] ([i915#6367])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/bat-mtlp-8/igt@i915_selftest@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-mtlp-8/igt@i915_selftest@[email protected]

* igt@kms_chamelium_hpd@common-hpd-after-suspend:
- bat-mtlp-8: NOTRUN -> [SKIP][15] ([i915#7828])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-mtlp-8/igt@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence:
- bat-adlp-9: NOTRUN -> [SKIP][16] ([i915#3546]) +2 similar issues
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-adlp-9/igt@[email protected]

* igt@kms_psr@primary_mmap_gtt:
- bat-rplp-1: NOTRUN -> [SKIP][17] ([i915#1072]) +1 similar issue
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-rplp-1/igt@kms_psr@primary_mmap_gtt.html

* igt@kms_setmode@basic-clone-single-crtc:
- bat-rplp-1: NOTRUN -> [ABORT][18] ([i915#8260] / [i915#8668])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-rplp-1/igt@[email protected]

#### Warnings ####

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-cfl-8700k: [FAIL][19] ([i915#7691]) -> [FAIL][20] ([i915#7940])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/fi-cfl-8700k/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/fi-cfl-8700k/igt@[email protected]

* igt@i915_selftest@live@execlists:
- fi-bsw-n3050: [ABORT][21] ([i915#7913]) -> [ABORT][22] ([i915#7911] / [i915#7913])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/fi-bsw-n3050/igt@i915_selftest@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/fi-bsw-n3050/igt@i915_selftest@[email protected]

* igt@i915_suspend@basic-s3-without-i915:
- bat-mtlp-8: [ABORT][23] -> [SKIP][24] ([i915#6645])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/bat-mtlp-8/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-mtlp-8/igt@[email protected]

* igt@kms_psr@cursor_plane_move:
- bat-rplp-1: [ABORT][25] ([i915#8434] / [i915#8668]) -> [SKIP][26] ([i915#1072])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13404/bat-rplp-1/igt@kms_psr@cursor_plane_move.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_121133v1/bat-rplp-1/igt@kms_psr@cursor_plane_move.html

[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#4258]: https://gitlab.freedesktop.org/drm/intel/issues/4258
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
[i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
[i915#7691]: https://gitlab.freedesktop.org/drm/intel/issues/7691
[i915#7699]: https://gitlab.freedesktop.org/drm/intel/issues/7699
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#7911]: https://gitlab.freedesktop.org/drm/intel/issues/7911
[i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
[i915#7920]: https://gitlab.freedesktop.org/drm/intel/issues/7920
[i915#7940]: https://gitlab.freedesktop.org/drm/intel/issues/7940
[i915#8260]: https://gitlab.freedesktop.org/drm/intel/issues/8260
[i915#8434]: https://gitlab.freedesktop.org/drm/intel/issues/8434
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668

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

* Linux: CI_DRM_13404 -> Patchwork_121133v1

CI-20190529: 20190529
CI_DRM_13404: 526f3e5b744ee37c2fd643a2efec898a1f967d36 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7398: 602cdd3c87fad86cab8b15fe4242f2a119ce48df @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_121133v1: 526f3e5b744ee37c2fd643a2efec898a1f967d36 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

f66b13da3daa drm/i915/gt: Apply workaround 22016122933 correctly a9f14f2c374f drm/i915: Make i915_coherent_map_type GT-centric

== Logs ==

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

Acked-by on v1 1/2
#7 lore raw
In reply to Jonathan Cavitt
Quoted 4 lines

Refactor i915_coherent_map_type to be GT-centric rather than device-centric. Each GT may require different coherency handling due to hardware workarounds.

Quoted 396 lines
---
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c        |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_object.h           |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c            |  6 +++---
 .../gpu/drm/i915/gem/selftests/i915_gem_migrate.c    | 12 ++++++------
 drivers/gpu/drm/i915/gt/intel_engine_pm.c            |  2 +-
 drivers/gpu/drm/i915/gt/intel_gt.c                   |  2 +-
 drivers/gpu/drm/i915/gt/intel_gtt.c                  |  4 ++--
 drivers/gpu/drm/i915/gt/intel_lrc.c                  |  2 +-
 drivers/gpu/drm/i915/gt/intel_ring.c                 |  2 +-
 drivers/gpu/drm/i915/gt/selftest_context.c           |  2 +-
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c         |  4 ++--
 drivers/gpu/drm/i915/gt/selftest_lrc.c               |  2 +-
 drivers/gpu/drm/i915/gt/shmem_utils.c                |  6 +++---
 drivers/gpu/drm/i915/gt/shmem_utils.h                |  4 +++-
 drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c            |  3 +--
 drivers/gpu/drm/i915/gt/uc/intel_guc.c               |  2 +-
 drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c            |  3 +--
 drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c             |  2 +-
 drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.c           |  2 +-
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c             |  2 +-
 drivers/gpu/drm/i915/selftests/igt_spinner.c         |  2 +-
 21 files changed, 34 insertions(+), 34 deletions(-)
drivers/gpu/drm/i915/display/intel_hdcp_gsc.c +2 -1
index ad0405375881..71da83f7e98b 100644
@@ -632,7 +632,7 @@ static int intel_hdcp_gsc_initialize_message(struct drm_i915_private *i915,
              return PTR_ERR(obj);
      }
 
-     cmd_in = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true));
+     cmd_in = i915_gem_object_pin_map_unlocked(obj,
+i915_coherent_map_type(gt, obj, true));
      if (IS_ERR(cmd_in)) {
              drm_err(&i915->drm, "Failed to map gsc message page!\n");
              err = PTR_ERR(cmd_in);
drivers/gpu/drm/i915/gem/i915_gem_object.h +1 -1
index 884a17275b3a..06220494d246 100644
@@ -716,7 +716,7 @@ void *__must_check i915_gem_object_pin_map(struct drm_i915_gem_object *obj,  void *__must_check i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj,
                                                  enum i915_map_type type);
 
-enum i915_map_type i915_coherent_map_type(struct drm_i915_private *i915,
+enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
                                        struct drm_i915_gem_object *obj,
                                        bool always_coherent);
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -3
index 89fc8ea6bcfc..44d93ead96ff 100644
@@ -465,16 +465,16 @@ void *i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj,
      return ret;
 }
 
-enum i915_map_type i915_coherent_map_type(struct drm_i915_private *i915,
+enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
                                        struct drm_i915_gem_object *obj,
                                        bool always_coherent)
 {
      /*
       * Wa_22016122933: always return I915_MAP_WC for MTL
       */
-     if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(i915))
+     if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(gt->i915))
              return I915_MAP_WC;
-     if (HAS_LLC(i915) || always_coherent)
+     if (HAS_LLC(gt->i915) || always_coherent)
              return I915_MAP_WB;
      else
              return I915_MAP_WC;
drivers/gpu/drm/i915/gem/selftests/i915_gem_migrate.c +6 -6
index a93a90b15907..1ad18a872750 100644
@@ -13,12 +13,12 @@
 #include "selftests/igt_spinner.h"
 
 static int igt_fill_check_buffer(struct drm_i915_gem_object *obj,
+                              struct intel_gt *gt,
                               bool fill)
 {
-     struct drm_i915_private *i915 = to_i915(obj->base.dev);
      unsigned int i, count = obj->base.size / sizeof(u32);
      enum i915_map_type map_type =
-             i915_coherent_map_type(i915, obj, false);
+             i915_coherent_map_type(gt, obj, false);
      u32 *cur;
      int err = 0;
 
@@ -66,7 +66,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src,
              if (err)
                      continue;
 
-             err = igt_fill_check_buffer(obj, true);
+             err = igt_fill_check_buffer(obj, gt, true);
              if (err)
                      continue;
 
@@ -86,7 +86,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src,
              if (err)
                      continue;
 
-             err = igt_fill_check_buffer(obj, false);
+             err = igt_fill_check_buffer(obj, gt, false);
      }
      i915_gem_object_put(obj);
 
@@ -233,7 +233,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,
                      continue;
 
              if (!vma) {
-                     err = igt_fill_check_buffer(obj, true);
+                     err = igt_fill_check_buffer(obj, gt, true);
                      if (err)
                              continue;
              }
@@ -276,7 +276,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,
              if (err)
                      goto out_unlock;
      } else {
-             err = igt_fill_check_buffer(obj, false);
+             err = igt_fill_check_buffer(obj, gt, false);
      }
 
 out_unlock:
drivers/gpu/drm/i915/gt/intel_engine_pm.c +1 -1
index 21af0ec52223..4cc9c5b8d28e 100644
@@ -39,7 +39,7 @@ static void dbg_poison_ce(struct intel_context *ce)
 
      if (ce->state) {
              struct drm_i915_gem_object *obj = ce->state->obj;
-             int type = i915_coherent_map_type(ce->engine->i915, obj, true);
+             int type = i915_coherent_map_type(ce->engine->gt, obj, true);
              void *map;
 
              if (!i915_gem_object_trylock(obj, NULL)) diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c

index 9f64d61dd5fc..aaa282b0725a 100644

drivers/gpu/drm/i915/gt/intel_gt.c +1 -1
@@ -591,7 +591,7 @@ static int __engines_record_defaults(struct intel_gt *gt)
                      continue;
 
              /* Keep a copy of the state's backing pages; free the obj */
-             state = shmem_create_from_object(rq->context->state->obj);
+             state = shmem_create_from_object(rq->context->state->obj, gt);
              if (IS_ERR(state)) {
                      err = PTR_ERR(state);
                      goto out;
drivers/gpu/drm/i915/gt/intel_gtt.c +2 -2
index 731d9f2bbc56..48f3a30dbc99 100644
@@ -89,7 +89,7 @@ int map_pt_dma(struct i915_address_space *vm, struct drm_i915_gem_object *obj)
      enum i915_map_type type;
      void *vaddr;
 
-     type = i915_coherent_map_type(vm->i915, obj, true);
+     type = i915_coherent_map_type(vm->gt, obj, true);
      vaddr = i915_gem_object_pin_map_unlocked(obj, type);
      if (IS_ERR(vaddr))
              return PTR_ERR(vaddr);
@@ -103,7 +103,7 @@ int map_pt_dma_locked(struct i915_address_space *vm, struct drm_i915_gem_object
      enum i915_map_type type;
      void *vaddr;
 
-     type = i915_coherent_map_type(vm->i915, obj, true);
+     type = i915_coherent_map_type(vm->gt, obj, true);
      vaddr = i915_gem_object_pin_map(obj, type);
      if (IS_ERR(vaddr))
              return PTR_ERR(vaddr);
drivers/gpu/drm/i915/gt/intel_lrc.c +1 -1
index 1b710102390b..c45e6d8cbaac 100644
@@ -1191,7 +1191,7 @@ lrc_pre_pin(struct intel_context *ce,
      GEM_BUG_ON(!i915_vma_is_pinned(ce->state));
 
      *vaddr = i915_gem_object_pin_map(ce->state->obj,
-                                      i915_coherent_map_type(ce->engine->i915,
+                                      i915_coherent_map_type(ce->engine->gt,
                                                              ce->state->obj,
                                                              false) |
                                       I915_MAP_OVERRIDE);
drivers/gpu/drm/i915/gt/intel_ring.c +1 -1
index fb99143be98e..a058532cc1b8 100644
@@ -56,7 +56,7 @@ int intel_ring_pin(struct intel_ring *ring, struct i915_gem_ww_ctx *ww)
      if (i915_vma_is_map_and_fenceable(vma) && !HAS_LLC(vma->vm->i915)) {
              addr = (void __force *)i915_vma_pin_iomap(vma);
      } else {
-             int type = i915_coherent_map_type(vma->vm->i915, vma->obj, false);
+             int type = i915_coherent_map_type(vma->vm->gt, vma->obj, false);
 
              addr = i915_gem_object_pin_map(vma->obj, type);
      }
drivers/gpu/drm/i915/gt/selftest_context.c +1 -1
index 76fbae358072..87fad1bc15a0 100644
@@ -88,7 +88,7 @@ static int __live_context_size(struct intel_engine_cs *engine)
              goto err;
 
      vaddr = i915_gem_object_pin_map_unlocked(ce->state->obj,
-                                              i915_coherent_map_type(engine->i915,
+                                              i915_coherent_map_type(engine->gt,
                                                                      ce->state->obj, false));
      if (IS_ERR(vaddr)) {
              err = PTR_ERR(vaddr);
drivers/gpu/drm/i915/gt/selftest_hangcheck.c +3 -2
index 8b0d84f2aad2..fdc0b565ee21 100644
@@ -73,7 +73,7 @@ static int hang_init(struct hang *h, struct intel_gt *gt)
      h->seqno = memset(vaddr, 0xff, PAGE_SIZE);
 
      vaddr = i915_gem_object_pin_map_unlocked(h->obj,
-                                              i915_coherent_map_type(gt->i915, h->obj, false));
+                                              i915_coherent_map_type(gt, h->obj, false));
      if (IS_ERR(vaddr)) {
              err = PTR_ERR(vaddr);
              goto err_unpin_hws;
@@ -119,7 +119,7 @@ hang_create_request(struct hang *h, struct intel_engine_cs *engine)
              return ERR_CAST(obj);
      }
 
-     vaddr = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt->i915, obj, false));
+     vaddr = i915_gem_object_pin_map_unlocked(obj,
+i915_coherent_map_type(gt, obj, false));
      if (IS_ERR(vaddr)) {
              i915_gem_object_put(obj);
              i915_vm_put(vm);
drivers/gpu/drm/i915/gt/selftest_lrc.c +1 -1
index a78a3d2c2e16..3d1daeac4c0c 100644
@@ -1292,7 +1292,7 @@ static int compare_isolation(struct intel_engine_cs *engine,
      }
 
      lrc = i915_gem_object_pin_map_unlocked(ce->state->obj,
-                                            i915_coherent_map_type(engine->i915,
+                                            i915_coherent_map_type(engine->gt,
                                                                    ce->state->obj,
                                                                    false));
      if (IS_ERR(lrc)) {
drivers/gpu/drm/i915/gt/shmem_utils.c +3 -3
index 449c9ed44382..3f2fea18746d 100644
@@ -31,9 +31,9 @@ struct file *shmem_create_from_data(const char *name, void *data, size_t len)
      return file;
 }
 
-struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
+struct file *shmem_create_from_object(struct drm_i915_gem_object *obj,
+                                   struct intel_gt *gt)
 {
-     struct drm_i915_private *i915 = to_i915(obj->base.dev);
      enum i915_map_type map_type;
      struct file *file;
      void *ptr;
@@ -44,7 +44,7 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
              return file;
      }
 
-     map_type = i915_coherent_map_type(i915, obj, true);
+     map_type = i915_coherent_map_type(gt, obj, true);
      ptr = i915_gem_object_pin_map_unlocked(obj, map_type);
      if (IS_ERR(ptr))
              return ERR_CAST(ptr);
drivers/gpu/drm/i915/gt/shmem_utils.h +3 -0
index b2b04d88c6e5..743a56307216 100644
@@ -11,9 +11,11 @@
 struct iosys_map;
 struct drm_i915_gem_object;
 struct file;
+struct intel_gt;
 
 struct file *shmem_create_from_data(const char *name, void *data, size_t len); -struct file *shmem_create_from_object(struct drm_i915_gem_object *obj);
+struct file *shmem_create_from_object(struct drm_i915_gem_object *obj,
+                                   struct intel_gt *gt);
 
 void *shmem_pin_map(struct file *file);  void shmem_unpin_map(struct file *file, void *ptr); diff --git a/drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c b/drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c

index ab1a456f833d..fb4933543f31 100644

drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c +1 -2
@@ -268,7 +268,6 @@ static int gsc_fw_load(struct intel_gsc_uc *gsc)  static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)  {
      struct intel_gt *gt = gsc_uc_to_gt(gsc);
-     struct drm_i915_private *i915 = gt->i915;
      void *src;
 
      if (!gsc->local)
@@ -278,7 +277,7 @@ static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
              return -ENOSPC;
 
      src = i915_gem_object_pin_map_unlocked(gsc->fw.obj,
-                                            i915_coherent_map_type(i915, gsc->fw.obj, true));
+                                            i915_coherent_map_type(gt, gsc->fw.obj, true));
      if (IS_ERR(src))
              return PTR_ERR(src);
 
drivers/gpu/drm/i915/gt/uc/intel_guc.c +0 -0
index 2eb891b270ae..effb37727093 100644
@@ -792,7 +792,7 @@ int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size,
              return PTR_ERR(vma);
 
      vaddr = i915_gem_object_pin_map_unlocked(vma->obj, > +                                              i915_coherent_map_type(guc_to_gt(guc),
                                                                      vma->obj, true));
      if (IS_ERR(vaddr)) {
              i915_vma_unpin_and_release(&vma, 0);
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +1 -2
index 48f506a26e6d..ca95ddadc3a8 100644
@@ -27,7 +27,6 @@ struct mtl_huc_auth_msg_out {  int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc)  {
      struct intel_gt *gt = huc_to_gt(huc);
-     struct drm_i915_private *i915 = gt->i915;
      struct drm_i915_gem_object *obj;
      struct mtl_huc_auth_msg_in *msg_in;
      struct mtl_huc_auth_msg_out *msg_out;
@@ -43,7 +42,7 @@ int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc)
      pkt_offset = i915_ggtt_offset(huc->heci_pkt);
 
      pkt_vaddr = i915_gem_object_pin_map_unlocked(obj,
-                                                  i915_coherent_map_type(i915, obj, true));
+                                                  i915_coherent_map_type(gt, obj, true));
      if (IS_ERR(pkt_vaddr))
              return PTR_ERR(pkt_vaddr);
 
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1 -1
index 7aadad5639c3..4f316f010b55 100644
@@ -1213,7 +1213,7 @@ static int uc_fw_rsa_data_create(struct intel_uc_fw *uc_fw)
              return PTR_ERR(vma);
 
      vaddr = i915_gem_object_pin_map_unlocked(vma->obj,
-                                              i915_coherent_map_type(gt->i915, vma->obj, true));
+                                              i915_coherent_map_type(gt, vma->obj, true));
      if (IS_ERR(vaddr)) {
              i915_vma_unpin_and_release(&vma, 0);
              err = PTR_ERR(vaddr);
drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.c +2 -1
index c7df47364013..8b5d3d129881 100644
@@ -336,7 +336,7 @@ gsccs_create_buffer(struct intel_gt *gt,
      }
 
      /* return a virtual pointer */
-     *map = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true));
+     *map = i915_gem_object_pin_map_unlocked(obj,
+i915_coherent_map_type(gt, obj, true));
      if (IS_ERR(*map)) {
              drm_err(&i915->drm, "Failed to map gsccs backend %s.\n", bufname);
              err = PTR_ERR(*map);
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +2 -1
index 1ce07d7e8769..00630a1c8e77 100644
@@ -245,7 +245,7 @@ static int alloc_streaming_command(struct intel_pxp *pxp)
      }
 
      /* map the lmem into the virtual memory pointer */
-     cmd = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true));
+     cmd = i915_gem_object_pin_map_unlocked(obj,
+i915_coherent_map_type(pxp->ctrl_gt, obj, true));
      if (IS_ERR(cmd)) {
              drm_err(&i915->drm, "Failed to map gsc message page!\n");
              err = PTR_ERR(cmd);
drivers/gpu/drm/i915/selftests/igt_spinner.c +1 -2
index 618d9386d554..b09e56427299 100644
@@ -97,7 +97,7 @@ int igt_spinner_pin(struct igt_spinner *spin,
      if (!spin->batch) {
              unsigned int mode;
 
-             mode = i915_coherent_map_type(spin->gt->i915, spin->obj, false);
+             mode = i915_coherent_map_type(spin->gt, spin->obj, false);
              vaddr = igt_spinner_pin_obj(ce, ww, spin->obj, mode, &spin->batch_vma);
              if (IS_ERR(vaddr))
                      return PTR_ERR(vaddr);
--

2.25.1

#8 lore raw
In reply to Jonathan Cavitt
Quoted 274 lines · Jonathan Cavitt

Refactor i915_coherent_map_type to be GT-centric rather than device-centric. Each GT may require different coherency handling due to hardware workarounds.

---
  drivers/gpu/drm/i915/display/intel_hdcp_gsc.c        |  2 +-
  drivers/gpu/drm/i915/gem/i915_gem_object.h           |  2 +-
  drivers/gpu/drm/i915/gem/i915_gem_pages.c            |  6 +++---
  .../gpu/drm/i915/gem/selftests/i915_gem_migrate.c    | 12 ++++++------
  drivers/gpu/drm/i915/gt/intel_engine_pm.c            |  2 +-
  drivers/gpu/drm/i915/gt/intel_gt.c                   |  2 +-
  drivers/gpu/drm/i915/gt/intel_gtt.c                  |  4 ++--
  drivers/gpu/drm/i915/gt/intel_lrc.c                  |  2 +-
  drivers/gpu/drm/i915/gt/intel_ring.c                 |  2 +-
  drivers/gpu/drm/i915/gt/selftest_context.c           |  2 +-
  drivers/gpu/drm/i915/gt/selftest_hangcheck.c         |  4 ++--
  drivers/gpu/drm/i915/gt/selftest_lrc.c               |  2 +-
  drivers/gpu/drm/i915/gt/shmem_utils.c                |  6 +++---
  drivers/gpu/drm/i915/gt/shmem_utils.h                |  4 +++-
  drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c            |  3 +--
  drivers/gpu/drm/i915/gt/uc/intel_guc.c               |  2 +-
  drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c            |  3 +--
  drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c             |  2 +-
  drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.c           |  2 +-
  drivers/gpu/drm/i915/pxp/intel_pxp_tee.c             |  2 +-
  drivers/gpu/drm/i915/selftests/igt_spinner.c         |  2 +-
  21 files changed, 34 insertions(+), 34 deletions(-)
drivers/gpu/drm/i915/display/intel_hdcp_gsc.c +1 -1
index ad0405375881..71da83f7e98b 100644
@@ -632,7 +632,7 @@ static int intel_hdcp_gsc_initialize_message(struct drm_i915_private *i915,
  		return PTR_ERR(obj);
  	}
 
-	cmd_in = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true));
+	cmd_in = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt, obj, true));
  	if (IS_ERR(cmd_in)) {
  		drm_err(&i915->drm, "Failed to map gsc message page!\n");
  		err = PTR_ERR(cmd_in);
drivers/gpu/drm/i915/gem/i915_gem_object.h +1 -1
index 884a17275b3a..06220494d246 100644
@@ -716,7 +716,7 @@ void *__must_check i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
  void *__must_check i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj,
  						    enum i915_map_type type);
 
-enum i915_map_type i915_coherent_map_type(struct drm_i915_private *i915,
+enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
  					  struct drm_i915_gem_object *obj,
  					  bool always_coherent);
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -3
index 89fc8ea6bcfc..44d93ead96ff 100644
@@ -465,16 +465,16 @@ void *i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj,
  	return ret;
  }
 
-enum i915_map_type i915_coherent_map_type(struct drm_i915_private *i915,
+enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
  					  struct drm_i915_gem_object *obj,
  					  bool always_coherent)
  {
  	/*
  	 * Wa_22016122933: always return I915_MAP_WC for MTL
  	 */
-	if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(i915))
+	if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(gt->i915))
  		return I915_MAP_WC;
-	if (HAS_LLC(i915) || always_coherent)
+	if (HAS_LLC(gt->i915) || always_coherent)
  		return I915_MAP_WB;
  	else
  		return I915_MAP_WC;
drivers/gpu/drm/i915/gem/selftests/i915_gem_migrate.c +6 -6
index a93a90b15907..1ad18a872750 100644
@@ -13,12 +13,12 @@
  #include "selftests/igt_spinner.h"
 
  static int igt_fill_check_buffer(struct drm_i915_gem_object *obj,
+				 struct intel_gt *gt,
  				 bool fill)
  {
-	struct drm_i915_private *i915 = to_i915(obj->base.dev);
  	unsigned int i, count = obj->base.size / sizeof(u32);
  	enum i915_map_type map_type =
-		i915_coherent_map_type(i915, obj, false);
+		i915_coherent_map_type(gt, obj, false);
  	u32 *cur;
  	int err = 0;
 
@@ -66,7 +66,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src,
  		if (err)
  			continue;
 
-		err = igt_fill_check_buffer(obj, true);
+		err = igt_fill_check_buffer(obj, gt, true);
  		if (err)
  			continue;
 
@@ -86,7 +86,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src,
  		if (err)
  			continue;
 
-		err = igt_fill_check_buffer(obj, false);
+		err = igt_fill_check_buffer(obj, gt, false);
  	}
  	i915_gem_object_put(obj);
 
@@ -233,7 +233,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,
  			continue;
 
  		if (!vma) {
-			err = igt_fill_check_buffer(obj, true);
+			err = igt_fill_check_buffer(obj, gt, true);
  			if (err)
  				continue;
  		}
@@ -276,7 +276,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,
  		if (err)
  			goto out_unlock;
  	} else {
-		err = igt_fill_check_buffer(obj, false);
+		err = igt_fill_check_buffer(obj, gt, false);
  	}
 
  out_unlock:
drivers/gpu/drm/i915/gt/intel_engine_pm.c +1 -1
index 21af0ec52223..4cc9c5b8d28e 100644
@@ -39,7 +39,7 @@ static void dbg_poison_ce(struct intel_context *ce)
 
  	if (ce->state) {
  		struct drm_i915_gem_object *obj = ce->state->obj;
-		int type = i915_coherent_map_type(ce->engine->i915, obj, true);
+		int type = i915_coherent_map_type(ce->engine->gt, obj, true);
  		void *map;
 
  		if (!i915_gem_object_trylock(obj, NULL))
drivers/gpu/drm/i915/gt/intel_gt.c +1 -1
index 9f64d61dd5fc..aaa282b0725a 100644
@@ -591,7 +591,7 @@ static int __engines_record_defaults(struct intel_gt *gt)
  			continue;
 
  		/* Keep a copy of the state's backing pages; free the obj */
-		state = shmem_create_from_object(rq->context->state->obj);
+		state = shmem_create_from_object(rq->context->state->obj, gt);
  		if (IS_ERR(state)) {
  			err = PTR_ERR(state);
  			goto out;
drivers/gpu/drm/i915/gt/intel_gtt.c +2 -2
index 731d9f2bbc56..48f3a30dbc99 100644
@@ -89,7 +89,7 @@ int map_pt_dma(struct i915_address_space *vm, struct drm_i915_gem_object *obj)
  	enum i915_map_type type;
  	void *vaddr;
 
-	type = i915_coherent_map_type(vm->i915, obj, true);
+	type = i915_coherent_map_type(vm->gt, obj, true);
  	vaddr = i915_gem_object_pin_map_unlocked(obj, type);
  	if (IS_ERR(vaddr))
  		return PTR_ERR(vaddr);
@@ -103,7 +103,7 @@ int map_pt_dma_locked(struct i915_address_space *vm, struct drm_i915_gem_object
  	enum i915_map_type type;
  	void *vaddr;
 
-	type = i915_coherent_map_type(vm->i915, obj, true);
+	type = i915_coherent_map_type(vm->gt, obj, true);
  	vaddr = i915_gem_object_pin_map(obj, type);
  	if (IS_ERR(vaddr))
  		return PTR_ERR(vaddr);
drivers/gpu/drm/i915/gt/intel_lrc.c +1 -1
index 1b710102390b..c45e6d8cbaac 100644
@@ -1191,7 +1191,7 @@ lrc_pre_pin(struct intel_context *ce,
  	GEM_BUG_ON(!i915_vma_is_pinned(ce->state));
 
  	*vaddr = i915_gem_object_pin_map(ce->state->obj,
-					 i915_coherent_map_type(ce->engine->i915,
+					 i915_coherent_map_type(ce->engine->gt,
  								ce->state->obj,
  								false) |
  					 I915_MAP_OVERRIDE);
drivers/gpu/drm/i915/gt/intel_ring.c +1 -1
index fb99143be98e..a058532cc1b8 100644
@@ -56,7 +56,7 @@ int intel_ring_pin(struct intel_ring *ring, struct i915_gem_ww_ctx *ww)
  	if (i915_vma_is_map_and_fenceable(vma) && !HAS_LLC(vma->vm->i915)) {
  		addr = (void __force *)i915_vma_pin_iomap(vma);
  	} else {
-		int type = i915_coherent_map_type(vma->vm->i915, vma->obj, false);
+		int type = i915_coherent_map_type(vma->vm->gt, vma->obj, false);
 
  		addr = i915_gem_object_pin_map(vma->obj, type);
  	}
drivers/gpu/drm/i915/gt/selftest_context.c +1 -1
index 76fbae358072..87fad1bc15a0 100644
@@ -88,7 +88,7 @@ static int __live_context_size(struct intel_engine_cs *engine)
  		goto err;
 
  	vaddr = i915_gem_object_pin_map_unlocked(ce->state->obj,
-						 i915_coherent_map_type(engine->i915,
+						 i915_coherent_map_type(engine->gt,
  									ce->state->obj, false));
  	if (IS_ERR(vaddr)) {
  		err = PTR_ERR(vaddr);
drivers/gpu/drm/i915/gt/selftest_hangcheck.c +2 -2
index 8b0d84f2aad2..fdc0b565ee21 100644
@@ -73,7 +73,7 @@ static int hang_init(struct hang *h, struct intel_gt *gt)
  	h->seqno = memset(vaddr, 0xff, PAGE_SIZE);
 
  	vaddr = i915_gem_object_pin_map_unlocked(h->obj,
-						 i915_coherent_map_type(gt->i915, h->obj, false));
+						 i915_coherent_map_type(gt, h->obj, false));
  	if (IS_ERR(vaddr)) {
  		err = PTR_ERR(vaddr);
  		goto err_unpin_hws;
@@ -119,7 +119,7 @@ hang_create_request(struct hang *h, struct intel_engine_cs *engine)
  		return ERR_CAST(obj);
  	}
 
-	vaddr = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt->i915, obj, false));
+	vaddr = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt, obj, false));
  	if (IS_ERR(vaddr)) {
  		i915_gem_object_put(obj);
  		i915_vm_put(vm);
drivers/gpu/drm/i915/gt/selftest_lrc.c +1 -1
index a78a3d2c2e16..3d1daeac4c0c 100644
@@ -1292,7 +1292,7 @@ static int compare_isolation(struct intel_engine_cs *engine,
  	}
 
  	lrc = i915_gem_object_pin_map_unlocked(ce->state->obj,
-					       i915_coherent_map_type(engine->i915,
+					       i915_coherent_map_type(engine->gt,
  								      ce->state->obj,
  								      false));
  	if (IS_ERR(lrc)) {
drivers/gpu/drm/i915/gt/shmem_utils.c +2 -2
index 449c9ed44382..3f2fea18746d 100644
@@ -31,9 +31,9 @@ struct file *shmem_create_from_data(const char *name, void *data, size_t len)
  	return file;
  }
 
-struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
+struct file *shmem_create_from_object(struct drm_i915_gem_object *obj,
+				      struct intel_gt *gt)
  {
-	struct drm_i915_private *i915 = to_i915(obj->base.dev);
  	enum i915_map_type map_type;
  	struct file *file;
  	void *ptr;

drivers/gpu/drm/i915/gt/shmem_utils.c struct file *shmem_create_from_object(struct drm_i915_gem_object *obj) · line 50

Quoted 8 lines
drivers/gpu/drm/i915/gt/shmem_utils.c +1 -1
@@ -44,7 +44,7 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
  		return file;
  	}
 
-	map_type = i915_coherent_map_type(i915, obj, true);
+	map_type = i915_coherent_map_type(gt, obj, true);
  	ptr = i915_gem_object_pin_map_unlocked(obj, map_type);
  	if (IS_ERR(ptr))
  		return ERR_CAST(ptr);

Semi-random place to comment, but it highlights well how IMO the API change to i915_coherent_map_type is a bit questionable.

This is not a shared mapping so workaround should not apply. There is no GT here at all so it is just a charade (passed in artificially to satisfy the API change) and so wrong.

Another instance of where mapping looks to be not shared seems to be the gsc_fw_load_prepare hunk, although I am not entirely sure about the lifecycle there. Presumably we populate the fw image on the CPU and then never touch it again at runtime but maybe that's not true, don't know.

Basically all GuC/HuC/PCP ones I am also not sure if they shared mappings or not.

The other ones seem okay to me - I mean truly objects which can be accesses by CPU and GPU simultaneously.

So question is can we do better in terms of API clarity and runtime scope? For instance should we leave i915_coherent_map_type as is and just have this smarter logic in a new intel_gt_coherent_map_type?

Downside is two APIs, which can add confusion too. Upside shmem_create_from_object is not misleading and can use a more efficient access. Maybe some other call sites too. How much efficient access matters.. probably not a lot. So I am thinking mostly from the point of view of being truthful to what is the issue.

Or even helpers should have explicit "shared" in the name?

Anyway, I think it is at least worth a short discussion.

Regards,

Tvrtko

Quoted 124 lines
drivers/gpu/drm/i915/gt/shmem_utils.h +3 -1
index b2b04d88c6e5..743a56307216 100644
@@ -11,9 +11,11 @@
  struct iosys_map;
  struct drm_i915_gem_object;
  struct file;
+struct intel_gt;
 
  struct file *shmem_create_from_data(const char *name, void *data, size_t len);
-struct file *shmem_create_from_object(struct drm_i915_gem_object *obj);
+struct file *shmem_create_from_object(struct drm_i915_gem_object *obj,
+				      struct intel_gt *gt);
 
  void *shmem_pin_map(struct file *file);
  void shmem_unpin_map(struct file *file, void *ptr);
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c +1 -2
index ab1a456f833d..fb4933543f31 100644
@@ -268,7 +268,6 @@ static int gsc_fw_load(struct intel_gsc_uc *gsc)
  static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
  {
  	struct intel_gt *gt = gsc_uc_to_gt(gsc);
-	struct drm_i915_private *i915 = gt->i915;
  	void *src;
 
  	if (!gsc->local)
@@ -278,7 +277,7 @@ static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
  		return -ENOSPC;
 
  	src = i915_gem_object_pin_map_unlocked(gsc->fw.obj,
-					       i915_coherent_map_type(i915, gsc->fw.obj, true));
+					       i915_coherent_map_type(gt, gsc->fw.obj, true));
  	if (IS_ERR(src))
  		return PTR_ERR(src);
 
drivers/gpu/drm/i915/gt/uc/intel_guc.c +1 -1
index 2eb891b270ae..effb37727093 100644
@@ -792,7 +792,7 @@ int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size,
  		return PTR_ERR(vma);
 
  	vaddr = i915_gem_object_pin_map_unlocked(vma->obj,
-						 i915_coherent_map_type(guc_to_gt(guc)->i915,
+						 i915_coherent_map_type(guc_to_gt(guc),
  									vma->obj, true));
  	if (IS_ERR(vaddr)) {
  		i915_vma_unpin_and_release(&vma, 0);
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +1 -2
index 48f506a26e6d..ca95ddadc3a8 100644
@@ -27,7 +27,6 @@ struct mtl_huc_auth_msg_out {
  int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc)
  {
  	struct intel_gt *gt = huc_to_gt(huc);
-	struct drm_i915_private *i915 = gt->i915;
  	struct drm_i915_gem_object *obj;
  	struct mtl_huc_auth_msg_in *msg_in;
  	struct mtl_huc_auth_msg_out *msg_out;
@@ -43,7 +42,7 @@ int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc)
  	pkt_offset = i915_ggtt_offset(huc->heci_pkt);
 
  	pkt_vaddr = i915_gem_object_pin_map_unlocked(obj,
-						     i915_coherent_map_type(i915, obj, true));
+						     i915_coherent_map_type(gt, obj, true));
  	if (IS_ERR(pkt_vaddr))
  		return PTR_ERR(pkt_vaddr);
 
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1 -1
index 7aadad5639c3..4f316f010b55 100644
@@ -1213,7 +1213,7 @@ static int uc_fw_rsa_data_create(struct intel_uc_fw *uc_fw)
  		return PTR_ERR(vma);
 
  	vaddr = i915_gem_object_pin_map_unlocked(vma->obj,
-						 i915_coherent_map_type(gt->i915, vma->obj, true));
+						 i915_coherent_map_type(gt, vma->obj, true));
  	if (IS_ERR(vaddr)) {
  		i915_vma_unpin_and_release(&vma, 0);
  		err = PTR_ERR(vaddr);
drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.c +1 -1
index c7df47364013..8b5d3d129881 100644
@@ -336,7 +336,7 @@ gsccs_create_buffer(struct intel_gt *gt,
  	}
 
  	/* return a virtual pointer */
-	*map = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true));
+	*map = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt, obj, true));
  	if (IS_ERR(*map)) {
  		drm_err(&i915->drm, "Failed to map gsccs backend %s.\n", bufname);
  		err = PTR_ERR(*map);
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +1 -1
index 1ce07d7e8769..00630a1c8e77 100644
@@ -245,7 +245,7 @@ static int alloc_streaming_command(struct intel_pxp *pxp)
  	}
 
  	/* map the lmem into the virtual memory pointer */
-	cmd = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true));
+	cmd = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(pxp->ctrl_gt, obj, true));
  	if (IS_ERR(cmd)) {
  		drm_err(&i915->drm, "Failed to map gsc message page!\n");
  		err = PTR_ERR(cmd);
drivers/gpu/drm/i915/selftests/igt_spinner.c +1 -1
index 618d9386d554..b09e56427299 100644
@@ -97,7 +97,7 @@ int igt_spinner_pin(struct igt_spinner *spin,
  	if (!spin->batch) {
  		unsigned int mode;
 
-		mode = i915_coherent_map_type(spin->gt->i915, spin->obj, false);
+		mode = i915_coherent_map_type(spin->gt, spin->obj, false);
  		vaddr = igt_spinner_pin_obj(ce, ww, spin->obj, mode, &spin->batch_vma);
  		if (IS_ERR(vaddr))
  			return PTR_ERR(vaddr);
#9 lore raw
In reply to Jonathan Cavitt

Hi Jonathan,

Quoted 3 lines · Jonathan Cavitt

Refactor i915_coherent_map_type to be GT-centric rather than device-centric. Each GT may require different coherency handling due to hardware workarounds.

[...]

Quoted 6 lines
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
-enum i915_map_type i915_coherent_map_type(struct drm_i915_private *i915,
+enum i915_map_type i915_coherent_map_type(struct intel_gt *gt,
 					  struct drm_i915_gem_object *obj,
 					  bool always_coherent)
 {
 	/*

drivers/gpu/drm/i915/gem/i915_gem_pages.c void *i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj, · line 480

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_pages.c +2 -2
 	 * Wa_22016122933: always return I915_MAP_WC for MTL
 	 */
-	if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(i915))
+	if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(gt->i915))
 		return I915_MAP_WC;
-	if (HAS_LLC(i915) || always_coherent)
+	if (HAS_LLC(gt->i915) || always_coherent)
 		return I915_MAP_WB;
 	else
 		return I915_MAP_WC;

this doesn't fully look right to me as gt-centric stuff need to be in the gt/ directory.

As for this patch, here we don't need any reference to the gt. You could eventually add some wrapper inside gt/ that perform the per 'gt' checks and at the end call this function here.

Andi