[Intel-gfx] [PATCH v2] tests/gem_reg_read: Extend and check for valid 36b counter

Chris Wilson chris at chris-wilson.co.uk
Thu Jul 16 03:53:23 PDT 2015


On Thu, Jul 16, 2015 at 12:37:55PM +0200, Michał Winiarski wrote:
> When reading the timestamp register with single 64b read, we are observing
> invalid values on x86_64:
> 
>     [f = valid counter value | X = garbage]
> 
>     i386:   0x0000000fffffffff
>     x86_64: 0xffffffffXXXXXXXX
> 
> Test checks if the counter is moving and increasing.
> Add a check to see if we can use (reg | 1) flag to get a proper 36b timestamp,
> shifting the value on x86_64 if we can't.
> 
> v2: More iterations of monotonic test, comments, minor fixups (Chris)
> 
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>

Down to being really pinicky now,

> +static int read_register(int fd, uint64_t offset, uint64_t * val)
>  {
> +	int ret;
>  	struct local_drm_i915_reg_read reg_read;
> +	reg_read.offset = offset;
>  
> -	reg_read.offset = 0x2358;
> -	igt_fail_on_f(drmIoctl(fd, REG_READ_IOCTL, &reg_read),
> -		      "positive test case failed: ");
> +	ret = drmIoctl(fd, REG_READ_IOCTL, &reg_read);

A nice trick to use here is

ret = 0;
if (drmIoctl())
	ret = -errno;

Then later bad-reg becomes igt_assert_eq(read_register(BAD), -EINVAL);

> +static uint64_t timer_query(int fd, uint64_t * val)

Return is just int

> +	igt_subtest("bad-register")
> +		igt_assert(read_register(fd, 0x12345678, &val) == -1 &&
> +				errno == EINVAL);
> +
> +	igt_subtest("timestamp-moving")
> +		test_timestamp_moving(fd);
>  
> -	igt_assert(ret != 0 && errno == EINVAL);
> +	igt_subtest("timestamp-monotonic")
> +		test_timestamp_monotonic(fd);

Both of these subtests should start with
	igt_skip(timer_query() != 0)
so that we correctly disable the test for all kernels/machines that don't
support the register read. (Rather than reporting the tests as fail.)
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list