Skip to content

Commit 03380d1

Browse files
mwiniarsickle
authored andcommitted
drm/i915/guc: Don't try to enable GuC logging when we're not using GuC
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: 9605d1c ("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
1 parent d3d5792 commit 03380d1

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

drivers/gpu/drm/i915/intel_guc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ static u32 get_log_control_flags(void)
229229

230230
GEM_BUG_ON(level < 0);
231231

232-
if (!GUC_LOG_LEVEL_TO_ENABLED(level))
232+
if (!GUC_LOG_LEVEL_IS_ENABLED(level))
233233
flags |= GUC_LOG_DEFAULT_DISABLED;
234234

235-
if (!GUC_LOG_LEVEL_TO_VERBOSE(level))
235+
if (!GUC_LOG_LEVEL_IS_VERBOSE(level))
236236
flags |= GUC_LOG_DISABLED;
237237
else
238238
flags |= GUC_LOG_LEVEL_TO_VERBOSITY(level) <<

drivers/gpu/drm/i915/intel_guc_log.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,7 @@ int intel_guc_log_level_set(struct intel_guc_log *log, u64 val)
515515
* GuC is recognizing log levels starting from 0 to max, we're using 0
516516
* as indication that logging should be disabled.
517517
*/
518-
if (val < GUC_LOG_LEVEL_DISABLED ||
519-
val > GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX))
518+
if (val < GUC_LOG_LEVEL_DISABLED || val > GUC_LOG_LEVEL_MAX)
520519
return -EINVAL;
521520

522521
mutex_lock(&dev_priv->drm.struct_mutex);
@@ -527,8 +526,8 @@ int intel_guc_log_level_set(struct intel_guc_log *log, u64 val)
527526
}
528527

529528
intel_runtime_pm_get(dev_priv);
530-
ret = guc_log_control(guc, GUC_LOG_LEVEL_TO_VERBOSE(val),
531-
GUC_LOG_LEVEL_TO_ENABLED(val),
529+
ret = guc_log_control(guc, GUC_LOG_LEVEL_IS_VERBOSE(val),
530+
GUC_LOG_LEVEL_IS_ENABLED(val),
532531
GUC_LOG_LEVEL_TO_VERBOSITY(val));
533532
intel_runtime_pm_put(dev_priv);
534533
if (ret) {

drivers/gpu/drm/i915/intel_guc_log.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ struct intel_guc;
4646
* log enabling, and separate bit for default logging - which "conveniently"
4747
* ignores the enable bit.
4848
*/
49-
#define GUC_LOG_LEVEL_DISABLED 0
50-
#define GUC_LOG_LEVEL_TO_ENABLED(x) ((x) > 0)
51-
#define GUC_LOG_LEVEL_TO_VERBOSE(x) ((x) > 1)
49+
#define GUC_LOG_LEVEL_DISABLED 0
50+
#define GUC_LOG_LEVEL_NON_VERBOSE 1
51+
#define GUC_LOG_LEVEL_IS_ENABLED(x) ((x) > GUC_LOG_LEVEL_DISABLED)
52+
#define GUC_LOG_LEVEL_IS_VERBOSE(x) ((x) > GUC_LOG_LEVEL_NON_VERBOSE)
5253
#define GUC_LOG_LEVEL_TO_VERBOSITY(x) ({ \
5354
typeof(x) _x = (x); \
54-
GUC_LOG_LEVEL_TO_VERBOSE(_x) ? _x - 2 : 0; \
55+
GUC_LOG_LEVEL_IS_VERBOSE(_x) ? _x - 2 : 0; \
5556
})
56-
#define GUC_VERBOSITY_TO_LOG_LEVEL(x) ((x) + 2)
57+
#define GUC_VERBOSITY_TO_LOG_LEVEL(x) ((x) + 2)
58+
#define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX)
5759

5860
struct intel_guc_log {
5961
u32 flags;

drivers/gpu/drm/i915/intel_uc.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,15 @@ static int __get_platform_enable_guc(struct drm_i915_private *dev_priv)
6969

7070
static int __get_default_guc_log_level(struct drm_i915_private *dev_priv)
7171
{
72-
int guc_log_level = 1; /* non-verbose */
72+
int guc_log_level;
7373

74-
/* Enable if we're running on platform with GuC and debug config */
75-
if (HAS_GUC(dev_priv) && intel_uc_is_using_guc() &&
76-
(IS_ENABLED(CONFIG_DRM_I915_DEBUG) ||
77-
IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)))
78-
guc_log_level =
79-
GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX);
74+
if (!HAS_GUC(dev_priv) || !intel_uc_is_using_guc())
75+
guc_log_level = GUC_LOG_LEVEL_DISABLED;
76+
else if (IS_ENABLED(CONFIG_DRM_I915_DEBUG) ||
77+
IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))
78+
guc_log_level = GUC_LOG_LEVEL_MAX;
79+
else
80+
guc_log_level = GUC_LOG_LEVEL_NON_VERBOSE;
8081

8182
/* Any platform specific fine-tuning can be done here */
8283

@@ -143,19 +144,17 @@ static void sanitize_options_early(struct drm_i915_private *dev_priv)
143144
i915_modparams.guc_log_level = 0;
144145
}
145146

146-
if (i915_modparams.guc_log_level >
147-
GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX)) {
147+
if (i915_modparams.guc_log_level > GUC_LOG_LEVEL_MAX) {
148148
DRM_WARN("Incompatible option detected: %s=%d, %s!\n",
149149
"guc_log_level", i915_modparams.guc_log_level,
150150
"verbosity too high");
151-
i915_modparams.guc_log_level =
152-
GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX);
151+
i915_modparams.guc_log_level = GUC_LOG_LEVEL_MAX;
153152
}
154153

155154
DRM_DEBUG_DRIVER("guc_log_level=%d (enabled:%s, verbose:%s, verbosity:%d)\n",
156155
i915_modparams.guc_log_level,
157156
yesno(i915_modparams.guc_log_level),
158-
yesno(GUC_LOG_LEVEL_TO_VERBOSE(i915_modparams.guc_log_level)),
157+
yesno(GUC_LOG_LEVEL_IS_VERBOSE(i915_modparams.guc_log_level)),
159158
GUC_LOG_LEVEL_TO_VERBOSITY(i915_modparams.guc_log_level));
160159

161160
/* Make sure that sanitization was done */

0 commit comments

Comments
 (0)