From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/i915: Wake up the bottom-half if we steal their interrupt
Date: Wed, 6 Jul 2016 10:31:09 +0100 [thread overview]
Message-ID: <577CCFDD.2000501@linux.intel.com> (raw)
In-Reply-To: <1467791159-23958-2-git-send-email-chris@chris-wilson.co.uk>
On 06/07/16 08:45, Chris Wilson wrote:
> Following on from the scenario Tvrtko envision to explain a hard-to-hit
> race with multiple first waiters, we could also then race in the
> __i915_request_irq_complete() and the bottom-half may miss the vital
> irq-seqno barrier and so go to sleep not noticing their seqno is
> complete.
>
> v2: unlock, not double lock the rcu_read_lock.
>
> Fixes: 3d5564e91025 ("drm/i915: Only apply one barrier after...")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index c269e0ad4057..11e9769411e9 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3998,7 +3998,10 @@ static inline bool __i915_request_irq_complete(struct drm_i915_gem_request *req)
> * is woken.
> */
> if (engine->irq_seqno_barrier &&
> + READ_ONCE(engine->breadcrumbs.tasklet) == current &&
> cmpxchg_relaxed(&engine->irq_posted, 1, 0)) {
> + struct task_struct *tsk;
> +
> /* The ordering of irq_posted versus applying the barrier
> * is crucial. The clearing of the current irq_posted must
> * be visible before we perform the barrier operation,
> @@ -4012,6 +4015,25 @@ static inline bool __i915_request_irq_complete(struct drm_i915_gem_request *req)
> * seqno update.
> */
> engine->irq_seqno_barrier(engine);
> +
> + /* If we consume the irq, but we are no longer the bottom-half,
> + * the real bottom-half may not have serialised their own
> + * seqno check with the irq-barrier (i.e. may have inspected
> + * the seqno before we believe it coherent since they see
> + * irq_posted == false but we are still running).
> + */
> + rcu_read_lock();
> + tsk = READ_ONCE(engine->breadcrumbs.tasklet);
> + if (tsk && tsk != current)
> + /* Note that if the bottom-half is changed as we
> + * are sending the wake-up, the new bottom-half will
> + * be woken by whomever made the change. We only have
> + * to worry about when we steal the irq-posted for
> + * ourself.
> + */
> + wake_up_process(tsk);
> + rcu_read_unlock();
> +
> if (i915_gem_request_completed(req))
> return true;
> }
>
Looks like added safety which can't harm anything apart from causing
some extra wakeups in cases where the code decides to wake up more than
one waiter. But honestly it was so mind-bending to try to evaluate the
impact of those so I capitulated there.
But as I said, don't see any issues with the code.
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-07-06 9:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-06 7:45 [PATCH 1/3] drm/i915: Always double check for a missed interrupt for new bottom halves Chris Wilson
2016-07-06 7:45 ` [PATCH 2/3] drm/i915: Wake up the bottom-half if we steal their interrupt Chris Wilson
2016-07-06 9:31 ` Tvrtko Ursulin [this message]
2016-07-06 7:45 ` [PATCH 3/3] drm/i915: Group the irq breadcrumb variables into the same cacheline Chris Wilson
2016-07-06 9:18 ` Tvrtko Ursulin
2016-07-06 9:36 ` Chris Wilson
2016-07-06 9:47 ` Tvrtko Ursulin
2016-07-06 8:11 ` ✗ Ro.CI.BAT: failure for series starting with [1/3] drm/i915: Always double check for a missed interrupt for new bottom halves Patchwork
2016-07-06 8:26 ` [PATCH 1/3] " Chris Wilson
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=577CCFDD.2000501@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox