All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values
@ 2016-08-26 17:42 Dave Gordon
  2016-08-26 17:42 ` [PATCH v4 1/5] drm/i915/guc: symbolic names for GuC submission preferences Dave Gordon
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Dave Gordon @ 2016-08-26 17:42 UTC (permalink / raw)
  To: intel-gfx

There are various literal constants used in the GuC module-parameter
processing code; this sequence of patches replaces them with symbolic
names for greater clarity.

And then it re-enables GuC submission by default :)

v3:
  Original patch broken into two (1/4 + 2/4)
  Name for GuC log level NONE added (3/4
  Re-enable GuC loading & submission (4/4)
  Added cover letter 

v4:
  Additional final patch (5/5) to change treatment of unrecognised
  option values (ignore them rather than force them into range).
  [Jani Nikula]

Dave Gordon (5):
  drm/i915/guc: symbolic names for GuC submission preferences
  drm/i915/guc: symbolic names for GuC firmare loading preferences
  drm/i915/guc: symbolic name for GuC log-level none
  drm/i915/guc: use symbolic names in setting defaults for module
    parameters
  drm/i915/guc: ignore unrecognised loading & submission options

 drivers/gpu/drm/i915/i915_guc_submission.c |  4 +--
 drivers/gpu/drm/i915/i915_params.c         | 10 +++---
 drivers/gpu/drm/i915/intel_guc.h           | 20 +++++++++++
 drivers/gpu/drm/i915/intel_guc_fwif.h      |  1 +
 drivers/gpu/drm/i915/intel_guc_loader.c    | 54 ++++++++++++++++++++++--------
 drivers/gpu/drm/i915/intel_lrc.c           |  4 +--
 6 files changed, 70 insertions(+), 23 deletions(-)

-- 
1.9.1

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v4 1/5] drm/i915/guc: symbolic names for GuC submission preferences
  2016-08-26 17:42 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
@ 2016-08-26 17:42 ` Dave Gordon
  2016-08-26 17:42 ` [PATCH v4 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences Dave Gordon
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Dave Gordon @ 2016-08-26 17:42 UTC (permalink / raw)
  To: intel-gfx

The existing code that accesses the "enable_guc_submission"
parameter uses explicit numerical values for the various
possibilities, including in one case relying on boolean 0/1
mapping to specific values (which could be confusing for
maintainers).

So this patch just provides and uses names for the values
representing the DEFAULT, DISABLED, PREFERRED, and MANDATORY
submission options that the user can select (-1, 0, 1, 2
respectively).

This should produce identical code to the previous version!

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_guc_submission.c |  2 +-
 drivers/gpu/drm/i915/intel_guc.h           |  6 ++++++
 drivers/gpu/drm/i915/intel_guc_loader.c    | 15 ++++++++-------
 drivers/gpu/drm/i915/intel_lrc.c           |  4 ++--
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index e436941..43b81d0 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -973,7 +973,7 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)
 	bitmap_clear(guc->doorbell_bitmap, 0, GUC_MAX_DOORBELLS);
 	i915_guc_submission_disable(dev_priv);
 
-	if (!i915.enable_guc_submission)
+	if (i915.enable_guc_submission == GUC_SUBMISSION_DISABLED)
 		return 0; /* not enabled  */
 
 	if (guc->ctx_pool_vma)
diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index c973262..941d70e 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -89,6 +89,12 @@ struct i915_guc_client {
 	uint64_t submissions[I915_NUM_ENGINES];
 };
 
+enum {
+	GUC_SUBMISSION_DEFAULT = -1,
+	GUC_SUBMISSION_DISABLED = 0,
+	GUC_SUBMISSION_PREFERRED,
+	GUC_SUBMISSION_MANDATORY
+};
 enum intel_guc_fw_status {
 	GUC_FIRMWARE_FAIL = -1,
 	GUC_FIRMWARE_NONE = 0,
diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
index e67d8de..9782f23 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -200,7 +200,7 @@ static void set_guc_init_params(struct drm_i915_private *dev_priv)
 	}
 
 	/* If GuC submission is enabled, set up additional parameters here */
-	if (i915.enable_guc_submission) {
+	if (i915.enable_guc_submission != GUC_SUBMISSION_DISABLED) {
 		u32 pgs = i915_ggtt_offset(dev_priv->guc.ctx_pool_vma);
 		u32 ctx_in_16 = GUC_MAX_GPU_CONTEXTS / 16;
 
@@ -507,7 +507,7 @@ int intel_guc_setup(struct drm_device *dev)
 		intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status),
 		intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
 
-	if (i915.enable_guc_submission) {
+	if (i915.enable_guc_submission != GUC_SUBMISSION_DISABLED) {
 		err = i915_guc_submission_enable(dev_priv);
 		if (err)
 			goto fail;
@@ -535,7 +535,7 @@ int intel_guc_setup(struct drm_device *dev)
 	 */
 	if (i915.enable_guc_loading > 1) {
 		ret = -EIO;
-	} else if (i915.enable_guc_submission > 1) {
+	} else if (i915.enable_guc_submission >= GUC_SUBMISSION_MANDATORY) {
 		ret = -EIO;
 	} else {
 		ret = 0;
@@ -550,7 +550,7 @@ int intel_guc_setup(struct drm_device *dev)
 	else
 		DRM_ERROR("GuC firmware load failed: %d\n", err);
 
-	if (i915.enable_guc_submission) {
+	if (i915.enable_guc_submission != GUC_SUBMISSION_DISABLED) {
 		if (fw_path == NULL)
 			DRM_INFO("GuC submission without firmware not supported\n");
 		if (ret == 0)
@@ -558,7 +558,7 @@ int intel_guc_setup(struct drm_device *dev)
 		else
 			DRM_ERROR("GuC init failed: %d\n", ret);
 	}
-	i915.enable_guc_submission = 0;
+	i915.enable_guc_submission = GUC_SUBMISSION_DISABLED;
 
 	return ret;
 }
@@ -703,8 +703,9 @@ void intel_guc_init(struct drm_device *dev)
 	/* A negative value means "use platform default" */
 	if (i915.enable_guc_loading < 0)
 		i915.enable_guc_loading = HAS_GUC_UCODE(dev);
-	if (i915.enable_guc_submission < 0)
-		i915.enable_guc_submission = HAS_GUC_SCHED(dev);
+	if (i915.enable_guc_submission <= GUC_SUBMISSION_DEFAULT)
+		i915.enable_guc_submission = HAS_GUC_SCHED(dev) ?
+			GUC_SUBMISSION_PREFERRED : GUC_SUBMISSION_DISABLED;
 
 	if (!HAS_GUC_UCODE(dev)) {
 		fw_path = NULL;
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 6b49df4..ba5a422 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -662,7 +662,7 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
 
 	request->ring = ce->ring;
 
-	if (i915.enable_guc_submission) {
+	if (i915.enable_guc_submission != GUC_SUBMISSION_DISABLED) {
 		/*
 		 * Check that the GuC has space for the request before
 		 * going any further, as the i915_add_request() call
@@ -798,7 +798,7 @@ static int intel_lr_context_pin(struct i915_gem_context *ctx,
 	ce->state->obj->dirty = true;
 
 	/* Invalidate GuC TLB. */
-	if (i915.enable_guc_submission) {
+	if (i915.enable_guc_submission != GUC_SUBMISSION_DISABLED) {
 		struct drm_i915_private *dev_priv = ctx->i915;
 		I915_WRITE(GEN8_GTCR, GEN8_GTCR_INVALIDATE);
 	}
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences
  2016-08-26 17:42 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
  2016-08-26 17:42 ` [PATCH v4 1/5] drm/i915/guc: symbolic names for GuC submission preferences Dave Gordon
