Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Larumbe <adrian.larumbe@collabora.com>
To: daniel@ffwll.ch, ramalingam.c@intel.com,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: adrian.larumbe@collabora.com, daniels@collabora.com
Subject: [Intel-gfx] [PATCH] drm/i915/dg2: make GuC FW a requirement for Gen12 and beyond devices
Date: Tue,  7 Dec 2021 17:53:01 +0000	[thread overview]
Message-ID: <20211207175301.321119-1-adrian.larumbe@collabora.com> (raw)

Beginning with DG2, all successive devices will require GuC FW to be
present and loaded at probe() time. This change alters error handling in
the FW init and load functions so that the driver's probe() function will
fail if GuC could not be loaded.

Signed-off-by: Adrian Larumbe <adrian.larumbe@collabora.com>
---
 drivers/gpu/drm/i915/gt/uc/intel_uc.c | 20 ++++++++++++++++----
 drivers/gpu/drm/i915/gt/uc/intel_uc.h |  4 ++--
 drivers/gpu/drm/i915/i915_gem.c       |  7 ++++++-
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
index 7660eba893fa..8b0778b6d9ab 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
@@ -277,14 +277,19 @@ static void guc_disable_communication(struct intel_guc *guc)
 	drm_dbg(&i915->drm, "GuC communication disabled\n");
 }
 
-static void __uc_fetch_firmwares(struct intel_uc *uc)
+static int __uc_fetch_firmwares(struct intel_uc *uc)
 {
+	struct drm_i915_private *i915 = uc_to_gt(uc)->i915;
 	int err;
 
 	GEM_BUG_ON(!intel_uc_wants_guc(uc));
 
 	err = intel_uc_fw_fetch(&uc->guc.fw);
 	if (err) {
+		/* GuC is mandatory on Gen12 and beyond */
+		if (GRAPHICS_VER(i915) >= 12)
+			return err;
+
 		/* Make sure we transition out of transient "SELECTED" state */
 		if (intel_uc_wants_huc(uc)) {
 			drm_dbg(&uc_to_gt(uc)->i915->drm,
@@ -293,11 +298,13 @@ static void __uc_fetch_firmwares(struct intel_uc *uc)
 						  INTEL_UC_FIRMWARE_ERROR);
 		}
 
-		return;
+		return 0;
 	}
 
 	if (intel_uc_wants_huc(uc))
 		intel_uc_fw_fetch(&uc->huc.fw);
+
+	return 0;
 }
 
 static void __uc_cleanup_firmwares(struct intel_uc *uc)
@@ -308,14 +315,19 @@ static void __uc_cleanup_firmwares(struct intel_uc *uc)
 
 static int __uc_init(struct intel_uc *uc)
 {
+	struct drm_i915_private *i915 = uc_to_gt(uc)->i915;
 	struct intel_guc *guc = &uc->guc;
 	struct intel_huc *huc = &uc->huc;
 	int ret;
 
 	GEM_BUG_ON(!intel_uc_wants_guc(uc));
 
-	if (!intel_uc_uses_guc(uc))
-		return 0;
+	if (!intel_uc_uses_guc(uc)) {
+		if (GRAPHICS_VER(i915) >= 12)
+			return -EINVAL;
+		else
+			return 0;
+	}
 
 	if (i915_inject_probe_failure(uc_to_gt(uc)->i915))
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.h b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
index 866b462821c0..3bcd781447bc 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
@@ -17,7 +17,7 @@ struct intel_uc;
 
 struct intel_uc_ops {
 	int (*sanitize)(struct intel_uc *uc);
-	void (*init_fw)(struct intel_uc *uc);
+	int (*init_fw)(struct intel_uc *uc);
 	void (*fini_fw)(struct intel_uc *uc);
 	int (*init)(struct intel_uc *uc);
 	void (*fini)(struct intel_uc *uc);
@@ -104,7 +104,7 @@ static inline _TYPE intel_uc_##_NAME(struct intel_uc *uc) \
 	return _RET; \
 }
 intel_uc_ops_function(sanitize, sanitize, int, 0);
-intel_uc_ops_function(fetch_firmwares, init_fw, void, );
+intel_uc_ops_function(fetch_firmwares, init_fw, int, 0);
 intel_uc_ops_function(cleanup_firmwares, fini_fw, void, );
 intel_uc_ops_function(init, init, int, 0);
 intel_uc_ops_function(fini, fini, void, );
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 527228d4da7e..7f8204af6826 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1049,7 +1049,12 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
 	if (ret)
 		return ret;
 
-	intel_uc_fetch_firmwares(&dev_priv->gt.uc);
+	ret = intel_uc_fetch_firmwares(&dev_priv->gt.uc);
+	if (ret) {
+		i915_probe_error(dev_priv, "Failed to fetch firmware\n");
+		return ret;
+	}
+
 	intel_wopcm_init(&dev_priv->wopcm);
 
 	ret = i915_init_ggtt(dev_priv);
-- 
2.34.1


             reply	other threads:[~2021-12-07 19:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07 17:53 Adrian Larumbe [this message]
2021-12-07 21:42 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/dg2: make GuC FW a requirement for Gen12 and beyond devices Patchwork
2021-12-07 22:12 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-12-07 23:15 ` [Intel-gfx] [PATCH] " John Harrison
2021-12-08 17:58   ` Robert Beckett
     [not found]     ` <27c067e1-3bb3-efce-ee6f-ffce2224f5d1@intel.com>
2021-12-09 14:41       ` Robert Beckett
2021-12-09 17:06         ` John Harrison
2021-12-08  6:36 ` [Intel-gfx] ✗ Fi.CI.IGT: failure for " Patchwork
2021-12-08  8:25 ` [Intel-gfx] [PATCH] " Tvrtko Ursulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211207175301.321119-1-adrian.larumbe@collabora.com \
    --to=adrian.larumbe@collabora.com \
    --cc=daniel@ffwll.ch \
    --cc=daniels@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ramalingam.c@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox