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

Joonas Lahtinen
2016-07-21T13:55:03Z

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@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?

Regards, Joonas

>   engine->submit_request = i9xx_submit_request;
>
>   if (INTEL_GEN(dev_priv) >= 8)
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation