diff mbox

[i-g-t,2/3] lib: Add reset-type helper in ioctl_wrappers

Message ID 20170620182502.28553-2-michel.thierry@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michel Thierry June 20, 2017, 6:25 p.m. UTC
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.

Signed-off-by: Michel Thierry <michel.thierry@intel.com>
---
 lib/ioctl_wrappers.c | 22 ++++++++++++++++++++++
 lib/ioctl_wrappers.h |  1 +
 2 files changed, 23 insertions(+)

Comments

Arkadiusz Hiler June 28, 2017, 2:10 p.m. UTC | #1
On Tue, Jun 20, 2017 at 11:25:01AM -0700, Michel Thierry wrote:
> 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.
> 
> Signed-off-by: Michel Thierry <michel.thierry@intel.com>
> ---
>  lib/ioctl_wrappers.c | 22 ++++++++++++++++++++++
>  lib/ioctl_wrappers.h |  1 +
>  2 files changed, 23 insertions(+)
> 
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index 0816a7b6..958b7d03 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -1199,6 +1199,28 @@ 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)

What about using an enum to save us commenting on the magic numbers
later on?
Michel Thierry June 28, 2017, 5:19 p.m. UTC | #2
On 6/28/2017 7:10 AM, Arkadiusz Hiler wrote:
> On Tue, Jun 20, 2017 at 11:25:01AM -0700, Michel Thierry wrote:
>> 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.
>>
>> Signed-off-by: Michel Thierry <michel.thierry@intel.com>
>> ---
>>   lib/ioctl_wrappers.c | 22 ++++++++++++++++++++++
>>   lib/ioctl_wrappers.h |  1 +
>>   2 files changed, 23 insertions(+)
>>
>> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
>> index 0816a7b6..958b7d03 100644
>> --- a/lib/ioctl_wrappers.c
>> +++ b/lib/ioctl_wrappers.c
>> @@ -1199,6 +1199,28 @@ 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)
> 
> What about using an enum to save us commenting on the magic numbers
> later on?
> 

The problem with enum is that we will forget to keep them updated.
But I can do something like we have for gem_gtt_type(); instead of tests 
calling gem_gpu_reset_type directly, I add these helpers:

- gem_reset_enabled {return gem_gpu_reset_type > 0}
- gem_reset_engine_enabled {return gem_gpu_reset_type > 1}

-Michel
diff mbox

Patch

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 0816a7b6..958b7d03 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1199,6 +1199,28 @@  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_available_fences:
  * @fd: open i915 drm file descriptor
  *
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index e1279d94..0fd4e8e4 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -164,6 +164,7 @@  bool gem_has_blt(int fd);
 bool gem_has_vebox(int fd);
 bool gem_has_bsd2(int fd);
 int gem_gtt_type(int fd);
+int gem_gpu_reset_type(int fd);
 bool gem_uses_ppgtt(int fd);
 bool gem_uses_full_ppgtt(int fd);
 int gem_available_fences(int fd);