diff mbox

RFC drm/i915: Switch to kernel context before idling at runtime

Message ID 20180426094157.1981-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson April 26, 2018, 9:41 a.m. UTC
We can reduce our exposure to random neutrinos by resting on the kernel
context having flushed out the user contexts to system memory and
beyond. The corollary is that we then we require two passes through the
idle handler to go to sleep, which on a truly idle system involves an
extra pass through the slow and irregular retire work handler.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Chris Wilson April 26, 2018, 10:38 a.m. UTC | #1
Quoting Patchwork (2018-04-26 11:18:58)
> == Series Details ==
> 
> Series: RFC drm/i915: Switch to kernel context before idling at runtime
> URL   : https://patchwork.freedesktop.org/series/42321/
> State : failure
> 
> == Summary ==
> 
> = CI Bug Log - changes from CI_DRM_4101 -> Patchwork_8809 =
> 
> == Summary - FAILURE ==
> 
>   Serious unknown changes coming with Patchwork_8809 absolutely need to be
>   verified manually.
>   
>   If you think the reported changes have nothing to do with the changes
>   introduced in Patchwork_8809, please notify your bug team to allow them
>   to document this new failure mode, which will reduce false positives in CI.
> 
>   External URL: https://patchwork.freedesktop.org/api/1.0/series/42321/revisions/1/mbox/
> 
> == Possible new issues ==
> 
>   Here are the unknown changes that may have been introduced in Patchwork_8809:
> 
>   === IGT changes ===
> 
>     ==== Possible regressions ====

Welp, that was embarrassing. So imagine I remembered to add the lock.
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 795ca83aed7a..041a11c395a3 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3554,6 +3554,16 @@  i915_gem_idle_work_handler(struct work_struct *work)
 	if (!READ_ONCE(dev_priv->gt.awake))
 		return;
 
+	/*
+	 * Flush out the last user context, leaving only the pinned
+	 * kernel context resident. When we are idling on the kernel_context,
+	 * no more new requests (with a context switch) are emitted and we
+	 * can finally rest. A consequence is that the idle work handler is
+	 * always called at least twice before idling (and if the system is
+	 * idle that implies a round trip through the retire worker).
+	 */
+	i915_gem_switch_to_kernel_context(dev_priv);
+
 	/*
 	 * Wait for last execlists context complete, but bail out in case a
 	 * new request is submitted. As we don't trust the hardware, we