Re: [igt-dev] [PATCH i-g-t] tests/dumb_buffer: Tests for creation

Chris Wilson
2019-11-15T15:44:56Z

Quoting Ramalingam C (2019-11-15 15:38:47)
> +static void *thread_clear(void *data)
> +{
> + struct thread_clear *arg = data;
> + unsigned long checked = 0;
> + int i915 = arg->i915;
> +
> + igt_until_timeout(arg->timeout) {
> + struct drm_mode_create_dumb create = {};
> + uint64_t npages;
> + uint32_t stride;
> +
> + npages = random();
> + npages = npages << 32;
> + npages |= random();
> + npages = get_npages(&arg->max, npages);
> +
> + for(uint64_t _npages = npages; npages > 0; npages -= _npages)
> + {
> + create.bpp = 32;
> + create.width = PAGE_SIZE / (create.bpp / 8);
> + stride = create.width * DIV_ROUND_UP(create.bpp, 8);
> + _npages = npages <= (((unsigned int)~0U) / stride) ?
> + npages : (((unsigned int)~0U) / stride);
> + create.height = _npages;
> +
> + do_ioctl(i915, DRM_IOCTL_MODE_CREATE_DUMB, &create);
> +
> + igt_assert(_npages == create.size / PAGE_SIZE);
> +
> + for (uint64_t page = 0; page < _npages; page++) {
> + uint64_t x;
> +
> + gem_read(i915, create.handle,
> + page * 4096 +
> + (page % (4096 - sizeof(x))),
> + &x, sizeof(x));

If we replace the read here with dump_mmap, we can make this generic and
work on any driver. (DRIVER_ANY, and place under tests/ not tests/i915)
[You will of course then want to do a few tests to exercise the
dump_mmap_ioctl itself to verify it separately.]

Otherwise,
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Thanks, that satisfies my worry about closing a potential back door.
-Chris