Skip to contentSkip to conversation

GuC Scrub vol. 1

PATCH Superseded Arkadiusz Hiler 4 participants 23 messages Feb 22, 2017 – Feb 23, 2017

Subsystems (2)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v4 cover GuC Scrub vol. 1

General GuC/HuC cleanup simplifying logic, and moving chunks around, as the area got pretty rusty.

A lot of logic were extracted from intel_guc_load() to other functions - it not only did handle the actual loading but had WA implementations and had the code thatenabled submission baked it.

This is the first part of effort to clean it up.

v2: rebase after HuC merge + feedback
v3: even more renaming that aims to make things more semantic
v4: some naming improvements, some bikeshedding

Arkadiusz Hiler (8):
drm/i915/uc: Rename intel_?uc_{setup,load}() to _init_hw() drm/i915/uc: Drop superfluous externs in intel_uc.h drm/i915/huc: Add huc_to_i915
drm/i915/uc: Rename intel_?uc_init() to intel_?uc_fetch_fw() drm/i915/uc: Make intel_uc_fw_fetch() static drm/i915/guc: Extract param logic form guc_init drm/i915/guc: Simplify intel_guc_init_hw() drm/i915/uc: Simplify firmware path handling

 drivers/gpu/drm/i915/i915_drv.c         |   5 +-
 drivers/gpu/drm/i915/i915_drv.h         |   5 +
 drivers/gpu/drm/i915/i915_gem.c         |   2 +-
 drivers/gpu/drm/i915/intel_guc_loader.c | 354 ++++----------------------------
 drivers/gpu/drm/i915/intel_huc.c        |  57 +++--
 drivers/gpu/drm/i915/intel_uc.c         | 280 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_uc.h         |  27 ++-
 7 files changed, 370 insertions(+), 360 deletions(-)
Signature · 6 lines
2.9.3

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

PATCH v4 1/8 drm/i915/uc: Rename intel_?uc_{setup, load}() to _init_hw()

GuC historically has two "startup" functions called _init() and _setup()

Then HuC came with it's _init() and _load().

This commit renames intel_guc_setup() and intel_huc_load() to *uc_init_hw() as they called from the i915_gem_init_hw().

The aim is to be consistent in that entry points called during particular driver init phases (e.g. init_hw) are all suffixed by that phase. When reading the leaf functions, it should be clear at what stage during the driver load it is called and therefore what operations are legal at that point.

v2: commit message update (Chris Wilson)

---
 drivers/gpu/drm/i915/i915_gem.c         |  2 +-
 drivers/gpu/drm/i915/intel_guc_loader.c | 14 +++++++-------
 drivers/gpu/drm/i915/intel_huc.c        |  6 +++---
 drivers/gpu/drm/i915/intel_uc.h         |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index d930328..bbe2df9 100644
@@ -4512,7 +4512,7 @@ int i915_gem_init_hw(struct drm_i915_private *dev_priv)
 	intel_mocs_init_l3cc_table(dev_priv);
 
 	/* We can't enable contexts until all firmware is loaded */
-	ret = intel_guc_setup(dev_priv);
+	ret = intel_guc_init_hw(dev_priv);
 	if (ret)
 		goto out;
 
drivers/gpu/drm/i915/intel_guc_loader.c +7 -7
index 9885f76..9f09e26 100644
@@ -428,19 +428,19 @@ static int guc_hw_reset(struct drm_i915_private *dev_priv)
 }
 
 /**
- * intel_guc_setup() - finish preparing the GuC for activity
+ * intel_guc_init_hw() - finish preparing the GuC for activity
  * @dev_priv:	i915 device private
  *
- * Called from gem_init_hw() during driver loading and also after a GPU reset.
+ * Called during driver loading and also after a GPU reset.
  *
  * The main action required here it to load the GuC uCode into the device.
  * The firmware image should have already been fetched into memory by the
- * earlier call to intel_guc_init(), so here we need only check that worked,
- * and then transfer the image to the h/w.
+ * earlier call to intel_guc_init(), so here we need only check that
+ * worked, and then transfer the image to the h/w.
  *
  * Return:	non-zero code on error
  */
-int intel_guc_setup(struct drm_i915_private *dev_priv)
+int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 {
 	struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
 	const char *fw_path = guc_fw->path;
@@ -506,7 +506,7 @@ int intel_guc_setup(struct drm_i915_private *dev_priv)
 		if (err)
 			goto fail;
 
-		intel_huc_load(dev_priv);
+		intel_huc_init_hw(dev_priv);
 		err = guc_ucode_xfer(dev_priv);
 		if (!err)
 			break;
@@ -729,7 +729,7 @@ void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
  * Called early during driver load, but after GEM is initialised.
  *
  * The firmware will be transferred to the GuC's memory later,
- * when intel_guc_setup() is called.
+ * when intel_guc_init_hw() is called.
  */
 void intel_guc_init(struct drm_i915_private *dev_priv)
 {
drivers/gpu/drm/i915/intel_huc.c +3 -3
index c28543d..babe0eb 100644
@@ -150,7 +150,7 @@ static int huc_ucode_xfer(struct drm_i915_private *dev_priv)
  * is not capable or driver yet support it. And there will be no error message
  * for INTEL_UC_FIRMWARE_NONE cases.
  *
- * The DMA-copying to HW is done later when intel_huc_load() is called.
+ * The DMA-copying to HW is done later when intel_huc_init_hw() is called.
  */
 void intel_huc_init(struct drm_i915_private *dev_priv)
 {
@@ -191,7 +191,7 @@ void intel_huc_init(struct drm_i915_private *dev_priv)
 }
 
 /**
- * intel_huc_load() - load HuC uCode to device
+ * intel_huc_init_hw() - load HuC uCode to device
  * @dev_priv: the drm_i915_private device
  *
  * Called from guc_setup() during driver loading and also after a GPU reset.
@@ -203,7 +203,7 @@ void intel_huc_init(struct drm_i915_private *dev_priv)
  *
  * Return:	non-zero code on error
  */
-int intel_huc_load(struct drm_i915_private *dev_priv)
+int intel_huc_init_hw(struct drm_i915_private *dev_priv)
 {
 	struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
 	int err;
drivers/gpu/drm/i915/intel_uc.h +2 -2
index d74f4d3..dd34a1b 100644
@@ -190,7 +190,7 @@ int intel_guc_sample_forcewake(struct intel_guc *guc);
 
 /* intel_guc_loader.c */
 extern void intel_guc_init(struct drm_i915_private *dev_priv);
-extern int intel_guc_setup(struct drm_i915_private *dev_priv);
+extern int intel_guc_init_hw(struct drm_i915_private *dev_priv);
 extern void intel_guc_fini(struct drm_i915_private *dev_priv);
 extern const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status);
 extern int intel_guc_suspend(struct drm_i915_private *dev_priv);
@@ -225,7 +225,7 @@ static inline u32 guc_ggtt_offset(struct i915_vma *vma)
 /* intel_huc.c */
 void intel_huc_init(struct drm_i915_private *dev_priv);
 void intel_huc_fini(struct drm_i915_private  *dev_priv);
-int intel_huc_load(struct drm_i915_private *dev_priv);
+int intel_huc_init_hw(struct drm_i915_private *dev_priv);
 void intel_guc_auth_huc(struct drm_i915_private *dev_priv);
 
 #endif
Signature · 6 lines
2.9.3

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

PATCH v4 2/8 drm/i915/uc: Drop superfluous externs in intel_uc.h

In reply to Arkadiusz Hiler

Externs are implicit and we generally try to avoid them.

Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_uc.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_uc.h +6 -6
index dd34a1b..41b7351 100644
@@ -189,12 +189,12 @@ int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len);
 int intel_guc_sample_forcewake(struct intel_guc *guc);
 
 /* intel_guc_loader.c */
-extern void intel_guc_init(struct drm_i915_private *dev_priv);
-extern int intel_guc_init_hw(struct drm_i915_private *dev_priv);
-extern void intel_guc_fini(struct drm_i915_private *dev_priv);
-extern const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status);
-extern int intel_guc_suspend(struct drm_i915_private *dev_priv);
-extern int intel_guc_resume(struct drm_i915_private *dev_priv);
+void intel_guc_init(struct drm_i915_private *dev_priv);
+int intel_guc_init_hw(struct drm_i915_private *dev_priv);
+void intel_guc_fini(struct drm_i915_private *dev_priv);
+const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status);
+int intel_guc_suspend(struct drm_i915_private *dev_priv);
+int intel_guc_resume(struct drm_i915_private *dev_priv);
 void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
 	struct intel_uc_fw *uc_fw);
 u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v4 2/8
#3 lore raw

Re: [PATCH 2/8] drm/i915/uc: Drop superfluous externs in intel_uc.h

Quoted 4 lines · Arkadiusz Hiler

Externs are implicit and we generally try to avoid them.

Cc Michal Wajdeczko <[email protected]>

Yeah, for actual "extern" there's EXPORT_SYMBOL (which is not needed here).

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH v4 3/8 drm/i915/huc: Add huc_to_i915

In reply to Arkadiusz Hiler

Used to obtain "dev_priv" from huc struct pointer. We already have similar thing for guc.

---
 drivers/gpu/drm/i915/i915_drv.h | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +5 -0
index 4e7046d..7366ada 100644
@@ -2528,6 +2528,11 @@ static inline struct drm_i915_private *guc_to_i915(struct intel_guc *guc)
 	return container_of(guc, struct drm_i915_private, guc);
 }
 
+static inline struct drm_i915_private *huc_to_i915(struct intel_huc *huc)
+{
+	return container_of(huc, struct drm_i915_private, huc);
+}
+
 /* Simple iterator over all initialised engines */
 #define for_each_engine(engine__, dev_priv__, id__) \
 	for ((id__) = 0; \
Signature · 6 lines
2.9.3

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

PATCH v4 4/8 drm/i915/uc: Rename intel_?uc_init() to intel_?uc_fetch_fw()

In reply to Arkadiusz Hiler

Trying to have subject_verb_object ordering and more descriptive names, the intel_huc_init() and intel_guc_init() functions are renamed:

* intel_guc is the subject, so those functions now take intel_guc structure, instead of the dev_priv
* fetch is the verb
* fw is the object which better describes the function's role

Same change is done for the huc counterpart.

Also we bulk call both functions from higher-level intel_uc_fetch_fw:
* intel being the subject (taking the dev_priv as param)
* fetch being the verb
* uc_fw being the subject

v2: settle on intel_uc_fetch_fw name (M. Wajdeczko)

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Michal Winiarski <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c         |  3 +--
 drivers/gpu/drm/i915/intel_guc_loader.c | 30 +++++++++++++-------------
 drivers/gpu/drm/i915/intel_huc.c        | 37 ++++++++++++++++-----------------
 drivers/gpu/drm/i915/intel_uc.c         |  6 ++++++
 drivers/gpu/drm/i915/intel_uc.h         |  5 +++--
 5 files changed, 43 insertions(+), 38 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -2
index b76e8f7..078ac3e 100644
@@ -609,8 +609,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
 	if (ret)
 		goto cleanup_irq;
 
-	intel_huc_init(dev_priv);
-	intel_guc_init(dev_priv);
+	intel_uc_fetch_fw(dev_priv);
 
 	ret = i915_gem_init(dev_priv);
 	if (ret)
drivers/gpu/drm/i915/intel_guc_loader.c +15 -15
index 9f09e26..753aeef 100644
@@ -723,17 +723,17 @@ void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
 }
 
 /**
- * intel_guc_init() - define parameters and fetch firmware
- * @dev_priv:	i915 device private
+ * intel_guc_fetch_fw() - define parameters and fetch firmware
+ * @guc:	intel_guc struct
  *
  * Called early during driver load, but after GEM is initialised.
  *
  * The firmware will be transferred to the GuC's memory later,
  * when intel_guc_init_hw() is called.
  */
