drm/i915/guc: Extract param logic form guc_init_fw()
authorArkadiusz Hiler <arkadiusz.hiler@intel.com>
Tue, 14 Mar 2017 14:28:10 +0000 (15:28 +0100)
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Wed, 15 Mar 2017 12:26:30 +0000 (14:26 +0200)
Let intel_guc_init_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_init_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)
v4: update title to reflect new function name + rebase
v5: text && remove 2 uneccessary checks (M. Wajdeczko)

Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/intel_guc_loader.c
drivers/gpu/drm/i915/intel_huc.c
drivers/gpu/drm/i915/intel_uc.c
drivers/gpu/drm/i915/intel_uc.h

index 8a456ec520199d8ae0b71e2895e94f1bbf41d1c4..9164167cd14721b0bab4f2d78ca83aee79b50e5e 100644 (file)
@@ -988,6 +988,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);
 }
 
 /**
index 3a37d14587a32437824d74223e3d4cae70c55c29..e732266fd610c5425de96a82fa93c5ce8483b337 100644 (file)
@@ -534,20 +534,7 @@ void intel_guc_init_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)) {
+       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;
@@ -567,9 +554,6 @@ void intel_guc_init_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')
index fda473db317e4d33c5659da563b11e9708891fed..168aab1e15da8f824fb9788f237ab1e38436bdb5 100644 (file)
@@ -162,9 +162,6 @@ void intel_huc_init_fw(struct intel_huc *huc)
        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;
index e5155deee69e242564c5903b3a9a72e6b450ac42..f0a69d4388bb21db8c8ec4e0b574d92436cf5bec 100644 (file)
 #include "intel_uc.h"
 #include <linux/firmware.h>
 
+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);
@@ -33,7 +54,12 @@ void intel_uc_init_early(struct drm_i915_private *dev_priv)
 
 void intel_uc_init_fw(struct drm_i915_private *dev_priv)
 {
-       intel_huc_init_fw(&dev_priv->huc);
+       if (!i915.enable_guc_loading)
+               return;
+
+       if (HAS_HUC_UCODE(dev_priv))
+               intel_huc_init_fw(&dev_priv->huc);
+
        intel_guc_init_fw(&dev_priv->guc);
 }
 
index 26d5c6aab9c1dd316d5569c721856c688db0cc31..c5179efe2db90c6abfa1da3546a3d4263eba3658 100644 (file)
@@ -184,6 +184,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_init_fw(struct drm_i915_private *dev_priv);
 void intel_uc_prepare_fw(struct drm_i915_private *dev_priv,