[igt-dev] [PATCH i-g-t v3 1/2] lib/igt_gt: Check for shared reset domain

Dixit, Ashutosh ashutosh.dixit at intel.com
Mon Jan 17 20:20:42 UTC 2022


On Mon, 17 Jan 2022 00:56:59 -0800, <priyanka.dandamudi at intel.com> wrote:
>
> +bool has_shared_reset_domain(int fd, const intel_ctx_t *ctx)
> +{
> +	const struct intel_execution_engine2 *e;
> +	bool rcs0 = false;
> +	bool ccs0 = false;
> +	int ccs_count = 0;
> +
> +	for_each_ctx_engine(fd, ctx, e) {
> +		if ((rcs0 && ccs0) || (ccs_count > 1))
> +			break;
> +		else if (e->class == I915_ENGINE_CLASS_RENDER)
> +			rcs0 = true;
> +		else if (e->class == I915_ENGINE_CLASS_COMPUTE) {
> +			ccs0 = true;
> +			ccs_count++;
> +		}
> +	}
> +	return ((rcs0 && ccs0) || (ccs_count > 1));
> +}

No need for bool, just use counts. Something like:

bool has_shared_reset_domain(int fd, const intel_ctx_t *ctx)
{
	const struct intel_execution_engine2 *e;
	int rcs = 0, ccs = 0;

	for_each_ctx_engine(fd, ctx, e) {
		if (e->class == I915_ENGINE_CLASS_RENDER)
			rcs++;
		else if (e->class == I915_ENGINE_CLASS_COMPUTE)
			ccs++;
	}

	return ((rcs && ccs) || (ccs >= 2));
}

Hmm, this can just be:

bool has_shared_reset_domain(int fd, const intel_ctx_t *ctx)
{
	const struct intel_execution_engine2 *e;
	int count = 0;

	for_each_ctx_engine(fd, ctx, e)
		if (e->class == I915_ENGINE_CLASS_RENDER ||
			e->class == I915_ENGINE_CLASS_COMPUTE)
		count++;

	return count >= 2;
}


More information about the igt-dev mailing list