From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Try harder to finish the idle-worker
Date: Mon, 04 Sep 2017 13:19:09 +0300 [thread overview]
Message-ID: <87shg23gwy.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20170901141123.10167-1-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> If a worker requeues itself, it may switch to a different kworker pool,
> which flush_work() considers as complete. To be strict, we then need to
> keep flushing the work until it is no longer pending.
>
> References: https://bugs.freedesktop.org/show_bug.cgi?id=102456
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 3 +--
> drivers/gpu/drm/i915/i915_gem.c | 3 +--
> drivers/gpu/drm/i915/i915_utils.h | 13 +++++++++++++
> 3 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 48572b157222..1dd687a74879 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -4202,8 +4202,7 @@ fault_irq_set(struct drm_i915_private *i915,
> mutex_unlock(&i915->drm.struct_mutex);
>
> /* Flush idle worker to disarm irq */
> - while (flush_delayed_work(&i915->gt.idle_work))
> - ;
> + drain_delayed_work(&i915->gt.idle_work);
>
> return 0;
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index e4cc08bc518c..1829d3fa15d1 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4582,8 +4582,7 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv)
> /* As the idle_work is rearming if it detects a race, play safe and
> * repeat the flush until it is definitely idle.
> */
> - while (flush_delayed_work(&dev_priv->gt.idle_work))
> - ;
> + drain_delayed_work(&dev_priv->gt.idle_work);
>
> /* Assert that we sucessfully flushed all the work and
> * reset the GPU back to its idle, low power state.
> diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
> index 12fc250b47b9..4f7ffa0976b1 100644
> --- a/drivers/gpu/drm/i915/i915_utils.h
> +++ b/drivers/gpu/drm/i915/i915_utils.h
> @@ -119,4 +119,17 @@ static inline void __list_del_many(struct list_head *head,
> WRITE_ONCE(head->next, first);
> }
>
> +/*
> + * Wait until the work is finally complete, even if it tries to postpone
> + * by requeueing itself. Note, that if the worker never cancels itself,
> + * we will spin forever.
> + */
> +static inline void drain_delayed_work(struct delayed_work *dw)
> +{
> + do {
> + while (flush_delayed_work(dw))
> + ;
> + } while (delayed_work_pending(dw));
So we end spinning if someone doesn't let go of mutex.
Add a timeout for doing this and let it slide into
suspend with a error message anyways instead of spinning
forever?
-Mika
> +}
> +
> #endif /* !__I915_UTILS_H */
> --
> 2.14.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-09-04 10:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-01 14:11 [PATCH] drm/i915: Try harder to finish the idle-worker Chris Wilson
2017-09-01 14:57 ` ✗ Fi.CI.BAT: warning for " Patchwork
2017-09-04 8:35 ` [PATCH] " Daniel Vetter
2017-09-04 11:04 ` Chris Wilson
2017-09-05 13:36 ` Tejun Heo
2017-09-05 13:43 ` Chris Wilson
2017-09-05 13:48 ` Tejun Heo
2017-09-04 10:19 ` Mika Kuoppala [this message]
2017-09-04 10:49 ` 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=87shg23gwy.fsf@gaia.fi.intel.com \
--to=mika.kuoppala@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 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.