[PATCH v3 08/12] drm/i915/guc: Make guc_log_level parameter immutable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch introduces i915 internal state variable in GuC log struct,
"level" which will be copied from guc_log_level modparam during i915
load and thereafter be available for user updates. This will make
guc_log_level parameter immutable.

Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@xxxxxxxxx>
Cc: Michal Wajdeczko <michal.wajdeczko@xxxxxxxxx>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@xxxxxxxxx>
Cc: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
---
 drivers/gpu/drm/i915/i915_debugfs.c  |  2 +-
 drivers/gpu/drm/i915/intel_guc.c     |  6 +++---
 drivers/gpu/drm/i915/intel_guc_log.c | 23 ++++++++++-------------
 drivers/gpu/drm/i915/intel_guc_log.h |  6 ++++++
 drivers/gpu/drm/i915/intel_uc.c      | 11 +++++++++--
 5 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 2bb6307..16f9a95 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2459,7 +2459,7 @@ static int i915_guc_log_control_get(void *data, u64 *val)
 	if (!dev_priv->guc.log.vma)
 		return -EINVAL;
 
-	*val = i915_modparams.guc_log_level;
+	*val = dev_priv->guc.log.level;
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/i915/intel_guc.c b/drivers/gpu/drm/i915/intel_guc.c
index 0184c86..d351642 100644
--- a/drivers/gpu/drm/i915/intel_guc.c
+++ b/drivers/gpu/drm/i915/intel_guc.c
@@ -253,9 +253,9 @@ void intel_guc_init_params(struct intel_guc *guc)
 
 	params[GUC_CTL_LOG_PARAMS] = guc->log.flags;
 
-	if (i915_modparams.guc_log_level >= 0) {
+	if (guc->log.level >= 0) {
 		params[GUC_CTL_DEBUG] =
-			i915_modparams.guc_log_level << GUC_LOG_VERBOSITY_SHIFT;
+			guc->log.level << GUC_LOG_VERBOSITY_SHIFT;
 	} else {
 		params[GUC_CTL_DEBUG] = GUC_LOG_DISABLED;
 	}
@@ -451,7 +451,7 @@ int intel_guc_resume(struct drm_i915_private *dev_priv)
 	if (guc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
 		return 0;
 
-	if (i915_modparams.guc_log_level >= 0)
+	if (guc->log.level >= 0)
 		intel_enable_guc_interrupts(guc);
 
 	data[0] = INTEL_GUC_ACTION_EXIT_S_STATE;
diff --git a/drivers/gpu/drm/i915/intel_guc_log.c b/drivers/gpu/drm/i915/intel_guc_log.c
index 3a895a3..d979830 100644
--- a/drivers/gpu/drm/i915/intel_guc_log.c
+++ b/drivers/gpu/drm/i915/intel_guc_log.c
@@ -148,7 +148,7 @@ static int guc_log_relay_file_create(struct intel_guc *guc)
 	struct dentry *log_dir;
 	int ret;
 
-	if (i915_modparams.guc_log_level < 0)
+	if (guc->log.level < 0)
 		return 0;
 
 	/* For now create the log file in /sys/kernel/debug/dri/0 dir */
@@ -365,7 +365,7 @@ int intel_guc_log_runtime_create(struct intel_guc *guc)
 	size_t n_subbufs, subbuf_size;
 	int ret;
 
-	if (i915_modparams.guc_log_level < 0)
+	if (guc->log.level < 0)
 		return 0;
 
 	lockdep_assert_held(&dev_priv->drm.struct_mutex);
@@ -427,7 +427,7 @@ void intel_guc_log_runtime_destroy(struct intel_guc *guc)
 {
 	/*
 	 * It's possible that the runtime stuff was never allocated because
-	 * guc_log_level was < 0 at the time
+	 * guc->log.level was < 0 at the time
 	 **/
 	if (!guc_log_has_runtime(guc))
 		return;
@@ -464,7 +464,7 @@ static int guc_log_late_setup(struct intel_guc *guc)
 	intel_guc_log_runtime_destroy(guc);
 err:
 	/* logging will remain off */
-	i915_modparams.guc_log_level = -1;
+	guc->log.level = -1;
 	return ret;
 }
 
@@ -485,7 +485,7 @@ static void guc_log_capture_logs(struct intel_guc *guc)
 static void guc_flush_logs(struct intel_guc *guc)
 {
 	if (!USES_GUC_SUBMISSION(dev_priv) ||
-	    (i915_modparams.guc_log_level < 0))
+	    guc->log.level < 0)
 		return;
 
 	/* First disable the interrupts, will be renabled afterwards */
@@ -513,9 +513,6 @@ int intel_guc_log_create(struct intel_guc *guc)
 
 	GEM_BUG_ON(guc->log.vma);
 
-	if (i915_modparams.guc_log_level > GUC_LOG_VERBOSITY_MAX)
-		i915_modparams.guc_log_level = GUC_LOG_VERBOSITY_MAX;
-
 	/* The first page is to save log buffer state. Allocate one
 	 * extra page for others in case for overlap */
 	size = (1 + GUC_LOG_DPC_PAGES + 1 +
@@ -552,7 +549,7 @@ int intel_guc_log_create(struct intel_guc *guc)
 
 err:
 	/* logging will be off */
-	i915_modparams.guc_log_level = -1;
+	guc->log.level = -1;
 	return ret;
 }
 
@@ -575,7 +572,7 @@ int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)
 		return -EINVAL;
 
 	/* This combination doesn't make sense & won't have any effect */
-	if (!log_param.logging_enabled && (i915_modparams.guc_log_level < 0))
+	if (!log_param.logging_enabled && guc->log.level < 0)
 		return 0;
 
 	ret = guc_log_control(guc, log_param.value);
@@ -585,7 +582,7 @@ int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)
 	}
 
 	if (log_param.logging_enabled) {
-		i915_modparams.guc_log_level = log_param.verbosity;
+		guc->log.level = log_param.verbosity;
 
 		/* If log_level was set as -1 at boot time, then the relay channel file
 		 * wouldn't have been created by now and interrupts also would not have
@@ -608,7 +605,7 @@ int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)
 		guc_flush_logs(guc);
 
 		/* As logging is disabled, update log level to reflect that */
-		i915_modparams.guc_log_level = -1;
+		guc->log.level = -1;
 	}
 
 	return ret;
