Message ID | 20180530135334.25113-1-piotr.piorkowski@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi, On Wed, 30 May 2018 15:53:28 +0200, Piotr Piorkowski <piotr.piorkowski@intel.com> wrote: > From: Piotr Piórkowski <piotr.piorkowski@intel.com> > > Currently we are using modparam as placeholder for GuC log level. > Stop doing this and keep runtime GuC level in intel_guc_log struct. > > Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com> > Cc: Michal Wajdeczko <michal.wajdeczko@intel.com> > Cc: Michał Winiarski <michal.winiarski@intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > Cc: Chris Wilson <chris@chris-wilson.co.uk> > --- > drivers/gpu/drm/i915/intel_guc.c | 8 +++----- > drivers/gpu/drm/i915/intel_guc_log.c | 18 +++++------------- > drivers/gpu/drm/i915/intel_guc_log.h | 9 ++++++++- > drivers/gpu/drm/i915/intel_uc.c | 2 +- > 4 files changed, 17 insertions(+), 20 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_guc.c > b/drivers/gpu/drm/i915/intel_guc.c > index 116f4ccf1bbd..9025837850ad 100644 > --- a/drivers/gpu/drm/i915/intel_guc.c > +++ b/drivers/gpu/drm/i915/intel_guc.c > @@ -203,13 +203,11 @@ void intel_guc_fini(struct intel_guc *guc) > guc_shared_data_destroy(guc); > } > -static u32 get_log_control_flags(void) > +static u32 guc_ctl_debug_flags(struct intel_guc *guc) > { > - u32 level = i915_modparams.guc_log_level; > + u32 level = intel_guc_log_level_get(&guc->log); > u32 flags = 0; > - GEM_BUG_ON(level < 0); > - > if (!GUC_LOG_LEVEL_IS_ENABLED(level)) > flags |= GUC_LOG_DEFAULT_DISABLED; > @@ -250,7 +248,7 @@ void intel_guc_init_params(struct intel_guc *guc) > params[GUC_CTL_LOG_PARAMS] = guc->log.flags; > - params[GUC_CTL_DEBUG] = get_log_control_flags(); > + params[GUC_CTL_DEBUG] = guc_ctl_debug_flags(guc); > /* If GuC submission is enabled, set up additional parameters here */ > if (USES_GUC_SUBMISSION(dev_priv)) { > diff --git a/drivers/gpu/drm/i915/intel_guc_log.c > b/drivers/gpu/drm/i915/intel_guc_log.c > index 401e1704d61e..c036d0fac370 100644 > --- a/drivers/gpu/drm/i915/intel_guc_log.c > +++ b/drivers/gpu/drm/i915/intel_guc_log.c > @@ -475,11 +475,12 @@ int intel_guc_log_create(struct intel_guc_log *log) > offset = intel_guc_ggtt_offset(guc, vma) >> PAGE_SHIFT; > log->flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags; > + log->level = i915_modparams.guc_log_level; > + > return 0; > err: > - /* logging will be off */ > - i915_modparams.guc_log_level = 0; > + DRM_ERROR("Failed to allocate GuC log buffer. %d\n", ret); > return ret; > } > @@ -488,14 +489,6 @@ void intel_guc_log_destroy(struct intel_guc_log > *log) > i915_vma_unpin_and_release(&log->vma); > } > -int intel_guc_log_level_get(struct intel_guc_log *log) > -{ > - GEM_BUG_ON(!log->vma); > - GEM_BUG_ON(i915_modparams.guc_log_level < 0); > - > - return i915_modparams.guc_log_level; > -} > - > int intel_guc_log_level_set(struct intel_guc_log *log, u64 val) > { > struct intel_guc *guc = log_to_guc(log); > @@ -504,7 +497,6 @@ int intel_guc_log_level_set(struct intel_guc_log > *log, u64 val) > BUILD_BUG_ON(GUC_LOG_VERBOSITY_MIN != 0); > GEM_BUG_ON(!log->vma); > - GEM_BUG_ON(i915_modparams.guc_log_level < 0); > /* > * GuC is recognizing log levels starting from 0 to max, we're using 0 > @@ -515,7 +507,7 @@ int intel_guc_log_level_set(struct intel_guc_log > *log, u64 val) > mutex_lock(&dev_priv->drm.struct_mutex); > - if (i915_modparams.guc_log_level == val) { > + if (log->level == val) { > ret = 0; > goto out_unlock; > } > @@ -530,7 +522,7 @@ int intel_guc_log_level_set(struct intel_guc_log > *log, u64 val) > goto out_unlock; > } > - i915_modparams.guc_log_level = val; > + log->level = val; > out_unlock: > mutex_unlock(&dev_priv->drm.struct_mutex); > diff --git a/drivers/gpu/drm/i915/intel_guc_log.h > b/drivers/gpu/drm/i915/intel_guc_log.h > index fa80535a6f9d..ea375c3b5d08 100644 > --- a/drivers/gpu/drm/i915/intel_guc_log.h > +++ b/drivers/gpu/drm/i915/intel_guc_log.h > @@ -30,6 +30,7 @@ > #include <linux/workqueue.h> > #include "intel_guc_fwif.h" > +#include "i915_gem.h" > struct intel_guc; > @@ -58,6 +59,7 @@ struct intel_guc; > #define GUC_LOG_LEVEL_MAX > GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX) > struct intel_guc_log { > + u32 level; > u32 flags; > struct i915_vma *vma; > struct { > @@ -80,7 +82,6 @@ void intel_guc_log_init_early(struct intel_guc_log > *log); > int intel_guc_log_create(struct intel_guc_log *log); > void intel_guc_log_destroy(struct intel_guc_log *log); > -int intel_guc_log_level_get(struct intel_guc_log *log); > int intel_guc_log_level_set(struct intel_guc_log *log, u64 control_val); > bool intel_guc_log_relay_enabled(const struct intel_guc_log *log); > int intel_guc_log_relay_open(struct intel_guc_log *log); > @@ -89,4 +90,10 @@ void intel_guc_log_relay_close(struct intel_guc_log > *log); > void intel_guc_log_handle_flush_event(struct intel_guc_log *log); > +static inline u32 intel_guc_log_level_get(struct intel_guc_log *log) hmm, it's little unfortunate that earlier this function was not named as: intel_guc_log_get_level(struct intel_guc_log *log) with matching: intel_guc_log_set_level(struct intel_guc_log *log, u32 level) but maybe we can fix it now or in near future? > +{ > + GEM_BUG_ON(!log->vma); hmm, maybe we can drop this BUG_ON as we will have level=0(disabled) when there is no vma - and this level value is expected/correct. > + return log->level; > +} > + > #endif > diff --git a/drivers/gpu/drm/i915/intel_uc.c > b/drivers/gpu/drm/i915/intel_uc.c > index 6a73e81f373b..5ce8d5df1b58 100644 > --- a/drivers/gpu/drm/i915/intel_uc.c > +++ b/drivers/gpu/drm/i915/intel_uc.c > @@ -207,7 +207,7 @@ void intel_uc_init_mmio(struct drm_i915_private > *i915) > static void guc_capture_load_err_log(struct intel_guc *guc) > { > - if (!guc->log.vma || !i915_modparams.guc_log_level) > + if (!guc->log.vma || !intel_guc_log_level_get(&guc->log)) this could simplified if we drop BUG_ON from intel_guc_log_level_get > return; > if (!guc->load_err_log) with removed GEM_BUG_ON, with or/without renamed get/set_level functions, this is Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
diff --git a/drivers/gpu/drm/i915/intel_guc.c b/drivers/gpu/drm/i915/intel_guc.c index 116f4ccf1bbd..9025837850ad 100644 --- a/drivers/gpu/drm/i915/intel_guc.c +++ b/drivers/gpu/drm/i915/intel_guc.c @@ -203,13 +203,11 @@ void intel_guc_fini(struct intel_guc *guc) guc_shared_data_destroy(guc); } -static u32 get_log_control_flags(void) +static u32 guc_ctl_debug_flags(struct intel_guc *guc) { - u32 level = i915_modparams.guc_log_level; + u32 level = intel_guc_log_level_get(&guc->log); u32 flags = 0; - GEM_BUG_ON(level < 0); - if (!GUC_LOG_LEVEL_IS_ENABLED(level)) flags |= GUC_LOG_DEFAULT_DISABLED; @@ -250,7 +248,7 @@ void intel_guc_init_params(struct intel_guc *guc) params[GUC_CTL_LOG_PARAMS] = guc->log.flags; - params[GUC_CTL_DEBUG] = get_log_control_flags(); + params[GUC_CTL_DEBUG] = guc_ctl_debug_flags(guc); /* If GuC submission is enabled, set up additional parameters here */ if (USES_GUC_SUBMISSION(dev_priv)) { diff --git a/drivers/gpu/drm/i915/intel_guc_log.c b/drivers/gpu/drm/i915/intel_guc_log.c index 401e1704d61e..c036d0fac370 100644 --- a/drivers/gpu/drm/i915/intel_guc_log.c +++ b/drivers/gpu/drm/i915/intel_guc_log.c @@ -475,11 +475,12 @@ int intel_guc_log_create(struct intel_guc_log *log) offset = intel_guc_ggtt_offset(guc, vma) >> PAGE_SHIFT; log->flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags; + log->level = i915_modparams.guc_log_level; + return 0; err: - /* logging will be off */ - i915_modparams.guc_log_level = 0; + DRM_ERROR("Failed to allocate GuC log buffer. %d\n", ret); return ret; } @@ -488,14 +489,6 @@ void intel_guc_log_destroy(struct intel_guc_log *log) i915_vma_unpin_and_release(&log->vma); } -int intel_guc_log_level_get(struct intel_guc_log *log) -{ - GEM_BUG_ON(!log->vma); - GEM_BUG_ON(i915_modparams.guc_log_level < 0); - - return i915_modparams.guc_log_level; -} - int intel_guc_log_level_set(struct intel_guc_log *log, u64 val) { struct intel_guc *guc = log_to_guc(log); @@ -504,7 +497,6 @@ int intel_guc_log_level_set(struct intel_guc_log *log, u64 val) BUILD_BUG_ON(GUC_LOG_VERBOSITY_MIN != 0); GEM_BUG_ON(!log->vma); - GEM_BUG_ON(i915_modparams.guc_log_level < 0); /* * GuC is recognizing log levels starting from 0 to max, we're using 0 @@ -515,7 +507,7 @@ int intel_guc_log_level_set(struct intel_guc_log *log, u64 val) mutex_lock(&dev_priv->drm.struct_mutex); - if (i915_modparams.guc_log_level == val) { + if (log->level == val) { ret = 0; goto out_unlock; } @@ -530,7 +522,7 @@ int intel_guc_log_level_set(struct intel_guc_log *log, u64 val) goto out_unlock; } - i915_modparams.guc_log_level = val; + log->level = val; out_unlock: mutex_unlock(&dev_priv->drm.struct_mutex); diff --git a/drivers/gpu/drm/i915/intel_guc_log.h b/drivers/gpu/drm/i915/intel_guc_log.h index fa80535a6f9d..ea375c3b5d08 100644 --- a/drivers/gpu/drm/i915/intel_guc_log.h +++ b/drivers/gpu/drm/i915/intel_guc_log.h @@ -30,6 +30,7 @@ #include <linux/workqueue.h> #include "intel_guc_fwif.h" +#include "i915_gem.h" struct intel_guc; @@ -58,6 +59,7 @@ struct intel_guc; #define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX) struct intel_guc_log { + u32 level; u32 flags; struct i915_vma *vma; struct { @@ -80,7 +82,6 @@ void intel_guc_log_init_early(struct intel_guc_log *log); int intel_guc_log_create(struct intel_guc_log *log); void intel_guc_log_destroy(struct intel_guc_log *log); -int intel_guc_log_level_get(struct intel_guc_log *log); int intel_guc_log_level_set(struct intel_guc_log *log, u64 control_val); bool intel_guc_log_relay_enabled(const struct intel_guc_log *log); int intel_guc_log_relay_open(struct intel_guc_log *log); @@ -89,4 +90,10 @@ void intel_guc_log_relay_close(struct intel_guc_log *log); void intel_guc_log_handle_flush_event(struct intel_guc_log *log); +static inline u32 intel_guc_log_level_get(struct intel_guc_log *log) +{ + GEM_BUG_ON(!log->vma); + return log->level; +} + #endif diff --git a/drivers/gpu/drm/i915/intel_uc.c b/drivers/gpu/drm/i915/intel_uc.c index 6a73e81f373b..5ce8d5df1b58 100644 --- a/drivers/gpu/drm/i915/intel_uc.c +++ b/drivers/gpu/drm/i915/intel_uc.c @@ -207,7 +207,7 @@ void intel_uc_init_mmio(struct drm_i915_private *i915) static void guc_capture_load_err_log(struct intel_guc *guc) { - if (!guc->log.vma || !i915_modparams.guc_log_level) + if (!guc->log.vma || !intel_guc_log_level_get(&guc->log)) return; if (!guc->load_err_log)