Skip to contentSkip to conversation

drm/i915/huc: Move firmware selection to init_early

PATCH Superseded Michal Wajdeczko 4 participants 11 messages Nov 30, 2017

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 drm/i915/huc: Move firmware selection to init_early

Doing HuC firmware path selection from sanitize_options function is not perfect, while there is no problem with doing so during early init stage as we already have all needed data.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Sagar Arun Kamble <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h  |  3 ++
 drivers/gpu/drm/i915/intel_huc.c | 60 +++++++++++++++++++++++++---------------
 drivers/gpu/drm/i915/intel_huc.h |  2 +-
 drivers/gpu/drm/i915/intel_uc.c  |  4 +--
 4 files changed, 42 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index bddd658..4c3616b 100644
@@ -3232,6 +3232,9 @@ intel_info(const struct drm_i915_private *dev_priv)
 #define HAS_GUC_CT(dev_priv)	((dev_priv)->info.has_guc_ct)
 #define HAS_GUC_UCODE(dev_priv)	(HAS_GUC(dev_priv))
 #define HAS_GUC_SCHED(dev_priv)	(HAS_GUC(dev_priv))
+
+/* For now, anything with a GuC has also HuC */
+#define HAS_HUC(dev_priv)	(HAS_GUC(dev_priv))
 #define HAS_HUC_UCODE(dev_priv)	(HAS_GUC(dev_priv))
 
 #define HAS_RESOURCE_STREAMER(dev_priv) ((dev_priv)->info.has_resource_streamer)
drivers/gpu/drm/i915/intel_huc.c +37 -23

80 lines not on this page · raw message

drivers/gpu/drm/i915/intel_huc.h +1 -1
index aaa38b9..3d757bc 100644
@@ -34,7 +34,7 @@ struct intel_huc {
 	/* HuC-specific additions */
 };
 
-void intel_huc_select_fw(struct intel_huc *huc);
+void intel_huc_init_early(struct intel_huc *huc);
 void intel_huc_init_hw(struct intel_huc *huc);
 void intel_huc_auth(struct intel_huc *huc);
 
drivers/gpu/drm/i915/intel_uc.c +1 -3
index 1e2a30a..95b524c 100644
@@ -65,9 +65,6 @@ void intel_uc_sanitize_options(struct drm_i915_private *dev_priv)
 
 	/* Verify firmware version */
 	if (i915_modparams.enable_guc_loading) {
-		if (HAS_HUC_UCODE(dev_priv))
-			intel_huc_select_fw(&dev_priv->huc);
-
 		if (intel_guc_fw_select(&dev_priv->guc))
 			i915_modparams.enable_guc_loading = 0;
 	}
@@ -84,6 +81,7 @@ void intel_uc_sanitize_options(struct drm_i915_private *dev_priv)
 void intel_uc_init_early(struct drm_i915_private *dev_priv)
 {
 	intel_guc_init_early(&dev_priv->guc);
+	intel_huc_init_early(&dev_priv->huc);
 }
 
 void intel_uc_init_fw(struct drm_i915_private *dev_priv)
Signature · 6 lines
2.7.4

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

PATCH 2/6 drm/i915/guc: Move firmware selection to init_early

Doing GuC firmware path selection from sanitize_options function is not perfect, while there is no problem with doing so during early init stage as we already have all needed data.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Sagar Arun Kamble <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc.c    |  1 +
 drivers/gpu/drm/i915/intel_guc_fw.c | 63 +++++++++++++++++++++----------------
 drivers/gpu/drm/i915/intel_guc_fw.h |  2 +-
 drivers/gpu/drm/i915/intel_uc.c     |  2 +-
 drivers/gpu/drm/i915/intel_uc_fw.h  |  5 +++
 5 files changed, 44 insertions(+), 29 deletions(-)
