intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Dave Gordon <david.s.gordon@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/i915: use effective_size for ringbuffer calculations
Date: Fri, 12 Jun 2015 20:55:09 +0100	[thread overview]
Message-ID: <557B391D.9050208@intel.com> (raw)
In-Reply-To: <20150612181203.GN28462@nuc-i3427.alporthouse.com>

On 12/06/15 19:12, Chris Wilson wrote:
> On Fri, Jun 12, 2015 at 06:09:07PM +0100, Dave Gordon wrote:
>> When calculating the available space in a ringbuffer, we should
>> use the effective_size rather than the true size of the ring.
>>
>> v2: rebase to latest drm-intel-nightly
>> v3: rebase to latest drm-intel-nightly
>>
>> Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
>> ---
>>  drivers/gpu/drm/i915/intel_lrc.c        |    5 +++--
>>  drivers/gpu/drm/i915/intel_ringbuffer.c |    9 ++++++---
>>  2 files changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
>> index 9b74ffa..454e836 100644
>> --- a/drivers/gpu/drm/i915/intel_lrc.c
>> +++ b/drivers/gpu/drm/i915/intel_lrc.c
>> @@ -699,7 +699,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,
>>  
>>  		/* Would completion of this request free enough space? */
>>  		space = __intel_ring_space(request->postfix, ringbuf->tail,
>> -					   ringbuf->size);
>> +					   ringbuf->effective_size);
>>  		if (space >= bytes)
>>  			break;
>>  	}
>> @@ -711,7 +711,8 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,
>>  	if (ret)
>>  		return ret;
>>  
>> -	ringbuf->space = space;
>> +	/* Update ring space after wait+retire */
>> +	intel_ring_update_space(ringbuf);
> 
> Does the function not do what it says on the tin? At least make it seem
> like you are explaining your reasoning, not documenting the following
> function.
> 
> /*
>  * Having waited for the request, query the HEAD of most recent retired
>  * request and use that for our space calcuations.
>  */

That's what the comment means; the important bit is mentioning "retire",
since it's not explicitly called from here but only via wait_request().
We could say,

	/*
	 * After waiting, at least one request must have completed
	 * and been retired, so make sure that the ringbuffer's
	 * space calculations are up to date
	 */
	intel_ring_update_space(ringbuf);
	BUG_ON(ringbuf->space < bytes);

> However, that makes an incorrect assumption about the waiter. Given that
> the current code is written such that ringbuf->last_retired_head =
> request->postfix and that space is identical to the repeated
> calculation, what is your intention exactly?
> -Chris

Three factors:

* firstly, a preference: I find it logically simpler that there should
be one and only one piece of code that writes into ringbuf->space. One
doesn't then have to reason about whether two different calculations are
in fact equivalent.

* secondly, for future proofing: although wait_request() now retires
only up to the waited-for request, that wasn't always the case, nor is
there any reason why it could not in future opportunistically retire
additional requests that have completed while it was waiting.

* thirdly, for correctness: using the function has the additional effect
of consuming the last_retired_head value set by retire_request. If this
is not done, a later call to intel_ring_space() may become confused,
with the result that 'head' (and therefore 'space') will be incorrectly
updated.

.Dave.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-06-12 19:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1433789441-8295-1-git-send-email-david.s.gordon@intel.com>
2015-06-12 17:09 ` [PATCH v2] Resolve issues with ringbuffer space management Dave Gordon
2015-06-12 17:09   ` [PATCH 1/2] drm/i915: use effective_size for ringbuffer calculations Dave Gordon
2015-06-12 18:12     ` Chris Wilson
2015-06-12 19:55       ` Dave Gordon [this message]
2015-06-12 20:41         ` Chris Wilson
2015-06-12 17:09   ` [PATCH 2/2] drm/i915: Rework order of operations in {__intel, logical}_ring_prepare() Dave Gordon
2015-06-12 18:05     ` Chris Wilson
2015-06-12 18:54       ` Dave Gordon
2015-06-12 19:10         ` Chris Wilson
2015-06-12 20:25   ` (no subject) Dave Gordon
2015-06-12 20:25     ` [PATCH 1/2] drm/i915: Don't wait twice in {__intel, logical}_ring_prepare() Dave Gordon
2015-06-12 20:25     ` [PATCH 2/2] drm/i915: Allocate OLR more safely (workaround until OLR goes away) Dave Gordon
2015-06-17 11:04     ` (no subject) Daniel Vetter
2015-06-17 12:41       ` Jani Nikula
2015-06-18 10:30       ` Dave Gordon

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=557B391D.9050208@intel.com \
    --to=david.s.gordon@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;
as well as URLs for NNTP newsgroup(s).