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 2/5] drm/i915/guc: symbolic names for GuC firmare loading preferences
Date: Fri, 26 Aug 2016 18:42:40 +0100	[thread overview]
Message-ID: <1472233363-31668-3-git-send-email-david.s.gordon@intel.com> (raw)
In-Reply-To: <1472233363-31668-1-git-send-email-david.s.gordon@intel.com>

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

  parent reply	other threads:[~2016-08-26 17:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=1472233363-31668-3-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.