From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/9] drm/i915: Flush logical context image out to memory upon suspend
Date: Fri, 15 Jul 2016 13:41:33 +0300 [thread overview]
Message-ID: <87inw7p4iq.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <1468577481-4798-2-git-send-email-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> Before suspend, and especially before building the hibernation image, we
> need to context image to be coherent in memory. To do this we require
> that we perform a context switch to a disposable context (i.e. the
> dev_priv->kernel_context) - when that switch is complete, all other
> context images will be complete. This leaves the kernel_context image as
> incomplete, but fortunately that is disposable and we can do a quick
> fixup of the logical state after resuming.
>
> Testcase: igt/gem_exec_suspend # bsw
> References: https://bugs.freedesktop.org/show_bug.cgi?id=96526
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_drv.c | 4 +---
> drivers/gpu/drm/i915/i915_drv.h | 1 +
> drivers/gpu/drm/i915/i915_gem.c | 46 +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 48 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 15440123e38d..c5b7b8e0678a 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -1590,9 +1590,7 @@ static int i915_drm_resume(struct drm_device *dev)
>
> intel_csr_ucode_resume(dev_priv);
>
> - mutex_lock(&dev->struct_mutex);
> - i915_gem_restore_gtt_mappings(dev);
> - mutex_unlock(&dev->struct_mutex);
> + i915_gem_resume(dev);
>
> i915_restore_state(dev);
> intel_opregion_setup(dev_priv);
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 1ec523d29789..e73c0fc84c73 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3384,6 +3384,7 @@ void i915_gem_init_swizzling(struct drm_device *dev);
> void i915_gem_cleanup_engines(struct drm_device *dev);
> int __must_check i915_gem_wait_for_idle(struct drm_i915_private *dev_priv);
> int __must_check i915_gem_suspend(struct drm_device *dev);
> +void i915_gem_resume(struct drm_device *dev);
> void __i915_add_request(struct drm_i915_gem_request *req,
> struct drm_i915_gem_object *batch_obj,
> bool flush_caches);
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index cf0e8aa8035c..8b42a5101f11 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4974,6 +4974,35 @@ i915_gem_stop_engines(struct drm_device *dev)
> dev_priv->gt.stop_engine(engine);
> }
>
> +static int switch_to_kernel_context(struct drm_i915_private *dev_priv)
> +{
> + struct intel_engine_cs *engine;
> +
> + for_each_engine(engine, dev_priv) {
> + struct drm_i915_gem_request *req;
> + int ret;
> +
> + if (engine->last_context == NULL)
> + continue;
> +
> + if (engine->last_context == dev_priv->kernel_context)
> + continue;
> +
> + req = i915_gem_request_alloc(engine, dev_priv->kernel_context);
> + if (IS_ERR(req))
> + return PTR_ERR(req);
> +
> + ret = 0;
> + if (!i915.enable_execlists)
> + ret = i915_switch_context(req);
> + i915_add_request_no_flush(req);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
Why do you want keep this separate? Altho the evict one is a little
bit different and as I didn't see any perf implications: Why not
consolidate the evict one and this one and have i915_gem_idle which
would park to default and wait for idle.
Other than that, this all looks fine.
-Mika
> int
> i915_gem_suspend(struct drm_device *dev)
> {
> @@ -4983,6 +5012,10 @@ i915_gem_suspend(struct drm_device *dev)
> intel_suspend_gt_powersave(dev_priv);
>
> mutex_lock(&dev->struct_mutex);
> + ret = switch_to_kernel_context(dev_priv);
> + if (ret)
> + goto err;
> +
> ret = i915_gem_wait_for_idle(dev_priv);
> if (ret)
> goto err;
> @@ -5009,6 +5042,19 @@ err:
> return ret;
> }
>
> +void i915_gem_resume(struct drm_device *dev)
> +{
> + struct drm_i915_private *dev_priv = to_i915(dev);
> +
> + mutex_lock(&dev->struct_mutex);
> +
> + if (i915.enable_execlists)
> + intel_lr_context_reset(dev_priv, dev_priv->kernel_context);
> +
> + i915_gem_restore_gtt_mappings(dev);
> + mutex_unlock(&dev->struct_mutex);
> +}
> +
> void i915_gem_init_swizzling(struct drm_device *dev)
> {
> struct drm_i915_private *dev_priv = to_i915(dev);
> --
> 2.8.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
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-15 10:42 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-15 10:11 Derive requests from dma-buf fence Chris Wilson
2016-07-15 10:11 ` [PATCH 1/9] drm/i915: Flush logical context image out to memory upon suspend Chris Wilson
2016-07-15 10:41 ` Mika Kuoppala [this message]
2016-07-15 11:11 ` Chris Wilson
2016-07-15 10:11 ` [PATCH 2/9] drm/i915: Move GEM request routines to i915_gem_request.c Chris Wilson
2016-07-15 10:41 ` Joonas Lahtinen
2016-07-15 10:43 ` Mika Kuoppala
2016-07-15 10:11 ` [PATCH 3/9] drm/i915: Retire oldest completed request before allocating next Chris Wilson
2016-07-15 10:11 ` [PATCH 4/9] drm/i915: Mark all current requests as complete before resetting them Chris Wilson
2016-07-15 10:11 ` [PATCH 5/9] drm/i915: Derive GEM requests from dma-fence Chris Wilson
2016-07-15 10:11 ` [PATCH 6/9] drm/i915: Disable waitboosting for fence_wait() Chris Wilson
2016-07-15 10:47 ` Joonas Lahtinen
2016-07-15 11:08 ` Chris Wilson
2016-07-15 11:49 ` Chris Wilson
2016-07-15 12:07 ` Joonas Lahtinen
2016-07-15 10:49 ` Mika Kuoppala
2016-07-15 11:06 ` Chris Wilson
2016-07-15 11:53 ` [PATCH v2] " Chris Wilson
2016-07-15 12:25 ` Mika Kuoppala
2016-07-15 10:11 ` [PATCH 7/9] drm/i915: Disable waitboosting for mmioflips/semaphores Chris Wilson
2016-07-15 11:08 ` Mika Kuoppala
2016-07-15 12:50 ` Chris Wilson
2016-07-15 12:26 ` Mika Kuoppala
2016-07-15 10:11 ` [PATCH 8/9] drm/i915: Wait on external rendering for GEM objects Chris Wilson
2016-07-18 10:18 ` Chris Wilson
2016-07-19 6:45 ` Daniel Vetter
2016-07-15 10:11 ` [PATCH 9/9] drm/i915: Mark imported dma-buf objects as being coherent Chris Wilson
2016-07-15 11:33 ` Mika Kuoppala
2016-07-15 10:48 ` ✗ Ro.CI.BAT: failure for series starting with [1/9] drm/i915: Flush logical context image out to memory upon suspend 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=87inw7p4iq.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.