-void intel_guc_init(struct drm_i915_private *dev_priv)
+void intel_guc_fetch_fw(struct intel_guc *guc)
 {
-	struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
+	struct drm_i915_private *dev_priv = guc_to_i915(guc);
 	const char *fw_path;
 
 	if (!HAS_GUC(dev_priv)) {
@@ -751,23 +751,23 @@ void intel_guc_init(struct drm_i915_private *dev_priv)
 		fw_path = NULL;
 	} else if (IS_SKYLAKE(dev_priv)) {
 		fw_path = I915_SKL_GUC_UCODE;
-		guc_fw->major_ver_wanted = SKL_FW_MAJOR;
-		guc_fw->minor_ver_wanted = SKL_FW_MINOR;
+		guc->fw.major_ver_wanted = SKL_FW_MAJOR;
+		guc->fw.minor_ver_wanted = SKL_FW_MINOR;
 	} else if (IS_BROXTON(dev_priv)) {
 		fw_path = I915_BXT_GUC_UCODE;
-		guc_fw->major_ver_wanted = BXT_FW_MAJOR;
-		guc_fw->minor_ver_wanted = BXT_FW_MINOR;
+		guc->fw.major_ver_wanted = BXT_FW_MAJOR;
+		guc->fw.minor_ver_wanted = BXT_FW_MINOR;
 	} else if (IS_KABYLAKE(dev_priv)) {
 		fw_path = I915_KBL_GUC_UCODE;
-		guc_fw->major_ver_wanted = KBL_FW_MAJOR;
-		guc_fw->minor_ver_wanted = KBL_FW_MINOR;
+		guc->fw.major_ver_wanted = KBL_FW_MAJOR;
+		guc->fw.minor_ver_wanted = KBL_FW_MINOR;
 	} else {
 		fw_path = "";	/* unknown device */
 	}
 
-	guc_fw->path = fw_path;
-	guc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
-	guc_fw->load_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.path = fw_path;
+	guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.load_status = INTEL_UC_FIRMWARE_NONE;
 
 	/* Early (and silent) return if GuC loading is disabled */
 	if (!i915.enable_guc_loading)
@@ -777,9 +777,9 @@ void intel_guc_init(struct drm_i915_private *dev_priv)
 	if (*fw_path == '\0')
 		return;
 
-	guc_fw->fetch_status = INTEL_UC_FIRMWARE_PENDING;
+	guc->fw.fetch_status = INTEL_UC_FIRMWARE_PENDING;
 	DRM_DEBUG_DRIVER("GuC firmware pending, path %s\n", fw_path);
-	intel_uc_fw_fetch(dev_priv, guc_fw);
+	intel_uc_fw_fetch(dev_priv, &guc->fw);
 	/* status must now be FAIL or SUCCESS */
 }
 
drivers/gpu/drm/i915/intel_huc.c +18 -19
index babe0eb..0725e6f 100644
@@ -141,8 +141,8 @@ static int huc_ucode_xfer(struct drm_i915_private *dev_priv)
 }
 
 /**
- * intel_huc_init() - initiate HuC firmware loading request
- * @dev_priv: the drm_i915_private device
+ * intel_huc_fetch_fw() - initiate HuC firmware loading request
+ * @huc:	intel_huc struct
  *
  * Called early during driver load, but after GEM is initialised. The loading
  * will continue only when driver explicitly specify firmware name and version.
@@ -152,42 +152,41 @@ static int huc_ucode_xfer(struct drm_i915_private *dev_priv)
  *
  * The DMA-copying to HW is done later when intel_huc_init_hw() is called.
  */
-void intel_huc_init(struct drm_i915_private *dev_priv)
+void intel_huc_fetch_fw(struct intel_huc *huc)
 {
-	struct intel_huc *huc = &dev_priv->huc;
-	struct intel_uc_fw *huc_fw = &huc->fw;
+	struct drm_i915_private *dev_priv = huc_to_i915(huc);
 	const char *fw_path = NULL;
 
-	huc_fw->path = NULL;
-	huc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
-	huc_fw->load_status = INTEL_UC_FIRMWARE_NONE;
-	huc_fw->fw = INTEL_UC_FW_TYPE_HUC;
+	huc->fw.path = NULL;
+	huc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
+	huc->fw.load_status = INTEL_UC_FIRMWARE_NONE;
+	huc->fw.fw = INTEL_UC_FW_TYPE_HUC;
 
 	if (!HAS_HUC_UCODE(dev_priv))
 		return;
 
 	if (IS_SKYLAKE(dev_priv)) {
 		fw_path = I915_SKL_HUC_UCODE;
-		huc_fw->major_ver_wanted = SKL_HUC_FW_MAJOR;
-		huc_fw->minor_ver_wanted = SKL_HUC_FW_MINOR;
+		huc->fw.major_ver_wanted = SKL_HUC_FW_MAJOR;
+		huc->fw.minor_ver_wanted = SKL_HUC_FW_MINOR;
 	} else if (IS_BROXTON(dev_priv)) {
 		fw_path = I915_BXT_HUC_UCODE;
-		huc_fw->major_ver_wanted = BXT_HUC_FW_MAJOR;
-		huc_fw->minor_ver_wanted = BXT_HUC_FW_MINOR;
+		huc->fw.major_ver_wanted = BXT_HUC_FW_MAJOR;
+		huc->fw.minor_ver_wanted = BXT_HUC_FW_MINOR;
 	} else if (IS_KABYLAKE(dev_priv)) {
 		fw_path = I915_KBL_HUC_UCODE;
-		huc_fw->major_ver_wanted = KBL_HUC_FW_MAJOR;
-		huc_fw->minor_ver_wanted = KBL_HUC_FW_MINOR;
+		huc->fw.major_ver_wanted = KBL_HUC_FW_MAJOR;
+		huc->fw.minor_ver_wanted = KBL_HUC_FW_MINOR;
 	}
 
-	huc_fw->path = fw_path;
-	huc_fw->fetch_status = INTEL_UC_FIRMWARE_PENDING;
+	huc->fw.path = fw_path;
+	huc->fw.fetch_status = INTEL_UC_FIRMWARE_PENDING;
 
 	DRM_DEBUG_DRIVER("HuC firmware pending, path %s\n", fw_path);
 
-	WARN(huc_fw->path == NULL, "HuC present but no fw path\n");
+	WARN(huc->fw.path == NULL, "HuC present but no fw path\n");
 
-	intel_uc_fw_fetch(dev_priv, huc_fw);
+	intel_uc_fw_fetch(dev_priv, &huc->fw);
 }
 
 /**
drivers/gpu/drm/i915/intel_uc.c +6 -0
index c46bc85..5bb9149 100644
@@ -30,6 +30,12 @@ void intel_uc_init_early(struct drm_i915_private *dev_priv)
 	mutex_init(&dev_priv->guc.send_mutex);
 }
 
+void intel_uc_fetch_fw(struct drm_i915_private *dev_priv)
+{
+	intel_huc_fetch_fw(&dev_priv->huc);
+	intel_guc_fetch_fw(&dev_priv->guc);
+}
+
 /*
  * Read GuC command/status register (SOFT_SCRATCH_0)
  * Return true if it contains a response rather than a command
drivers/gpu/drm/i915/intel_uc.h +3 -2
index 41b7351..db596b6 100644
@@ -185,11 +185,12 @@ struct intel_huc {
 
 /* intel_uc.c */
 void intel_uc_init_early(struct drm_i915_private *dev_priv);
+void intel_uc_fetch_fw(struct drm_i915_private *dev_priv);
 int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len);
 int intel_guc_sample_forcewake(struct intel_guc *guc);
 
 /* intel_guc_loader.c */
-void intel_guc_init(struct drm_i915_private *dev_priv);
+void intel_guc_fetch_fw(struct intel_guc *guc);
 int intel_guc_init_hw(struct drm_i915_private *dev_priv);
 void intel_guc_fini(struct drm_i915_private *dev_priv);
 const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status);
@@ -223,7 +224,7 @@ static inline u32 guc_ggtt_offset(struct i915_vma *vma)
 }
 
 /* intel_huc.c */
-void intel_huc_init(struct drm_i915_private *dev_priv);
+void intel_huc_fetch_fw(struct intel_huc *huc);
 void intel_huc_fini(struct drm_i915_private  *dev_priv);
 int intel_huc_init_hw(struct drm_i915_private *dev_priv);
 void intel_guc_auth_huc(struct drm_i915_private *dev_priv);
Signature · 6 lines
2.9.3

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

Re: [PATCH 4/8] drm/i915/uc: Rename intel_?uc_init() to intel_?uc_fetch_fw()

Quoted 22 lines · Arkadiusz Hiler

Trying to have subject_verb_object ordering and more descriptive names, the intel_huc_init() and intel_guc_init() functions are renamed:

 * intel_guc is the subject, so those functions now take intel_guc structure, instead of the dev_priv
 * fetch is the verb
 * fw is the object which better describes the function's role

Same change is done for the huc counterpart.

Also we bulk call both functions from higher-level intel_uc_fetch_fw:
 * intel being the subject (taking the dev_priv as param)
 * fetch being the verb
 * uc_fw being the subject

v2: settle on intel_uc_fetch_fw name (M. Wajdeczko)

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Michal Winiarski <[email protected]>

<SNIP>

drivers/gpu/drm/i915/i915_drv.c static int i915_load_modeset_init(struct drm_device *dev) · line 612

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -609,8 +609,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
  	if (ret)
  		goto cleanup_irq;

drivers/gpu/drm/i915/i915_drv.c +1 -2
-	intel_huc_init(dev_priv);
-	intel_guc_init(dev_priv);
+	intel_uc_fetch_fw(dev_priv);

intel_uc_init fits this context. (See below)

Quoted 11 lines

 /**
- * intel_guc_init() - define parameters and fetch firmware
- * @dev_priv: i915 device private
+ * intel_guc_fetch_fw() - define parameters and fetch firmware
+ * @guc: intel_guc struct
  *
  * Called early during driver load, but after GEM is initialised. *
  * The firmware will be transferred to the GuC's memory later,
  * when intel_guc_init_hw() is called.
  */

"define parameters" is little vague, maybe "select and fetch firmware"?

