[Intel-gfx] [PATCH igt] lib/i915: Query semaphore status using GETPARAM

Chris Wilson chris at chris-wilson.co.uk
Sat Oct 28 11:13:55 UTC 2017


Wherever possible we want to use existing ioctls rather than poking the
volatile modparams, in this case we already provide
I915_PARAM_HAS_SEMAPHORES so we have no excuse to peek i915.semaphores.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 lib/i915/gem_submission.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c
index 2a57e7ab..882d4f41 100644
--- a/lib/i915/gem_submission.c
+++ b/lib/i915/gem_submission.c
@@ -22,6 +22,9 @@
  */
 
 #include <stdbool.h>
+#include <sys/ioctl.h>
+
+#include <i915_drm.h>
 
 #include "igt_core.h"
 #include "igt_sysfs.h"
@@ -41,6 +44,18 @@
  * semaphores for synchronization between engines.
  */
 
+static bool has_semaphores(int fd, int dir)
+{
+	int val = 0;
+	struct drm_i915_getparam gp = {
+		gp.param = I915_PARAM_HAS_SEMAPHORES,
+		gp.value = &val,
+	};
+	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) < 0)
+		val = igt_sysfs_get_boolean(dir, "semaphores");
+	return val;
+}
+
 /**
  * gem_submission_method:
  * @fd: open i915 drm file descriptor
@@ -69,7 +84,7 @@ unsigned gem_submission_method(int fd)
 		goto out;
 	}
 
-	active = igt_sysfs_get_boolean(dir, "semaphores");
+	active = has_semaphores(fd, dir);
 	if (active) {
 		flags |= GEM_SUBMISSION_SEMAPHORES;
 	}
-- 
2.15.0.rc2



More information about the Intel-gfx mailing list