diff mbox

[i-g-t] igt/gem_mmap_gtt: Check for known incoherency before testing

Message ID 20180720080755.20579-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson July 20, 2018, 8:07 a.m. UTC
We test map_gtt coherency (whether or not a write via the mmap_gtt is
immediately visible in the backing storage to a read via mmap_cpu) but
we know that several platforms are inherently incorrect and require some
form of hammer to workaround internal delays. These platforms break our
ABI guarantees and so we report the change in ABI via a driver getparam.

If we know the platform doesn't meet the ABI guarantee, skip the test.
If it is meant to work, test!

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 tests/gem_mmap_gtt.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Tvrtko Ursulin July 20, 2018, 3:39 p.m. UTC | #1
On 20/07/2018 09:07, Chris Wilson wrote:
> We test map_gtt coherency (whether or not a write via the mmap_gtt is
> immediately visible in the backing storage to a read via mmap_cpu) but
> we know that several platforms are inherently incorrect and require some
> form of hammer to workaround internal delays. These platforms break our
> ABI guarantees and so we report the change in ABI via a driver getparam.
> 
> If we know the platform doesn't meet the ABI guarantee, skip the test.
> If it is meant to work, test!
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
>   tests/gem_mmap_gtt.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
> index c8a0bedec..f63535556 100644
> --- a/tests/gem_mmap_gtt.c
> +++ b/tests/gem_mmap_gtt.c
> @@ -309,6 +309,18 @@ test_write_gtt(int fd)
>   	munmap(src, OBJECT_SIZE);
>   }
>   
> +static bool is_coherent(int i915)
> +{
> +	int val = 1; /* by default, we assume GTT is coherent, hence the test */
> +	struct drm_i915_getparam gp = {
> +		gp.param = 52, /* GTT_COHERENT */
> +		gp.value = &val,
> +	};
> +
> +	ioctl(i915, DRM_IOCTL_I915_GETPARAM, &gp);
> +	return val;
> +}
> +
>   static void
>   test_coherency(int fd)
>   {
> @@ -316,6 +328,7 @@ test_coherency(int fd)
>   	uint32_t *gtt, *cpu;
>   	int i;
>   
> +	igt_require(is_coherent(fd));
>   	igt_require(igt_setup_clflush());
>   
>   	handle = gem_create(fd, OBJECT_SIZE);
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
diff mbox

Patch

diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index c8a0bedec..f63535556 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -309,6 +309,18 @@  test_write_gtt(int fd)
 	munmap(src, OBJECT_SIZE);
 }
 
+static bool is_coherent(int i915)
+{
+	int val = 1; /* by default, we assume GTT is coherent, hence the test */
+	struct drm_i915_getparam gp = {
+		gp.param = 52, /* GTT_COHERENT */
+		gp.value = &val,
+	};
+
+	ioctl(i915, DRM_IOCTL_I915_GETPARAM, &gp);
+	return val;
+}
+
 static void
 test_coherency(int fd)
 {
@@ -316,6 +328,7 @@  test_coherency(int fd)
 	uint32_t *gtt, *cpu;
 	int i;
 
+	igt_require(is_coherent(fd));
 	igt_require(igt_setup_clflush());
 
 	handle = gem_create(fd, OBJECT_SIZE);