drivers/gpu/drm/i915/intel_guc.c +1 -0
index 823d0c2..8136478 100644
@@ -61,6 +61,7 @@ void intel_guc_init_send_regs(struct intel_guc *guc)
 
 void intel_guc_init_early(struct intel_guc *guc)
 {
+	intel_guc_fw_init_early(guc);
 	intel_guc_ct_init_early(&guc->ct);
 
 	mutex_init(&guc->send_mutex);
drivers/gpu/drm/i915/intel_guc_fw.c +36 -27

81 lines not on this page · raw message

drivers/gpu/drm/i915/intel_guc_fw.h +1 -1
index 023f5ba..4ec5d3d 100644
@@ -27,7 +27,7 @@
 
 struct intel_guc;
 
-int intel_guc_fw_select(struct intel_guc *guc);
+void intel_guc_fw_init_early(struct intel_guc *guc);
 int intel_guc_fw_upload(struct intel_guc *guc);
 
 #endif
drivers/gpu/drm/i915/intel_uc.c +1 -1
index 95b524c..4b7f2a7 100644
@@ -65,7 +65,7 @@ void intel_uc_sanitize_options(struct drm_i915_private *dev_priv)
 
 	/* Verify firmware version */
 	if (i915_modparams.enable_guc_loading) {
-		if (intel_guc_fw_select(&dev_priv->guc))
+		if (!intel_uc_fw_is_selected(&dev_priv->guc.fw))
 			i915_modparams.enable_guc_loading = 0;
 	}
 
drivers/gpu/drm/i915/intel_uc_fw.h +5 -0
index 5394d9d..d5fd460 100644
@@ -110,6 +110,11 @@ void intel_uc_fw_init(struct intel_uc_fw *uc_fw, enum intel_uc_fw_type type)
 	uc_fw->type = type;
 }
 
+static inline bool intel_uc_fw_is_selected(struct intel_uc_fw *uc_fw)
+{
+	return uc_fw->path != NULL;
+}
+
 void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
 		       struct intel_uc_fw *uc_fw);
 int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
Signature · 6 lines
2.7.4

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

PATCH 3/6 drm/i915/guc: Introduce USES_GUC_xxx helper macros

In reply to Michal Wajdeczko

In the upcoming patch we will change the way how to recognize when GuC is in use. Using helper macros will minimize scope of that changes. While here, update dev_info message.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Sagar Arun Kamble <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h            |  4 ++++
 drivers/gpu/drm/i915/i915_gem_context.c    |  4 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.c        |  2 +-
 drivers/gpu/drm/i915/i915_irq.c            |  2 +-
 drivers/gpu/drm/i915/intel_guc.c           |  2 +-
 drivers/gpu/drm/i915/intel_guc_log.c       |  6 +++---
 drivers/gpu/drm/i915/intel_gvt.c           |  2 +-
 drivers/gpu/drm/i915/intel_uc.c            | 23 +++++++++++------------
 drivers/gpu/drm/i915/selftests/intel_guc.c |  2 +-
 9 files changed, 25 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 4c3616b..2c386c7 100644
@@ -3237,6 +3237,10 @@ intel_info(const struct drm_i915_private *dev_priv)
 #define HAS_HUC(dev_priv)	(HAS_GUC(dev_priv))
 #define HAS_HUC_UCODE(dev_priv)	(HAS_GUC(dev_priv))
 
+/* Having a GuC is not the same as using a GuC */
+#define USES_GUC(dev_priv)		(i915_modparams.enable_guc_loading)
+#define USES_GUC_SUBMISSION(dev_priv)	(i915_modparams.enable_guc_submission)
+
 #define HAS_RESOURCE_STREAMER(dev_priv) ((dev_priv)->info.has_resource_streamer)
 
 #define HAS_POOLED_EU(dev_priv)	((dev_priv)->info.has_pooled_eu)
drivers/gpu/drm/i915/i915_gem_context.c +2 -2
index ce3139e..21ce374 100644
@@ -316,7 +316,7 @@ __create_hw_context(struct drm_i915_private *dev_priv,
 	 * present or not in use we still need a small bias as ring wraparound
 	 * at offset 0 sometimes hangs. No idea why.
 	 */
-	if (HAS_GUC(dev_priv) && i915_modparams.enable_guc_loading)
+	if (USES_GUC(dev_priv))
 		ctx->ggtt_offset_bias = GUC_WOPCM_TOP;
 	else
 		ctx->ggtt_offset_bias = I915_GTT_PAGE_SIZE;
@@ -409,7 +409,7 @@ i915_gem_context_create_gvt(struct drm_device *dev)
 	i915_gem_context_set_closed(ctx); /* not user accessible */
 	i915_gem_context_clear_bannable(ctx);
 	i915_gem_context_set_force_single_submission(ctx);
-	if (!i915_modparams.enable_guc_submission)
+	if (!USES_GUC_SUBMISSION(to_i915(dev)))
 		ctx->ring_size = 512 * PAGE_SIZE; /* Max ring buffer size */
 
 	GEM_BUG_ON(i915_gem_context_is_kernel(ctx));
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
index f3c35e8..209bb11 100644
@@ -3503,7 +3503,7 @@ int i915_ggtt_probe_hw(struct drm_i915_private *dev_priv)
 	 * currently don't have any bits spare to pass in this upper
 	 * restriction!
 	 */
-	if (HAS_GUC(dev_priv) && i915_modparams.enable_guc_loading) {
+	if (USES_GUC(dev_priv)) {
 		ggtt->base.total = min_t(u64, ggtt->base.total, GUC_GGTT_TOP);
 		ggtt->mappable_end = min(ggtt->mappable_end, ggtt->base.total);
 	}
drivers/gpu/drm/i915/i915_irq.c +1 -1
index 4fb183a..5e4f44f 100644
@@ -1400,7 +1400,7 @@ gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir, int test_shift)
 
 	if (iir & (GT_RENDER_USER_INTERRUPT << test_shift)) {
 		notify_ring(engine);
-		tasklet |= i915_modparams.enable_guc_submission;
+		tasklet |= USES_GUC_SUBMISSION(engine->i915);
 	}
 
 	if (tasklet)
drivers/gpu/drm/i915/intel_guc.c +1 -1
index 8136478..39919e9 100644
@@ -129,7 +129,7 @@ void intel_guc_init_params(struct intel_guc *guc)
 	}
 
 	/* If GuC submission is enabled, set up additional parameters here */
