[Intel-gfx] [PATCH i-g-t v2 1/2] lib: Move __gem_context_create to common ioctl wrapper library.

Chris Wilson chris at chris-wilson.co.uk
Fri Oct 13 20:56:02 UTC 2017


Quoting Antonio Argenziano (2017-10-13 21:49:28)
>  static void gem_require_context(int fd)
>  {
> -       igt_require(__gem_context_create(fd));
> +       uint32_t ctx_id = 0;
> +       __gem_context_create(fd, &ctx_id);
> +       igt_require(ctx_id);

Still that leaks.

uint32_t has_contexts = 0;
__gem_context_create(fd, &has_contexts);
if (has_contexts)
	gem_context_destroy(fd, has_contexts);
igt_require(has_contexts);

Note that before we can drop the require from gem_context_create() we
have to go throw and teach all users to do the manual
gem_require_context() first.

Second note,

static bool gem_has_contexts(int fd)
{
	uint32_t ctx_id = 0;
	__gem_context_create(fd, &ctx_id);
	if (ctx_id)
		gem_context_destroy(fd, ctx_id);
	return ctx_id;
}

void gem_require_contexts(int fd)
{
	igt_require(gem_has_contexts(fd));
}
-Chris


More information about the Intel-gfx mailing list