drm/i915/uc: Fetch uC firmware in init_early
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 23 Mar 2018 12:34:50 +0000 (12:34 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 23 Mar 2018 17:03:24 +0000 (17:03 +0000)
We were fetching uC firmwares in separate uc_init_fw step, while
there is no reason why we can't fetch them during init_early.
This will also simplify upcoming patches, as size of the firmware
may be used for register initialization.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20180323123451.59244-2-michal.wajdeczko@intel.com
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/intel_guc_fw.c
drivers/gpu/drm/i915/intel_huc_fw.c
drivers/gpu/drm/i915/intel_uc.c
drivers/gpu/drm/i915/intel_uc.h

index 2561974af79c0f41536bb50658d57ec2f58dfd2e..db223378d84b0456ba910041490fec96c82c4098 100644 (file)
@@ -692,11 +692,9 @@ static int i915_load_modeset_init(struct drm_device *dev)
        if (ret)
                goto cleanup_irq;
 
-       intel_uc_init_fw(dev_priv);
-
        ret = i915_gem_init(dev_priv);
        if (ret)
-               goto cleanup_uc;
+               goto cleanup_irq;
 
        intel_setup_overlay(dev_priv);
 
@@ -716,8 +714,6 @@ cleanup_gem:
        if (i915_gem_suspend(dev_priv))
                DRM_ERROR("failed to idle hardware; continuing to unload!\n");
        i915_gem_fini(dev_priv);
-cleanup_uc:
-       intel_uc_fini_fw(dev_priv);
 cleanup_irq:
        drm_irq_uninstall(dev);
        intel_teardown_gmbus(dev_priv);
@@ -962,6 +958,7 @@ err_engines:
 static void i915_driver_cleanup_early(struct drm_i915_private *dev_priv)
 {
        intel_irq_fini(dev_priv);
+       intel_uc_cleanup_early(dev_priv);
        i915_gem_cleanup_early(dev_priv);
        i915_workqueues_cleanup(dev_priv);
        i915_engines_cleanup(dev_priv);
@@ -1457,7 +1454,6 @@ void i915_driver_unload(struct drm_device *dev)
        i915_reset_error_state(dev_priv);
 
        i915_gem_fini(dev_priv);
-       intel_uc_fini_fw(dev_priv);
        intel_fbc_cleanup_cfb(dev_priv);
 
        intel_power_domains_fini(dev_priv);
index 978668cf82cca5841d9988f97d332aa367169bcc..a9e6fcce467c62a7e9b0e3035a181bbe46cd007f 100644 (file)
@@ -275,9 +275,8 @@ static int guc_fw_xfer(struct intel_uc_fw *guc_fw, struct i915_vma *vma)
  * Called from intel_uc_init_hw() during driver load, resume from sleep and
  * after a GPU reset.
  *
- * The firmware image should have already been fetched into memory by the
- * earlier call to intel_uc_init_fw(), so here we need to only check that
- * fetch succeeded, and then transfer the image to the h/w.
+ * The firmware image should have already been fetched into memory, so only
+ * check that fetch succeeded, and then transfer the image to the h/w.
  *
  * Return:     non-zero code on error
  */
index bb0f8b7a8d2b6d46285dd75d9a27e697663d52a9..f93d2384d4820ee23245f5d3eeb64fe39fd7aebe 100644 (file)
@@ -155,9 +155,8 @@ static int huc_fw_xfer(struct intel_uc_fw *huc_fw, struct i915_vma *vma)
  * Called from intel_uc_init_hw() during driver load, resume from sleep and
  * after a GPU reset. Note that HuC must be loaded before GuC.
  *
- * The firmware image should have already been fetched into memory by the
- * earlier call to intel_uc_init_fw(), so here we need to only check that
- * fetch succeeded, and then transfer the image to the h/w.
+ * The firmware image should have already been fetched into memory, so only
+ * check that fetch succeeded, and then transfer the image to the h/w.
  *
  * Return:     non-zero code on error
  */
index 34f8a2c219d862a5d3eeb964135d0f8e8bbda899..4aad8442e7898bcf37dbbbad112d9f119492fc79 100644 (file)
@@ -162,36 +162,35 @@ static void sanitize_options_early(struct drm_i915_private *dev_priv)
        GEM_BUG_ON(i915_modparams.guc_log_level < 0);
 }
 
-void intel_uc_init_early(struct drm_i915_private *dev_priv)
+void intel_uc_init_early(struct drm_i915_private *i915)
 {
-       intel_guc_init_early(&dev_priv->guc);
-       intel_huc_init_early(&dev_priv->huc);
+       struct intel_guc *guc = &i915->guc;
+       struct intel_huc *huc = &i915->huc;
 
-       sanitize_options_early(dev_priv);
-}
+       intel_guc_init_early(guc);
+       intel_huc_init_early(huc);
 
-void intel_uc_init_fw(struct drm_i915_private *dev_priv)
-{
-       if (!USES_GUC(dev_priv))
-               return;
+       sanitize_options_early(i915);
 
-       if (USES_HUC(dev_priv))
-               intel_uc_fw_fetch(dev_priv, &dev_priv->huc.fw);
+       if (USES_GUC(i915))
+               intel_uc_fw_fetch(i915, &guc->fw);
 
-       intel_uc_fw_fetch(dev_priv, &dev_priv->guc.fw);
+       if (USES_HUC(i915))
+               intel_uc_fw_fetch(i915, &huc->fw);
 }
 
-void intel_uc_fini_fw(struct drm_i915_private *dev_priv)
+void intel_uc_cleanup_early(struct drm_i915_private *i915)
 {
-       if (!USES_GUC(dev_priv))
-               return;
+       struct intel_guc *guc = &i915->guc;
+       struct intel_huc *huc = &i915->huc;
 
-       intel_uc_fw_fini(&dev_priv->guc.fw);
+       if (USES_HUC(i915))
+               intel_uc_fw_fini(&huc->fw);
 
-       if (USES_HUC(dev_priv))
-               intel_uc_fw_fini(&dev_priv->huc.fw);
+       if (USES_GUC(i915))
+               intel_uc_fw_fini(&guc->fw);
 
-       guc_free_load_err_log(&dev_priv->guc);
+       guc_free_load_err_log(guc);
 }
 
 /**
index 937e6117525884bc229015503371578e6a123713..25d73ada74ae455fed80d2699b69fcb4978adae6 100644 (file)
@@ -29,9 +29,8 @@
 #include "i915_params.h"
 
 void intel_uc_init_early(struct drm_i915_private *dev_priv);
+void intel_uc_cleanup_early(struct drm_i915_private *dev_priv);
 void intel_uc_init_mmio(struct drm_i915_private *dev_priv);
-void intel_uc_init_fw(struct drm_i915_private *dev_priv);
-void intel_uc_fini_fw(struct drm_i915_private *dev_priv);
 int intel_uc_init_misc(struct drm_i915_private *dev_priv);
 void intel_uc_fini_misc(struct drm_i915_private *dev_priv);
 void intel_uc_sanitize(struct drm_i915_private *dev_priv);