Re: [igt-dev] [PATCH i-g-t v2] tests/gem_create: Test unaligned BO size update

Chris Wilson
2019-03-26T18:06:00Z

Quoting Michał Winiarski (2019-03-26 17:39:25)
> The driver is supposed to update the size when it's trying to outsmart
> userspace. Let's test it.
>
> v2: Rework to use local ioctl wrapper (Chris)
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Janusz Krzysztofik <janusz.krzysztofik@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
> +static void size_update(int fd)
> +{
> + int size_initial_nonaligned = 16;

16 is the size of one xmm register. It might be valid one year ;)

I would pick a !power-of-two to be sure it will never be a valid size.
15?

> + struct drm_i915_gem_create create = {
> + .size = size_initial_nonaligned,
> + };
> +
> + igt_assert_eq(create_ioctl(fd, &create), 0);
> + igt_assert_neq(create.size, size_initial_nonaligned);
> +}

But yes, that seems reasonable avoidance of saying precisely what
the alignment might be since PAGE_SIZE is pure accident, although
commonplace throughout the ABI.

> @@ -233,4 +260,7 @@ igt_main
>
> igt_subtest("create-clear")
> always_clear(fd, 30);
> +
> + igt_subtest("create-size-update")
> + size_update(fd);

I'd place it earlier since it is a basic test. But whatever works.

With s/16/15/
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris