[igt-dev] [PATCH i-g-t 39/77] tests/i915/gem_exec_await: Convert to intel_ctx_t

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Jun 15 06:56:23 UTC 2021


On Mon, Jun 14, 2021 at 11:36:54AM -0500, Jason Ekstrand wrote:
> Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
> ---
>  tests/i915/gem_exec_await.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/i915/gem_exec_await.c b/tests/i915/gem_exec_await.c
> index 6db30695f..5270b4cdf 100644
> --- a/tests/i915/gem_exec_await.c
> +++ b/tests/i915/gem_exec_await.c
> @@ -63,16 +63,19 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags)
>  		struct drm_i915_gem_exec_object2 exec[2];
>  		struct drm_i915_gem_relocation_entry reloc;
>  		struct drm_i915_gem_execbuffer2 execbuf;
> +		const intel_ctx_t *ctx;
>  		uint32_t *cmd;
>  	} *exec;
>  	struct drm_i915_gem_exec_object2 *obj;
>  	struct drm_i915_gem_execbuffer2 execbuf;
> +	const intel_ctx_t *ctx;
>  	unsigned engines[I915_EXEC_RING_MASK + 1], nengine;
>  	unsigned long count;
>  	double time;
>  
> +	ctx = intel_ctx_create_all_physical(fd);
>  	nengine = 0;
> -	__for_each_physical_engine(fd, engine) {
> +	for_each_ctx_engine(fd, ctx, engine) {
>  		if (!gem_class_has_mutable_submission(fd, engine->class))
>  			continue;
>  
> @@ -106,7 +109,10 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags)
>  					 I915_EXEC_HANDLE_LUT);
>  
>  		if (flags & CONTEXTS) {
> -			exec[e].execbuf.rsvd1 = gem_context_create(fd);
> +			exec[e].ctx = intel_ctx_create(fd, &ctx->cfg);
> +			exec[e].execbuf.rsvd1 = exec[e].ctx->id;
> +		} else {
> +			exec[e].execbuf.rsvd1 = ctx->id;
>  		}
>  
>  		exec[e].exec[0].handle = gem_create(fd, 4096);
> @@ -151,9 +157,9 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags)
>  			int i;
>  
>  			if (flags & CONTEXTS) {
> -				gem_context_destroy(fd, exec[e].execbuf.rsvd1);
> -				exec[e].execbuf.rsvd1 =
> -					gem_context_clone_with_engines(fd, 0);
> +				intel_ctx_destroy(fd, exec[e].ctx);
> +				exec[e].ctx = intel_ctx_create(fd, &ctx->cfg);
> +				exec[e].execbuf.rsvd1 = exec[e].ctx->id;
>  			}
>  
>  			exec[e].reloc.presumed_offset = exec[e].exec[1].offset;
> @@ -193,6 +199,7 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags)
>  			execbuf.flags = (engines[e] |
>  					 I915_EXEC_NO_RELOC |
>  					 I915_EXEC_HANDLE_LUT);
> +			execbuf.rsvd1 = ctx->id;
>  			gem_execbuf(fd, &execbuf);
>  		}
>  		clock_gettime(CLOCK_MONOTONIC, &now);
> @@ -214,7 +221,7 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags)
>  
>  	for (unsigned e = 0; e < nengine; e++) {
>  		if (flags & CONTEXTS)
> -			gem_context_destroy(fd, exec[e].execbuf.rsvd1);
> +			intel_ctx_destroy(fd, exec[e].ctx);
>  
>  		for (unsigned n = 0; n < ring_size; n++)
>  			gem_close(fd, exec[e].obj[n].handle);
> @@ -223,6 +230,7 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags)
>  		munmap(exec[e].cmd, 4096);
>  		gem_close(fd, exec[e].exec[1].handle);
>  	}
> +	intel_ctx_destroy(fd, ctx);
>  	free(exec);
>  }

Looks ok.

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

--
Zbigniew

>  
> -- 
> 2.31.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev


More information about the igt-dev mailing list