[PATCH v4 5/5] drm/i915/guc: ignore unrecognised loading & submission options

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

 



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@xxxxxxxxx>
Cc: Jani Nikula <jani.nikula@xxxxxxxxxxxxxxx>
---
 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 94db252..f8c44b1 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -91,10 +91,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 898cccb..8a81e80 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -521,9 +521,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;
@@ -687,13 +687,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@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