[Intel-gfx] [PATCH 2/2] drm/i915: Move execlists port head instead of memmoving array

Chris Wilson chris at chris-wilson.co.uk
Thu Nov 2 15:07:52 UTC 2017


Quoting Mika Kuoppala (2017-10-31 15:27:34)
> From: Mika Kuoppala <mika.kuoppala at intel.com>
> 
> As all our access to execlist ports are through head and tail
> helpers, we can now move the head instead of memmoving the array.
> 
> v2: use memset (Chris)
> 
> Cc: Michał Winiarski <michal.winiarski at intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Signed-off-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_ringbuffer.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
> index 387667fe50d3..011c4b8f1339 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.h
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
> @@ -611,13 +611,13 @@ static inline struct execlist_port *
>  execlists_head_complete(struct intel_engine_execlists * const execlists,
>                         struct execlist_port * const port)
>  {
> -       const unsigned int m = execlists->port_mask;
> -
> -       GEM_BUG_ON(port_index(port, execlists) != 0);
> +       GEM_BUG_ON(port_index(port, execlists) != execlists->port_head);
> +       GEM_BUG_ON(!port_isset(port));
>         GEM_BUG_ON(!execlists_is_active(execlists, EXECLISTS_ACTIVE_USER));
>  
> -       memmove(port, port + 1, m * sizeof(struct execlist_port));
> -       memset(port + m, 0, sizeof(struct execlist_port));
> +       memset(port, 0, sizeof(*port));
> +
> +       execlists->port_head = port_head_add(execlists, 1);

Ok, I would have gone for

port = port_next(port);
execlists->port_head = port - execlists->port;
return port;

That to me looks more natural advance of port as we complete the
requests, and matches the loop in the irq handler.

Care to crunch the numbers and see which gcc favours?
-Chris


More information about the Intel-gfx mailing list