All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Gordon <david.s.gordon@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v4 5/5] drm/i915/guc: ignore unrecognised loading & submission options
Date: Tue,  9 Aug 2016 11:54:42 +0100	[thread overview]
Message-ID: <1470740082-12945-6-git-send-email-david.s.gordon@intel.com> (raw)
In-Reply-To: <1470740082-12945-1-git-send-email-david.s.gordon@intel.com>

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 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-08-09 10:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 1/5] drm/i915/guc: symbolic names for GuC submission preferences Dave Gordon
2016-08-09 10:54 ` [PATCH v4 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences Dave Gordon
2016-08-09 10:54 ` [PATCH v4 3/5] drm/i915/guc: symbolic name for GuC log-level none Dave Gordon
2016-08-09 10:54 ` [PATCH v4 4/5] drm/i915/guc: use symbolic names in setting defaults for module parameters Dave Gordon
2016-08-09 10:54 ` Dave Gordon [this message]
2016-08-09 11:25 ` ✗ Ro.CI.BAT: warning for drm/i915/guc: use symbolic names for module parameter values (rev2) Patchwork
2016-08-09 15:40   ` Dave Gordon
2016-08-10  6:30 ` ✗ Ro.CI.BAT: failure " Patchwork
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 5/5] drm/i915/guc: ignore unrecognised loading & submission options Dave Gordon
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 5/5] drm/i915/guc: ignore unrecognised loading & submission options Dave Gordon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470740082-12945-6-git-send-email-david.s.gordon@intel.com \
    --to=david.s.gordon@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.