[igt-dev] [PATCH i-g-t v14 19/33] tests/gem_softpin: Verify allocator and execbuf pair work together
Chris Wilson
chris at chris-wilson.co.uk
Thu Jan 14 12:35:32 UTC 2021
Quoting Zbigniew Kempczyński (2021-01-14 12:22:19)
> +static void __exec_using_allocator(uint64_t ahnd, int fd, int num_obj,
> + bool pinned)
> +{
> + const uint32_t bbe = MI_BATCH_BUFFER_END;
> + struct drm_i915_gem_execbuffer2 execbuf;
> + struct drm_i915_gem_exec_object2 object[num_obj];
> + uint64_t stored_offsets[num_obj];
> + int i;
> +
> + memset(object, 0, sizeof(object));
> + for (i = 0; i < num_obj; i++) {
> + uint32_t sz = (rand() % 15 + 1) * 4096;
> + if (i == num_obj - 1)
> + sz = 4096;
> + object[i].handle = gem_create(fd, sz);
> + object[i].offset = intel_allocator_alloc(ahnd, object[i].handle,
> + sz, 0);
> + object[i].offset = gen8_canonical_addr(object[i].offset);
> + object[i].flags = pinned ? EXEC_OBJECT_PINNED : 0;
> + if (object[i].offset >= 1ull << 32)
> + object[i].flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
> + }
> + gem_write(fd, object[--i].handle, 0, &bbe, sizeof(bbe));
> +
> + if (!pinned)
> + for (i = 0; i < num_obj; i++)
> + stored_offsets[i] = object[i].offset;
> +
> + memset(&execbuf, 0, sizeof(execbuf));
> + execbuf.buffers_ptr = to_user_pointer(object);
> + execbuf.buffer_count = num_obj;
> + gem_execbuf(fd, &execbuf);
> +
> + for (i = 0; i < num_obj; i++) {
> + intel_allocator_free(ahnd, object[i].handle);
> + gem_close(fd, object[i].handle);
> + }
> +
> + /* Check kernel will keep offsets even pinned is not set. */
> + if (!pinned)
> + for (i = 0; i < num_obj; i++)
> + igt_assert_eq_u64(stored_offsets[i], object[i].offset);
We should check this anyway to verify the kernel doesn't moved our
pinned objects.
-Chris
More information about the igt-dev
mailing list