Quoted 8 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1 -1
-void intel_guc_init(struct drm_i915_private *dev_priv)
+void intel_guc_fetch_fw(struct intel_guc *guc)

 {

drivers/gpu/drm/i915/intel_guc_loader.c +1 -1
-	struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
+	struct drm_i915_private *dev_priv = guc_to_i915(guc);

  const char *fw_path;

  if (!HAS_GUC(dev_priv)) {

This parameter dance needs to be moved away from guc_fetch_fw function, into intel_sanitize_options (I'm pretty sure I've mentioned this earlier).

Quoted 24 lines
drivers/gpu/drm/i915/intel_guc_loader.c +6 -6
@@ -751,23 +751,23 @@ void intel_guc_init(struct drm_i915_private *dev_priv)
  		fw_path = NULL;
  	} else if (IS_SKYLAKE(dev_priv)) {
  		fw_path = I915_SKL_GUC_UCODE;
-		guc_fw->major_ver_wanted = SKL_FW_MAJOR;
-		guc_fw->minor_ver_wanted = SKL_FW_MINOR;
+		guc->fw.major_ver_wanted = SKL_FW_MAJOR;
+		guc->fw.minor_ver_wanted = SKL_FW_MINOR;
  	} else if (IS_BROXTON(dev_priv)) {
  		fw_path = I915_BXT_GUC_UCODE;
-		guc_fw->major_ver_wanted = BXT_FW_MAJOR;
-		guc_fw->minor_ver_wanted = BXT_FW_MINOR;
+		guc->fw.major_ver_wanted = BXT_FW_MAJOR;
+		guc->fw.minor_ver_wanted = BXT_FW_MINOR;
  	} else if (IS_KABYLAKE(dev_priv)) {
  		fw_path = I915_KBL_GUC_UCODE;
-		guc_fw->major_ver_wanted = KBL_FW_MAJOR;
-		guc_fw->minor_ver_wanted = KBL_FW_MINOR;
+		guc->fw.major_ver_wanted = KBL_FW_MAJOR;
+		guc->fw.minor_ver_wanted = KBL_FW_MINOR;
  	} else {

  fw_path = ""; /* unknown device */
  }

drivers/gpu/drm/i915/intel_guc_loader.c void intel_guc_init(struct drm_i915_private *dev_priv) · line 768

Quoted 4 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1 -3
-	guc_fw->path = fw_path;
-	guc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
-	guc_fw->load_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.path = fw_path;

Just get rid of fw_path variable and assign directly, also hoist the warning to the else branch, which can then do "return;"

drivers/gpu/drm/i915/intel_guc_loader.c void intel_guc_init(struct drm_i915_private *dev_priv) · line 770

Quoted 2 lines
drivers/gpu/drm/i915/intel_guc_loader.c +2 -0
+	guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.load_status = INTEL_UC_FIRMWARE_NONE;

Hoist this assignment before the if block, so no need to special for the early return from else branch.

<SNIP>

Quoted 4 lines

 /**
- * intel_huc_init() - initiate HuC firmware loading request
- * @dev_priv: the drm_i915_private device
+ * intel_huc_fetch_fw() - initiate HuC firmware loading request

Correct this commit too to be more descriptive.

Quoted 5 lines

+ * @huc: intel_huc struct
  *
  * Called early during driver load, but after GEM is initialised. The loading
  * will continue only when driver explicitly specify firmware name and version.

drivers/gpu/drm/i915/intel_huc.c static int huc_ucode_xfer(struct drm_i915_private *dev_priv) · line 158

Quoted 10 lines
drivers/gpu/drm/i915/intel_huc.c +2 -3
@@ -152,42 +152,41 @@ static int huc_ucode_xfer(struct drm_i915_private *dev_priv)
   *
   * The DMA-copying to HW is done later when intel_huc_init_hw() is called.
   */
-void intel_huc_init(struct drm_i915_private *dev_priv)
+void intel_huc_fetch_fw(struct intel_huc *huc)
  {
-	struct intel_huc *huc = &dev_priv->huc;
-	struct intel_uc_fw *huc_fw = &huc->fw;
+	struct drm_i915_private *dev_priv = huc_to_i915(huc);
  	const char *fw_path = NULL;

Similarly arrange to get rid of fw_path here.

<SNIP>

Quoted 5 lines
drivers/gpu/drm/i915/intel_uc.c +0 -0
@@ -30,6 +30,12 @@ void intel_uc_init_early(struct drm_i915_private *dev_priv)
  	mutex_init(&dev_priv->guc.send_mutex);
  }


+void intel_uc_fetch_fw(struct drm_i915_private *dev_priv)

This function might be worth calling intel_uc_init (See above), if the need comes to add other stuff. But either way.

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

Re: [PATCH 4/8] drm/i915/uc: Rename intel_?uc_init() to intel_?uc_fetch_fw()

Quoted 26 lines · Joonas Lahtinen
Quoted 22 lines · Arkadiusz Hiler

Trying to have subject_verb_object ordering and more descriptive names, the intel_huc_init() and intel_guc_init() functions are renamed:

 * intel_guc is the subject, so those functions now take intel_guc structure, instead of the dev_priv
 * fetch is the verb
 * fw is the object which better describes the function's role

Same change is done for the huc counterpart.

Also we bulk call both functions from higher-level intel_uc_fetch_fw:
 * intel being the subject (taking the dev_priv as param)
 * fetch being the verb
 * uc_fw being the subject

v2: settle on intel_uc_fetch_fw name (M. Wajdeczko)

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Michal Winiarski <[email protected]>

<SNIP>

Quoted 9 lines

drivers/gpu/drm/i915/i915_drv.c static int i915_load_modeset_init(struct drm_device *dev) · line 612

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -609,8 +609,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
  	if (ret)
  		goto cleanup_irq;

drivers/gpu/drm/i915/i915_drv.c +1 -2
-	intel_huc_init(dev_priv);
-	intel_guc_init(dev_priv);
+	intel_uc_fetch_fw(dev_priv);

intel_uc_init fits this context. (See below)

Answer below.

Quoted 13 lines
Quoted 12 lines

 /**
- * intel_guc_init() - define parameters and fetch firmware
- * @dev_priv: i915 device private
+ * intel_guc_fetch_fw() - define parameters and fetch firmware
+ * @guc: intel_guc struct
  *
  * Called early during driver load, but after GEM is initialised. *
  * The firmware will be transferred to the GuC's memory later,
  * when intel_guc_init_hw() is called.
  */

Quoted 1 line

"define parameters" is little vague, maybe "select and fetch firmware"?

I like those verbs. Let start using it through the whole thing!

Quoted 13 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1 -1
-void intel_guc_init(struct drm_i915_private *dev_priv)
+void intel_guc_fetch_fw(struct intel_guc *guc)

 {

drivers/gpu/drm/i915/intel_guc_loader.c +1 -1
-	struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
+	struct drm_i915_private *dev_priv = guc_to_i915(guc);

  const char *fw_path;

  if (!HAS_GUC(dev_priv)) {

This parameter dance needs to be moved away from guc_fetch_fw function, into intel_sanitize_options (I'm pretty sure I've mentioned this earlier).

This is removed in patch 8, as the fetch_fw is called conditionally.

Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/intel_guc_loader.c +6 -6
@@ -751,23 +751,23 @@ void intel_guc_init(struct drm_i915_private *dev_priv)
  		fw_path = NULL;
  	} else if (IS_SKYLAKE(dev_priv)) {
  		fw_path = I915_SKL_GUC_UCODE;
-		guc_fw->major_ver_wanted = SKL_FW_MAJOR;
-		guc_fw->minor_ver_wanted = SKL_FW_MINOR;
+		guc->fw.major_ver_wanted = SKL_FW_MAJOR;
+		guc->fw.minor_ver_wanted = SKL_FW_MINOR;
  	} else if (IS_BROXTON(dev_priv)) {
  		fw_path = I915_BXT_GUC_UCODE;
-		guc_fw->major_ver_wanted = BXT_FW_MAJOR;
-		guc_fw->minor_ver_wanted = BXT_FW_MINOR;
+		guc->fw.major_ver_wanted = BXT_FW_MAJOR;
+		guc->fw.minor_ver_wanted = BXT_FW_MINOR;
  	} else if (IS_KABYLAKE(dev_priv)) {
  		fw_path = I915_KBL_GUC_UCODE;
-		guc_fw->major_ver_wanted = KBL_FW_MAJOR;
-		guc_fw->minor_ver_wanted = KBL_FW_MINOR;
+		guc->fw.major_ver_wanted = KBL_FW_MAJOR;
+		guc->fw.minor_ver_wanted = KBL_FW_MINOR;
  	} else {

  fw_path = ""; /* unknown device */
  }

Quoted 8 lines

drivers/gpu/drm/i915/intel_guc_loader.c void intel_guc_init(struct drm_i915_private *dev_priv) · line 768

Quoted 5 lines

drivers/gpu/drm/i915/intel_guc_loader.c +1 -3
-	guc_fw->path = fw_path;
-	guc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
-	guc_fw->load_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.path = fw_path;

Just get rid of fw_path variable and assign directly, also hoist the warning to the else branch, which can then do "return;"

This is done done in patch 8.

Quoted 5 lines

drivers/gpu/drm/i915/intel_guc_loader.c void intel_guc_init(struct drm_i915_private *dev_priv) · line 770

Quoted 2 lines
drivers/gpu/drm/i915/intel_guc_loader.c +2 -0
+	guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.load_status = INTEL_UC_FIRMWARE_NONE;

Hoist this assignment before the if block, so no need to special for the early return from else branch.

This is done done in patch 8.

Quoted 8 lines

<SNIP>

Quoted 4 lines

 /**
- * intel_huc_init() - initiate HuC firmware loading request
- * @dev_priv: the drm_i915_private device
+ * intel_huc_fetch_fw() - initiate HuC firmware loading request

Correct this commit too to be more descriptive.

Okay.

Quoted 9 lines
Quoted 9 lines

+ * @huc: intel_huc struct
  *
  * Called early during driver load, but after GEM is initialised. The loading
  * will continue only when driver explicitly specify firmware name and version.

drivers/gpu/drm/i915/intel_huc.c +0 -1
@@ -152,42 +152,41 @@ static int huc_ucode_xfer(struct drm_i915_private *dev_priv)
   *
   * The DMA-copying to HW is done later when intel_huc_init_hw() is called.
   */
-void intel_huc_init(struct drm_i915_private *dev_priv)
Quoted 8 lines

drivers/gpu/drm/i915/intel_huc.c static int huc_ucode_xfer(struct drm_i915_private *dev_priv) · line 158

Quoted 6 lines
drivers/gpu/drm/i915/intel_huc.c +2 -2
+void intel_huc_fetch_fw(struct intel_huc *huc)
  {
-	struct intel_huc *huc = &dev_priv->huc;
-	struct intel_uc_fw *huc_fw = &huc->fw;
+	struct drm_i915_private *dev_priv = huc_to_i915(huc);
  	const char *fw_path = NULL;

Similarly arrange to get rid of fw_path here.

Patch 8 in the series addresses that issue as well. Maybe I should move them around?

Quoted 10 lines

<SNIP>

Quoted 5 lines
drivers/gpu/drm/i915/intel_uc.c +0 -0
@@ -30,6 +30,12 @@ void intel_uc_init_early(struct drm_i915_private *dev_priv)
  	mutex_init(&dev_priv->guc.send_mutex);
  }


+void intel_uc_fetch_fw(struct drm_i915_private *dev_priv)

This function might be worth calling intel_uc_init (See above), if the need comes to add other stuff. But either way.

This is quite confusing now. I was fine it being named init, someone suggested to be more descriptive with the name, as it is not general enough to be "init". Seemed reasonable enough for me, so I incorporated that in the respin.

This is turning into some heavy bikeshedding now...

I agree that it's more than fetch, it actually selects + fetches + populates the structures.

I'll gladly ignore previous feedback on being to vague with name and just go with init, but let give the _fw postfix one last chance:

intel_guc_init_fw {
    intel_guc_select_fw
    if (NULL != guc.fw.path)
	    intel_uc_prepare_fw
}

Where select does what the guc's fetch fw does sans the uc_fetch call.

Also intel_{g,h}uc_select_fw can be made part of the sanitize options, but I think it better belongs here.

That's is basing on your suggestions for the other patch.

Signature · 6 lines
Cheers,
Arek
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#8 lore raw

Re: [PATCH 4/8] drm/i915/uc: Rename intel_?uc_init() to intel_?uc_fetch_fw()

Quoted 20 lines · Arkadiusz Hiler
Quoted 12 lines · Joonas Lahtinen
Quoted 12 lines

+ * @huc: intel_huc struct
  *
  * Called early during driver load, but after GEM is initialised. The loading
  * will continue only when driver explicitly specify firmware name and version.

drivers/gpu/drm/i915/intel_huc.c +1 -1
@@ -152,42 +152,41 @@ static int huc_ucode_xfer(struct drm_i915_private *dev_priv)
   *
   * The DMA-copying to HW is done later when intel_huc_init_hw() is called.
   */
-void intel_huc_init(struct drm_i915_private *dev_priv)
+void intel_huc_fetch_fw(struct intel_huc *huc)
  {
Quoted 6 lines

Review static int huc_ucode_xfer(struct drm_i915_private *dev_priv) · line 160

Quoted 4 lines
(quoted diff) +0 -0
 > > > -	struct intel_huc *huc = &dev_priv->huc;
 > > > -	struct intel_uc_fw *huc_fw = &huc->fw;
 > > > +	struct drm_i915_private *dev_priv = huc_to_i915(huc);
 > > >  	const char *fw_path = NULL;

Similarly arrange to get rid of fw_path here.

Quoted 2 lines

Patch 8 in the series addresses that issue as well. Maybe I should move them around?

Nah, it's fine, the intermediary steps need to be working (for bisecting), but not necessarily 100% pretty. If it's addressed later, it's good.

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_uc.c +0 -0
@@ -30,6 +30,12 @@ void intel_uc_init_early(struct drm_i915_private *dev_priv)
  	mutex_init(&dev_priv->guc.send_mutex);
  }


+void intel_uc_fetch_fw(struct drm_i915_private *dev_priv)

This function might be worth calling intel_uc_init (See above), if the need comes to add other stuff. But either way.

Quoted 6 lines

This is quite confusing now. I was fine it being named init, someone suggested to be more descriptive with the name, as it is not general enough to be "init". Seemed reasonable enough for me, so I incorporated that in the respin.

This is turning into some heavy bikeshedding now...

That's why actual code in the mailing list is the only right way, discussion in IRC can be misleading :)

Quoted 11 lines

I agree that it's more than fetch, it actually selects + fetches + populates the structures.

I'll gladly ignore previous feedback on being to vague with name and just go with init, but let give the _fw postfix one last chance:

intel_guc_init_fw {
    intel_guc_select_fw
    if (NULL != guc.fw.path)

if (guc.fw.patch) to stick to coding style.

Quoted 4 lines

    intel_uc_prepare_fw
}

Where select does what the guc's fetch fw does sans the uc_fetch call.

Sounds good to me.

Quoted 4 lines

Also intel_{g,h}uc_select_fw can be made part of the sanitize options, but I think it better belongs here.

That's is basing on your suggestions for the other patch.

Thats, correct, select_fw should be here.

        if (!HAS_GUC(dev_priv)) {
                i915.enable_guc_loading = 0;
                i915.enable_guc_submission = 0;
        } else {
                /* A negative value means "use platform default" */
                if (i915.enable_guc_loading < 0)
                        i915.enable_guc_loading = HAS_GUC_UCODE(dev_priv);
                if (i915.enable_guc_submission < 0)
                        i915.enable_guc_submission = HAS_GUC_SCHED(dev_priv);
        }

This part is a perfect fit to the sanitize_options function, because that's what it does, makes sure we don't try to enable something we don't have.

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH v4 5/8 drm/i915/uc: Make intel_uc_fw_fetch() static

In reply to Arkadiusz Hiler

intel_uc_fw_fetch() is confusingly named in the light of recent changes.

It's also in the wrong place - 'guc_loader.h' - it's used for both guc and huc, which was reflected in name, but not it's location, so let's move it to 'intel_uc.c'.

We can make a intel_uc_fw callback out of it, to avoid leaking it outside intel_uc.c

Cc Joonas Lahtinen <[email protected]>
Cc Michal Winiarski <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc_loader.c | 137 +------------------------------
 drivers/gpu/drm/i915/intel_huc.c        |   2 +-
 drivers/gpu/drm/i915/intel_uc.c         | 141 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_uc.h         |   4 +-
 4 files changed, 145 insertions(+), 139 deletions(-)
drivers/gpu/drm/i915/intel_guc_loader.c +1 -136
index 753aeef..110dfd1 100644
@@ -26,7 +26,6 @@
  *    Dave Gordon <[email protected]>
  *    Alex Dai <[email protected]>
  */
-#include <linux/firmware.h>
 #include "i915_drv.h"
 #include "intel_uc.h"
 
@@ -587,140 +586,6 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 	return ret;
 }
 
-void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
-			 struct intel_uc_fw *uc_fw)
-{
-	struct pci_dev *pdev = dev_priv->drm.pdev;
-	struct drm_i915_gem_object *obj;
-	const struct firmware *fw = NULL;
-	struct uc_css_header *css;
-	size_t size;
-	int err;
-
-	DRM_DEBUG_DRIVER("before requesting firmware: uC fw fetch status %s\n",
-		intel_uc_fw_status_repr(uc_fw->fetch_status));
-
-	err = request_firmware(&fw, uc_fw->path, &pdev->dev);
-	if (err)
-		goto fail;
-	if (!fw)
-		goto fail;
-
-	DRM_DEBUG_DRIVER("fetch uC fw from %s succeeded, fw %p\n",
-		uc_fw->path, fw);
-
-	/* Check the size of the blob before examining buffer contents */
-	if (fw->size < sizeof(struct uc_css_header)) {
-		DRM_NOTE("Firmware header is missing\n");
-		goto fail;
-	}
-
-	css = (struct uc_css_header *)fw->data;
-
-	/* Firmware bits always start from header */
-	uc_fw->header_offset = 0;
-	uc_fw->header_size = (css->header_size_dw - css->modulus_size_dw -
-		css->key_size_dw - css->exponent_size_dw) * sizeof(u32);
-
-	if (uc_fw->header_size != sizeof(struct uc_css_header)) {
-		DRM_NOTE("CSS header definition mismatch\n");
-		goto fail;
-	}
-
-	/* then, uCode */
-	uc_fw->ucode_offset = uc_fw->header_offset + uc_fw->header_size;
-	uc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32);
-
-	/* now RSA */
-	if (css->key_size_dw != UOS_RSA_SCRATCH_MAX_COUNT) {
-		DRM_NOTE("RSA key size is bad\n");
-		goto fail;
-	}
-	uc_fw->rsa_offset = uc_fw->ucode_offset + uc_fw->ucode_size;
-	uc_fw->rsa_size = css->key_size_dw * sizeof(u32);
-
-	/* At least, it should have header, uCode and RSA. Size of all three. */
-	size = uc_fw->header_size + uc_fw->ucode_size + uc_fw->rsa_size;
-	if (fw->size < size) {
-		DRM_NOTE("Missing firmware components\n");
-		goto fail;
-	}
-
-	/*
-	 * The GuC firmware image has the version number embedded at a well-known
-	 * offset within the firmware blob; note that major / minor version are
-	 * TWO bytes each (i.e. u16), although all pointers and offsets are defined
-	 * in terms of bytes (u8).
-	 */
-	switch (uc_fw->fw) {
-	case INTEL_UC_FW_TYPE_GUC:
-		/* Header and uCode will be loaded to WOPCM. Size of the two. */
-		size = uc_fw->header_size + uc_fw->ucode_size;
-
-		/* Top 32k of WOPCM is reserved (8K stack + 24k RC6 context). */
-		if (size > intel_guc_wopcm_size(dev_priv)) {
-			DRM_ERROR("Firmware is too large to fit in WOPCM\n");
-			goto fail;
-		}
-		uc_fw->major_ver_found = css->guc.sw_version >> 16;
-		uc_fw->minor_ver_found = css->guc.sw_version & 0xFFFF;
-		break;
-
-	case INTEL_UC_FW_TYPE_HUC:
-		uc_fw->major_ver_found = css->huc.sw_version >> 16;
-		uc_fw->minor_ver_found = css->huc.sw_version & 0xFFFF;
-		break;
-
-	default:
-		DRM_ERROR("Unknown firmware type %d\n", uc_fw->fw);
-		err = -ENOEXEC;
-		goto fail;
-	}
-
-	if (uc_fw->major_ver_found != uc_fw->major_ver_wanted ||
-	    uc_fw->minor_ver_found < uc_fw->minor_ver_wanted) {
-		DRM_NOTE("uC firmware version %d.%d, required %d.%d\n",
-			uc_fw->major_ver_found, uc_fw->minor_ver_found,
-			uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted);
-		err = -ENOEXEC;
-		goto fail;
-	}
-
-	DRM_DEBUG_DRIVER("firmware version %d.%d OK (minimum %d.%d)\n",
-			uc_fw->major_ver_found, uc_fw->minor_ver_found,
-			uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted);
-
-	mutex_lock(&dev_priv->drm.struct_mutex);
-	obj = i915_gem_object_create_from_data(dev_priv, fw->data, fw->size);
-	mutex_unlock(&dev_priv->drm.struct_mutex);
-	if (IS_ERR_OR_NULL(obj)) {
-		err = obj ? PTR_ERR(obj) : -ENOMEM;
-		goto fail;
-	}
-
-	uc_fw->obj = obj;
-	uc_fw->size = fw->size;
-
-	DRM_DEBUG_DRIVER("uC fw fetch status SUCCESS, obj %p\n",
-			uc_fw->obj);
-
-	release_firmware(fw);
-	uc_fw->fetch_status = INTEL_UC_FIRMWARE_SUCCESS;
-	return;
-
-fail:
-	DRM_WARN("Failed to fetch valid uC firmware from %s (error %d)\n",
-		 uc_fw->path, err);
-	DRM_DEBUG_DRIVER("uC fw fetch status FAIL; err %d, fw %p, obj %p\n",
-		err, fw, uc_fw->obj);
-
-	obj = fetch_and_zero(&uc_fw->obj);
-	if (obj)
-		i915_gem_object_put(obj);
-
-	release_firmware(fw);		/* OK even if fw is NULL */
-	uc_fw->fetch_status = INTEL_UC_FIRMWARE_FAIL;
-}
 
 /**
  * intel_guc_fetch_fw() - define parameters and fetch firmware
@@ -779,7 +644,7 @@ void intel_guc_fetch_fw(struct intel_guc *guc)
 
 	guc->fw.fetch_status = INTEL_UC_FIRMWARE_PENDING;
 	DRM_DEBUG_DRIVER("GuC firmware pending, path %s\n", fw_path);
-	intel_uc_fw_fetch(dev_priv, &guc->fw);
+	guc->fw.fetch(dev_priv, &guc->fw);
 	/* status must now be FAIL or SUCCESS */
 }
 
