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: Hold irq-off for the entire fake lock period
Date: Thu, 22 Aug 2019 16:00:47 +0300 [thread overview]
Message-ID: <8736htuzgg.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20190822121205.16711-1-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> Sadly lockdep records when the irqs are reenabled and then marks up the
> fake lock as being irq-unsafe. Our hand is forced and so we must mark up
> the entire fake lock critical section as irq-off.
>
Tricky tweaks are tricky. It was not so easy
to lure lockdep to do our bidding :(
> Hopefully this is the last tweak required!
That's the spirit.
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Fixes: d67739268cf0 ("drm/i915/gt: Mark up the nested engine-pm timeline lock as irqsafe")
> 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/gt/intel_engine_pm.c | 28 +++++++++++++++--------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
> index a372d4ea9370..65b5ca74b394 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
> @@ -39,27 +39,32 @@ static int __engine_unpark(struct intel_wakeref *wf)
>
> #if IS_ENABLED(CONFIG_LOCKDEP)
>
> -static inline void __timeline_mark_lock(struct intel_context *ce)
> +static inline unsigned long __timeline_mark_lock(struct intel_context *ce)
> {
> unsigned long flags;
>
> local_irq_save(flags);
> mutex_acquire(&ce->timeline->mutex.dep_map, 2, 0, _THIS_IP_);
> - local_irq_restore(flags);
> +
> + return flags;
> }
>
> -static inline void __timeline_mark_unlock(struct intel_context *ce)
> +static inline void __timeline_mark_unlock(struct intel_context *ce,
> + unsigned long flags)
> {
> mutex_release(&ce->timeline->mutex.dep_map, 0, _THIS_IP_);
> + local_irq_restore(flags);
> }
>
> #else
>
> -static inline void __timeline_mark_lock(struct intel_context *ce)
> +static inline unsigned long __timeline_mark_lock(struct intel_context *ce)
> {
> + return 0;
> }
>
> -static inline void __timeline_mark_unlock(struct intel_context *ce)
> +static inline void __timeline_mark_unlock(struct intel_context *ce,
> + unsigned long flags)
> {
> }
>
> @@ -68,6 +73,8 @@ static inline void __timeline_mark_unlock(struct intel_context *ce)
> static bool switch_to_kernel_context(struct intel_engine_cs *engine)
> {
> struct i915_request *rq;
> + unsigned long flags;
> + bool result = true;
>
> /* Already inside the kernel context, safe to power down. */
> if (engine->wakeref_serial == engine->serial)
> @@ -89,12 +96,12 @@ static bool switch_to_kernel_context(struct intel_engine_cs *engine)
> * retiring the last request, thus all rings should be empty and
> * all timelines idle.
> */
> - __timeline_mark_lock(engine->kernel_context);
> + flags = __timeline_mark_lock(engine->kernel_context);
>
> rq = __i915_request_create(engine->kernel_context, GFP_NOWAIT);
> if (IS_ERR(rq))
> /* Context switch failed, hope for the best! Maybe reset? */
> - return true;
> + goto out_unlock;
>
> intel_timeline_enter(rq->timeline);
>
> @@ -110,9 +117,10 @@ static bool switch_to_kernel_context(struct intel_engine_cs *engine)
> __intel_wakeref_defer_park(&engine->wakeref);
> __i915_request_queue(rq, NULL);
>
> - __timeline_mark_unlock(engine->kernel_context);
> -
> - return false;
> + result = false;
> +out_unlock:
> + __timeline_mark_unlock(engine->kernel_context, flags);
> + return result;
> }
>
> static int __engine_park(struct intel_wakeref *wf)
> --
> 2.23.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-08-22 14:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-22 12:12 [PATCH] drm/i915: Hold irq-off for the entire fake lock period Chris Wilson
2019-08-22 13:00 ` Mika Kuoppala [this message]
2019-08-22 13:06 ` ✓ Fi.CI.BAT: success for " Patchwork
2019-08-23 6:08 ` ✗ Fi.CI.IGT: failure " 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=8736htuzgg.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.