summaryrefslogtreecommitdiff
path: root/lib/ioctl_wrappers.c
diff options
context:
space:
mode:
authorMichel Thierry <michel.thierry@intel.com>2017-06-28 11:36:54 -0700
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2017-07-17 11:34:12 +0300
commitbcb9d6f8b9f93610bf5964381431eef5c0dfa675 (patch)
treef35c179be5826232fab21b40fe623e4333e72c53 /lib/ioctl_wrappers.c
parent4fd7a5f76dbde723a749ea8e9a8d68b73487b712 (diff)
lib: Add reset-type helper in ioctl_wrappers
Soon we will have tests that are only for platforms with reset-engine (GEN8+), so add a helper to query the has_gpu_reset via the getparam ioctl. v2: Add more helper functions to avoid using magic numbers in tests (Arek). Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Signed-off-by: Michel Thierry <michel.thierry@intel.com> Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r--lib/ioctl_wrappers.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 2bbaed54..51000bac 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1193,6 +1193,57 @@ bool gem_uses_full_ppgtt(int fd)
}
/**
+ * gem_gpu_reset_type:
+ * @fd: open i915 drm file descriptor
+ *
+ * Query whether reset-engine (2), global-reset (1) or reset-disable (0)
+ * is available.
+ *
+ * Returns: GPU reset type available
+ */
+int gem_gpu_reset_type(int fd)
+{
+ struct drm_i915_getparam gp;
+ int gpu_reset_type = -1;
+
+ memset(&gp, 0, sizeof(gp));
+ gp.param = I915_PARAM_HAS_GPU_RESET;
+ gp.value = &gpu_reset_type;
+ drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+ return gpu_reset_type;
+}
+
+/**
+ * gem_gpu_reset_enabled:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to check whether the kernel internally uses hangchecks
+ * and can reset the GPU upon hang detection. Note that this is also true when
+ * reset-engine (the lightweight, single engine reset) is available.
+ *
+ * Returns: Whether the driver will detect hangs and perform a reset.
+ */
+bool gem_gpu_reset_enabled(int fd)
+{
+ return gem_gpu_reset_type(fd) > 0;
+}
+
+/**
+ * gem_engine_reset_enabled:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to check whether the kernel internally uses hangchecks
+ * and can reset individual engines upon hang detection.
+ *
+ * Returns: Whether the driver will detect hangs and perform an engine reset.
+ */
+bool gem_engine_reset_enabled(int fd)
+{
+ return gem_gpu_reset_type(fd) > 1;
+}
+
+/**
* gem_available_fences:
* @fd: open i915 drm file descriptor
*