drivers/gpu/drm/i915/intel_huc.c +1 -1
index 0725e6f..7527988 100644
@@ -186,7 +186,7 @@ void intel_huc_fetch_fw(struct intel_huc *huc)
 
 	WARN(huc->fw.path == NULL, "HuC present but no fw path\n");
 
-	intel_uc_fw_fetch(dev_priv, &huc->fw);
+	huc->fw.fetch(dev_priv, &huc->fw);
 }
 
 /**
drivers/gpu/drm/i915/intel_uc.c +141 -0

157 lines not on this page · raw message

drivers/gpu/drm/i915/intel_uc.h +2 -2
index db596b6..b9d2230 100644
@@ -110,6 +110,8 @@ enum intel_uc_fw_type {
  * of fetching, caching, and loading the firmware image into the GuC.
  */
 struct intel_uc_fw {
+	void (*fetch)(struct drm_i915_private *dev_priv,
+		      struct intel_uc_fw *uc_fw);
 	const char *path;
 	size_t size;
 	struct drm_i915_gem_object *obj;
@@ -196,8 +198,6 @@ void intel_guc_fini(struct drm_i915_private *dev_priv);
 const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status);
 int intel_guc_suspend(struct drm_i915_private *dev_priv);
 int intel_guc_resume(struct drm_i915_private *dev_priv);