@ 2016-08-26 17:42 ` Dave Gordon
  2016-08-26 17:42 ` [PATCH v4 3/5] drm/i915/guc: symbolic name for GuC log-level none Dave Gordon
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Dave Gordon @ 2016-08-26 17:42 UTC (permalink / raw)
  To: intel-gfx

The existing code that accesses the "enable_guc_loading"
parameter uses explicit numerical values for the various
possibilities,  including in one case relying on boolean
0/1 mapping to specific values (which could be confusing
for maintainers).

So this patch just provides and uses names for the values
representing the DEFAULT, DISABLED, PREFERRED, and MANDATORY
options that the user can select (-1, 0, 1, 2 respectively).

This should produce identical code to the previous version!

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_guc.h        | 14 ++++++++++++++
 drivers/gpu/drm/i915/intel_guc_loader.c | 13 +++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index 941d70e..83c2f295 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -89,12 +89,26 @@ struct i915_guc_client {
 	uint64_t submissions[I915_NUM_ENGINES];
 };
 
+/*
+ * These signed ranges represent user-requested preferences.
+ * Out-of-range values from the user will be clipped towards
+ * zero: any negative value is treated as -1, anything over 2
+ * is just 2. ANY user-supplied value also taints the kernel.
+ */
 enum {
 	GUC_SUBMISSION_DEFAULT = -1,
 	GUC_SUBMISSION_DISABLED = 0,
 	GUC_SUBMISSION_PREFERRED,
 	GUC_SUBMISSION_MANDATORY
 };
