All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: "Michał Winiarski" <michal.winiarski@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 4/5] drm/i915/guc: Make adding GuC work items lockless
Date: Tue, 12 Sep 2017 22:22:12 +0100	[thread overview]
Message-ID: <150525133228.18386.5080488191524013276@mail.alporthouse.com> (raw)
In-Reply-To: <20170912174056.20139-4-michal.winiarski@intel.com>

Quoting Michał Winiarski (2017-09-12 18:40:55)
> @@ -434,11 +430,16 @@ 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;
> +       /* Find our offset and postincrement WQ tail for next time, free space
> +        * is guaranteed.
> +        */
> +       do {
> +               wq_off = READ_ONCE(desc->tail);
> +               wq_next = (wq_off + wqi_size) & (GUC_WQ_SIZE - 1);
> +               GEM_BUG_ON(CIRC_SPACE(wq_off, READ_ONCE(desc->head),
> +                                     GUC_WQ_SIZE) < wqi_size);
> +       } while (cmpxchg(&desc->tail, wq_off, wq_next) != wq_off);
>         GEM_BUG_ON(wq_off & (wqi_size - 1));

I forgot the trick in cmpxchg to avoid the READ_ONCE in every loop:
	wq_next = READ_ONCE(desc->tail);
	do {
		wq_off = wq_next;
		wq_next = (wq_off + wqi_size) & (GUC_WQ_SIZE - 1);
		GEM_BUG_ON(...);
	} while ((wq_next = cmpxchg(&desc->tail, wq_off, wq_next) != wq_off);
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-09-12 21:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 17:40 [PATCH 1/5] drm/i915/guc: Remove obsolete comments and remove unused variable Michał Winiarski
2017-09-12 17:40 ` [PATCH 2/5] drm/i915/guc: Submit GuC workitems containing coalesced requests Michał Winiarski
2017-09-12 17:40 ` [PATCH 3/5] drm/i915/guc: Simplify GuC doorbell logic Michał Winiarski
2017-09-12 20:24   ` Chris Wilson
2017-09-12 17:40 ` [PATCH v2 4/5] drm/i915/guc: Make adding GuC work items lockless Michał Winiarski
2017-09-12 21:22   ` Chris Wilson [this message]
2017-09-12 17:40 ` [PATCH 5/5] HAX Enable GuC Submission for CI Michał Winiarski
2017-09-12 18:36 ` ✗ Fi.CI.BAT: failure for series starting with [1/5] drm/i915/guc: Remove obsolete comments and remove unused variable Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150525133228.18386.5080488191524013276@mail.alporthouse.com \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=michal.winiarski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.