-void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
-	struct intel_uc_fw *uc_fw);
 u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
 
 /* i915_guc_submission.c */
Signature · 6 lines
2.9.3

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

Re: [PATCH 5/8] drm/i915/uc: Make intel_uc_fw_fetch() static

Quoted 12 lines · Arkadiusz Hiler

intel_uc_fw_fetch() is confusingly named in the light of recent changes.

It's also in the wrong place - 'guc_loader.h' - it's used for both guc and huc, which was reflected in name, but not it's location, so let's move it to 'intel_uc.c'.

We can make a intel_uc_fw callback out of it, to avoid leaking it outside intel_uc.c

Cc Joonas Lahtinen <[email protected]>
Cc Michal Winiarski <[email protected]>

<SNIP>

drivers/gpu/drm/i915/intel_uc.c void intel_uc_init_early(struct drm_i915_private *dev_priv) · line 42

Quoted 8 lines
(quoted diff) +0 -0
@@ -32,7 +36,10 @@ void intel_uc_init_early(struct drm_i915_private *dev_priv)


 void intel_uc_fetch_fw(struct drm_i915_private *dev_priv) {

drivers/gpu/drm/i915/intel_uc.c +1 -0
+	dev_priv->huc.fw.fetch = uc_fetch_fw;

  intel_huc_fetch_fw(&dev_priv->huc);

drivers/gpu/drm/i915/intel_uc.c +2 -0
+
+	dev_priv->guc.fw.fetch = uc_fetch_fw;

I'm bit confused, I was under impression these functions were going to be different for each uC? If they're not, then it most definitely should not be a function pointer.

	int ret;

	ret = intel_huc_select_fw(dev_priv->huc);
	if (ret)
		goto err;
	ret = intel_uc_fw_prepare(&dev_priv->huc->fw);
	if (ret)
		goto err;

	ret = intel_guc_select_fw(dev_priv->guc);
	if (ret)
		goto err_huc;
	ret = intel_uc_fw_prepare(&dev_priv->guc->fw);
	if (ret)

goto err_huc;

	return 0;

err_huc:

	intel_uc_fw_unprepare(&dev_priv->huc->fw);
err:
	return ret;

By always involving proper onion teardown, no dangling objects are left around.

Quoted 7 lines

  intel_guc_fetch_fw(&dev_priv->guc);
 }

(quoted diff) +0 -0
@@ -120,3 +127,137 @@ int intel_guc_sample_forcewake(struct intel_guc *guc)
 >  	return intel_guc_send(guc, action, ARRAY_SIZE(action));
  }

drivers/gpu/drm/i915/intel_uc.c int intel_guc_sample_forcewake(struct intel_guc *guc) · line 138

Quoted 9 lines
drivers/gpu/drm/i915/intel_uc.c +9 -0
+static void uc_fetch_fw(struct drm_i915_private *dev_priv,
+			  struct intel_uc_fw *uc_fw)
+{
+	struct pci_dev *pdev = dev_priv->drm.pdev;
+	struct drm_i915_gem_object *obj;
+	const struct firmware *fw = NULL;
+	struct uc_css_header *css;
+	size_t size;
+	int err;

This function should be named differently, because it doesn't simply fetch it, but also validates and makes an object of it (which may be left dangling).

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

Re: [PATCH 5/8] drm/i915/uc: Make intel_uc_fw_fetch() static

Quoted 16 lines · Joonas Lahtinen
Quoted 12 lines · Arkadiusz Hiler

intel_uc_fw_fetch() is confusingly named in the light of recent changes.

It's also in the wrong place - 'guc_loader.h' - it's used for both guc and huc, which was reflected in name, but not it's location, so let's move it to 'intel_uc.c'.

We can make a intel_uc_fw callback out of it, to avoid leaking it outside intel_uc.c

Cc Joonas Lahtinen <[email protected]>
Cc Michal Winiarski <[email protected]>

<SNIP>

Quoted 12 lines

drivers/gpu/drm/i915/intel_uc.c void intel_uc_init_early(struct drm_i915_private *dev_priv) · line 42

Quoted 8 lines
(quoted diff) +0 -0
@@ -32,7 +36,10 @@ void intel_uc_init_early(struct drm_i915_private *dev_priv)


 void intel_uc_fetch_fw(struct drm_i915_private *dev_priv) {

drivers/gpu/drm/i915/intel_uc.c +1 -0
+	dev_priv->huc.fw.fetch = uc_fetch_fw;

  intel_huc_fetch_fw(&dev_priv->huc);

drivers/gpu/drm/i915/intel_uc.c +2 -0
+
+	dev_priv->guc.fw.fetch = uc_fetch_fw;

I'm bit confused, I was under impression these functions were going to be different for each uC? If they're not, then it most definitely should not be a function pointer.

The issue I presented on the IRC (maybe not clearly enough) was just placement and naming of that function. The proposition with callback seemd odd, but since it was backed by couple of people I commited to it.

Glad you spoted that here.

Quoted 19 lines
	int ret;

	ret = intel_huc_select_fw(dev_priv->huc);
	if (ret)
		goto err;
	ret = intel_uc_fw_prepare(&dev_priv->huc->fw);
	if (ret)
		goto err;

	ret = intel_guc_select_fw(dev_priv->guc);
	if (ret)
		goto err_huc;
	ret = intel_uc_fw_prepare(&dev_priv->guc->fw);
	if (ret)

goto err_huc;

	return 0;
Quoted 7 lines

err_huc:

	intel_uc_fw_unprepare(&dev_priv->huc->fw);
err:
	return ret;

By always involving proper onion teardown, no dangling objects are left around.

That's exactly what I was missing in my approach. Thanks!

Quoted 5 lines
Quoted 5 lines

  intel_guc_fetch_fw(&dev_priv->guc);
 }

(quoted diff) +0 -0
@@ -120,3 +127,137 @@ int intel_guc_sample_forcewake(struct intel_guc *guc)
 >  	return intel_guc_send(guc, action, ARRAY_SIZE(action));
Quoted 15 lines

drivers/gpu/drm/i915/intel_uc.c int intel_guc_sample_forcewake(struct intel_guc *guc) · line 138

Quoted 11 lines
(quoted diff) +0 -0
  }

drivers/gpu/drm/i915/intel_uc.c +9 -0
+static void uc_fetch_fw(struct drm_i915_private *dev_priv,
+			  struct intel_uc_fw *uc_fw)
+{
+	struct pci_dev *pdev = dev_priv->drm.pdev;
+	struct drm_i915_gem_object *obj;
+	const struct firmware *fw = NULL;
+	struct uc_css_header *css;
+	size_t size;
+	int err;

This function should be named differently, because it doesn't simply fetch it, but also validates and makes an object of it (which may be left dangling).

intel_uc_fw_prepare you've used in the example above seems like a good name.

Onto fixing this mess. Thanks for the input :-)

Signature · 6 lines
Cheers,
Arek
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

PATCH v4 6/8 drm/i915/guc: Extract param logic form guc_init

In reply to Arkadiusz Hiler

Let intel_guc_fetch_fw() focus on determining and fetching the correct firmware.

This patch introduces intel_uc_sanitize_options() that is called from intel_sanitize_options().

Then, if we have GuC, we can call intel_guc_fetch_fw() conditionally and we do not have to do the internal checks.

v2: fix comment, notify when nuking GuC explicitly enabled (M. Wajdeczko)
v3: fix comment again, change the nuke message (M. Wajdeczko)

Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c         |  2 ++
 drivers/gpu/drm/i915/intel_guc_loader.c | 16 +---------------
 drivers/gpu/drm/i915/intel_uc.c         | 27 ++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_uc.h         |  1 +
 4 files changed, 30 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index 078ac3e..2559ada 100644
@@ -993,6 +993,8 @@ static void intel_sanitize_options(struct drm_i915_private *dev_priv)
 
 	i915.semaphores = intel_sanitize_semaphores(dev_priv, i915.semaphores);
 	DRM_DEBUG_DRIVER("use GPU semaphores? %s\n", yesno(i915.semaphores));