-	if (i915_modparams.enable_guc_submission) {
+	if (USES_GUC_SUBMISSION(dev_priv)) {
 		u32 ads = guc_ggtt_offset(guc->ads_vma) >> PAGE_SHIFT;
 		u32 pgs = guc_ggtt_offset(dev_priv->guc.stage_desc_pool);
 		u32 ctx_in_16 = GUC_MAX_STAGE_DESCRIPTORS / 16;
drivers/gpu/drm/i915/intel_guc_log.c +3 -3
index 76d3eb1..1a2c5ee 100644
@@ -505,7 +505,7 @@ static void guc_flush_logs(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
 
-	if (!i915_modparams.enable_guc_submission ||
+	if (!USES_GUC_SUBMISSION(dev_priv) ||
 	    (i915_modparams.guc_log_level < 0))
 		return;
 
@@ -646,7 +646,7 @@ int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)
 
 void i915_guc_log_register(struct drm_i915_private *dev_priv)
 {
-	if (!i915_modparams.enable_guc_submission ||
+	if (!USES_GUC_SUBMISSION(dev_priv) ||
 	    (i915_modparams.guc_log_level < 0))
 		return;
 
@@ -657,7 +657,7 @@ void i915_guc_log_register(struct drm_i915_private *dev_priv)
 
 void i915_guc_log_unregister(struct drm_i915_private *dev_priv)
 {
-	if (!i915_modparams.enable_guc_submission)
+	if (!USES_GUC_SUBMISSION(dev_priv))
 		return;
 
 	mutex_lock(&dev_priv->drm.struct_mutex);
drivers/gpu/drm/i915/intel_gvt.c +1 -1
index 126f7c7..a2fe7c8 100644
@@ -95,7 +95,7 @@ int intel_gvt_init(struct drm_i915_private *dev_priv)
 		return 0;
 	}
 
-	if (i915_modparams.enable_guc_submission) {
+	if (USES_GUC_SUBMISSION(dev_priv)) {
 		DRM_ERROR("i915 GVT-g loading failed due to Graphics virtualization is not yet supported with GuC submission\n");
 		return -EIO;
 	}
drivers/gpu/drm/i915/intel_uc.c +11 -12
index 4b7f2a7..ed2dd76 100644
@@ -152,7 +152,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 	struct intel_guc *guc = &dev_priv->guc;
 	int ret, attempts;
 
-	if (!i915_modparams.enable_guc_loading)
+	if (!USES_GUC(dev_priv))
 		return 0;
 
 	guc_disable_communication(guc);
@@ -161,7 +161,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 	/* We need to notify the guc whenever we change the GGTT */
 	i915_ggtt_enable_guc(dev_priv);
 
-	if (i915_modparams.enable_guc_submission) {
+	if (USES_GUC_SUBMISSION(dev_priv)) {
 		/*
 		 * This is stuff we need to have available at fw load time
 		 * if we are planning to enable submission later
@@ -211,7 +211,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 		goto err_log_capture;
 
 	intel_huc_auth(&dev_priv->huc);
-	if (i915_modparams.enable_guc_submission) {
+	if (USES_GUC_SUBMISSION(dev_priv)) {
 		if (i915_modparams.guc_log_level >= 0)
 			gen9_enable_guc_interrupts(dev_priv);
 
@@ -220,11 +220,10 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 			goto err_interrupts;
 	}
 
-	dev_info(dev_priv->drm.dev, "GuC %s (firmware %s [version %u.%u])\n",
-		 i915_modparams.enable_guc_submission ? "submission enabled" :
-							"loaded",
-		 guc->fw.path,
+	dev_info(dev_priv->drm.dev, "GuC firmware version %u.%u\n",
 		 guc->fw.major_ver_found, guc->fw.minor_ver_found);
+	dev_info(dev_priv->drm.dev, "GuC submission %s\n",
+		 enableddisabled(USES_GUC_SUBMISSION(dev_priv)));
 
 	return 0;
 
@@ -243,7 +242,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 err_log_capture:
 	guc_capture_load_err_log(guc);
 err_submission:
-	if (i915_modparams.enable_guc_submission)
+	if (USES_GUC_SUBMISSION(dev_priv))
 		intel_guc_submission_fini(guc);
 err_guc:
 	i915_ggtt_disable_guc(dev_priv);
@@ -257,7 +256,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 		ret = 0;
 	}
 
-	if (i915_modparams.enable_guc_submission) {
+	if (USES_GUC_SUBMISSION(dev_priv)) {
 		i915_modparams.enable_guc_submission = 0;
 		DRM_NOTE("Falling back from GuC submission to execlist mode\n");
 	}
@@ -273,15 +272,15 @@ void intel_uc_fini_hw(struct drm_i915_private *dev_priv)
 
 	guc_free_load_err_log(guc);
 
-	if (!i915_modparams.enable_guc_loading)
+	if (!USES_GUC(dev_priv))
 		return;
 
-	if (i915_modparams.enable_guc_submission)
+	if (USES_GUC_SUBMISSION(dev_priv))
 		intel_guc_submission_disable(guc);
 
 	guc_disable_communication(guc);
 
-	if (i915_modparams.enable_guc_submission) {
+	if (USES_GUC_SUBMISSION(dev_priv)) {
 		gen9_disable_guc_interrupts(dev_priv);
 		intel_guc_submission_fini(guc);
 	}
drivers/gpu/drm/i915/selftests/intel_guc.c +1 -1
index 7b23597..68d6a69 100644
@@ -362,7 +362,7 @@ int intel_guc_live_selftest(struct drm_i915_private *dev_priv)
 		SUBTEST(igt_guc_doorbells),
 	};
 
-	if (!i915_modparams.enable_guc_submission)
+	if (!USES_GUC_SUBMISSION(dev_priv))
 		return 0;
 
 	return i915_subtests(tests, dev_priv);
Signature · 6 lines
2.7.4

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

PATCH 4/6 drm/i915/guc: Combine enable_guc_loading|submission modparams

In reply to Michal Wajdeczko

We currently have two module parameters that control GuC:
"enable_guc_loading" and "enable_guc_submission". Whenever we need submission=1, we also need loading=1. We also need loading=1 when we want to want to load and verify the HuC.

Lets combine above module parameters into one "enable_guc" modparam. New supported bit values are:

0=disable GuC (no GuC submission, no HuC)
1=enable GuC submission
2=enable HuC load

Special value "-1" can be used to let driver decide what option should be enabled for given platform based on hardware/firmware availability or preference.

Explicit enabling any of the GuC features makes GuC load a required step, fallback to non-GuC mode will not be supported.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Sagar Arun Kamble <[email protected]>
Cc Sujaritha Sundaresan <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h    |   5 +-
 drivers/gpu/drm/i915/i915_params.c |  11 ++--
 drivers/gpu/drm/i915/i915_params.h |   3 +-
 drivers/gpu/drm/i915/intel_uc.c    | 100 +++++++++++++++++++++----------------
 4 files changed, 64 insertions(+), 55 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -2
index 2c386c7..9162a60 100644
@@ -3238,8 +3238,9 @@ intel_info(const struct drm_i915_private *dev_priv)
 #define HAS_HUC_UCODE(dev_priv)	(HAS_GUC(dev_priv))
 
 /* Having a GuC is not the same as using a GuC */
-#define USES_GUC(dev_priv)		(i915_modparams.enable_guc_loading)
-#define USES_GUC_SUBMISSION(dev_priv)	(i915_modparams.enable_guc_submission)
+#define USES_GUC(dev_priv)		(!!(i915_modparams.enable_guc > 0))
+#define USES_GUC_SUBMISSION(dev_priv)	(!!(i915_modparams.enable_guc & 1))
+#define USES_HUC(dev_priv)		(!!(i915_modparams.enable_guc & 2))
 
 #define HAS_RESOURCE_STREAMER(dev_priv) ((dev_priv)->info.has_resource_streamer)
 
drivers/gpu/drm/i915/i915_params.c +4 -7
index 3328147..8654e45 100644
@@ -154,13 +154,10 @@ i915_param_named_unsafe(edp_vswing, int, 0400,
 	"(0=use value from vbt [default], 1=low power swing(200mV),"
 	"2=default swing(400mV))");
 
-i915_param_named_unsafe(enable_guc_loading, int, 0400,
-	"Enable GuC firmware loading "
-	"(-1=auto, 0=never [default], 1=if available, 2=required)");
-
-i915_param_named_unsafe(enable_guc_submission, int, 0400,
-	"Enable GuC submission "
-	"(-1=auto, 0=never [default], 1=if available, 2=required)");
+i915_param_named_unsafe(enable_guc, int, 0400,
+	"Enable GuC load for GuC submission and/or HuC load. "
+	"Required functionality can be selected using bitmask values. "
+	"(-1=auto, 0=disable [default], 1=GuC submission, 2=HuC load)");
 
 i915_param_named(guc_log_level, int, 0400,
 	"GuC firmware logging level (-1:disabled (default), 0-3:enabled)");
drivers/gpu/drm/i915/i915_params.h +1 -2
index 8321bd8..10e2f74 100644
@@ -42,8 +42,7 @@
 	param(int, disable_power_well, -1) \
 	param(int, enable_ips, 1) \
 	param(int, invert_brightness, 0) \
-	param(int, enable_guc_loading, 0) \
-	param(int, enable_guc_submission, 0) \
+	param(int, enable_guc, 0) \
 	param(int, guc_log_level, -1) \
 	param(char *, guc_firmware_path, NULL) \
 	param(char *, huc_firmware_path, NULL) \
drivers/gpu/drm/i915/intel_uc.c +56 -44

132 lines not on this page · raw message

Signature · 6 lines
2.7.4

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

PATCH 5/6 drm/i915/huc: Load HuC only if requested

In reply to Michal Wajdeczko

Our new "enable_guc" modparam allows to control whenever HuC should be loaded. However existing code will try load and authenticate HuC always when we use the GuC. This patch is trying to enforce modparam selection.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Sagar Arun Kamble <[email protected]>
---
 drivers/gpu/drm/i915/intel_huc.c | 21 +++++++++++----------
 drivers/gpu/drm/i915/intel_huc.h |  4 ++--
 drivers/gpu/drm/i915/intel_uc.c  | 17 +++++++++++++++--
 3 files changed, 28 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_huc.c +11 -10
index 6d0e050..abe301f 100644
@@ -181,17 +181,17 @@ static int huc_ucode_xfer(struct intel_uc_fw *huc_fw, struct i915_vma *vma)
  * intel_huc_init_hw() - load HuC uCode to device
  * @huc: intel_huc structure
  *
- * Called from guc_setup() during driver loading and also after a GPU reset.
- * Be note that HuC loading must be done before GuC loading.
+ * Called from intel_uc_init_hw() during driver loading and also after a GPU
+ * reset. Be note that HuC loading must be done before GuC loading.
  *
  * The firmware image should have already been fetched into memory by the
- * earlier call to intel_huc_init(), so here we need only check that
+ * earlier call to intel_uc_init_fw(), so here we need only check that
  * is succeeded, and then transfer the image to the h/w.
  *
  */
-void intel_huc_init_hw(struct intel_huc *huc)
+int intel_huc_init_hw(struct intel_huc *huc)
 {
-	intel_uc_fw_upload(&huc->fw, huc_ucode_xfer);
+	return intel_uc_fw_upload(&huc->fw, huc_ucode_xfer);
 }
 
 /**
@@ -205,7 +205,7 @@ void intel_huc_init_hw(struct intel_huc *huc)
  * signature through intel_guc_auth_huc(). It then waits for 50ms for
  * firmware verification ACK and unpins the object.
  */
-void intel_huc_auth(struct intel_huc *huc)
+int intel_huc_auth(struct intel_huc *huc)
 {
 	struct drm_i915_private *i915 = huc_to_i915(huc);
 	struct intel_guc *guc = &i915->guc;
@@ -213,14 +213,14 @@ void intel_huc_auth(struct intel_huc *huc)
 	int ret;
 
 	if (huc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
-		return;
+		return -ENOEXEC;
 
 	vma = i915_gem_object_ggtt_pin(huc->fw.obj, NULL, 0, 0,
 				PIN_OFFSET_BIAS | GUC_WOPCM_TOP);
 	if (IS_ERR(vma)) {
-		DRM_ERROR("failed to pin huc fw object %d\n",
-				(int)PTR_ERR(vma));
-		return;
+		ret = (int)PTR_ERR(vma);
+		DRM_ERROR("HuC: Failed to pin huc fw object %d\n", ret);
+		return ret;
 	}
 
 	ret = intel_guc_auth_huc(guc,
@@ -243,4 +243,5 @@ void intel_huc_auth(struct intel_huc *huc)
 
 out:
 	i915_vma_unpin(vma);
+	return ret;
 }
drivers/gpu/drm/i915/intel_huc.h +2 -2
index 3d757bc..40039db 100644
@@ -35,7 +35,7 @@ struct intel_huc {
 };
 
 void intel_huc_init_early(struct intel_huc *huc);
-void intel_huc_init_hw(struct intel_huc *huc);
-void intel_huc_auth(struct intel_huc *huc);
+int intel_huc_init_hw(struct intel_huc *huc);
+int intel_huc_auth(struct intel_huc *huc);
 
 #endif
drivers/gpu/drm/i915/intel_uc.c +15 -2
index 1d91991..4cc653a 100644
@@ -174,6 +174,7 @@ static void guc_disable_communication(struct intel_guc *guc)
 int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 {
 	struct intel_guc *guc = &dev_priv->guc;
+	struct intel_huc *huc = &dev_priv->huc;
 	int ret, attempts;
 
 	if (!USES_GUC(dev_priv))
@@ -220,7 +221,12 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 		if (ret)
 			goto err_submission;
 
-		intel_huc_init_hw(&dev_priv->huc);
+		if (USES_HUC(dev_priv)) {
+			ret = intel_huc_init_hw(huc);
+			if (ret)
+				break;
+		}
+
 		intel_guc_init_params(guc);
 		ret = intel_guc_fw_upload(guc);
 		if (ret == 0 || ret != -EAGAIN)
@@ -238,7 +244,12 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 	if (ret)
 		goto err_log_capture;
 
-	intel_huc_auth(&dev_priv->huc);
+	if (USES_HUC(dev_priv)) {
+		ret = intel_huc_auth(huc);
+		if (ret)
+			goto err_interrupts;
+	}
+
 	if (USES_GUC_SUBMISSION(dev_priv)) {
 		if (i915_modparams.guc_log_level >= 0)
 			gen9_enable_guc_interrupts(dev_priv);
@@ -252,6 +263,8 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 		 guc->fw.major_ver_found, guc->fw.minor_ver_found);
 	dev_info(dev_priv->drm.dev, "GuC submission %s\n",
 		 enableddisabled(USES_GUC_SUBMISSION(dev_priv)));
+	dev_info(dev_priv->drm.dev, "HuC %s\n",
+		 enableddisabled(USES_HUC(dev_priv)));
 
 	return 0;
 
Signature · 6 lines
2.7.4

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

PATCH 6/6 HAX enable GuC/HuC load

In reply to Michal Wajdeczko

Also revert ("drm/i915/guc: Assert that we switch between known ggtt->invalidate functions")

---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 8 ++------
 drivers/gpu/drm/i915/i915_params.h  | 2 +-
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -6
index 209bb11..a5e75a3 100644
@@ -3590,17 +3590,13 @@ int i915_ggtt_enable_hw(struct drm_i915_private *dev_priv)
 
 void i915_ggtt_enable_guc(struct drm_i915_private *i915)
 {
-	GEM_BUG_ON(i915->ggtt.invalidate != gen6_ggtt_invalidate);
-
 	i915->ggtt.invalidate = guc_ggtt_invalidate;
 }
 
 void i915_ggtt_disable_guc(struct drm_i915_private *i915)
 {
-	/* We should only be called after i915_ggtt_enable_guc() */
-	GEM_BUG_ON(i915->ggtt.invalidate != guc_ggtt_invalidate);
-
-	i915->ggtt.invalidate = gen6_ggtt_invalidate;
+	if (i915->ggtt.invalidate == guc_ggtt_invalidate)
+		i915->ggtt.invalidate = gen6_ggtt_invalidate;
 }
 
 void i915_gem_restore_gtt_mappings(struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_params.h +1 -1
index 10e2f74..fd5e598 100644
@@ -42,7 +42,7 @@
 	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.7.4

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

✗ Fi.CI.BAT: failure for series starting with [1/6] drm/i915/huc: Move firmware selection to init_early

In reply to Michal Wajdeczko
== Series Details ==

== Series Details ==

Series: series starting with [1/6] drm/i915/huc: Move firmware selection to init_early
URL : https://patchwork.freedesktop.org/series/34694/
State : failure

== Summary ==

Series 34694v1 series starting with [1/6] drm/i915/huc: Move firmware selection to init_early
https://patchwork.freedesktop.org/api/1.0/series/34694/revisions/1/mbox/

Test debugfs_test:

        Subgroup read_all_entries:
                pass       -> DMESG-WARN (fi-skl-6260u)
                pass       -> DMESG-WARN (fi-skl-6600u)
                pass       -> DMESG-WARN (fi-skl-6700hq)
                pass       -> DMESG-WARN (fi-skl-6700k)
                pass       -> DMESG-WARN (fi-skl-6770hq)
                pass       -> DMESG-WARN (fi-skl-gvtdvm)
                pass       -> DMESG-WARN (fi-bxt-dsi)
                pass       -> DMESG-WARN (fi-bxt-j4205)
                pass       -> DMESG-WARN (fi-kbl-7500u) fdo#103285
                pass       -> DMESG-WARN (fi-kbl-7560u)
                pass       -> DMESG-WARN (fi-kbl-7567u)
                pass       -> DMESG-WARN (fi-kbl-r)
                pass       -> SKIP       (fi-glk-1)
Test drv_hangman:
        Subgroup error-state-basic:
                pass       -> SKIP       (fi-glk-1)
Test gem_busy:
        Subgroup basic-busy-default:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-hang-default:
                pass       -> SKIP       (fi-glk-1)
Test gem_close_race:
        Subgroup basic-process:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-threads:
                pass       -> SKIP       (fi-glk-1)
Test gem_cpu_reloc:
        Subgroup basic:
                pass       -> SKIP       (fi-glk-1)
Test gem_cs_tlb:
        Subgroup basic-default:
                pass       -> SKIP       (fi-glk-1)
Test gem_ctx_create:
        Subgroup basic:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-files:
                pass       -> SKIP       (fi-glk-1) fdo#103706 +6
Test gem_ctx_exec:
        Subgroup basic:
                pass       -> SKIP       (fi-glk-1)
Test gem_ctx_switch:
        Subgroup basic-default:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-default-heavy:
                pass       -> SKIP       (fi-glk-1)
Test gem_exec_basic:
        Subgroup basic-blt:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-bsd:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-default:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-render:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-vebox:
                pass       -> SKIP       (fi-glk-1)
        Subgroup gtt-blt:
                pass       -> SKIP       (fi-glk-1)
        Subgroup gtt-bsd:
                pass       -> SKIP       (fi-glk-1)
        Subgroup gtt-default:
                pass       -> SKIP       (fi-glk-1)
        Subgroup gtt-render:
                pass       -> SKIP       (fi-glk-1)
        Subgroup gtt-vebox:
                pass       -> SKIP       (fi-glk-1)
        Subgroup readonly-blt:
                pass       -> SKIP       (fi-glk-1)
        Subgroup readonly-bsd:
                pass       -> SKIP       (fi-glk-1)
        Subgroup readonly-default:
                pass       -> SKIP       (fi-glk-1)
        Subgroup readonly-render:
                pass       -> SKIP       (fi-glk-1)
        Subgroup readonly-vebox:
                pass       -> SKIP       (fi-glk-1)
Test gem_exec_create:
        Subgroup basic:
                pass       -> SKIP       (fi-glk-1)
Test gem_exec_fence:
        Subgroup basic-busy-default:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-wait-default:
                pass       -> SKIP       (fi-glk-1)
        Subgroup await-hang-default:
                pass       -> SKIP       (fi-glk-1)
        Subgroup nb-await-default:
                pass       -> SKIP       (fi-glk-1)
Test gem_exec_flush:
        Subgroup basic-batch-kernel-default-uc:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-batch-kernel-default-wb:
                pass       -> SKIP       (fi-glk-1)
        Subgroup basic-uc-pro-default:
                pass       -> SKIP       (fi-glk-1)

WARNING: Long output truncated

07df63d96015816fbf6dd44e634474587931a294 drm-tip: 2017y-11m-30d-17h-26m-53s UTC integration manifest 78b9914aafd1 HAX enable GuC/HuC load
3a85ce21c36b drm/i915/huc: Load HuC only if requested
3cefedc168cd drm/i915/guc: Combine enable_guc_loading|submission modparams 8c7d73f5cddd drm/i915/guc: Introduce USES_GUC_xxx helper macros
91490671d57c drm/i915/guc: Move firmware selection to init_early
a69c8bf855e2 drm/i915/huc: Move firmware selection to init_early

== Logs ==

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

#7 lore raw

Re: ✗ Fi.CI.BAT: failure for series starting with [1/6] drm/i915/huc: Move firmware selection to init_early

Quoting Patchwork (2017-11-30 18:37:38)

Quoted 7 lines

== Series Details ==

Series: series starting with [1/6] drm/i915/huc: Move firmware selection to init_early
URL : https://patchwork.freedesktop.org/series/34694/
State : failure

WARNING: Long output truncated

What's CI is trying to tell us there at the end is that we have a NULL deref in guc_doorbell_destroy if we fail to load the guc firmware. So we need to double check all the guc_init_submission failure paths.

I'm still on the fence as to whether forcing -EIO on init failure is a good plan. We still have to go through all the reset code, teaching it that it's ok to fail (or at least the failure is expected and to be quiet, as we've already already the user to it).
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: ✗ Fi.CI.BAT: failure for series starting with [1/6] drm/i915/huc: Move firmware selection to init_early

Quoted 11 lines · Chris Wilson

Quoting Patchwork (2017-11-30 18:37:38)

Quoted 7 lines

== Series Details ==

Series: series starting with [1/6] drm/i915/huc: Move firmware selection to init_early
URL : https://patchwork.freedesktop.org/series/34694/
State : failure

WARNING: Long output truncated

What's CI is trying to tell us there at the end is that we have a NULL deref in guc_doorbell_destroy if we fail to load the guc firmware. So we need to double check all the guc_init_submission failure paths.

guc_submission_disable in intel_uc_fini_hw is gated by module param still. either we need to migrate to internal submission init state or update enable_guc=0 on guc init failure when we have set auto option.
Taking sanitization past guc_fetch and making intel_uc_fw_is_selected rely on fetch_status looks best option though because if we want to return -EIO then i915 load should mark as device init failure which isn't happening currently (leading to reset path failures as well)

Quoted 9 lines

I'm still on the fence as to whether forcing -EIO on init failure is a good plan. We still have to go through all the reset code, teaching it that it's ok to fail (or at least the failure is expected and to be quiet, as we've already already the user to it).
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

#9 lore raw

Re: ✗ Fi.CI.BAT: failure for series starting with [1/6] drm/i915/huc: Move firmware selection to init_early

Quoted 6 lines · Sagar Arun Kamble
Quoted 3 lines · Chris Wilson

Quoting Patchwork (2017-11-30 18:37:38)

Quoted 2 lines

== Series Details ==

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

Series: series starting with [1/6] drm/i915/huc: Move firmware selection to init_early
URL : https://patchwork.freedesktop.org/series/34694/
State : failure

WARNING: Long output truncated

What's CI is trying to tell us there at the end is that we have a NULL deref in guc_doorbell_destroy if we fail to load the guc firmware. So we need to double check all the guc_init_submission failure paths.

It looks that I've introduced new failure path when we fail to fetch HuC firmware. Then intel_uc_fw_upload() will return -EIO (btw I guess -ENOEXEC would be better there).

Quoted 1 line

guc_submission_disable in intel_uc_fini_hw is gated by module param still.

This alone is not that bad.
Here problem is that intel_uc_fini_hw() was called regardless of our earlier unrecoverable failure in uc_init_hw() which I wrongly report as -EIO (leading to reset/wedged path)

Quoted 2 lines

either we need to migrate to internal submission init state or update enable_guc=0 on guc init failure when we have set auto option.

I wanted to avoid changing modparam after sanitize() as modparam should not be treated as runtime/internal state variable

Quoted 1 line

Taking sanitization past guc_fetch and making intel_uc_fw_is_selected rely on fetch_status looks

But even if we fetch earlier, in sanitize() we should not attempt to modify modparam beyond auto mode. And successful fetch status will not help us when we later fail during fw xfer...

Quoted 2 lines

best option though because if we want to return -EIO then i915 load should mark as device init failure which isn't happening currently (leading to reset path failures as well)

We should return proper 'ret' and make sure it is not -EIO to be in sync with the trailing comment that says 'no fallback'

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

#10 lore raw

Re: ✗ Fi.CI.BAT: failure for series starting with [1/6] drm/i915/huc: Move firmware selection to init_early

In reply to Chris Wilson
Quoted 9 lines · Chris Wilson

Quoting Patchwork (2017-11-30 18:37:38)

Quoted 7 lines

== Series Details ==

Series: series starting with [1/6] drm/i915/huc: Move firmware selection to init_early
URL : https://patchwork.freedesktop.org/series/34694/
State : failure

WARNING: Long output truncated

Quoted 8 lines

What's CI is trying to tell us there at the end is that we have a NULL deref in guc_doorbell_destroy if we fail to load the guc firmware. So we need to double check all the guc_init_submission failure paths.

I'm still on the fence as to whether forcing -EIO on init failure is a good plan. We still have to go through all the reset code, teaching it that it's ok to fail (or at least the failure is expected and to be quiet, as we've already already the user to it).

Well, I must admit that returning -EIO from init() was a bad idea, as my goal was to make GuC mandatory/required if enabled by modparam
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx