drm/i915/guc: Don't try to enable GuC logging when we're not using GuC
authorMichał Winiarski <michal.winiarski@intel.com>
Tue, 20 Mar 2018 11:55:17 +0000 (12:55 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 20 Mar 2018 14:55:58 +0000 (14:55 +0000)
When changing the default values for guc_log_level, we accidentally left
the log enabled on non-guc platforms. Let's fix that.

v2: Define the levels used and remove (now obsolete) comments (Chris)
v3: Use "IS" rather than "TO" for booleans (Chris)

Fixes: 9605d1ce7c6b ("drm/i915/guc: Default to non-verbose GuC logging")
Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@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/20180320115517.20423-1-michal.winiarski@intel.com
drivers/gpu/drm/i915/intel_guc.c
drivers/gpu/drm/i915/intel_guc_log.c
drivers/gpu/drm/i915/intel_guc_log.h
drivers/gpu/drm/i915/intel_uc.c

index ee5230cc722e1f2ef93ff8a5a138c124a0438706..4b7c9c6415ddfab55e689c2b322cbf318955cef5 100644 (file)
@@ -229,10 +229,10 @@ static u32 get_log_control_flags(void)
 
        GEM_BUG_ON(level < 0);
 
-       if (!GUC_LOG_LEVEL_TO_ENABLED(level))
+       if (!GUC_LOG_LEVEL_IS_ENABLED(level))
                flags |= GUC_LOG_DEFAULT_DISABLED;
 
-       if (!GUC_LOG_LEVEL_TO_VERBOSE(level))
+       if (!GUC_LOG_LEVEL_IS_VERBOSE(level))
                flags |= GUC_LOG_DISABLED;
        else
                flags |= GUC_LOG_LEVEL_TO_VERBOSITY(level) <<
index 4cb422ceb2837464b41fb3ba928e8cbf425bd6bf..ae9b2569adab2a6fc7b7f8a358fe04707065ff2b 100644 (file)
@@ -515,8 +515,7 @@ int intel_guc_log_level_set(struct intel_guc_log *log, u64 val)
         * GuC is recognizing log levels starting from 0 to max, we're using 0
         * as indication that logging should be disabled.
         */
-       if (val < GUC_LOG_LEVEL_DISABLED ||
-           val > GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX))
+       if (val < GUC_LOG_LEVEL_DISABLED || val > GUC_LOG_LEVEL_MAX)
                return -EINVAL;
 
        mutex_lock(&dev_priv->drm.struct_mutex);
@@ -527,8 +526,8 @@ int intel_guc_log_level_set(struct intel_guc_log *log, u64 val)
        }
 
        intel_runtime_pm_get(dev_priv);
-       ret = guc_log_control(guc, GUC_LOG_LEVEL_TO_VERBOSE(val),
-                             GUC_LOG_LEVEL_TO_ENABLED(val),
+       ret = guc_log_control(guc, GUC_LOG_LEVEL_IS_VERBOSE(val),
+                             GUC_LOG_LEVEL_IS_ENABLED(val),
                              GUC_LOG_LEVEL_TO_VERBOSITY(val));
        intel_runtime_pm_put(dev_priv);
        if (ret) {
index af1532c0d3e4070351bbf33efb7060312b40ca10..1b0d2fa4c0b6aadcb2d03903b7f20366e1fd1370 100644 (file)
@@ -46,14 +46,16 @@ struct intel_guc;
  * log enabling, and separate bit for default logging - which "conveniently"
  * ignores the enable bit.
  */
-#define GUC_LOG_LEVEL_DISABLED                 0
-#define GUC_LOG_LEVEL_TO_ENABLED(x)            ((x) > 0)
-#define GUC_LOG_LEVEL_TO_VERBOSE(x)            ((x) > 1)
+#define GUC_LOG_LEVEL_DISABLED         0
+#define GUC_LOG_LEVEL_NON_VERBOSE      1
+#define GUC_LOG_LEVEL_IS_ENABLED(x)    ((x) > GUC_LOG_LEVEL_DISABLED)
+#define GUC_LOG_LEVEL_IS_VERBOSE(x)    ((x) > GUC_LOG_LEVEL_NON_VERBOSE)
 #define GUC_LOG_LEVEL_TO_VERBOSITY(x) ({               \
        typeof(x) _x = (x);                             \
-       GUC_LOG_LEVEL_TO_VERBOSE(_x) ? _x - 2 : 0;      \
+       GUC_LOG_LEVEL_IS_VERBOSE(_x) ? _x - 2 : 0;      \
 })
-#define GUC_VERBOSITY_TO_LOG_LEVEL(x)          ((x) + 2)
+#define GUC_VERBOSITY_TO_LOG_LEVEL(x)  ((x) + 2)
+#define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX)
 
 struct intel_guc_log {
        u32 flags;
index 34e847d0ee4c5a6ac5adeea7d9fd1ba4cb27de0f..2befcafbaabeb7c18b6409cb40a2e233129fc10c 100644 (file)
@@ -69,14 +69,15 @@ static int __get_platform_enable_guc(struct drm_i915_private *dev_priv)
 
 static int __get_default_guc_log_level(struct drm_i915_private *dev_priv)
 {
-       int guc_log_level = 1; /* non-verbose */
+       int guc_log_level;
 
-       /* Enable if we're running on platform with GuC and debug config */
-       if (HAS_GUC(dev_priv) && intel_uc_is_using_guc() &&
-           (IS_ENABLED(CONFIG_DRM_I915_DEBUG) ||
-            IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)))
-               guc_log_level =
-                       GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX);
+       if (!HAS_GUC(dev_priv) || !intel_uc_is_using_guc())
+               guc_log_level = GUC_LOG_LEVEL_DISABLED;
+       else if (IS_ENABLED(CONFIG_DRM_I915_DEBUG) ||
+                IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))
+               guc_log_level = GUC_LOG_LEVEL_MAX;
+       else
+               guc_log_level = GUC_LOG_LEVEL_NON_VERBOSE;
 
        /* Any platform specific fine-tuning can be done here */
 
@@ -143,19 +144,17 @@ static void sanitize_options_early(struct drm_i915_private *dev_priv)
                i915_modparams.guc_log_level = 0;
        }
 
-       if (i915_modparams.guc_log_level >
-           GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX)) {
+       if (i915_modparams.guc_log_level > GUC_LOG_LEVEL_MAX) {
                DRM_WARN("Incompatible option detected: %s=%d, %s!\n",
                         "guc_log_level", i915_modparams.guc_log_level,
                         "verbosity too high");
-               i915_modparams.guc_log_level =
-                       GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX);
+               i915_modparams.guc_log_level = GUC_LOG_LEVEL_MAX;
        }
 
        DRM_DEBUG_DRIVER("guc_log_level=%d (enabled:%s, verbose:%s, verbosity:%d)\n",
                         i915_modparams.guc_log_level,
                         yesno(i915_modparams.guc_log_level),
-                        yesno(GUC_LOG_LEVEL_TO_VERBOSE(i915_modparams.guc_log_level)),
+                        yesno(GUC_LOG_LEVEL_IS_VERBOSE(i915_modparams.guc_log_level)),
                         GUC_LOG_LEVEL_TO_VERBOSITY(i915_modparams.guc_log_level));
 
        /* Make sure that sanitization was done */