dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	Jason Ekstrand <jason@jlekstrand.net>
Subject: Re: [Intel-gfx] [PATCH 18/27] drm/i915/gem: Optionally set SSEU in intel_context_set_gem
Date: Wed, 5 May 2021 10:52:56 +0100	[thread overview]
Message-ID: <d59f518c-7c61-9190-b404-62256611fa3b@linux.intel.com> (raw)
In-Reply-To: <YJJpvYcU76jTnz4b@phenom.ffwll.local>


On 05/05/2021 10:47, Daniel Vetter wrote:
> On Wed, May 05, 2021 at 10:28:59AM +0100, Tvrtko Ursulin wrote:
>>
>> On 04/05/2021 20:00, Daniel Vetter wrote:
>>> On Mon, May 03, 2021 at 10:57:39AM -0500, Jason Ekstrand wrote:
>>>> For now this is a no-op because everyone passes in a null SSEU but it
>>>> lets us get some of the error handling and selftest refactoring plumbed
>>>> through.
>>>>
>>>> Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
>>>
>>> it is a bit icky that intel_context_set_gem also sets the sseu, feels a
>>> bit like a layering violation, but welp I couldn't come up with a better
>>> idea either.
>>>
>>> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>>
>> It is actually quite horrible. As you say it breaks separation of duties and
>> open codes stuff all over the place without transferring over the commentary
>> about why.
> 
> I didn't really see lost commentary anywhere? Can you pls point out what
> got lost?

I glanced over two new places which check for RENDER_CLASS without any 
commentary while the existing code helpfully says:

	/* Only render engine supports RPCS configuration. */
	if (ce->engine->class != RENDER_CLASS) {
		ret = -ENODEV;
		goto out_ce;
	}

But really that is really just a symptom how mixed up the flows end up 
with this patch. In other words I am not suggesting those two new sites 
should have the same comment, just highlighting that the design is not good.

Regards,

Tvrtko

  -Daniel
> 
>>
>> Regards,
>>
>> Tvrtko
>>
>>>> ---
>>>>    drivers/gpu/drm/i915/gem/i915_gem_context.c   | 41 +++++++++++++++----
>>>>    .../gpu/drm/i915/gem/selftests/mock_context.c |  6 ++-
>>>>    2 files changed, 36 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
>>>> index ce729e640bbf7..6dd50d669c5b9 100644
>>>> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
>>>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
>>>> @@ -320,9 +320,12 @@ context_get_vm_rcu(struct i915_gem_context *ctx)
>>>>    	} while (1);
>>>>    }
>>>> -static void intel_context_set_gem(struct intel_context *ce,
>>>> -				  struct i915_gem_context *ctx)
>>>> +static int intel_context_set_gem(struct intel_context *ce,
>>>> +				 struct i915_gem_context *ctx,
>>>> +				 struct intel_sseu sseu)
>>>>    {
>>>> +	int ret = 0;
>>>> +
>>>>    	GEM_BUG_ON(rcu_access_pointer(ce->gem_context));
>>>>    	RCU_INIT_POINTER(ce->gem_context, ctx);
>>>> @@ -349,6 +352,12 @@ static void intel_context_set_gem(struct intel_context *ce,
>>>>    		intel_context_set_watchdog_us(ce, (u64)timeout_ms * 1000);
>>>>    	}
>>>> +
>>>> +	/* A valid SSEU has no zero fields */
>>>> +	if (sseu.slice_mask && !WARN_ON(ce->engine->class != RENDER_CLASS))
>>>> +		ret = intel_context_reconfigure_sseu(ce, sseu);
>>>> +
>>>> +	return ret;
>>>>    }
>>>>    static void __free_engines(struct i915_gem_engines *e, unsigned int count)
>>>> @@ -416,7 +425,8 @@ static struct i915_gem_engines *alloc_engines(unsigned int count)
>>>>    	return e;
>>>>    }
>>>> -static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx)
>>>> +static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx,
>>>> +						struct intel_sseu rcs_sseu)
>>>>    {
>>>>    	const struct intel_gt *gt = &ctx->i915->gt;
>>>>    	struct intel_engine_cs *engine;
>>>> @@ -429,6 +439,8 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx)
>>>>    	for_each_engine(engine, gt, id) {
>>>>    		struct intel_context *ce;
>>>> +		struct intel_sseu sseu = {};
>>>> +		int ret;
>>>>    		if (engine->legacy_idx == INVALID_ENGINE)
>>>>    			continue;
>>>> @@ -442,10 +454,18 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx)
>>>>    			goto free_engines;
>>>>    		}
>>>> -		intel_context_set_gem(ce, ctx);
>>>> -
>>>>    		e->engines[engine->legacy_idx] = ce;
>>>>    		e->num_engines = max(e->num_engines, engine->legacy_idx + 1);
>>>> +
>>>> +		if (engine->class == RENDER_CLASS)
>>>> +			sseu = rcs_sseu;
>>>> +
>>>> +		ret = intel_context_set_gem(ce, ctx, sseu);
>>>> +		if (ret) {
>>>> +			err = ERR_PTR(ret);
>>>> +			goto free_engines;
>>>> +		}
>>>> +
>>>>    	}
>>>>    	return e;
>>>> @@ -759,6 +779,7 @@ __create_context(struct drm_i915_private *i915,
>>>>    {
>>>>    	struct i915_gem_context *ctx;
>>>>    	struct i915_gem_engines *e;
>>>> +	struct intel_sseu null_sseu = {};
>>>>    	int err;
>>>>    	int i;
>>>> @@ -776,7 +797,7 @@ __create_context(struct drm_i915_private *i915,
>>>>    	INIT_LIST_HEAD(&ctx->stale.engines);
>>>>    	mutex_init(&ctx->engines_mutex);
>>>> -	e = default_engines(ctx);
>>>> +	e = default_engines(ctx, null_sseu);
>>>>    	if (IS_ERR(e)) {
>>>>    		err = PTR_ERR(e);
>>>>    		goto err_free;
>>>> @@ -1544,6 +1565,7 @@ set_engines__load_balance(struct i915_user_extension __user *base, void *data)
>>>>    	struct intel_engine_cs *stack[16];
>>>>    	struct intel_engine_cs **siblings;
>>>>    	struct intel_context *ce;
>>>> +	struct intel_sseu null_sseu = {};
>>>>    	u16 num_siblings, idx;
>>>>    	unsigned int n;
>>>>    	int err;
>>>> @@ -1616,7 +1638,7 @@ set_engines__load_balance(struct i915_user_extension __user *base, void *data)
>>>>    		goto out_siblings;
>>>>    	}
>>>> -	intel_context_set_gem(ce, set->ctx);
>>>> +	intel_context_set_gem(ce, set->ctx, null_sseu);
>>>>    	if (cmpxchg(&set->engines->engines[idx], NULL, ce)) {
>>>>    		intel_context_put(ce);
>>>> @@ -1724,6 +1746,7 @@ set_engines(struct i915_gem_context *ctx,
>>>>    	struct drm_i915_private *i915 = ctx->i915;
>>>>    	struct i915_context_param_engines __user *user =
>>>>    		u64_to_user_ptr(args->value);
>>>> +	struct intel_sseu null_sseu = {};
>>>>    	struct set_engines set = { .ctx = ctx };
>>>>    	unsigned int num_engines, n;
>>>>    	u64 extensions;
>>>> @@ -1733,7 +1756,7 @@ set_engines(struct i915_gem_context *ctx,
>>>>    		if (!i915_gem_context_user_engines(ctx))
>>>>    			return 0;
>>>> -		set.engines = default_engines(ctx);
>>>> +		set.engines = default_engines(ctx, null_sseu);
>>>>    		if (IS_ERR(set.engines))
>>>>    			return PTR_ERR(set.engines);
>>>> @@ -1790,7 +1813,7 @@ set_engines(struct i915_gem_context *ctx,
>>>>    			return PTR_ERR(ce);
>>>>    		}
>>>> -		intel_context_set_gem(ce, ctx);
>>>> +		intel_context_set_gem(ce, ctx, null_sseu);
>>>>    		set.engines->engines[n] = ce;
>>>>    	}
>>>> diff --git a/drivers/gpu/drm/i915/gem/selftests/mock_context.c b/drivers/gpu/drm/i915/gem/selftests/mock_context.c
>>>> index e0f512ef7f3c6..cbeefd060e97b 100644
>>>> --- a/drivers/gpu/drm/i915/gem/selftests/mock_context.c
>>>> +++ b/drivers/gpu/drm/i915/gem/selftests/mock_context.c
>>>> @@ -14,6 +14,7 @@ mock_context(struct drm_i915_private *i915,
>>>>    {
>>>>    	struct i915_gem_context *ctx;
>>>>    	struct i915_gem_engines *e;
>>>> +	struct intel_sseu null_sseu = {};
>>>>    	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
>>>>    	if (!ctx)
>>>> @@ -31,7 +32,7 @@ mock_context(struct drm_i915_private *i915,
>>>>    	i915_gem_context_set_persistence(ctx);
>>>>    	mutex_init(&ctx->engines_mutex);
>>>> -	e = default_engines(ctx);
>>>> +	e = default_engines(ctx, null_sseu);
>>>>    	if (IS_ERR(e))
>>>>    		goto err_free;
>>>>    	RCU_INIT_POINTER(ctx->engines, e);
>>>> @@ -112,6 +113,7 @@ live_context_for_engine(struct intel_engine_cs *engine, struct file *file)
>>>>    {
>>>>    	struct i915_gem_engines *engines;
>>>>    	struct i915_gem_context *ctx;
>>>> +	struct intel_sseu null_sseu = {};
>>>>    	struct intel_context *ce;
>>>>    	engines = alloc_engines(1);
>>>> @@ -130,7 +132,7 @@ live_context_for_engine(struct intel_engine_cs *engine, struct file *file)
>>>>    		return ERR_CAST(ce);
>>>>    	}
>>>> -	intel_context_set_gem(ce, ctx);
>>>> +	intel_context_set_gem(ce, ctx, null_sseu);
>>>>    	engines->engines[0] = ce;
>>>>    	engines->num_engines = 1;
>>>> -- 
>>>> 2.31.1
>>>>
>>>> _______________________________________________
>>>> Intel-gfx mailing list
>>>> Intel-gfx@lists.freedesktop.org
>>>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>>>
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2021-05-05  9:53 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-03 15:57 [PATCH 00/27] drm/i915/gem: ioctl clean-ups (v5) Jason Ekstrand
2021-05-03 15:57 ` [PATCH 01/27] drm/i915: Drop I915_CONTEXT_PARAM_RINGSIZE Jason Ekstrand
2021-05-03 15:57 ` [PATCH 02/27] drm/i915: Stop storing the ring size in the ring pointer Jason Ekstrand
2021-05-04  8:47   ` Daniel Vetter
2021-05-14 18:06     ` Jason Ekstrand
2021-05-03 15:57 ` [PATCH 03/27] drm/i915: Drop I915_CONTEXT_PARAM_NO_ZEROMAP Jason Ekstrand
2021-05-04  8:48   ` [Intel-gfx] " Daniel Vetter
2021-05-03 15:57 ` [PATCH 04/27] drm/i915/gem: Set the watchdog timeout directly in intel_context_set_gem (v2) Jason Ekstrand
2021-05-03 15:57 ` [PATCH 05/27] drm/i915/gem: Return void from context_apply_all Jason Ekstrand
2021-05-03 15:57 ` [PATCH 06/27] drm/i915: Drop the CONTEXT_CLONE API Jason Ekstrand
2021-05-04  8:50   ` [Intel-gfx] " Daniel Vetter
2021-05-14 18:07     ` Jason Ekstrand
2021-05-03 15:57 ` [PATCH 07/27] drm/i915: Implement SINGLE_TIMELINE with a syncobj (v4) Jason Ekstrand
2021-05-03 15:57 ` [PATCH 08/27] drm/i915: Drop getparam support for I915_CONTEXT_PARAM_ENGINES Jason Ekstrand
2021-05-03 15:57 ` [PATCH 09/27] drm/i915/gem: Disallow bonding of virtual engines (v3) Jason Ekstrand
2021-05-03 15:57 ` [PATCH 10/27] drm/i915/gem: Remove engine auto-magic with FENCE_SUBMIT Jason Ekstrand
2021-05-04  8:56   ` Daniel Vetter
2021-05-14 18:19     ` Jason Ekstrand
2021-05-03 15:57 ` [PATCH 11/27] drm/i915/request: Remove the hook from await_execution Jason Ekstrand
2021-05-04  8:55   ` Daniel Vetter
2021-05-03 15:57 ` [PATCH 12/27] drm/i915/gem: Disallow creating contexts with too many engines Jason Ekstrand
2021-05-05  9:56   ` [Intel-gfx] " Tvrtko Ursulin
2021-05-03 15:57 ` [PATCH 13/27] drm/i915: Stop manually RCU banging in reset_stats_ioctl (v2) Jason Ekstrand
2021-05-03 15:57 ` [PATCH 14/27] drm/i915/gem: Add a separate validate_priority helper Jason Ekstrand
2021-05-03 15:57 ` [PATCH 15/27] drm/i915: Add gem/i915_gem_context.h to the docs Jason Ekstrand
2021-05-04  9:11   ` Daniel Vetter
2021-05-03 15:57 ` [PATCH 16/27] drm/i915/gem: Add an intermediate proto_context struct Jason Ekstrand
2021-05-04 16:13   ` Daniel Vetter
2021-06-02 21:53     ` Jason Ekstrand
2021-06-03  7:07       ` Daniel Vetter
2021-05-05 10:09   ` [Intel-gfx] " Tvrtko Ursulin
2021-05-03 15:57 ` [PATCH 17/27] drm/i915/gem: Rework error handling in default_engines Jason Ekstrand
2021-05-04 16:17   ` [Intel-gfx] " Daniel Vetter
2021-05-14 18:21     ` Jason Ekstrand
2021-05-03 15:57 ` [PATCH 18/27] drm/i915/gem: Optionally set SSEU in intel_context_set_gem Jason Ekstrand
2021-05-04 19:00   ` [Intel-gfx] " Daniel Vetter
2021-05-05  9:28     ` Tvrtko Ursulin
2021-05-05  9:47       ` Daniel Vetter
2021-05-05  9:52         ` Tvrtko Ursulin [this message]
2021-05-03 15:57 ` [PATCH 19/27] drm/i915/gem: Use the proto-context to handle create parameters Jason Ekstrand
2021-05-04 20:33   ` Daniel Vetter
2021-05-14 19:13     ` Jason Ekstrand
2021-05-17 13:40       ` Daniel Vetter
2021-05-17 17:04         ` Jason Ekstrand
2021-05-17 18:44           ` Daniel Vetter
2021-05-18 10:51             ` Jani Nikula
2021-05-03 15:57 ` [PATCH 20/27] drm/i915/gem: Return an error ptr from context_lookup Jason Ekstrand
2021-05-03 15:57 ` [PATCH 21/27] drm/i915/gt: Drop i915_address_space::file (v2) Jason Ekstrand
2021-05-03 15:57 ` [PATCH 22/27] drm/i915/gem: Delay context creation Jason Ekstrand
2021-05-03 19:38   ` [Intel-gfx] " kernel test robot
2021-05-04 20:53     ` Daniel Vetter
2021-05-04 20:53   ` Daniel Vetter
2021-05-03 15:57 ` [PATCH 23/27] drm/i915/gem: Don't allow changing the VM on running contexts Jason Ekstrand
2021-05-03 18:52   ` [Intel-gfx] " kernel test robot
2021-05-04 21:00     ` Daniel Vetter
2021-05-04 21:17   ` Daniel Vetter
2021-05-03 15:57 ` [PATCH 24/27] drm/i915/gem: Don't allow changing the engine set " Jason Ekstrand
2021-05-05  9:49   ` [Intel-gfx] " Daniel Vetter
2021-05-03 15:57 ` [PATCH 25/27] drm/i915/selftests: Take a VM in kernel_context() Jason Ekstrand
2021-05-05  9:50   ` Daniel Vetter
2021-05-03 15:57 ` [PATCH 26/27] i915/gem/selftests: Assign the VM at context creation in igt_shared_ctx_exec Jason Ekstrand
2021-05-05  9:53   ` [Intel-gfx] " Daniel Vetter
2021-05-03 15:57 ` [PATCH 27/27] drm/i915/gem: Roll all of context creation together Jason Ekstrand
2021-05-05 10:05   ` [Intel-gfx] " Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d59f518c-7c61-9190-b404-62256611fa3b@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jason@jlekstrand.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).