[Intel-gfx] [PATCH 4/5] drm/i915/guc: Cleanup adding GuC work items

Chris Wilson chris at chris-wilson.co.uk
Sun Sep 17 12:47:18 UTC 2017


Quoting MichaƂ Winiarski (2017-09-14 09:32:15)
> @@ -434,11 +432,12 @@ static void guc_wq_item_append(struct i915_guc_client *client,
>          */
>         BUILD_BUG_ON(wqi_size != 16);
>  
> -       /* postincrement WQ tail for next time */
> -       wq_off = client->wq_tail;
> +       /* Postincrement WQ tail for next time, free space is guaranteed. */
> +       wq_off = READ_ONCE(desc->tail);
> +       GEM_BUG_ON(CIRC_SPACE(wq_off, READ_ONCE(desc->head),
> +                             GUC_WQ_SIZE) < wqi_size);
> +       WRITE_ONCE(desc->tail, (wq_off + wqi_size) & (GUC_WQ_SIZE - 1));
>         GEM_BUG_ON(wq_off & (wqi_size - 1));
> -       client->wq_tail += wqi_size;
> -       client->wq_tail &= client->wq_size - 1;
>  
>         /* WQ starts from the page after doorbell / process_desc */
>         wqi = client->vaddr + wq_off + GUC_DB_SIZE;
> @@ -451,7 +450,7 @@ static void guc_wq_item_append(struct i915_guc_client *client,
>  
>         wqi->context_desc = lower_32_bits(intel_lr_context_descriptor(ctx, engine));
>  
> -       wqi->submit_element_info = tail << WQ_RING_TAIL_SHIFT;
> +       wqi->submit_element_info = ring_tail << WQ_RING_TAIL_SHIFT;
>         wqi->fence_id = rq->global_seqno;

Ah, you reminded me that we should set the wq element before updating
the tail, i.e. move the
	WRITE_ONCE(desc->tail, (wq_off + wqi_size) & (GUC_WQ_SIZE - 1));
to here.
-Chris


More information about the Intel-gfx mailing list