+
+	intel_uc_sanitize_options(dev_priv);
 }
 
 /**
drivers/gpu/drm/i915/intel_guc_loader.c +1 -15
index 110dfd1..e74c127 100644
@@ -588,7 +588,7 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 
 
 /**
- * intel_guc_fetch_fw() - define parameters and fetch firmware
+ * intel_guc_fetch_fw() - determine and fetch firmware
  * @guc:	intel_guc struct
  *
  * Called early during driver load, but after GEM is initialised.
@@ -601,17 +601,6 @@ void intel_guc_fetch_fw(struct intel_guc *guc)
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
 	const char *fw_path;
 
-	if (!HAS_GUC(dev_priv)) {
-		i915.enable_guc_loading = 0;
-		i915.enable_guc_submission = 0;
-	} else {
-		/* A negative value means "use platform default" */
-		if (i915.enable_guc_loading < 0)
-			i915.enable_guc_loading = HAS_GUC_UCODE(dev_priv);
-		if (i915.enable_guc_submission < 0)
-			i915.enable_guc_submission = HAS_GUC_SCHED(dev_priv);
-	}
-
 	if (!HAS_GUC_UCODE(dev_priv)) {
 		fw_path = NULL;
 	} else if (IS_SKYLAKE(dev_priv)) {
@@ -634,9 +623,6 @@ void intel_guc_fetch_fw(struct intel_guc *guc)
 	guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
 	guc->fw.load_status = INTEL_UC_FIRMWARE_NONE;
 
-	/* Early (and silent) return if GuC loading is disabled */
-	if (!i915.enable_guc_loading)
-		return;
 	if (fw_path == NULL)
 		return;
 	if (*fw_path == '\0')
drivers/gpu/drm/i915/intel_uc.c +26 -1
index 222a928..9355907 100644
@@ -29,6 +29,27 @@
 static void uc_fetch_fw(struct drm_i915_private *dev_priv,
 			  struct intel_uc_fw *uc_fw);
 
+void intel_uc_sanitize_options(struct drm_i915_private *dev_priv)
+{
+	if (!HAS_GUC(dev_priv)) {
+		if (i915.enable_guc_loading > 0)
+			DRM_INFO("Ignoring GuC options, no hardware");
+
+		i915.enable_guc_loading = 0;
+		i915.enable_guc_submission = 0;
+	} else {
+		/* A negative value means "use platform default" */
+		if (i915.enable_guc_loading < 0)
+			i915.enable_guc_loading = HAS_GUC_UCODE(dev_priv);
+		if (i915.enable_guc_submission < 0)
+			i915.enable_guc_submission = HAS_GUC_SCHED(dev_priv);
+
+		/* can't enable guc submission without guc loaded */
+		if (!i915.enable_guc_loading)
+			i915.enable_guc_submission = 0;
+	}
+}
+
 void intel_uc_init_early(struct drm_i915_private *dev_priv)
 {
 	mutex_init(&dev_priv->guc.send_mutex);
@@ -36,8 +57,12 @@ void intel_uc_init_early(struct drm_i915_private *dev_priv)
 
 void intel_uc_fetch_fw(struct drm_i915_private *dev_priv)
 {
+	if (!i915.enable_guc_loading)
+		return;
+
 	dev_priv->huc.fw.fetch = uc_fetch_fw;
-	intel_huc_fetch_fw(&dev_priv->huc);
+	if (HAS_HUC_UCODE(dev_priv))
+		intel_huc_fetch_fw(&dev_priv->huc);
 
 	dev_priv->guc.fw.fetch = uc_fetch_fw;
 	intel_guc_fetch_fw(&dev_priv->guc);
drivers/gpu/drm/i915/intel_uc.h +1 -0
index b9d2230..cf5d0f4 100644
@@ -186,6 +186,7 @@ struct intel_huc {
 };
 
 /* intel_uc.c */
+void intel_uc_sanitize_options(struct drm_i915_private *dev_priv);
 void intel_uc_init_early(struct drm_i915_private *dev_priv);
 void intel_uc_fetch_fw(struct drm_i915_private *dev_priv);
 int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len);
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v4 6/8
#13 lore raw

Re: [PATCH 6/8] drm/i915/guc: Extract param logic form guc_init

Quoted 9 lines · Arkadiusz Hiler

Let intel_guc_fetch_fw() focus on determining and fetching the correct firmware.

This patch introduces intel_uc_sanitize_options() that is called from intel_sanitize_options().

Then, if we have GuC, we can call intel_guc_fetch_fw() conditionally and we do not have to do the internal checks.

Quoted 7 lines

v2: fix comment, notify when nuking GuC explicitly enabled (M. Wajdeczko)
v3: fix comment again, change the nuke message (M. Wajdeczko)

Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>

Ah, you already had this patch :)

One note below.

<SNIP>

drivers/gpu/drm/i915/intel_uc.c void intel_uc_init_early(struct drm_i915_private *dev_priv) · line 65

Quoted 11 lines
(quoted diff) +0 -0
@@ -36,8 +57,12 @@ void intel_uc_init_early(struct drm_i915_private *dev_priv)


 void intel_uc_fetch_fw(struct drm_i915_private *dev_priv) {

drivers/gpu/drm/i915/intel_uc.c +3 -0
+	if (!i915.enable_guc_loading)
+		return;
+

  dev_priv->huc.fw.fetch = uc_fetch_fw;

drivers/gpu/drm/i915/intel_uc.c +2 -1
-	intel_huc_fetch_fw(&dev_priv->huc);
+	if (HAS_HUC_UCODE(dev_priv))
+		intel_huc_fetch_fw(&dev_priv->huc);

With the addition of select_fw, the check would become

if (dev_priv->huc->fw.path)

to allow specifying the firmware from command line.

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

PATCH v4 7/8 drm/i915/guc: Simplify intel_guc_init_hw()

In reply to Arkadiusz Hiler

Current version of intel_guc_init_hw() does a lot:
- cares about submission
- loads huc
- implement WA

This change offloads some of the logic to intel_uc_load(), which now cares about the above.

v2: rename guc_hw_reset and fix typo in define name (M. Wajdeczko)
v3: rename once again

Cc Anusha Srivatsa <[email protected]>
Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c         |   2 +-
 drivers/gpu/drm/i915/intel_guc_loader.c | 136 +++-----------------------------
 drivers/gpu/drm/i915/intel_uc.c         | 107 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_uc.h         |   5 ++
 4 files changed, 125 insertions(+), 125 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index bbe2df9..ec958cf 100644
@@ -4512,7 +4512,7 @@ int i915_gem_init_hw(struct drm_i915_private *dev_priv)
 	intel_mocs_init_l3cc_table(dev_priv);
 
 	/* We can't enable contexts until all firmware is loaded */
-	ret = intel_guc_init_hw(dev_priv);
+	ret = intel_uc_init_hw(dev_priv);
 	if (ret)
 		goto out;
 
drivers/gpu/drm/i915/intel_guc_loader.c +12 -124

204 lines not on this page · raw message

drivers/gpu/drm/i915/intel_uc.c +107 -0

119 lines not on this page · raw message

drivers/gpu/drm/i915/intel_uc.h +5 -0
index cf5d0f4..721a6c2 100644
@@ -29,6 +29,8 @@
 #include "intel_ringbuffer.h"
 
 #include "i915_vma.h"
+/* WaEnableGuCBootHashCheckNotSet:skl,bxt */
+#define GUC_WA_HASH_CHECK_NOT_SET_ATTEMPTS 3
 
 struct drm_i915_gem_request;
 
@@ -189,6 +191,7 @@ struct intel_huc {
 void intel_uc_sanitize_options(struct drm_i915_private *dev_priv);
 void intel_uc_init_early(struct drm_i915_private *dev_priv);
 void intel_uc_fetch_fw(struct drm_i915_private *dev_priv);
+int intel_uc_init_hw(struct drm_i915_private *dev_priv);
 int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len);
 int intel_guc_sample_forcewake(struct intel_guc *guc);
 
@@ -199,6 +202,8 @@ void intel_guc_fini(struct drm_i915_private *dev_priv);
 const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status);
 int intel_guc_suspend(struct drm_i915_private *dev_priv);
 int intel_guc_resume(struct drm_i915_private *dev_priv);
+void intel_guc_interrupts_release(struct drm_i915_private *dev_priv);
+void intel_guc_interrupts_capture(struct drm_i915_private *dev_priv);
 u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
 
 /* i915_guc_submission.c */
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v4 7/8
#15 lore raw

Re: [PATCH 7/8] drm/i915/guc: Simplify intel_guc_init_hw()

Quoted 16 lines · Arkadiusz Hiler

Current version of intel_guc_init_hw() does a lot:
 - cares about submission
 - loads huc
 - implement WA

This change offloads some of the logic to intel_uc_load(), which now cares about the above.

v2: rename guc_hw_reset and fix typo in define name (M. Wajdeczko)
v3: rename once again

Cc Anusha Srivatsa <[email protected]>
Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>

<SNIP>

Quoted 12 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1 -1
@@ -443,147 +425,53 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
  {
  	struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
  	const char *fw_path = guc_fw->path;
-	int retries, ret, err;
+	int ret;


  DRM_DEBUG_DRIVER("GuC fw status: path %s, fetch %s, load %s\n", fw_path, intel_uc_fw_status_repr(guc_fw->fetch_status), intel_uc_fw_status_repr(guc_fw->load_status));

drivers/gpu/drm/i915/intel_guc_loader.c int intel_guc_init_hw(struct drm_i915_private *dev_priv) · line 435

Quoted 6 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1 -5
-	/* Loading forbidden, or no firmware to load? */
-	if (!i915.enable_guc_loading) {
-		err = 0;
-		goto fail;
-	} else if (fw_path == NULL) {
+	if (fw_path == NULL) {

if (!fw_path)

Quoted 1 line

  /* Device is known to have no uCode (e.g. no GuC) */

Spurious comment.

Quoted 5 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1 -2
-		err = -ENXIO;
-		goto fail;
+		return -ENXIO;

  } else if (*fw_path == '\0') {
  /* Device has a GuC but we don't know what f/w to load? */

Even more spurious comment, as there's WARN :)

Quoted 7 lines

  WARN(1, "No GuC firmware known for this platform!\n");

drivers/gpu/drm/i915/intel_guc_loader.c +1 -2
-		err = -ENODEV;
-		goto fail;
+		return -ENODEV;

  }

  /* Fetch failed, or already fetched but failed to load? */

Code is again self-documenting here.

Quoted 9 lines

  if (guc_fw->fetch_status != INTEL_UC_FIRMWARE_SUCCESS) {

drivers/gpu/drm/i915/intel_guc_loader.c +1 -2
-		err = -EIO;
-		goto fail;
+		return -EIO;

  } else if (guc_fw->load_status == INTEL_UC_FIRMWARE_FAIL) {

drivers/gpu/drm/i915/intel_guc_loader.c +1 -2
-		err = -ENOEXEC;
-		goto fail;
+		return -ENOEXEC;

  }

Single line braces can be dropped.

drivers/gpu/drm/i915/intel_uc.c void intel_uc_fetch_fw(struct drm_i915_private *dev_priv) · line 93

Quoted 2 lines
drivers/gpu/drm/i915/intel_uc.c +2 -0
+int intel_uc_init_hw(struct drm_i915_private *dev_priv)
+{

This function is still lacking onion tear-down (because it's so convoluted), but it's in the better direction (and it was previously so).

+++ b/drivers/gpu/drm/i915/intel_uc.h

drivers/gpu/drm/i915/intel_uc.h line 33

Quoted 6 lines
drivers/gpu/drm/i915/intel_uc.h +0 -0
@@ -29,6 +29,8 @@
  #include "intel_ringbuffer.h"


 #include "i915_vma.h"

drivers/gpu/drm/i915/intel_uc.h +2 -0
+/* WaEnableGuCBootHashCheckNotSet:skl,bxt */
+#define GUC_WA_HASH_CHECK_NOT_SET_ATTEMPTS 3

As this is a W/A only, I'd keep the code local to single spot.

With above stylistic nitpicks;

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

PATCH v4 8/8 drm/i915/uc: Simplify firmware path handling

In reply to Arkadiusz Hiler

Currently fw->path values can represent one of three possible states:

1) NULL - device without the uC
2) '\0' - device with the uC but have no firmware
3) else - device with the uC and we have firmware

Second case is used only to WARN at a later stage.

We can WARN right away and merge cases 1 and 2.

Code can be even further simplified and common (HuC/GuC logic) happening right before the fetch can be offloaded to the common function.

v2: fewer temporary variables, more straightforward flow (M. Wajdeczko)
v3: DRM_ERROR instead of WARN (M. Wajdeczko)

Cc Anusha Srivatsa <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc_loader.c | 39 +++++++++++----------------------
 drivers/gpu/drm/i915/intel_huc.c        | 20 +++++------------
 drivers/gpu/drm/i915/intel_uc.c         |  5 +++--
 3 files changed, 22 insertions(+), 42 deletions(-)
drivers/gpu/drm/i915/intel_guc_loader.c +13 -26
index 549a254..336e97d 100644
@@ -433,12 +433,8 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 		intel_uc_fw_status_repr(guc_fw->load_status));
 
 	if (fw_path == NULL) {
-		/* Device is known to have no uCode (e.g. no GuC) */
+		/* We do not have uCode for the device */
 		return -ENXIO;
-	} else if (*fw_path == '\0') {
-		/* Device has a GuC but we don't know what f/w to load? */
-		WARN(1, "No GuC firmware known for this platform!\n");
-		return -ENODEV;
 	}
 
 	/* Fetch failed, or already fetched but failed to load? */
@@ -474,7 +470,6 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 	return 0;
 }
 
-
 /**
  * intel_guc_fetch_fw() - determine and fetch firmware
  * @guc:	intel_guc struct
@@ -487,39 +482,31 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 void intel_guc_fetch_fw(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
-	const char *fw_path;
 
-	if (!HAS_GUC_UCODE(dev_priv)) {
-		fw_path = NULL;
-	} else if (IS_SKYLAKE(dev_priv)) {
-		fw_path = I915_SKL_GUC_UCODE;
+	guc->fw.path = NULL;
+	guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.load_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.fw = INTEL_UC_FW_TYPE_GUC;
+
+	if (IS_SKYLAKE(dev_priv)) {
+		guc->fw.path = I915_SKL_GUC_UCODE;
 		guc->fw.major_ver_wanted = SKL_FW_MAJOR;
 		guc->fw.minor_ver_wanted = SKL_FW_MINOR;
 	} else if (IS_BROXTON(dev_priv)) {
-		fw_path = I915_BXT_GUC_UCODE;
+		guc->fw.path = I915_BXT_GUC_UCODE;
 		guc->fw.major_ver_wanted = BXT_FW_MAJOR;
 		guc->fw.minor_ver_wanted = BXT_FW_MINOR;
 	} else if (IS_KABYLAKE(dev_priv)) {
-		fw_path = I915_KBL_GUC_UCODE;
+		guc->fw.path = I915_KBL_GUC_UCODE;
 		guc->fw.major_ver_wanted = KBL_FW_MAJOR;
 		guc->fw.minor_ver_wanted = KBL_FW_MINOR;
 	} else {
-		fw_path = "";	/* unknown device */
+		DRM_ERROR("No GuC firmware known for platform with GuC!\n");
+		i915.enable_guc_loading = 0;
+		return;
 	}
 
