Skip to contentSkip to conversation

drm/i915/guc: Fix GuC pin bias and WOPCM initialization order

PATCH Superseded Jakub Bartmiński 4 participants 10 messages Jul 17, 2018

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/i915/guc: Fix GuC pin bias and WOPCM initialization order

It would seem that we are using uninitialized WOPCM variables when setting the GuC pin bias. The pin bias has to be set after the WOPCM, but before the call to i915_gem_contexts_init where the first contexts are pinned so the safest place to set it seems to be right after initializing the relevant variables in intel_wopcm_init.

Cc Chris Wilson <[email protected]>
Cc Michał Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc.c   | 21 ---------------------
 drivers/gpu/drm/i915/intel_wopcm.c | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/intel_guc.c +0 -21
index e12bd259df17..47cacd59ac32 100644
@@ -27,8 +27,6 @@
 #include "intel_guc_submission.h"
 #include "i915_drv.h"
 
-static void guc_init_ggtt_pin_bias(struct intel_guc *guc);
-
 static void gen8_guc_raise_irq(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
@@ -142,8 +140,6 @@ int intel_guc_init_misc(struct intel_guc *guc)
 	struct drm_i915_private *i915 = guc_to_i915(guc);
 	int ret;
 
-	guc_init_ggtt_pin_bias(guc);
-
 	ret = guc_init_wq(guc);
 	if (ret)
 		return ret;
@@ -611,23 +607,6 @@ int intel_guc_resume(struct intel_guc *guc)
  * actual GuC WOPCM size.
  */
 
-/**
- * guc_init_ggtt_pin_bias() - Initialize the GuC ggtt_pin_bias value.
- * @guc: intel_guc structure.
- *
- * This function will calculate and initialize the ggtt_pin_bias value based on
- * overall WOPCM size and GuC WOPCM size.
- */
-static void guc_init_ggtt_pin_bias(struct intel_guc *guc)
-{
-	struct drm_i915_private *i915 = guc_to_i915(guc);
-
-	GEM_BUG_ON(!i915->wopcm.size);
-	GEM_BUG_ON(i915->wopcm.size < i915->wopcm.guc.base);
-
-	guc->ggtt_pin_bias = i915->wopcm.size - i915->wopcm.guc.base;
-}
-
 /**
  * intel_guc_allocate_vma() - Allocate a GGTT VMA for GuC usage
  * @guc:	the guc
drivers/gpu/drm/i915/intel_wopcm.c +19 -0
index 74bf76f3fddc..02f602db9548 100644
@@ -140,6 +140,23 @@ static inline int check_hw_restriction(struct drm_i915_private *i915,
 	return err;
 }
 
+/**
+ * wopcm_init_guc_ggtt_pin_bias() - Initialize the GuC ggtt_pin_bias value.
+ * @wopcm: pointer to intel_wopcm.
+ *
+ * This function will calculate and initialize the GuC ggtt_pin_bias value based
+ * on overall WOPCM size and GuC WOPCM size.
+ */
+static void wopcm_init_guc_ggtt_pin_bias(struct intel_wopcm *wopcm)
+{
+	struct drm_i915_private *i915 = wopcm_to_i915(wopcm);
+
+	GEM_BUG_ON(!wopcm->size);
+	GEM_BUG_ON(wopcm->size < wopcm->guc.base);
+
+	i915->guc.ggtt_pin_bias = wopcm->size - wopcm->guc.base;
+}
+
 /**
  * intel_wopcm_init() - Initialize the WOPCM structure.
  * @wopcm: pointer to intel_wopcm.
@@ -207,6 +224,8 @@ int intel_wopcm_init(struct intel_wopcm *wopcm)
 	wopcm->guc.base = guc_wopcm_base;
 	wopcm->guc.size = guc_wopcm_size;
 
+	wopcm_init_guc_ggtt_pin_bias(wopcm);
+
 	return 0;
 }
 
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/3 drm/i915/guc: Move the pin bias value from GuC to GGTT

Removing the pin bias from GuC allows us to not check for GuC when pinning contexts, which fixes the assertion error on unresolved GuC platform default in mock context selftest.

WOPCM (and GuC-specific pin bias) initialization has to be postponed until the default value is set for ggtt.pin_bias inside i915_gem_init_ggtt, and still has to occur before context pinning inside i915_gem_contexts_init.

With this change the intel_guc_ggtt_offset function has to know the full declaration of the drm_i915_private structure so it can no longer be located in the intel_guc.h header file due to include order.

Cc Chris Wilson <[email protected]>
Cc Michał Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c           |  8 +++---
 drivers/gpu/drm/i915/i915_gem_context.c   | 10 +------
 drivers/gpu/drm/i915/i915_gem_gtt.c       |  6 +++++
 drivers/gpu/drm/i915/i915_gem_gtt.h       |  2 ++
 drivers/gpu/drm/i915/intel_guc.c          | 33 ++++++++++++++++++++---
 drivers/gpu/drm/i915/intel_guc.h          | 28 +------------------
 drivers/gpu/drm/i915/intel_huc.c          |  2 +-
 drivers/gpu/drm/i915/intel_uc_fw.c        |  2 +-
 drivers/gpu/drm/i915/intel_wopcm.c        | 13 ++++-----
 drivers/gpu/drm/i915/selftests/mock_gtt.c |  2 ++
 10 files changed, 54 insertions(+), 52 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +4 -4
index ed2be33ec58a..45f69f588e6d 100644
@@ -5471,10 +5471,6 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
 	if (ret)
 		return ret;
 
-	ret = intel_wopcm_init(&dev_priv->wopcm);
-	if (ret)
-		goto err_uc_misc;
-
 	/* This is just a security blanket to placate dragons.
 	 * On some systems, we very sporadically observe that the first TLBs
 	 * used by the CS may be stale, despite us poking the TLB reset. If
@@ -5490,6 +5486,10 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
 		goto err_unlock;
 	}
 
+	ret = intel_wopcm_init(&dev_priv->wopcm);
+	if (ret)
+		goto err_uc_misc;
+
 	ret = i915_gem_contexts_init(dev_priv);
 	if (ret) {
 		GEM_BUG_ON(ret == -EIO);
drivers/gpu/drm/i915/i915_gem_context.c +1 -9
index b10770cfccd2..32f96b8cd9c4 100644
@@ -329,15 +329,7 @@ __create_hw_context(struct drm_i915_private *dev_priv,
 	ctx->desc_template =
 		default_desc_template(dev_priv, dev_priv->mm.aliasing_ppgtt);
 
-	/*
-	 * GuC requires the ring to be placed in Non-WOPCM memory. If GuC is not
-	 * present or not in use we still need a small bias as ring wraparound
-	 * at offset 0 sometimes hangs. No idea why.
-	 */
-	if (USES_GUC(dev_priv))
-		ctx->ggtt_offset_bias = dev_priv->guc.ggtt_pin_bias;
-	else
-		ctx->ggtt_offset_bias = I915_GTT_PAGE_SIZE;
+	ctx->ggtt_offset_bias = dev_priv->ggtt.pin_bias;
 
 	return ctx;
 
drivers/gpu/drm/i915/i915_gem_gtt.c +6 -0
index d0acef299b9c..62bfb06a3aae 100644
@@ -2917,6 +2917,12 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)
 	struct drm_mm_node *entry;
 	int ret;
 
