From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v3 1/5] drm/i915: Report both waiters and success from intel_engine_wakeup()
Date: Mon, 27 Feb 2017 10:03:32 +0000 [thread overview]
Message-ID: <b18358e1-7890-0b5e-6152-aad2b76005c9@linux.intel.com> (raw)
In-Reply-To: <20170224180149.8737-1-chris@chris-wilson.co.uk>
On 24/02/2017 18:01, Chris Wilson wrote:
> The two users of the return value from intel_engine_wakeup() are
> expecting different results. In the breadcrumbs hangcheck, we are using
> it to determine whether wake_up_process() detected the waiter was
> currently running (and if so we presume that it hasn't yet missed the
> interrupt). However, in the fake_irq path, we are using the return value
> as a check as to whether there are any waiters, and so we may
> incorrectly stop the fake-irq if that waiter was currently running.
>
> To handle the two different needs, return both bits of information!
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/intel_breadcrumbs.c | 28 +++++++++++++++++++++++++++-
> drivers/gpu/drm/i915/intel_ringbuffer.h | 26 +++-----------------------
> 2 files changed, 30 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_breadcrumbs.c b/drivers/gpu/drm/i915/intel_breadcrumbs.c
> index 027c93e34c97..64e1b0c2d8b6 100644
> --- a/drivers/gpu/drm/i915/intel_breadcrumbs.c
> +++ b/drivers/gpu/drm/i915/intel_breadcrumbs.c
> @@ -26,6 +26,32 @@
>
> #include "i915_drv.h"
>
> +unsigned int intel_engine_wakeup(struct intel_engine_cs *engine)
How come you decided to un-inline it? Changes shouldn't have made a big
difference to its size I would have thought.
> +{
> + unsigned int ret = 0;
Optional bikeshed - maybe call it res or something, since ret is usually
used for < 0 || 0.
> +
> + /* Note that for this not to dangerously chase a dangling pointer,
> + * we must hold the rcu_read_lock here.
> + *
> + * Also note that tsk is likely to be in !TASK_RUNNING state so an
> + * early test for tsk->state != TASK_RUNNING before wake_up_process()
> + * is unlikely to be beneficial.
> + */
> + if (intel_engine_has_waiter(engine)) {
> + struct task_struct *tsk;
> +
> + ret = ENGINE_WAKEUP_WAITER;
> +
> + rcu_read_lock();
> + tsk = rcu_dereference(engine->breadcrumbs.irq_seqno_bh);
> + if (tsk && !wake_up_process(tsk))
> + ret |= ENGINE_WAKEUP_ACTIVE;
> + rcu_read_unlock();
> + }
> +
> + return ret;
> +}
> +
> static unsigned long wait_timeout(void)
> {
> return round_jiffies_up(jiffies + DRM_I915_HANGCHECK_JIFFIES);
> @@ -49,7 +75,7 @@ static void intel_breadcrumbs_hangcheck(unsigned long data)
> * to process the pending interrupt (e.g, low priority task on a loaded
> * system) and wait until it sleeps before declaring a missed interrupt.
> */
> - if (!intel_engine_wakeup(engine)) {
> + if (intel_engine_wakeup(engine) & ENGINE_WAKEUP_ACTIVE) {
> mod_timer(&b->hangcheck, wait_timeout());
> return;
> }
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
> index 0f29e07a9581..7d753dc1b89d 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.h
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
> @@ -642,29 +642,9 @@ static inline bool intel_engine_has_waiter(const struct intel_engine_cs *engine)
> return rcu_access_pointer(engine->breadcrumbs.irq_seqno_bh);
> }
>
> -static inline bool intel_engine_wakeup(const struct intel_engine_cs *engine)
> -{
> - bool wakeup = false;
> -
> - /* Note that for this not to dangerously chase a dangling pointer,
> - * we must hold the rcu_read_lock here.
> - *
> - * Also note that tsk is likely to be in !TASK_RUNNING state so an
> - * early test for tsk->state != TASK_RUNNING before wake_up_process()
> - * is unlikely to be beneficial.
> - */
> - if (intel_engine_has_waiter(engine)) {
> - struct task_struct *tsk;
> -
> - rcu_read_lock();
> - tsk = rcu_dereference(engine->breadcrumbs.irq_seqno_bh);
> - if (tsk)
> - wakeup = wake_up_process(tsk);
> - rcu_read_unlock();
> - }
> -
> - return wakeup;
> -}
> +unsigned int intel_engine_wakeup(struct intel_engine_cs *engine);
> +#define ENGINE_WAKEUP_WAITER BIT(0)
> +#define ENGINE_WAKEUP_ACTIVE BIT(1)
>
> void intel_engine_reset_breadcrumbs(struct intel_engine_cs *engine);
> void intel_engine_fini_breadcrumbs(struct intel_engine_cs *engine);
>
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:[~2017-02-27 10:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 18:01 [PATCH v3 1/5] drm/i915: Report both waiters and success from intel_engine_wakeup() Chris Wilson
2017-02-24 18:01 ` [PATCH v3 2/5] drm/i915: Signal first fence from irq handler if complete Chris Wilson
2017-02-25 10:05 ` [PATCH v4] " Chris Wilson
2017-02-27 10:04 ` Tvrtko Ursulin
2017-02-24 18:01 ` [PATCH v3 3/5] drm/i915: Defer enabling hangcheck to the first fake breadcrumb interrupt Chris Wilson
2017-02-27 10:15 ` Tvrtko Ursulin
2017-02-24 18:01 ` [PATCH v3 4/5] drm/i915: Delay disabling the user interrupt for breadcrumbs Chris Wilson
2017-02-27 10:31 ` Tvrtko Ursulin
2017-02-27 11:02 ` Chris Wilson
2017-02-24 18:01 ` [PATCH v3 5/5] drm/i915: Simplify intel_engine_wakeup() Chris Wilson
2017-02-27 10:34 ` Tvrtko Ursulin
2017-02-24 18:52 ` ✗ Fi.CI.BAT: warning for series starting with [v3,1/5] drm/i915: Report both waiters and success from intel_engine_wakeup() Patchwork
2017-02-25 10:52 ` ✓ Fi.CI.BAT: success for series starting with [v3,1/5] drm/i915: Report both waiters and success from intel_engine_wakeup() (rev2) Patchwork
2017-02-27 10:03 ` Tvrtko Ursulin [this message]
2017-02-27 10:35 ` [PATCH v3 1/5] drm/i915: Report both waiters and success from intel_engine_wakeup() 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=b18358e1-7890-0b5e-6152-aad2b76005c9@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