@@ -617,7 +614,7 @@ int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)
 void i915_guc_log_register(struct drm_i915_private *dev_priv)
 {
 	if (!USES_GUC_SUBMISSION(dev_priv) ||
-	    (i915_modparams.guc_log_level < 0))
+	    dev_priv->guc.log.level < 0)
 		return;
 
 	mutex_lock(&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 345447a..362bbef 100644
--- a/drivers/gpu/drm/i915/intel_guc_log.h
+++ b/drivers/gpu/drm/i915/intel_guc_log.h
@@ -33,6 +33,12 @@
 struct intel_guc;
 
 struct intel_guc_log {
+	/*
+	 * Current GuC firmware logging level. This depends on kernel parameter
+	 * guc_log_level during load and thereafter on user requests. It has
+	 * similar semantics as guc_log_level. (-1:disabled, "0-3:enabled)")
+	 */
+	int level;
 	u32 flags;
 	struct i915_vma *vma;
 	/* The runtime stuff gets created only when GuC logging gets enabled */
diff --git a/drivers/gpu/drm/i915/intel_uc.c b/drivers/gpu/drm/i915/intel_uc.c
index bc7f549..e2e2020 100644
--- a/drivers/gpu/drm/i915/intel_uc.c
+++ b/drivers/gpu/drm/i915/intel_uc.c
@@ -107,6 +107,11 @@ void intel_uc_sanitize_options(struct drm_i915_private *dev_priv)
 
 	/* Make sure that sanitization was done */
 	GEM_BUG_ON(i915_modparams.enable_guc < 0);
+
+	if (i915_modparams.guc_log_level > GUC_LOG_VERBOSITY_MAX)
+		i915_modparams.guc_log_level = GUC_LOG_VERBOSITY_MAX;
+
+	dev_priv->guc.log.level = i915_modparams.guc_log_level;
 }
 
 void intel_uc_init_early(struct drm_i915_private *dev_priv)
@@ -152,7 +157,7 @@ void intel_uc_init_mmio(struct drm_i915_private *dev_priv)
 
 static void guc_capture_load_err_log(struct intel_guc *guc)
 {
-	if (!guc->log.vma || i915_modparams.guc_log_level < 0)
+	if (!guc->log.vma || guc->log.level < 0)
 		return;
 
 	if (!guc->load_err_log)
@@ -324,7 +329,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 	}
 
 	if (USES_GUC_SUBMISSION(dev_priv)) {
-		if (i915_modparams.guc_log_level >= 0)
+		if (guc->log.level >= 0)
 			intel_enable_guc_interrupts(guc);
 
 		ret = intel_guc_submission_enable(guc);
@@ -358,6 +363,8 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
 	if (GEM_WARN_ON(ret == -EIO))
 		ret = -EINVAL;
 
+	guc->log.level = -1;
+
 	dev_err(dev_priv->drm.dev, "GuC initialization failed %d\n", ret);
 	return ret;
 }
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux