[Intel-gfx] [PATCH 1/2] drm/i915: Introduce execlist_port_* accessors

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


Quoting Mika Kuoppala (2017-11-02 14:32:38)
> From: Mika Kuoppala <mika.kuoppala at intel.com>
> 
> Instead of trusting that first available port is at index 0,
> use accessor to hide this. This is a preparation for a
> following patches where head can be at arbitrary location
> in the port array.
> 
> v2: improved commit message, elsp_ready readability (Chris)
> v3: s/execlist_port_index/execlist_port (Chris)
> v4: rebase to new naming
> v5: fix port_next indexing
> v6: adapt to preempt
> v7: improved _port_next (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/i915_gpu_error.c      |  6 ++--
>  drivers/gpu/drm/i915/i915_guc_submission.c | 50 ++++++++++++++++++------------
>  drivers/gpu/drm/i915/intel_engine_cs.c     | 18 ++++++-----
>  drivers/gpu/drm/i915/intel_lrc.c           | 49 ++++++++++++++++++-----------
>  drivers/gpu/drm/i915/intel_ringbuffer.h    | 44 ++++++++++++++++++++++++--
>  5 files changed, 119 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
> index 653fb69e7ecb..6d0bdb03b3f0 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -1333,11 +1333,13 @@ static void engine_record_requests(struct intel_engine_cs *engine,
>  static void error_record_engine_execlists(struct intel_engine_cs *engine,
>                                           struct drm_i915_error_engine *ee)
>  {
> -       const struct intel_engine_execlists * const execlists = &engine->execlists;
> +       struct intel_engine_execlists * const execlists = &engine->execlists;
>         unsigned int n;
>  
>         for (n = 0; n < execlists_num_ports(execlists); n++) {
> -               struct drm_i915_gem_request *rq = port_request(&execlists->port[n]);
> +               struct drm_i915_gem_request *rq;
> +
> +               rq = port_request(execlists_port(execlists, n));
>  
This newline isn't as interesting as the others. No one will shed a tear
if it is removed.

>                 if (!rq)
>                         break;

> @@ -665,7 +670,8 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
>  
>                                 if (submit)
>                                         port_assign(port, last);
> -                               port++;
> +
> +                               port = execlists_port_next(execlists, port);
>  

Spare us this newline as well. Let's have the advance and BUG() tightly
coupled.

>                                 GEM_BUG_ON(port_isset(port));
>                         }
> @@ -699,8 +705,10 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
>  void
>  execlists_cancel_port_requests(struct intel_engine_execlists * const execlists)
>  {
> -       struct execlist_port *port = execlists->port;
>         unsigned int num_ports = execlists_num_ports(execlists);
> +       struct execlist_port *port;
> +
> +       port = execlists_port_head(execlists);
>  
>         while (num_ports-- && port_isset(port)) {

	for (port = execlists_port_head(execlists);
	     num_ports-- && port_isset(port);
	     port = execlists_head_complete(execlists, port)) {

Might as well complete the transformation to more normal code ;)

> +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;
> @@ -580,6 +618,8 @@ execlists_port_complete(struct intel_engine_execlists * const execlists,
>  
>         memmove(port, port + 1, m * sizeof(struct execlist_port));
>         memset(port + m, 0, sizeof(struct execlist_port));
> +
> +       return execlists_port_head(execlists);

Hang on a sec, isn't port->head itself meant to advance here? Oh,
that'll be the next patch and this is just prep.

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the Intel-gfx mailing list