+	/*
+	 * We need a small bias as ring wraparound at offset 0
+	 * sometimes hangs. No idea why.
+	 */
+	ggtt->pin_bias = I915_GTT_PAGE_SIZE;
+
 	ret = intel_vgt_balloon(dev_priv);
 	if (ret)
 		return ret;
drivers/gpu/drm/i915/i915_gem_gtt.h +2 -0
index 14e62651010b..71e8cf24c800 100644
@@ -396,6 +396,8 @@ struct i915_ggtt {
 
 	int mtrr;
 
+	u32 pin_bias;
+
 	struct drm_mm_node error_capture;
 };
 
drivers/gpu/drm/i915/intel_guc.c +29 -4
index 47cacd59ac32..eb9a2caa6560 100644
@@ -607,6 +607,31 @@ int intel_guc_resume(struct intel_guc *guc)
  * actual GuC WOPCM size.
  */
 
+/**
+ * intel_guc_ggtt_offset() - Get and validate the GGTT offset of @vma
+ * @guc: intel_guc structure.
+ * @vma: i915 graphics virtual memory area.
+ *
+ * GuC does not allow any gfx GGTT address that falls into range
+ * [0, ggtt.pin_bias), which is reserved for Boot ROM, SRAM and WOPCM.
+ * Currently, in order to exclude [0, ggtt.pin_bias) address space from
+ * GGTT, all gfx objects used by GuC are allocated with intel_guc_allocate_vma()
+ * and pinned with PIN_OFFSET_BIAS along with the value of ggtt.pin_bias.
+ *
+ * Return: GGTT offset of the @vma.
+ */
+u32 intel_guc_ggtt_offset(struct intel_guc *guc, struct i915_vma *vma)
+{
+	struct drm_i915_private *i915 = guc_to_i915(guc);
+
+	u32 offset = i915_ggtt_offset(vma);
+
+	GEM_BUG_ON(offset < i915->ggtt.pin_bias);
+	GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
+
+	return offset;
+}
+
 /**
  * intel_guc_allocate_vma() - Allocate a GGTT VMA for GuC usage
  * @guc:	the guc
@@ -622,21 +647,21 @@ int intel_guc_resume(struct intel_guc *guc)
  */
 struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size)
 {
-	struct drm_i915_private *dev_priv = guc_to_i915(guc);
+	struct drm_i915_private *i915 = guc_to_i915(guc);
 	struct drm_i915_gem_object *obj;
 	struct i915_vma *vma;
 	int ret;
 
-	obj = i915_gem_object_create(dev_priv, size);
+	obj = i915_gem_object_create(i915, size);
 	if (IS_ERR(obj))
 		return ERR_CAST(obj);
 
-	vma = i915_vma_instance(obj, &dev_priv->ggtt.vm, NULL);
+	vma = i915_vma_instance(obj, &i915->ggtt.vm, NULL);
 	if (IS_ERR(vma))
 		goto err;
 
 	ret = i915_vma_pin(vma, 0, PAGE_SIZE,
-			   PIN_GLOBAL | PIN_OFFSET_BIAS | guc->ggtt_pin_bias);
+			   PIN_GLOBAL | PIN_OFFSET_BIAS | i915->ggtt.pin_bias);
 	if (ret) {
 		vma = ERR_PTR(ret);
 		goto err;
drivers/gpu/drm/i915/intel_guc.h +1 -27
index 4121928a495e..b0e5c99c0338 100644
@@ -49,9 +49,6 @@ struct intel_guc {
 	struct intel_guc_log log;
 	struct intel_guc_ct ct;
 
-	/* Offset where Non-WOPCM memory starts. */
-	u32 ggtt_pin_bias;
-
 	/* Log snapshot if GuC errors during load */
 	struct drm_i915_gem_object *load_err_log;
 
@@ -123,30 +120,7 @@ static inline void intel_guc_to_host_event_handler(struct intel_guc *guc)
 
 /* GuC addresses above GUC_GGTT_TOP also don't map through the GTT */
 #define GUC_GGTT_TOP	0xFEE00000
-
-/**
- * intel_guc_ggtt_offset() - Get and validate the GGTT offset of @vma
- * @guc: intel_guc structure.
- * @vma: i915 graphics virtual memory area.
- *
- * GuC does not allow any gfx GGTT address that falls into range
- * [0, GuC ggtt_pin_bias), which is reserved for Boot ROM, SRAM and WOPCM.
- * Currently, in order to exclude [0, GuC ggtt_pin_bias) address space from
- * GGTT, all gfx objects used by GuC are allocated with intel_guc_allocate_vma()
- * and pinned with PIN_OFFSET_BIAS along with the value of GuC ggtt_pin_bias.
- *
- * Return: GGTT offset of the @vma.
- */
-static inline u32 intel_guc_ggtt_offset(struct intel_guc *guc,
-					struct i915_vma *vma)
-{
-	u32 offset = i915_ggtt_offset(vma);
-
-	GEM_BUG_ON(offset < guc->ggtt_pin_bias);
-	GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
-
-	return offset;
-}
+u32 intel_guc_ggtt_offset(struct intel_guc *guc, struct i915_vma *vma);
 
 void intel_guc_init_early(struct intel_guc *guc);
 void intel_guc_init_send_regs(struct intel_guc *guc);
drivers/gpu/drm/i915/intel_huc.c +1 -1
index ffcad5fad6a7..37ef540dd280 100644
@@ -63,7 +63,7 @@ int intel_huc_auth(struct intel_huc *huc)
 		return -ENOEXEC;
 
 	vma = i915_gem_object_ggtt_pin(huc->fw.obj, NULL, 0, 0,
-				       PIN_OFFSET_BIAS | guc->ggtt_pin_bias);
+				       PIN_OFFSET_BIAS | i915->ggtt.pin_bias);
 	if (IS_ERR(vma)) {
 		ret = PTR_ERR(vma);
 		DRM_ERROR("HuC: Failed to pin huc fw object %d\n", ret);
drivers/gpu/drm/i915/intel_uc_fw.c +1 -1
index 6e8e0b546743..fd496416087c 100644
@@ -222,7 +222,7 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
 		goto fail;
 	}
 
-	ggtt_pin_bias = to_i915(uc_fw->obj->base.dev)->guc.ggtt_pin_bias;
+	ggtt_pin_bias = to_i915(uc_fw->obj->base.dev)->ggtt.pin_bias;
 	vma = i915_gem_object_ggtt_pin(uc_fw->obj, NULL, 0, 0,
 				       PIN_OFFSET_BIAS | ggtt_pin_bias);
 	if (IS_ERR(vma)) {
drivers/gpu/drm/i915/intel_wopcm.c +7 -6
index 02f602db9548..a869fad27db3 100644
@@ -141,20 +141,21 @@ static inline int check_hw_restriction(struct drm_i915_private *i915,
 }
 
 /**
- * wopcm_init_guc_ggtt_pin_bias() - Initialize the GuC ggtt_pin_bias value.
+ * wopcm_init_ggtt_pin_bias() - Initialize the ggtt pin bias value.
  * @wopcm: pointer to intel_wopcm.
  *
- * This function will calculate and initialize the GuC ggtt_pin_bias value based
- * on overall WOPCM size and GuC WOPCM size.
+ * Any objects shared with GuC can't overlap with WOPCM.
+ * This function will calculate and initialize the ggtt pin bias value
+ * based on overall WOPCM size and GuC WOPCM size.
  */
-static void wopcm_init_guc_ggtt_pin_bias(struct intel_wopcm *wopcm)
+static void wopcm_init_ggtt_pin_bias(struct intel_wopcm *wopcm)
 {
 	struct drm_i915_private *i915 = wopcm_to_i915(wopcm);
 
 	GEM_BUG_ON(!wopcm->size);
 	GEM_BUG_ON(wopcm->size < wopcm->guc.base);
 
-	i915->guc.ggtt_pin_bias = wopcm->size - wopcm->guc.base;
+	i915->ggtt.pin_bias = wopcm->size - wopcm->guc.base;
 }
 
 /**
@@ -224,7 +225,7 @@ int intel_wopcm_init(struct intel_wopcm *wopcm)
 	wopcm->guc.base = guc_wopcm_base;
 	wopcm->guc.size = guc_wopcm_size;
 
-	wopcm_init_guc_ggtt_pin_bias(wopcm);
+	wopcm_init_ggtt_pin_bias(wopcm);
 
 	return 0;
 }
drivers/gpu/drm/i915/selftests/mock_gtt.c +2 -0
index a140ea5c3a7c..3afff10e94d9 100644
@@ -117,6 +117,8 @@ void mock_init_ggtt(struct drm_i915_private *i915)
 	ggtt->vm.vma_ops.set_pages   = ggtt_set_pages;
 	ggtt->vm.vma_ops.clear_pages = clear_pages;
 
+	ggtt->pin_bias = I915_GTT_PAGE_SIZE;
+
 	i915_address_space_init(&ggtt->vm, i915);
 }
 
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH 2/3] drm/i915/guc: Move the pin bias value from GuC to GGTT

Quoting Jakub Bartmiński (2018-07-17 12:55:59)

drivers/gpu/drm/i915/i915_gem.c int i915_gem_init(struct drm_i915_private *dev_priv) · line 5491

Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c +3 -0
@@ -5490,6 +5486,10 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
                goto err_unlock;
        }
 
+       ret = intel_wopcm_init(&dev_priv->wopcm);
+       if (ret)
+               goto err_uc_misc;

Hmm. are you sure about the unwind? Looks like it should be err_ggtt.

For science, I would suggest putting a couple of i915_inject_fault() around the wopcm_init() paths.

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
index b10770cfccd2..32f96b8cd9c4 100644
@@ -329,15 +329,7 @@ __create_hw_context(struct drm_i915_private *dev_priv,
        ctx->desc_template =
                default_desc_template(dev_priv, dev_priv->mm.aliasing_ppgtt);
 

drivers/gpu/drm/i915/i915_gem_context.c __create_hw_context(struct drm_i915_private *dev_priv, · line 332

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -9
-       /*
-        * GuC requires the ring to be placed in Non-WOPCM memory. If GuC is not
-        * present or not in use we still need a small bias as ring wraparound
-        * at offset 0 sometimes hangs. No idea why.
-        */
-       if (USES_GUC(dev_priv))
-               ctx->ggtt_offset_bias = dev_priv->guc.ggtt_pin_bias;
-       else
-               ctx->ggtt_offset_bias = I915_GTT_PAGE_SIZE;
+       ctx->ggtt_offset_bias = dev_priv->ggtt.pin_bias;

We could probably also remove it from ctx now (in a later patch).

drivers/gpu/drm/i915/i915_gem_context.c

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
-static void wopcm_init_guc_ggtt_pin_bias(struct intel_wopcm *wopcm)
+static void wopcm_init_ggtt_pin_bias(struct intel_wopcm *wopcm)
 {
        struct drm_i915_private *i915 = wopcm_to_i915(wopcm);
 
        GEM_BUG_ON(!wopcm->size);
        GEM_BUG_ON(wopcm->size < wopcm->guc.base);
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
-       i915->guc.ggtt_pin_bias = wopcm->size - wopcm->guc.base;
+       i915->ggtt.pin_bias = wopcm->size - wopcm->guc.base;

For safety,

	i915->ggtt.pin_bias = max(i915->gtt.pin_bias,
				  wopcm->size - wopcm->guc.base);
Quoted 14 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
@@ -224,7 +225,7 @@ int intel_wopcm_init(struct intel_wopcm *wopcm)
        wopcm->guc.base = guc_wopcm_base;
        wopcm->guc.size = guc_wopcm_size;
 
-       wopcm_init_guc_ggtt_pin_bias(wopcm);
+       wopcm_init_ggtt_pin_bias(wopcm);
 
        return 0;
 }
drivers/gpu/drm/i915/selftests/mock_gtt.c +0 -0
index a140ea5c3a7c..3afff10e94d9 100644

drivers/gpu/drm/i915/selftests/mock_gtt.c void mock_init_ggtt(struct drm_i915_private *i915) · line 120

Quoted 4 lines
drivers/gpu/drm/i915/selftests/mock_gtt.c +1 -0
@@ -117,6 +117,8 @@ void mock_init_ggtt(struct drm_i915_private *i915)
        ggtt->vm.vma_ops.set_pages   = ggtt_set_pages;
        ggtt->vm.vma_ops.clear_pages = clear_pages;
 
+       ggtt->pin_bias = I915_GTT_PAGE_SIZE;

For mocking, we can leave it at zero (I think we don't assert that PIN_OFFSET_BIAS can't be zero).
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

PATCH 3/3 HAX enable guc for CI

In reply to Jakub Bartmiński

From: Michał Winiarski <[email protected]>

---
 drivers/gpu/drm/i915/i915_params.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_params.h +1 -1
index aebe0469ddaa..3e4e128237ac 100644
@@ -47,7 +47,7 @@ struct drm_printer;
 	param(int, disable_power_well, -1) \
 	param(int, enable_ips, 1) \
 	param(int, invert_brightness, 0) \
-	param(int, enable_guc, 0) \
+	param(int, enable_guc, -1) \
 	param(int, guc_log_level, -1) \
 	param(char *, guc_firmware_path, NULL) \
 	param(char *, huc_firmware_path, NULL) \
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
In reply to Jakub Bartmiński

Quoting Jakub Bartmiński (2018-07-17 12:55:58)

Quoted 5 lines

It would seem that we are using uninitialized WOPCM variables when setting the GuC pin bias. The pin bias has to be set after the WOPCM, but before the call to i915_gem_contexts_init where the first contexts are pinned so the safest place to set it seems to be right after initializing the relevant variables in intel_wopcm_init.

Oops, do you have a Fixes? Any idea as to how this didn't reveal itself under our superficial testing?
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
Quoted 8 lines · Chris Wilson

Quoting Jakub Bartmiński (2018-07-17 12:55:58)

Quoted 5 lines

It would seem that we are using uninitialized WOPCM variables when setting the GuC pin bias. The pin bias has to be set after the WOPCM, but before the call to i915_gem_contexts_init where the first contexts are pinned so the safest place to set it seems to be right after initializing the relevant variables in intel_wopcm_init.

Oops, do you have a Fixes?

Ha, it could be my fault: intel_wopcm_init and intel_uc_init_misc were swapped in ("drm/i915/uc: Fetch GuC/HuC firmwares from guc/huc specific init")

Michal
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw
In reply to Jakub Bartmiński
Quoted 76 lines · Jakub Bartmiński

It would seem that we are using uninitialized WOPCM variables when setting the GuC pin bias. The pin bias has to be set after the WOPCM, but before the call to i915_gem_contexts_init where the first contexts are pinned so the safest place to set it seems to be right after initializing the relevant variables in intel_wopcm_init.

Cc Chris Wilson <[email protected]>
Cc Michał Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc.c   | 21 ---------------------
 drivers/gpu/drm/i915/intel_wopcm.c | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/intel_guc.c +0 -9
index e12bd259df17..47cacd59ac32 100644
@@ -27,8 +27,6 @@
 #include "intel_guc_submission.h"
 #include "i915_drv.h"
-static void guc_init_ggtt_pin_bias(struct intel_guc *guc);
-
 static void gen8_guc_raise_irq(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
@@ -142,8 +140,6 @@ int intel_guc_init_misc(struct intel_guc *guc)
 	struct drm_i915_private *i915 = guc_to_i915(guc);
 	int ret;
-	guc_init_ggtt_pin_bias(guc);
-
 	ret = guc_init_wq(guc);
 	if (ret)
 		return ret;
@@ -611,23 +607,6 @@ int intel_guc_resume(struct intel_guc *guc)
  * actual GuC WOPCM size.
  */
-/**
- * guc_init_ggtt_pin_bias() - Initialize the GuC ggtt_pin_bias value.
- * @guc: intel_guc structure.
- *
- * This function will calculate and initialize the ggtt_pin_bias value  

based on
- * overall WOPCM size and GuC WOPCM size.
- */

drivers/gpu/drm/i915/intel_guc.c +0 -10
-static void guc_init_ggtt_pin_bias(struct intel_guc *guc)
-{
-	struct drm_i915_private *i915 = guc_to_i915(guc);
-
-	GEM_BUG_ON(!i915->wopcm.size);
-	GEM_BUG_ON(i915->wopcm.size < i915->wopcm.guc.base);
-
-	guc->ggtt_pin_bias = i915->wopcm.size - i915->wopcm.guc.base;
-}
-
 /**
  * intel_guc_allocate_vma() - Allocate a GGTT VMA for GuC usage
  * @guc:	the guc
drivers/gpu/drm/i915/intel_wopcm.c +2 -0
index 74bf76f3fddc..02f602db9548 100644
@@ -140,6 +140,23 @@ static inline int check_hw_restriction(struct  
 drm_i915_private *i915,
 	return err;
 }
+/**
+ * wopcm_init_guc_ggtt_pin_bias() - Initialize the GuC ggtt_pin_bias  

value.
+ * @wopcm: pointer to intel_wopcm.
+ *
+ * This function will calculate and initialize the GuC ggtt_pin_bias value based
+ * on overall WOPCM size and GuC WOPCM size.
+ */

drivers/gpu/drm/i915/intel_wopcm.c static inline int check_hw_restriction(struct drm_i915_private *i915, · line 157

Quoted 8 lines
drivers/gpu/drm/i915/intel_wopcm.c +8 -0
+static void wopcm_init_guc_ggtt_pin_bias(struct intel_wopcm *wopcm)
+{
+	struct drm_i915_private *i915 = wopcm_to_i915(wopcm);
+
+	GEM_BUG_ON(!wopcm->size);
+	GEM_BUG_ON(wopcm->size < wopcm->guc.base);
+
+	i915->guc.ggtt_pin_bias = wopcm->size - wopcm->guc.base;

Hmm, I don't like the idea to modify GuC (or GGTT later on) internals directly from WOPCM private functions.

Maybe you can change your series to first move pin_bias from GuC to GGTT and then immediately setup it inside i915_gem_init_ggtt() which is called after intel_wopcm_init() and before i915_gem_contexts_init()

Michal

drivers/gpu/drm/i915/intel_wopcm.c int intel_wopcm_init(struct intel_wopcm *wopcm) · line 229

Quoted 12 lines
drivers/gpu/drm/i915/intel_wopcm.c +4 -0
+}
+
 /**
  * intel_wopcm_init() - Initialize the WOPCM structure.
  * @wopcm: pointer to intel_wopcm.
@@ -207,6 +224,8 @@ int intel_wopcm_init(struct intel_wopcm *wopcm)
 	wopcm->guc.base = guc_wopcm_base;
 	wopcm->guc.size = guc_wopcm_size;
+	wopcm_init_guc_ggtt_pin_bias(wopcm);
+
 	return 0;
 }

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw
Quoted 110 lines · Michal Wajdeczko
Quoted 88 lines · Jakub Bartmiński

It would seem that we are using uninitialized WOPCM variables when setting the GuC pin bias. The pin bias has to be set after the WOPCM,
but before the call to i915_gem_contexts_init where the first contexts
are pinned so the safest place to set it seems to be right after initializing the relevant variables in intel_wopcm_init.

Cc Chris Wilson <[email protected]>
Cc Michał Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc.c   | 21 ---------------------
 drivers/gpu/drm/i915/intel_wopcm.c | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/intel_guc.c +0 -6
index e12bd259df17..47cacd59ac32 100644
@@ -27,8 +27,6 @@
 #include "intel_guc_submission.h"
 #include "i915_drv.h"
-static void guc_init_ggtt_pin_bias(struct intel_guc *guc);
-
 static void gen8_guc_raise_irq(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
@@ -142,8 +140,6 @@ int intel_guc_init_misc(struct intel_guc *guc)
 	struct drm_i915_private *i915 = guc_to_i915(guc);
 	int ret;
-	guc_init_ggtt_pin_bias(guc);
-
 	ret = guc_init_wq(guc);
 	if (ret)
 		return ret;
@@ -611,23 +607,6 @@ int intel_guc_resume(struct intel_guc *guc)
  * actual GuC WOPCM size.
  */
-/**
- * guc_init_ggtt_pin_bias() - Initialize the GuC ggtt_pin_bias

value.
- * @guc: intel_guc structure.
- *
- * This function will calculate and initialize the ggtt_pin_bias value
based on
- * overall WOPCM size and GuC WOPCM size.
- */

drivers/gpu/drm/i915/intel_guc.c +0 -8
-static void guc_init_ggtt_pin_bias(struct intel_guc *guc)
-{
-	struct drm_i915_private *i915 = guc_to_i915(guc);
-
-	GEM_BUG_ON(!i915->wopcm.size);
-	GEM_BUG_ON(i915->wopcm.size < i915->wopcm.guc.base);
-
-	guc->ggtt_pin_bias = i915->wopcm.size - i915-
Quoted 1 line

wopcm.guc.base;

drivers/gpu/drm/i915/intel_guc.c +0 -2
-}
-
 /**
  * intel_guc_allocate_vma() - Allocate a GGTT VMA for GuC usage
  * @guc:	the guc
drivers/gpu/drm/i915/intel_wopcm.c +0 -0
index 74bf76f3fddc..02f602db9548 100644
@@ -140,6 +140,23 @@ static inline int

check_hw_restriction(struct
drm_i915_private *i915,

drivers/gpu/drm/i915/intel_wopcm.c +2 -0
 	return err;
 }
+/**
+ * wopcm_init_guc_ggtt_pin_bias() - Initialize the GuC

ggtt_pin_bias
value.
+ * @wopcm: pointer to intel_wopcm.
+ *
+ * This function will calculate and initialize the GuC ggtt_pin_bias
value based
+ * on overall WOPCM size and GuC WOPCM size.
+ */
+static void wopcm_init_guc_ggtt_pin_bias(struct intel_wopcm *wopcm)

drivers/gpu/drm/i915/intel_wopcm.c static inline int check_hw_restriction(struct drm_i915_private *i915, · line 157

Quoted 7 lines
drivers/gpu/drm/i915/intel_wopcm.c +7 -0
+{
+	struct drm_i915_private *i915 = wopcm_to_i915(wopcm);
+
+	GEM_BUG_ON(!wopcm->size);
+	GEM_BUG_ON(wopcm->size < wopcm->guc.base);
+
+	i915->guc.ggtt_pin_bias = wopcm->size - wopcm->guc.base;

Hmm, I don't like the idea to modify GuC (or GGTT later on) internals directly from WOPCM private functions.

Maybe you can change your series to first move pin_bias from GuC to GGTT and then immediately setup it inside i915_gem_init_ggtt() which is called after intel_wopcm_init() and before i915_gem_contexts_init()

Michal

Quoted 12 lines

drivers/gpu/drm/i915/intel_wopcm.c int intel_wopcm_init(struct intel_wopcm *wopcm) · line 229

Quoted 12 lines
drivers/gpu/drm/i915/intel_wopcm.c +4 -0
+}
+
 /**
  * intel_wopcm_init() - Initialize the WOPCM structure.
  * @wopcm: pointer to intel_wopcm.
@@ -207,6 +224,8 @@ int intel_wopcm_init(struct intel_wopcm *wopcm)
 	wopcm->guc.base = guc_wopcm_base;
 	wopcm->guc.size = guc_wopcm_size;
+	wopcm_init_guc_ggtt_pin_bias(wopcm);
+
 	return 0;
 }

Indeed, since I don't think that the mock tests use this initialization path, we should be able to decide on how to set the new ggtt pin_bias value with the USES_GUC macro inside i915_gem_init_ggtt without raising any assertion failures.
I will also take into account Chris's suggestions and resend.

-Jakub

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] drm/i915/guc: Fix GuC pin bias and WOPCM initialization order

In reply to Jakub Bartmiński
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm/i915/guc: Fix GuC pin bias and WOPCM initialization order
URL : https://patchwork.freedesktop.org/series/46694/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
a306d95ba69b drm/i915/guc: Fix GuC pin bias and WOPCM initialization order
8109d90af98b drm/i915/guc: Move the pin bias value from GuC to GGTT
8eb45a9bb564 HAX enable guc for CI
-:19: ERROR:MISSING_SIGN_OFF: Missing Signed-off-by: line(s)

total: 1 errors, 0 warnings, 0 checks, 8 lines checked

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

✗ Fi.CI.BAT: failure for series starting with [1/3] drm/i915/guc: Fix GuC pin bias and WOPCM initialization order

In reply to Jakub Bartmiński
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm/i915/guc: Fix GuC pin bias and WOPCM initialization order
URL : https://patchwork.freedesktop.org/series/46694/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4501 -> Patchwork_9690 =

== Summary - FAILURE ==

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

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

External URL: https://patchwork.freedesktop.org/api/1.0/series/46694/revisions/1/mbox/

== Possible new issues ==

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

=== IGT changes ===

    ==== Possible regressions ====

    igt@core_auth@basic-auth:
      {fi-skl-iommu}:     PASS -> INCOMPLETE

    igt@drv_selftest@live_guc:
      fi-kbl-7567u:       PASS -> DMESG-WARN
      fi-skl-gvtdvm:      PASS -> DMESG-WARN
      fi-bxt-dsi:         PASS -> DMESG-WARN
      fi-whl-u:           PASS -> DMESG-WARN
      fi-kbl-7560u:       PASS -> DMESG-WARN
      fi-kbl-r:           PASS -> DMESG-WARN
      fi-kbl-x1275:       PASS -> DMESG-WARN
      fi-bxt-j4205:       PASS -> DMESG-WARN
      fi-cfl-s3:          PASS -> DMESG-WARN
      fi-kbl-7500u:       PASS -> DMESG-WARN
      fi-cfl-8700k:       PASS -> DMESG-WARN

    igt@drv_selftest@live_hangcheck:
      fi-whl-u:           PASS -> DMESG-FAIL
      fi-bxt-dsi:         PASS -> DMESG-FAIL
      fi-bxt-j4205:       PASS -> DMESG-FAIL

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
      {fi-cfl-8109u}:     NOTRUN -> INCOMPLETE

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_guc:
      fi-skl-6600u:       PASS -> DMESG-WARN (fdo#107175)
      fi-skl-6260u:       PASS -> DMESG-WARN (fdo#107175)
      fi-skl-6700k2:      PASS -> DMESG-WARN (fdo#107175)
      fi-skl-6770hq:      PASS -> DMESG-WARN (fdo#107175)
      fi-skl-6700hq:      PASS -> DMESG-WARN (fdo#107175)

    igt@drv_selftest@live_hangcheck:
      fi-skl-guc:         PASS -> DMESG-FAIL (fdo#107174)
      fi-skl-6600u:       PASS -> DMESG-FAIL (fdo#107174)
      fi-cfl-s3:          PASS -> DMESG-FAIL (fdo#106560)

    igt@kms_flip@basic-flip-vs-dpms:
      fi-skl-6700hq:      PASS -> DMESG-WARN (fdo#105998)

    igt@prime_vgem@basic-fence-flip:
      fi-glk-j4005:       PASS -> FAIL (fdo#104008)

    
    ==== Possible fixes ====

    igt@gem_exec_suspend@basic-s4-devices:
      fi-kbl-7500u:       DMESG-WARN (fdo#107139, fdo#105128) -> PASS

    igt@kms_busy@basic-flip-b:
      fi-skl-6700hq:      DMESG-WARN (fdo#105998) -> PASS +1

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         FAIL (fdo#104008) -> PASS

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

fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
fdo#105128 https://bugs.freedesktop.org/show_bug.cgi?id=105128
fdo#105998 https://bugs.freedesktop.org/show_bug.cgi?id=105998
fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
fdo#107139 https://bugs.freedesktop.org/show_bug.cgi?id=107139
fdo#107174 https://bugs.freedesktop.org/show_bug.cgi?id=107174
fdo#107175 https://bugs.freedesktop.org/show_bug.cgi?id=107175

== Participating hosts (46 -> 41) ==

Additional (1): fi-cfl-8109u
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-kbl-8809g

== Build changes ==

* Linux: CI_DRM_4501 -> Patchwork_9690

CI_DRM_4501: 692d13f7b75baf0bb8c58b9784569c52d68f01e2 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4559: 6d341aac2124836443ce74e8e97a4508ac8d5095 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9690: 8eb45a9bb564cb78bbd091dad25f2e974670d7cf @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

8eb45a9bb564 HAX enable guc for CI
8109d90af98b drm/i915/guc: Move the pin bias value from GuC to GGTT a306d95ba69b drm/i915/guc: Fix GuC pin bias and WOPCM initialization order

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9690/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx