Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/i915: Remove local timeline var from submit/unsubmit
Date: Thu, 22 Mar 2018 15:24:13 +0200	[thread overview]
Message-ID: <87h8p85jlu.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20180322131034.6036-1-chris@chris-wilson.co.uk>

Chris Wilson <chris@chris-wilson.co.uk> writes:

> Both request_submit and request_unsubmit deal with transferring the
> request from the client's timeline onto the execution timeline and back
> again. As both functions deal with a pair of timeline's, using a
> shorthand for just one of them is slightly confusing, especially as the

The amount confusion is correlated with readers previous knowledge about
timelines. Slightly is an understatement for the newcomers but
we can accept that as a good amount of confusion, on average.

> different functions use the shorthand for the alternate timeline.
> Instead, use the full version of each timeline so it should be easier to
> keep track of the transfer between the request/client and the engine.
>

I pondered if the comment can even be removed on this, much
easier to read, version. But as the comment gives a
proper names to timelines, it has value.

Only one thing remains is that should the 'client's timeline'
be changed to 'per context timeline' on this commit msg,
to reflect the comment in the code.

> v2: Refactor the common lock+list_move
> v3: Be clear we require the other timeline list to be locked as well.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/i915_request.c | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index 2325886d1d55..854af07994f3 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -492,10 +492,20 @@ static u32 timeline_get_seqno(struct intel_timeline *tl)
>  	return ++tl->seqno;
>  }
>  
> +static void move_to_timeline(struct i915_request *request,
> +			     struct intel_timeline *timeline)
> +{
> +	GEM_BUG_ON(request->timeline == request->engine->timeline);
> +	lockdep_assert_held(&request->engine->timeline->lock);
> +
> +	spin_lock(&request->timeline->lock);
> +	list_move_tail(&request->link, &timeline->requests);
> +	spin_unlock(&request->timeline->lock);
> +}
> +
>  void __i915_request_submit(struct i915_request *request)
>  {
>  	struct intel_engine_cs *engine = request->engine;
> -	struct intel_timeline *timeline;
>  	u32 seqno;
>  
>  	GEM_TRACE("%s fence %llx:%d -> global_seqno %d\n",
> @@ -506,12 +516,9 @@ void __i915_request_submit(struct i915_request *request)
>  	GEM_BUG_ON(!irqs_disabled());
>  	lockdep_assert_held(&engine->timeline->lock);
>  
> -	/* Transfer from per-context onto the global per-engine timeline */
> -	timeline = engine->timeline;
> -	GEM_BUG_ON(timeline == request->timeline);
>  	GEM_BUG_ON(request->global_seqno);
>  
> -	seqno = timeline_get_seqno(timeline);
> +	seqno = timeline_get_seqno(engine->timeline);
>  	GEM_BUG_ON(!seqno);
>  	GEM_BUG_ON(i915_seqno_passed(intel_engine_get_seqno(engine), seqno));
>  
> @@ -525,9 +532,8 @@ void __i915_request_submit(struct i915_request *request)
>  	engine->emit_breadcrumb(request,
>  				request->ring->vaddr + request->postfix);
>  
> -	spin_lock(&request->timeline->lock);
> -	list_move_tail(&request->link, &timeline->requests);
> -	spin_unlock(&request->timeline->lock);
> +	/* Transfer from per-context onto the global per-engine timeline */
> +	move_to_timeline(request, engine->timeline);
>  
>  	trace_i915_request_execute(request);
>  
> @@ -550,7 +556,6 @@ void i915_request_submit(struct i915_request *request)
>  void __i915_request_unsubmit(struct i915_request *request)
>  {
>  	struct intel_engine_cs *engine = request->engine;
> -	struct intel_timeline *timeline;
>  
>  	GEM_TRACE("%s fence %llx:%d <- global_seqno %d\n",
>  		  request->engine->name,
> @@ -578,12 +583,7 @@ void __i915_request_unsubmit(struct i915_request *request)
>  	spin_unlock(&request->lock);
>  
>  	/* Transfer back from the global per-engine timeline to per-context */
> -	timeline = request->timeline;
> -	GEM_BUG_ON(timeline == engine->timeline);
> -
> -	spin_lock(&timeline->lock);
> -	list_move(&request->link, &timeline->requests);
> -	spin_unlock(&timeline->lock);
> +	move_to_timeline(request, request->timeline);
>  
>  	/*
>  	 * We don't need to wake_up any waiters on request->execute, they
> -- 
> 2.16.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-03-22 13:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22 12:48 [PATCH] drm/i915: Remove local timeline var from submit/unsubmit Chris Wilson
2018-03-22 12:55 ` [PATCH v2] " Chris Wilson
2018-03-22 13:01   ` Chris Wilson
2018-03-22 13:10 ` [PATCH v3] " Chris Wilson
2018-03-22 13:24   ` Mika Kuoppala [this message]
2018-03-22 16:00     ` Chris Wilson
2018-03-22 13:17 ` ✓ Fi.CI.BAT: success for drm/i915: Remove local timeline var from submit/unsubmit (rev2) Patchwork
2018-03-22 13:48 ` ✓ Fi.CI.BAT: success for drm/i915: Remove local timeline var from submit/unsubmit (rev3) Patchwork
2018-03-22 14:38 ` ✗ Fi.CI.IGT: failure " Patchwork

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=87h8p85jlu.fsf@gaia.fi.intel.com \
    --to=mika.kuoppala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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