-	guc->fw.path = fw_path;
-	guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
-	guc->fw.load_status = INTEL_UC_FIRMWARE_NONE;
-
-	if (fw_path == NULL)
-		return;
-	if (*fw_path == '\0')
-		return;
-
-	guc->fw.fetch_status = INTEL_UC_FIRMWARE_PENDING;
-	DRM_DEBUG_DRIVER("GuC firmware pending, path %s\n", fw_path);
 	guc->fw.fetch(dev_priv, &guc->fw);
-	/* status must now be FAIL or SUCCESS */
 }
 
 /**
drivers/gpu/drm/i915/intel_huc.c +6 -14
index 7527988..411595d 100644
@@ -155,37 +155,29 @@ static int huc_ucode_xfer(struct drm_i915_private *dev_priv)
 void intel_huc_fetch_fw(struct intel_huc *huc)
 {
 	struct drm_i915_private *dev_priv = huc_to_i915(huc);
-	const char *fw_path = NULL;
 
 	huc->fw.path = NULL;
 	huc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
 	huc->fw.load_status = INTEL_UC_FIRMWARE_NONE;
 	huc->fw.fw = INTEL_UC_FW_TYPE_HUC;
 
-	if (!HAS_HUC_UCODE(dev_priv))
-		return;
-
 	if (IS_SKYLAKE(dev_priv)) {
-		fw_path = I915_SKL_HUC_UCODE;
+		huc->fw.path = I915_SKL_HUC_UCODE;
 		huc->fw.major_ver_wanted = SKL_HUC_FW_MAJOR;
 		huc->fw.minor_ver_wanted = SKL_HUC_FW_MINOR;
 	} else if (IS_BROXTON(dev_priv)) {
-		fw_path = I915_BXT_HUC_UCODE;
+		huc->fw.path = I915_BXT_HUC_UCODE;
 		huc->fw.major_ver_wanted = BXT_HUC_FW_MAJOR;
 		huc->fw.minor_ver_wanted = BXT_HUC_FW_MINOR;
 	} else if (IS_KABYLAKE(dev_priv)) {
-		fw_path = I915_KBL_HUC_UCODE;
+		huc->fw.path = I915_KBL_HUC_UCODE;
 		huc->fw.major_ver_wanted = KBL_HUC_FW_MAJOR;
 		huc->fw.minor_ver_wanted = KBL_HUC_FW_MINOR;
+	} else {
+		DRM_ERROR("No HuC firmware known for platform with HuC!\n");
+		return;
 	}
 
-	huc->fw.path = fw_path;
-	huc->fw.fetch_status = INTEL_UC_FIRMWARE_PENDING;
-
-	DRM_DEBUG_DRIVER("HuC firmware pending, path %s\n", fw_path);
-
-	WARN(huc->fw.path == NULL, "HuC present but no fw path\n");
-
 	huc->fw.fetch(dev_priv, &huc->fw);
 }
 
drivers/gpu/drm/i915/intel_uc.c +3 -2
index 3de5fba..4073549 100644
@@ -269,8 +269,9 @@ static void uc_fetch_fw(struct drm_i915_private *dev_priv,
 	size_t size;
 	int err;
 
-	DRM_DEBUG_DRIVER("before requesting firmware: uC fw fetch status %s\n",
-		intel_uc_fw_status_repr(uc_fw->fetch_status));
+	uc_fw->fetch_status = INTEL_UC_FIRMWARE_PENDING;
+
+	DRM_DEBUG_DRIVER("uC firmware pending, path %s\n", uc_fw->path);
 
 	err = request_firmware(&fw, uc_fw->path, &pdev->dev);
 	if (err)
Signature · 6 lines
2.9.3

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

Re: [PATCH 8/8] drm/i915/uc: Simplify firmware path handling

Quoted 77 lines · Arkadiusz Hiler

Currently fw->path values can represent one of three possible states:

1) NULL - device without the uC
2) '\0' - device with the uC but have no firmware
3) else - device with the uC and we have firmware

Second case is used only to WARN at a later stage.

We can WARN right away and merge cases 1 and 2.

Code can be even further simplified and common (HuC/GuC logic) happening right before the fetch can be offloaded to the common function.

v2: fewer temporary variables, more straightforward flow (M. Wajdeczko)
v3: DRM_ERROR instead of WARN (M. Wajdeczko)

Cc Anusha Srivatsa <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc_loader.c | 39 +++++++++++----------------------
 drivers/gpu/drm/i915/intel_huc.c        | 20 +++++------------
 drivers/gpu/drm/i915/intel_uc.c         |  5 +++--
 3 files changed, 22 insertions(+), 42 deletions(-)
drivers/gpu/drm/i915/intel_guc_loader.c +9 -12
index 549a254..336e97d 100644
@@ -433,12 +433,8 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 		intel_uc_fw_status_repr(guc_fw->load_status));
 
 	if (fw_path == NULL) {
-		/* Device is known to have no uCode (e.g. no GuC) */
+		/* We do not have uCode for the device */
 		return -ENXIO;
-	} else if (*fw_path == '\0') {
-		/* Device has a GuC but we don't know what f/w to load? */
-		WARN(1, "No GuC firmware known for this platform!\n");
-		return -ENODEV;
 	}
 
 	/* Fetch failed, or already fetched but failed to load? */
@@ -474,7 +470,6 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 	return 0;
 }
 
-
 /**
  * intel_guc_fetch_fw() - determine and fetch firmware
  * @guc:	intel_guc struct
@@ -487,39 +482,31 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 void intel_guc_fetch_fw(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
-	const char *fw_path;
 
-	if (!HAS_GUC_UCODE(dev_priv)) {
-		fw_path = NULL;
-	} else if (IS_SKYLAKE(dev_priv)) {
-		fw_path = I915_SKL_GUC_UCODE;
+	guc->fw.path = NULL;
+	guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.load_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.fw = INTEL_UC_FW_TYPE_GUC;
+
+	if (IS_SKYLAKE(dev_priv)) {
+		guc->fw.path = I915_SKL_GUC_UCODE;
 		guc->fw.major_ver_wanted = SKL_FW_MAJOR;
 		guc->fw.minor_ver_wanted = SKL_FW_MINOR;
 	} else if (IS_BROXTON(dev_priv)) {
-		fw_path = I915_BXT_GUC_UCODE;
+		guc->fw.path = I915_BXT_GUC_UCODE;
 		guc->fw.major_ver_wanted = BXT_FW_MAJOR;
 		guc->fw.minor_ver_wanted = BXT_FW_MINOR;

drivers/gpu/drm/i915/intel_guc_loader.c int intel_guc_init_hw(struct drm_i915_private *dev_priv) · line 506

Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_loader.c +4 -2
 	} else if (IS_KABYLAKE(dev_priv)) {
-		fw_path = I915_KBL_GUC_UCODE;
+		guc->fw.path = I915_KBL_GUC_UCODE;
 		guc->fw.major_ver_wanted = KBL_FW_MAJOR;
 		guc->fw.minor_ver_wanted = KBL_FW_MINOR;
 	} else {
-		fw_path = "";	/* unknown device */
+		DRM_ERROR("No GuC firmware known for platform with GuC!\n");
+		i915.enable_guc_loading = 0;
+		return;

Now plan for having fw_path overriden by a i915_param.guc_firmware.

Perhaps something like

	if (i915_param.guc_firmware) {
		guc->fw.path = i915_param.guc_firmware; /* needs 0400! */
		guc->fw.major_ver_wanted = -1;
		guc->fw.minor_ver_wanted = -1;
	} else if (IS_SKYLAKE....

works?
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#18 lore raw

Re: [PATCH 8/8] drm/i915/uc: Simplify firmware path handling

Quoted 91 lines · Chris Wilson
Quoted 77 lines · Arkadiusz Hiler

Currently fw->path values can represent one of three possible states:

1) NULL - device without the uC
2) '\0' - device with the uC but have no firmware
3) else - device with the uC and we have firmware

Second case is used only to WARN at a later stage.

We can WARN right away and merge cases 1 and 2.

Code can be even further simplified and common (HuC/GuC logic) happening right before the fetch can be offloaded to the common function.

v2: fewer temporary variables, more straightforward flow (M. Wajdeczko)
v3: DRM_ERROR instead of WARN (M. Wajdeczko)

Cc Anusha Srivatsa <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc_loader.c | 39 +++++++++++----------------------
 drivers/gpu/drm/i915/intel_huc.c        | 20 +++++------------
 drivers/gpu/drm/i915/intel_uc.c         |  5 +++--
 3 files changed, 22 insertions(+), 42 deletions(-)
drivers/gpu/drm/i915/intel_guc_loader.c +9 -12
index 549a254..336e97d 100644
@@ -433,12 +433,8 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 		intel_uc_fw_status_repr(guc_fw->load_status));
 
 	if (fw_path == NULL) {
-		/* Device is known to have no uCode (e.g. no GuC) */
+		/* We do not have uCode for the device */
 		return -ENXIO;
-	} else if (*fw_path == '\0') {
-		/* Device has a GuC but we don't know what f/w to load? */
-		WARN(1, "No GuC firmware known for this platform!\n");
-		return -ENODEV;
 	}
 
 	/* Fetch failed, or already fetched but failed to load? */
@@ -474,7 +470,6 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 	return 0;
 }
 
-
 /**
  * intel_guc_fetch_fw() - determine and fetch firmware
  * @guc:	intel_guc struct
@@ -487,39 +482,31 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 void intel_guc_fetch_fw(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
-	const char *fw_path;
 
-	if (!HAS_GUC_UCODE(dev_priv)) {
-		fw_path = NULL;
-	} else if (IS_SKYLAKE(dev_priv)) {
-		fw_path = I915_SKL_GUC_UCODE;
+	guc->fw.path = NULL;
+	guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.load_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.fw = INTEL_UC_FW_TYPE_GUC;
+
+	if (IS_SKYLAKE(dev_priv)) {
+		guc->fw.path = I915_SKL_GUC_UCODE;
 		guc->fw.major_ver_wanted = SKL_FW_MAJOR;
 		guc->fw.minor_ver_wanted = SKL_FW_MINOR;
 	} else if (IS_BROXTON(dev_priv)) {
-		fw_path = I915_BXT_GUC_UCODE;
+		guc->fw.path = I915_BXT_GUC_UCODE;
 		guc->fw.major_ver_wanted = BXT_FW_MAJOR;
 		guc->fw.minor_ver_wanted = BXT_FW_MINOR;

drivers/gpu/drm/i915/intel_guc_loader.c int intel_guc_init_hw(struct drm_i915_private *dev_priv) · line 506

Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_loader.c +4 -2
 	} else if (IS_KABYLAKE(dev_priv)) {
-		fw_path = I915_KBL_GUC_UCODE;
+		guc->fw.path = I915_KBL_GUC_UCODE;
 		guc->fw.major_ver_wanted = KBL_FW_MAJOR;
 		guc->fw.minor_ver_wanted = KBL_FW_MINOR;
 	} else {
-		fw_path = "";	/* unknown device */
+		DRM_ERROR("No GuC firmware known for platform with GuC!\n");
+		i915.enable_guc_loading = 0;
+		return;

