[Intel-gfx] [PATCH 15/18] drm/i915/ringbuffer: Specialise SNB+ request emission for semaphores

Chris Wilson chris at chris-wilson.co.uk
Thu Jul 21 14:10:38 UTC 2016


On Thu, Jul 21, 2016 at 04:55:00PM +0300, Joonas Lahtinen wrote:
> On ke, 2016-07-20 at 14:12 +0100, Chris Wilson wrote:
> > As gen6_emit_request() only differs from i9xx_emit_request() when
> > semaphores are enabled, only use the specialised vfunc in that scenario.
> > 
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> > ---
> >  drivers/gpu/drm/i915/intel_ringbuffer.c | 18 ++++++++----------
> >  1 file changed, 8 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> > index a74b42fc8f48..8ae25bcc876e 100644
> > --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> > +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> > @@ -1442,22 +1442,20 @@ static int i9xx_emit_request(struct drm_i915_gem_request *req)
> >  }
> >  
> >  /**
> > - * gen6_emit_request - Update the semaphore mailbox registers
> > + * gen6_sema_emit_request - Update the semaphore mailbox registers
> >   *
> >   * @request - request to write to the ring
> >   *
> >   * Update the mailbox registers in the *other* rings with the current seqno.
> >   * This acts like a signal in the canonical semaphore.
> >   */
> > -static int gen6_emit_request(struct drm_i915_gem_request *req)
> > +static int gen6_sema_emit_request(struct drm_i915_gem_request *req)
> >  {
> > -	if (req->engine->semaphore.signal) {
> > -		int ret;
> > +	int ret;
> >  
> > -		ret = req->engine->semaphore.signal(req);
> > -		if (ret)
> > -			return ret;
> > -	}
> > +	ret = req->engine->semaphore.signal(req);
> > +	if (ret)
> > +		return ret;
> >  
> >  	return i9xx_emit_request(req);
> >  }
> > @@ -2687,6 +2685,8 @@ static void intel_ring_init_semaphores(struct drm_i915_private *dev_priv,
> >  	if (!i915.semaphores)
> >  		return;
> >  
> > +	engine->emit_request = gen6_sema_emit_request;
> > +
> >  	if (INTEL_GEN(dev_priv) >= 8) {
> >  		u64 offset = i915_gem_obj_ggtt_offset(dev_priv->semaphore_obj);
> >  
> > @@ -2789,8 +2789,6 @@ static void intel_ring_default_vfuncs(struct drm_i915_private *dev_priv,
> >  	engine->init_hw = init_ring_common;
> >  
> >  	engine->emit_request = i9xx_emit_request;
> > -	if (INTEL_GEN(dev_priv) >= 6)
> > -		engine->emit_request = gen6_emit_request;
> 
> Not sure if I would prefer the assignment here still. If overrides
> happen from all around the codebase, it'll be harder to come up with
> what are the possible values for a vfunc, right?

It's definitely not a default function any more though. It needs to be
conditional on the semaphore setup. We could move the init_semaphores
earlier, and then do

engine->emit_request = i9xx_emit_request;
if (i915.semaphores)
	engine->emit_request = gen6_sema_emit_request;

here?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list