+enum {
+	FIRMWARE_LOAD_DEFAULT = -1,
+	FIRMWARE_LOAD_DISABLED = 0,
+	FIRMWARE_LOAD_PREFERRED,
+	FIRMWARE_LOAD_MANDATORY
+};
+
+/* These represent the actual firmware status  */
 enum intel_guc_fw_status {
 	GUC_FIRMWARE_FAIL = -1,
 	GUC_FIRMWARE_NONE = 0,
diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
index 9782f23..ea7ebbd 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -438,7 +438,7 @@ int intel_guc_setup(struct drm_device *dev)
 		intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
 
 	/* Loading forbidden, or no firmware to load? */
-	if (!i915.enable_guc_loading) {
+	if (i915.enable_guc_loading == FIRMWARE_LOAD_DISABLED) {
 		err = 0;
 		goto fail;
 	} else if (fw_path == NULL) {
@@ -533,7 +533,7 @@ int intel_guc_setup(struct drm_device *dev)
 	 * nonfatal error (i.e. it doesn't prevent driver load, but
 	 * marks the GPU as wedged until reset).
 	 */
-	if (i915.enable_guc_loading > 1) {
+	if (i915.enable_guc_loading >= FIRMWARE_LOAD_MANDATORY) {
 		ret = -EIO;
 	} else if (i915.enable_guc_submission >= GUC_SUBMISSION_MANDATORY) {
 		ret = -EIO;
@@ -700,9 +700,10 @@ void intel_guc_init(struct drm_device *dev)
 	struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
 	const char *fw_path;
 
-	/* A negative value means "use platform default" */
-	if (i915.enable_guc_loading < 0)
-		i915.enable_guc_loading = HAS_GUC_UCODE(dev);
+	/* Any negative value means "use platform default" */
+	if (i915.enable_guc_loading <= FIRMWARE_LOAD_DEFAULT)
+		i915.enable_guc_loading = HAS_GUC_UCODE(dev) ?
+			FIRMWARE_LOAD_PREFERRED : FIRMWARE_LOAD_DISABLED;
 	if (i915.enable_guc_submission <= GUC_SUBMISSION_DEFAULT)
 		i915.enable_guc_submission = HAS_GUC_SCHED(dev) ?
 			GUC_SUBMISSION_PREFERRED : GUC_SUBMISSION_DISABLED;
@@ -731,7 +732,7 @@ void intel_guc_init(struct drm_device *dev)
 	guc_fw->guc_fw_load_status = GUC_FIRMWARE_NONE;
 
 	/* Early (and silent) return if GuC loading is disabled */
-	if (!i915.enable_guc_loading)
+	if (i915.enable_guc_loading == FIRMWARE_LOAD_DISABLED)
 		return;
 	if (fw_path == NULL)
 		return;
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 3/5] drm/i915/guc: symbolic name for GuC log-level none
  2016-08-26 17:42 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
  2016-08-26 17:42 ` [PATCH v4 1/5] drm/i915/guc: symbolic names for GuC submission preferences Dave Gordon
  2016-08-26 17:42 ` [PATCH v4 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences Dave Gordon
@ 2016-08-26 17:42 ` Dave Gordon
  2016-08-26 17:42 ` [PATCH v4 4/5] drm/i915/guc: use symbolic names in setting defaults for module parameters Dave Gordon
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Dave Gordon @ 2016-08-26 17:42 UTC (permalink / raw)
  To: intel-gfx

The existing code that accesses the "guc_log_level" parameter
uses an explicit numerical value for the "no logging" case,
whereas there are symbolic names for the other levels.

So this patch just provides and uses a name for the default log
level (NONE), with the same numeric value that is already used.

This should produce identical code to the previous version!

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_guc_submission.c | 2 +-
 drivers/gpu/drm/i915/intel_guc_fwif.h      | 1 +
 drivers/gpu/drm/i915/intel_guc_loader.c    | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index 43b81d0..131fe2f 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -852,7 +852,7 @@ static void guc_create_log(struct intel_guc *guc)
 		vma = guc_allocate_vma(guc, size);
 		if (IS_ERR(vma)) {
 			/* logging will be off */
-			i915.guc_log_level = -1;
+			i915.guc_log_level = GUC_LOG_VERBOSITY_NONE;
 			return;
 		}
 
diff --git a/drivers/gpu/drm/i915/intel_guc_fwif.h b/drivers/gpu/drm/i915/intel_guc_fwif.h
index e40db2d..17814f7 100644
--- a/drivers/gpu/drm/i915/intel_guc_fwif.h
+++ b/drivers/gpu/drm/i915/intel_guc_fwif.h
@@ -132,6 +132,7 @@
 #define   GUC_LOG_VERBOSITY_HIGH	(2 << GUC_LOG_VERBOSITY_SHIFT)
 #define   GUC_LOG_VERBOSITY_ULTRA	(3 << GUC_LOG_VERBOSITY_SHIFT)
 /* Verbosity range-check limits, without the shift */
+#define	  GUC_LOG_VERBOSITY_NONE	(-1)
 #define	  GUC_LOG_VERBOSITY_MIN		0
 #define	  GUC_LOG_VERBOSITY_MAX		3
 #define	  GUC_LOG_VERBOSITY_MASK	0x0000000f
diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
index ea7ebbd..a7478b9 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -187,7 +187,7 @@ static void set_guc_init_params(struct drm_i915_private *dev_priv)
 	params[GUC_CTL_FEATURE] |= GUC_CTL_DISABLE_SCHEDULER |
 			GUC_CTL_VCS2_ENABLED;
 
-	if (i915.guc_log_level >= 0) {
+	if (i915.guc_log_level > GUC_LOG_VERBOSITY_NONE) {
 		params[GUC_CTL_LOG_PARAMS] = guc->log_flags;
 		params[GUC_CTL_DEBUG] =
 			i915.guc_log_level << GUC_LOG_VERBOSITY_SHIFT;
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 4/5] drm/i915/guc: use symbolic names in setting defaults for module parameters
  2016-08-26 17:42 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
                   ` (2 preceding siblings ...)
  2016-08-26 17:42 ` [PATCH v4 3/5] drm/i915/guc: symbolic name for GuC log-level none Dave Gordon
@ 2016-08-26 17:42 ` Dave Gordon
  2016-08-26 17:42 ` [PATCH v4 5/5] drm/i915/guc: ignore unrecognised loading & submission options Dave Gordon
  2016-08-26 18:20 ` ✓ Fi.CI.BAT: success for drm/i915/guc: use symbolic names for module parameter values (rev4) Patchwork
  5 siblings, 0 replies; 9+ messages in thread
From: Dave Gordon @ 2016-08-26 17:42 UTC (permalink / raw)
  To: intel-gfx

Of course, this also re-enables GuC loading and submission
by default on suitable platforms, since it's Intel's Plan
of Record that GuC submission shall be used where available.

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_params.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
index 768ad89..3354a30 100644
--- a/drivers/gpu/drm/i915/i915_params.c
+++ b/drivers/gpu/drm/i915/i915_params.c
@@ -55,9 +55,9 @@ struct i915_params i915 __read_mostly = {
 	.verbose_state_checks = 1,
 	.nuclear_pageflip = 0,
 	.edp_vswing = 0,
-	.enable_guc_loading = 0,
-	.enable_guc_submission = 0,
-	.guc_log_level = -1,
+	.enable_guc_loading = FIRMWARE_LOAD_DEFAULT,
+	.enable_guc_submission = GUC_SUBMISSION_DEFAULT,
+	.guc_log_level = GUC_LOG_VERBOSITY_NONE,
 	.enable_dp_mst = true,
 	.inject_load_failure = 0,
 	.enable_dpcd_backlight = false,
@@ -209,12 +209,12 @@ struct i915_params i915 __read_mostly = {
 module_param_named_unsafe(enable_guc_loading, i915.enable_guc_loading, int, 0400);
 MODULE_PARM_DESC(enable_guc_loading,
 		"Enable GuC firmware loading "
-		"(-1=auto, 0=never [default], 1=if available, 2=required)");
+		"(-1=auto [default], 0=never, 1=if available, 2=required)");
 
 module_param_named_unsafe(enable_guc_submission, i915.enable_guc_submission, int, 0400);
 MODULE_PARM_DESC(enable_guc_submission,
 		"Enable GuC submission "
-		"(-1=auto, 0=never [default], 1=if available, 2=required)");
+		"(-1=auto [default], 0=never, 1=if available, 2=required)");
 
 module_param_named(guc_log_level, i915.guc_log_level, int, 0400);
 MODULE_PARM_DESC(guc_log_level,
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 5/5] drm/i915/guc: ignore unrecognised loading & submission options
  2016-08-26 17:42 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
                   ` (3 preceding siblings ...)
  2016-08-26 17:42 ` [PATCH v4 4/5] drm/i915/guc: use symbolic names in setting defaults for module parameters Dave Gordon
@ 2016-08-26 17:42 ` Dave Gordon
  2016-08-26 18:20 ` ✓ Fi.CI.BAT: success for drm/i915/guc: use symbolic names for module parameter values (rev4) Patchwork
  5 siblings, 0 replies; 9+ messages in thread
From: Dave Gordon @ 2016-08-26 17:42 UTC (permalink / raw)
  To: intel-gfx

Previously the code allowed *any* values for the enable_guc_loading and
enable_guc_submission parameters, and forced them into range by clipping
at each extremum. This version instead ignores unknown values, treating
them as DEFAULT (which then gets converted to DISABLED or PREFERRED).

Of course we also have to report that we've ignored unknown values so
that the administrator or developer knows the kernel command line wasn't
sensible!

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_guc.h        |  8 ++++----
 drivers/gpu/drm/i915/intel_guc_loader.c | 34 ++++++++++++++++++++++++++++-----
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index 83c2f295..c865bde 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -90,10 +90,10 @@ struct i915_guc_client {
 };
 
 /*
- * These signed ranges represent user-requested preferences.
- * Out-of-range values from the user will be clipped towards
- * zero: any negative value is treated as -1, anything over 2
- * is just 2. ANY user-supplied value also taints the kernel.
+ * These values represent user-requested preferences; any other value will be
+ * treated as DEFAULT, so the driver will then choose an appropriate value.
+ *
+ * ANY user-supplied value (even DEFAULT) also taints the kernel.
  */
 enum {
 	GUC_SUBMISSION_DEFAULT = -1,
diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
index a7478b9..471e8b2 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -533,9 +533,9 @@ int intel_guc_setup(struct drm_device *dev)
 	 * nonfatal error (i.e. it doesn't prevent driver load, but
 	 * marks the GPU as wedged until reset).
 	 */
-	if (i915.enable_guc_loading >= FIRMWARE_LOAD_MANDATORY) {
+	if (i915.enable_guc_loading == FIRMWARE_LOAD_MANDATORY) {
 		ret = -EIO;
-	} else if (i915.enable_guc_submission >= GUC_SUBMISSION_MANDATORY) {
+	} else if (i915.enable_guc_submission == GUC_SUBMISSION_MANDATORY) {
 		ret = -EIO;
 	} else {
 		ret = 0;
@@ -700,13 +700,37 @@ void intel_guc_init(struct drm_device *dev)
 	struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
 	const char *fw_path;
 
-	/* Any negative value means "use platform default" */
-	if (i915.enable_guc_loading <= FIRMWARE_LOAD_DEFAULT)
+	/* Sanitise user-specified options */
+	switch (i915.enable_guc_loading) {
+	case FIRMWARE_LOAD_DISABLED:
+	case FIRMWARE_LOAD_PREFERRED:
+	case FIRMWARE_LOAD_MANDATORY:
+		break;
+
+	default:
+		DRM_INFO("ignoring unknown value %d for 'enable_guc_loading'\n",
+			 i915.enable_guc_loading);
+		/*FALLTHRU*/
+	case FIRMWARE_LOAD_DEFAULT:
 		i915.enable_guc_loading = HAS_GUC_UCODE(dev) ?
 			FIRMWARE_LOAD_PREFERRED : FIRMWARE_LOAD_DISABLED;
-	if (i915.enable_guc_submission <= GUC_SUBMISSION_DEFAULT)
+		break;
+	}
+
+	switch (i915.enable_guc_submission) {
+	case GUC_SUBMISSION_DISABLED:
+	case GUC_SUBMISSION_PREFERRED:
+	case GUC_SUBMISSION_MANDATORY:
+		break;
+
+	default:
+		DRM_INFO("ignoring unknown value %d for 'enable_guc_submission'\n",
+			 i915.enable_guc_submission);
+		/*FALLTHRU*/
+	case GUC_SUBMISSION_DEFAULT:
 		i915.enable_guc_submission = HAS_GUC_SCHED(dev) ?
 			GUC_SUBMISSION_PREFERRED : GUC_SUBMISSION_DISABLED;
+	}
 
 	if (!HAS_GUC_UCODE(dev)) {
 		fw_path = NULL;
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915/guc: use symbolic names for module parameter values (rev4)
  2016-08-26 17:42 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
                   ` (4 preceding siblings ...)
  2016-08-26 17:42 ` [PATCH v4 5/5] drm/i915/guc: ignore unrecognised loading & submission options Dave Gordon
@ 2016-08-26 18:20 ` Patchwork
  5 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2016-08-26 18:20 UTC (permalink / raw)
  To: Dave Gordon; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/guc: use symbolic names for module parameter values (rev4)
URL   : https://patchwork.freedesktop.org/series/10188/
State : success

== Summary ==

Series 10188v4 drm/i915/guc: use symbolic names for module parameter values
http://patchwork.freedesktop.org/api/1.0/series/10188/revisions/4/mbox/

Test drv_module_reload_basic:
                skip       -> PASS       (fi-skl-6260u)
Test kms_cursor_legacy:
        Subgroup basic-cursor-vs-flip-legacy:
                fail       -> PASS       (fi-bsw-n3050)

fi-bdw-5557u     total:252  pass:235  dwarn:0   dfail:0   fail:2   skip:15 
fi-bsw-n3050     total:252  pass:205  dwarn:0   dfail:0   fail:1   skip:46 
fi-byt-n2820     total:252  pass:207  dwarn:0   dfail:0   fail:3   skip:42 
fi-hsw-4770k     total:252  pass:228  dwarn:0   dfail:0   fail:2   skip:22 
fi-hsw-4770r     total:252  pass:224  dwarn:0   dfail:0   fail:2   skip:26 
fi-ivb-3520m     total:252  pass:220  dwarn:0   dfail:0   fail:1   skip:31 
fi-skl-6260u     total:252  pass:236  dwarn:0   dfail:0   fail:2   skip:14 
fi-skl-6700k     total:252  pass:222  dwarn:0   dfail:0   fail:2   skip:28 
fi-snb-2520m     total:252  pass:207  dwarn:0   dfail:0   fail:2   skip:43 
fi-snb-2600      total:252  pass:207  dwarn:0   dfail:0   fail:2   skip:43 

Results at /archive/results/CI_IGT_test/Patchwork_2435/

cdc87252779fbb627d0bb05a2690f4abfa7d8160 drm-intel-nightly: 2016y-08m-26d-17h-15m-21s UTC integration manifest
c8dd8f6 drm/i915/guc: ignore unrecognised loading & submission options
bd1a4a9 drm/i915/guc: use symbolic names in setting defaults for module parameters
19936fb drm/i915/guc: symbolic name for GuC log-level none
28104dc drm/i915/guc: symbolic names for GuC firmare loading preferences
d441335 drm/i915/guc: symbolic names for GuC submission preferences

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v4 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences
  2016-08-18 17:10 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
@ 2016-08-18 17:10 ` Dave Gordon
  0 siblings, 0 replies; 9+ messages in thread
From: Dave Gordon @ 2016-08-18 17:10 UTC (permalink / raw)
  To: intel-gfx

The existing code that accesses the "enable_guc_loading"
parameter uses explicit numerical values for the various
possibilities,  including in one case relying on boolean
0/1 mapping to specific values (which could be confusing
for maintainers).

So this patch just provides and uses names for the values
representing the DEFAULT, DISABLED, PREFERRED, and MANDATORY
options that the user can select (-1, 0, 1, 2 respectively).

This should produce identical code to the previous version!

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_guc.h        | 14 ++++++++++++++
 drivers/gpu/drm/i915/intel_guc_loader.c | 13 +++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index 941d70e..83c2f295 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -89,12 +89,26 @@ struct i915_guc_client {
 	uint64_t submissions[I915_NUM_ENGINES];
 };
 
+/*
+ * These signed ranges represent user-requested preferences.
+ * Out-of-range values from the user will be clipped towards
+ * zero: any negative value is treated as -1, anything over 2
+ * is just 2. ANY user-supplied value also taints the kernel.
+ */
 enum {
 	GUC_SUBMISSION_DEFAULT = -1,
 	GUC_SUBMISSION_DISABLED = 0,
 	GUC_SUBMISSION_PREFERRED,
 	GUC_SUBMISSION_MANDATORY
 };
+enum {
+	FIRMWARE_LOAD_DEFAULT = -1,
+	FIRMWARE_LOAD_DISABLED = 0,
+	FIRMWARE_LOAD_PREFERRED,
+	FIRMWARE_LOAD_MANDATORY
+};
+
+/* These represent the actual firmware status  */
 enum intel_guc_fw_status {
 	GUC_FIRMWARE_FAIL = -1,
 	GUC_FIRMWARE_NONE = 0,
diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
index 49f846c..da047a8 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -438,7 +438,7 @@ int intel_guc_setup(struct drm_device *dev)
 		intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
 
 	/* Loading forbidden, or no firmware to load? */
-	if (!i915.enable_guc_loading) {
+	if (i915.enable_guc_loading == FIRMWARE_LOAD_DISABLED) {
 		err = 0;
 		goto fail;
 	} else if (fw_path == NULL) {
@@ -533,7 +533,7 @@ int intel_guc_setup(struct drm_device *dev)
 	 * nonfatal error (i.e. it doesn't prevent driver load, but
 	 * marks the GPU as wedged until reset).
 	 */
-	if (i915.enable_guc_loading > 1) {
+	if (i915.enable_guc_loading >= FIRMWARE_LOAD_MANDATORY) {
 		ret = -EIO;
 	} else if (i915.enable_guc_submission >= GUC_SUBMISSION_MANDATORY) {
 		ret = -EIO;
@@ -699,9 +699,10 @@ void intel_guc_init(struct drm_device *dev)
 	struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
 	const char *fw_path;
 
-	/* A negative value means "use platform default" */
-	if (i915.enable_guc_loading < 0)
-		i915.enable_guc_loading = HAS_GUC_UCODE(dev);
+	/* Any negative value means "use platform default" */
+	if (i915.enable_guc_loading <= FIRMWARE_LOAD_DEFAULT)
+		i915.enable_guc_loading = HAS_GUC_UCODE(dev) ?
+			FIRMWARE_LOAD_PREFERRED : FIRMWARE_LOAD_DISABLED;
 	if (i915.enable_guc_submission <= GUC_SUBMISSION_DEFAULT)
 		i915.enable_guc_submission = HAS_GUC_SCHED(dev) ?
 			GUC_SUBMISSION_PREFERRED : GUC_SUBMISSION_DISABLED;
@@ -730,7 +731,7 @@ void intel_guc_init(struct drm_device *dev)
 	guc_fw->guc_fw_load_status = GUC_FIRMWARE_NONE;
 
 	/* Early (and silent) return if GuC loading is disabled */
-	if (!i915.enable_guc_loading)
+	if (i915.enable_guc_loading == FIRMWARE_LOAD_DISABLED)
 		return;
 	if (fw_path == NULL)
 		return;
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences
  2016-08-09 10:54 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
@ 2016-08-09 10:54 ` Dave Gordon
  0 siblings, 0 replies; 9+ messages in thread
From: Dave Gordon @ 2016-08-09 10:54 UTC (permalink / raw)
  To: intel-gfx

The existing code that accesses the "enable_guc_loading"
parameter uses explicit numerical values for the various
possibilities,  including in one case relying on boolean
0/1 mapping to specific values (which could be confusing
for maintainers).

So this patch just provides and uses names for the values
representing the DEFAULT, DISABLED, PREFERRED, and MANDATORY
options that the user can select (-1, 0, 1, 2 respectively).

This should produce identical code to the previous version!

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_guc.h        | 14 ++++++++++++++
 drivers/gpu/drm/i915/intel_guc_loader.c | 13 +++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index d15bac8..94db252 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -90,12 +90,26 @@ struct i915_guc_client {
 	uint64_t submissions[I915_NUM_ENGINES];
 };
 
+/*
+ * These signed ranges represent user-requested preferences.
+ * Out-of-range values from the user will be clipped towards
+ * zero: any negative value is treated as -1, anything over 2
+ * is just 2. ANY user-supplied value also taints the kernel.
+ */
 enum {
 	GUC_SUBMISSION_DEFAULT = -1,
 	GUC_SUBMISSION_DISABLED = 0,
 	GUC_SUBMISSION_PREFERRED,
 	GUC_SUBMISSION_MANDATORY
 };
+enum {
+	FIRMWARE_LOAD_DEFAULT = -1,
+	FIRMWARE_LOAD_DISABLED = 0,
+	FIRMWARE_LOAD_PREFERRED,
+	FIRMWARE_LOAD_MANDATORY
+};
+
+/* These represent the actual firmware status  */
 enum intel_guc_fw_status {
 	GUC_FIRMWARE_FAIL = -1,
 	GUC_FIRMWARE_NONE = 0,
diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
index 5128cbd..33d9770 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -426,7 +426,7 @@ int intel_guc_setup(struct drm_device *dev)
 		intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
 
 	/* Loading forbidden, or no firmware to load? */
-	if (!i915.enable_guc_loading) {
+	if (i915.enable_guc_loading == FIRMWARE_LOAD_DISABLED) {
 		err = 0;
 		goto fail;
 	} else if (fw_path == NULL) {
@@ -521,7 +521,7 @@ int intel_guc_setup(struct drm_device *dev)
 	 * nonfatal error (i.e. it doesn't prevent driver load, but
 	 * marks the GPU as wedged until reset).
 	 */
-	if (i915.enable_guc_loading > 1) {
+	if (i915.enable_guc_loading >= FIRMWARE_LOAD_MANDATORY) {
 		ret = -EIO;
 	} else if (i915.enable_guc_submission >= GUC_SUBMISSION_MANDATORY) {
 		ret = -EIO;
@@ -687,9 +687,10 @@ void intel_guc_init(struct drm_device *dev)
 	struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw;
 	const char *fw_path;
 
-	/* A negative value means "use platform default" */
-	if (i915.enable_guc_loading < 0)
-		i915.enable_guc_loading = HAS_GUC_UCODE(dev);
+	/* Any negative value means "use platform default" */
+	if (i915.enable_guc_loading <= FIRMWARE_LOAD_DEFAULT)
+		i915.enable_guc_loading = HAS_GUC_UCODE(dev) ?
+			FIRMWARE_LOAD_PREFERRED : FIRMWARE_LOAD_DISABLED;
 	if (i915.enable_guc_submission <= GUC_SUBMISSION_DEFAULT)
 		i915.enable_guc_submission = HAS_GUC_SCHED(dev) ?
 			GUC_SUBMISSION_PREFERRED : GUC_SUBMISSION_DISABLED;
@@ -718,7 +719,7 @@ void intel_guc_init(struct drm_device *dev)
 	guc_fw->guc_fw_load_status = GUC_FIRMWARE_NONE;
 
 	/* Early (and silent) return if GuC loading is disabled */
-	if (!i915.enable_guc_loading)
+	if (i915.enable_guc_loading == FIRMWARE_LOAD_DISABLED)
 		return;
 	if (fw_path == NULL)
 		return;
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-08-26 18:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-26 17:42 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
2016-08-26 17:42 ` [PATCH v4 1/5] drm/i915/guc: symbolic names for GuC submission preferences Dave Gordon
2016-08-26 17:42 ` [PATCH v4 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences Dave Gordon
2016-08-26 17:42 ` [PATCH v4 3/5] drm/i915/guc: symbolic name for GuC log-level none Dave Gordon
2016-08-26 17:42 ` [PATCH v4 4/5] drm/i915/guc: use symbolic names in setting defaults for module parameters Dave Gordon
2016-08-26 17:42 ` [PATCH v4 5/5] drm/i915/guc: ignore unrecognised loading & submission options Dave Gordon
2016-08-26 18:20 ` ✓ Fi.CI.BAT: success for drm/i915/guc: use symbolic names for module parameter values (rev4) Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2016-08-18 17:10 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
2016-08-18 17:10 ` [PATCH v4 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences Dave Gordon
2016-08-09 10:54 [PATCH v4 0/5] drm/i915/guc: use symbolic names for module parameter values Dave Gordon
2016-08-09 10:54 ` [PATCH v4 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences Dave Gordon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.