Now plan for having fw_path overriden by a i915_param.guc_firmware.

Quoted 7 lines

Perhaps something like

	if (i915_param.guc_firmware) {
		guc->fw.path = i915_param.guc_firmware; /* needs 0400! */
		guc->fw.major_ver_wanted = -1;
		guc->fw.minor_ver_wanted = -1;
	} else if (IS_SKYLAKE....

works?

Sorry, I do not quite understand the comment. Can you elaborate?

Signature · 6 lines
Cheers,
Arek
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#19 lore raw

Re: [PATCH 8/8] drm/i915/uc: Simplify firmware path handling

Quoted 100 lines · Arkadiusz Hiler
Quoted 91 lines · Chris Wilson
Quoted 77 lines · Arkadiusz Hiler

Currently fw->path values can represent one of three possible states:

1) NULL - device without the uC
2) '\0' - device with the uC but have no firmware
3) else - device with the uC and we have firmware

Second case is used only to WARN at a later stage.

We can WARN right away and merge cases 1 and 2.

Code can be even further simplified and common (HuC/GuC logic) happening right before the fetch can be offloaded to the common function.

v2: fewer temporary variables, more straightforward flow (M. Wajdeczko)
v3: DRM_ERROR instead of WARN (M. Wajdeczko)

Cc Anusha Srivatsa <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc_loader.c | 39 +++++++++++----------------------
 drivers/gpu/drm/i915/intel_huc.c        | 20 +++++------------
 drivers/gpu/drm/i915/intel_uc.c         |  5 +++--
 3 files changed, 22 insertions(+), 42 deletions(-)
drivers/gpu/drm/i915/intel_guc_loader.c +9 -12
index 549a254..336e97d 100644
@@ -433,12 +433,8 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 		intel_uc_fw_status_repr(guc_fw->load_status));
 
 	if (fw_path == NULL) {
-		/* Device is known to have no uCode (e.g. no GuC) */
+		/* We do not have uCode for the device */
 		return -ENXIO;
-	} else if (*fw_path == '\0') {
-		/* Device has a GuC but we don't know what f/w to load? */
-		WARN(1, "No GuC firmware known for this platform!\n");
-		return -ENODEV;
 	}
 
 	/* Fetch failed, or already fetched but failed to load? */
@@ -474,7 +470,6 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 	return 0;
 }
 
-
 /**
  * intel_guc_fetch_fw() - determine and fetch firmware
  * @guc:	intel_guc struct
@@ -487,39 +482,31 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
 void intel_guc_fetch_fw(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
-	const char *fw_path;
 
-	if (!HAS_GUC_UCODE(dev_priv)) {
-		fw_path = NULL;
-	} else if (IS_SKYLAKE(dev_priv)) {
-		fw_path = I915_SKL_GUC_UCODE;
+	guc->fw.path = NULL;
+	guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.load_status = INTEL_UC_FIRMWARE_NONE;
+	guc->fw.fw = INTEL_UC_FW_TYPE_GUC;
+
+	if (IS_SKYLAKE(dev_priv)) {
+		guc->fw.path = I915_SKL_GUC_UCODE;
 		guc->fw.major_ver_wanted = SKL_FW_MAJOR;
 		guc->fw.minor_ver_wanted = SKL_FW_MINOR;
 	} else if (IS_BROXTON(dev_priv)) {
-		fw_path = I915_BXT_GUC_UCODE;
+		guc->fw.path = I915_BXT_GUC_UCODE;
 		guc->fw.major_ver_wanted = BXT_FW_MAJOR;
 		guc->fw.minor_ver_wanted = BXT_FW_MINOR;

drivers/gpu/drm/i915/intel_guc_loader.c int intel_guc_init_hw(struct drm_i915_private *dev_priv) · line 506

Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_loader.c +4 -2
 	} else if (IS_KABYLAKE(dev_priv)) {
-		fw_path = I915_KBL_GUC_UCODE;
+		guc->fw.path = I915_KBL_GUC_UCODE;
 		guc->fw.major_ver_wanted = KBL_FW_MAJOR;
 		guc->fw.minor_ver_wanted = KBL_FW_MINOR;
 	} else {
-		fw_path = "";	/* unknown device */
+		DRM_ERROR("No GuC firmware known for platform with GuC!\n");
+		i915.enable_guc_loading = 0;
+		return;

Now plan for having fw_path overriden by a i915_param.guc_firmware.

Quoted 7 lines

Perhaps something like

	if (i915_param.guc_firmware) {
		guc->fw.path = i915_param.guc_firmware; /* needs 0400! */
		guc->fw.major_ver_wanted = -1;
		guc->fw.minor_ver_wanted = -1;
	} else if (IS_SKYLAKE....

works?

Quoted 1 line

Sorry, I do not quite understand the comment. Can you elaborate?

Nevermind, got it.

LGTM, but for it to fully work we need to make uc_fetch_fw (or however it will end up being named) aware that -1 have special meaning.

Now the version cross-check looks like that:

if (uc_fw->major_ver_found != uc_fw->major_ver_wanted ||

    uc_fw->minor_ver_found < uc_fw->minor_ver_wanted) {
Signature · 6 lines
Cheers,
Arek
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#20 lore raw

Re: [PATCH 8/8] drm/i915/uc: Simplify firmware path handling

Quoted 18 lines · Arkadiusz Hiler
Quoted 13 lines · Arkadiusz Hiler
Quoted 10 lines · Chris Wilson

Now plan for having fw_path overriden by a i915_param.guc_firmware.

Perhaps something like

	if (i915_param.guc_firmware) {
		guc->fw.path = i915_param.guc_firmware; /* needs 0400! */
		guc->fw.major_ver_wanted = -1;
		guc->fw.minor_ver_wanted = -1;
	} else if (IS_SKYLAKE....

works?

Quoted 1 line

Sorry, I do not quite understand the comment. Can you elaborate?

Nevermind, got it.

Quoted 7 lines

LGTM, but for it to fully work we need to make uc_fetch_fw (or however it will end up being named) aware that -1 have special meaning.

Now the version cross-check looks like that:

if (uc_fw->major_ver_found != uc_fw->major_ver_wanted || uc_fw->minor_ver_found < uc_fw->minor_ver_wanted) {

What Chris proposed, together with tweaking the check sounds good.

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v4 8/8
#21 lore raw

Re: [PATCH 8/8] drm/i915/uc: Simplify firmware path handling

In reply to Arkadiusz Hiler
Quoted 21 lines · Arkadiusz Hiler

Currently fw->path values can represent one of three possible states:

 1) NULL - device without the uC
 2) '\0' - device with the uC but have no firmware
 3) else - device with the uC and we have firmware

Second case is used only to WARN at a later stage.

We can WARN right away and merge cases 1 and 2.

Code can be even further simplified and common (HuC/GuC logic) happening right before the fetch can be offloaded to the common function.

v2: fewer temporary variables, more straightforward flow (M. Wajdeczko)
v3: DRM_ERROR instead of WARN (M. Wajdeczko)

Cc Anusha Srivatsa <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Michal Winiarski <[email protected]>
Cc Michal Wajdeczko <[email protected]>

<SNIP>

Quoted 3 lines
drivers/gpu/drm/i915/intel_guc_loader.c +0 -0
@@ -433,12 +433,8 @@ int intel_guc_init_hw(struct drm_i915_private *dev_priv)
  		intel_uc_fw_status_repr(guc_fw->load_status));

if (!guc_fw->path)

	return -ENXIO;
Quoted 9 lines

  if (fw_path == NULL) {

drivers/gpu/drm/i915/intel_guc_loader.c +1 -1
-		/* Device is known to have no uCode (e.g. no GuC) */
+		/* We do not have uCode for the device */

  return -ENXIO;

drivers/gpu/drm/i915/intel_guc_loader.c +0 -4
-	} else if (*fw_path == '\0') {
-		/* Device has a GuC but we don't know what f/w to load? */
-		WARN(1, "No GuC firmware known for this platform!\n");
-		return -ENODEV;

  }

<SNIP>

Quoted 4 lines
drivers/gpu/drm/i915/intel_guc_loader.c +0 -3
-
-	guc->fw.fetch_status = INTEL_UC_FIRMWARE_PENDING;
-	DRM_DEBUG_DRIVER("GuC firmware pending, path %s\n", fw_path);

  guc->fw.fetch(dev_priv, &guc->fw);

This was function pointer was discussed in other thread.

With above addressed;

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#22 lore raw

✓ Fi.CI.BAT: success for GuC Scrub vol. 1 (rev4)

In reply to Arkadiusz Hiler
== Series Details ==

== Series Details ==

Series: GuC Scrub vol. 1 (rev4)
URL : https://patchwork.freedesktop.org/series/16856/
State : success

== Summary ==

Series 16856v4 GuC Scrub vol. 1
https://patchwork.freedesktop.org/api/1.0/series/16856/revisions/4/mbox/

fi-bdw-5557u     total:253  pass:242  dwarn:0   dfail:0   fail:0   skip:11 
fi-bsw-n3050     total:253  pass:214  dwarn:0   dfail:0   fail:0   skip:39 
fi-bxt-j4205     total:253  pass:234  dwarn:0   dfail:0   fail:0   skip:19 
fi-bxt-t5700     total:83   pass:70   dwarn:0   dfail:0   fail:0   skip:12 
fi-byt-j1900     total:253  pass:226  dwarn:0   dfail:0   fail:0   skip:27 
fi-byt-n2820     total:253  pass:222  dwarn:0   dfail:0   fail:0   skip:31 
fi-hsw-4770      total:253  pass:237  dwarn:0   dfail:0   fail:0   skip:16 
fi-hsw-4770r     total:253  pass:237  dwarn:0   dfail:0   fail:0   skip:16 
fi-ilk-650       total:253  pass:203  dwarn:0   dfail:0   fail:0   skip:50 
fi-ivb-3520m     total:253  pass:235  dwarn:0   dfail:0   fail:0   skip:18 
fi-ivb-3770      total:253  pass:235  dwarn:0   dfail:0   fail:0   skip:18 
fi-kbl-7500u     total:253  pass:235  dwarn:0   dfail:0   fail:0   skip:18 
fi-skl-6260u     total:253  pass:243  dwarn:0   dfail:0   fail:0   skip:10 
fi-skl-6700hq    total:253  pass:236  dwarn:0   dfail:0   fail:0   skip:17 
fi-skl-6700k     total:253  pass:231  dwarn:4   dfail:0   fail:0   skip:18 
fi-skl-6770hq    total:253  pass:243  dwarn:0   dfail:0   fail:0   skip:10 
fi-snb-2520m     total:253  pass:225  dwarn:0   dfail:0   fail:0   skip:28 
fi-snb-2600      total:253  pass:224  dwarn:0   dfail:0   fail:0   skip:29 

bf89ec45d0822835b03910371ac0baf46c4efa2d drm-tip: 2017y-02m-22d-14h-30m-04s UTC integration manifest de86964 drm/i915/uc: Simplify firmware path handling
3bd35f1 drm/i915/guc: Simplify intel_guc_init_hw()
9d55149 drm/i915/guc: Extract param logic form guc_init
e5b5068 drm/i915/uc: Make intel_uc_fw_fetch() static
f32b9e4 drm/i915/uc: Rename intel_?uc_init() to intel_?uc_fetch_fw()
d2ca92a drm/i915/huc: Add huc_to_i915
20c4531 drm/i915/uc: Drop superfluous externs in intel_uc.h
437508e drm/i915/uc: Rename intel_?uc_{setup, load}() to _init_hw()

== Logs ==

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