Skip to contentSkip to conversation

drm/i915: Avoid GPU hang when coming out of s3 or s4

PATCH In review Peter Antoine 3 participants 5 messages Jun 22, 2015 – Jun 23, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Avoid GPU hang when coming out of s3 or s4

This patch fixes a timing issue that causes a GPU hang when the system comes out of power saving.

During pm_resume, We are submitting batchbuffers before enabling Interrupts this is causing us to miss the context switch interrupt, and in consequence intel_execlists_handle_ctx_events is not triggered.

This patch is based on a patch from Deepak S <[email protected]> from another platform.

The patch fixes an issue introduced by:
commit e7778be1eab918274f79603d7c17b3ec8be77386 drm/i915: Fix startup failure in LRC mode after recent init changes

The above patch added a call to init_context() to fix an issue introduced by a previous patch. But, it then opened up a small timing window for the batches being added by the init_context (basically setting up the context) to complete before the interrupts have been turned on, thus hanging the GPU.

[backport of 4.1 commit 364aece01a2dd748fc36a1e8bf52ef639b0857bd]

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89600

[Jani: fixed typo in subject, massaged the comments a bit]
---
 drivers/gpu/drm/i915/i915_drv.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +10 -3
index ec4d932..169123a 100644
@@ -693,6 +693,16 @@ static int i915_drm_resume(struct drm_device *dev)
 		intel_init_pch_refclk(dev);
 		drm_mode_config_reset(dev);
 
+		/*
+		 * Interrupts have to be enabled before any batches are run.
+		 * If not the GPU will hang. i915_gem_init_hw() will initiate
+		 * batches to update/restore the context.
+		 *
+		 * Modeset enabling in intel_modeset_init_hw() also needs
+		 * working interrupts.
+		 */
+		intel_runtime_pm_enable_interrupts(dev_priv);
+
 		mutex_lock(&dev->struct_mutex);
 		if (i915_gem_init_hw(dev)) {
 			DRM_ERROR("failed to re-initialize GPU, declaring wedged!\n");
@@ -700,9 +710,6 @@ static int i915_drm_resume(struct drm_device *dev)
 		}
 		mutex_unlock(&dev->struct_mutex);
 
-		/* We need working interrupts for modeset enabling ... */
-		intel_runtime_pm_enable_interrupts(dev_priv);
-
 		intel_modeset_init_hw(dev);
 
 		spin_lock_irq(&dev_priv->irq_lock);
Signature · 4 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe stable" in
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Peter Antoine

This patch fixes a timing issue that causes a GPU hang when the system comes out of power saving.

During pm_resume, We are submitting batchbuffers before enabling Interrupts this is causing us to miss the context switch interrupt, and in consequence intel_execlists_handle_ctx_events is not triggered.

This patch is based on a patch from Deepak S <[email protected]> from another platform.

The patch fixes an issue introduced by:
commit e7778be1eab918274f79603d7c17b3ec8be77386 drm/i915: Fix startup failure in LRC mode after recent init changes

The above patch added a call to init_context() to fix an issue introduced by a previous patch. But, it then opened up a small timing window for the batches being added by the init_context (basically setting up the context) to complete before the interrupts have been turned on, thus hanging the GPU.

Quoted 8 lines

[backport of 4.1 commit 364aece01a2dd748fc36a1e8bf52ef639b0857bd]

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89600

[Jani: fixed typo in subject, massaged the comments a bit]

...although based on the patch context I'm not sure why this needs a separate backport. Does it not cherry-pick cleanly to 4.0? The stable team should take care of these automatically.

BR,
Jani.

Quoted 38 lines
---
 drivers/gpu/drm/i915/i915_drv.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +10 -3
index ec4d932..169123a 100644
@@ -693,6 +693,16 @@ static int i915_drm_resume(struct drm_device *dev)
 		intel_init_pch_refclk(dev);
 		drm_mode_config_reset(dev);
 
+		/*
+		 * Interrupts have to be enabled before any batches are run.
+		 * If not the GPU will hang. i915_gem_init_hw() will initiate
+		 * batches to update/restore the context.
+		 *
+		 * Modeset enabling in intel_modeset_init_hw() also needs
+		 * working interrupts.
+		 */
+		intel_runtime_pm_enable_interrupts(dev_priv);
+
 		mutex_lock(&dev->struct_mutex);
 		if (i915_gem_init_hw(dev)) {
 			DRM_ERROR("failed to re-initialize GPU, declaring wedged!\n");
@@ -700,9 +710,6 @@ static int i915_drm_resume(struct drm_device *dev)
 		}
 		mutex_unlock(&dev->struct_mutex);
 
-		/* We need working interrupts for modeset enabling ... */
-		intel_runtime_pm_enable_interrupts(dev_priv);
-
 		intel_modeset_init_hw(dev);
 
 		spin_lock_irq(&dev_priv->irq_lock);
Signature · 1 line
1.9.1
Signature · 3 lines
Jani Nikula, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe stable" in
author Acked-by Jani Nikula
#2 lore raw

Hi Jani,

I was told it needs doing by Daniel.

Peter.

-----Original Message-----
From: Nikula, Jani
Sent: Tuesday, June 23, 2015 8:13 AM
To: Antoine, Peter; [email protected]
Cc: [email protected]; Antoine, Peter
Subject: Re: [PATCH] drm/i915: Avoid GPU hang when coming out of s3 or s4

Quoted 20 lines · Peter Antoine

This patch fixes a timing issue that causes a GPU hang when the system comes out of power saving.

During pm_resume, We are submitting batchbuffers before enabling Interrupts this is causing us to miss the context switch interrupt, and in consequence intel_execlists_handle_ctx_events is not triggered.

This patch is based on a patch from Deepak S <[email protected]> from another platform.

The patch fixes an issue introduced by:
commit e7778be1eab918274f79603d7c17b3ec8be77386 drm/i915: Fix startup failure in LRC mode after recent init changes

The above patch added a call to init_context() to fix an issue introduced by a previous patch. But, it then opened up a small timing window for the batches being added by the init_context (basically setting up the context) to complete before the interrupts have been turned on, thus hanging the GPU.

Quoted 8 lines

[backport of 4.1 commit 364aece01a2dd748fc36a1e8bf52ef639b0857bd]

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89600

[Jani: fixed typo in subject, massaged the comments a bit]

...although based on the patch context I'm not sure why this needs a separate backport. Does it not cherry-pick cleanly to 4.0? The stable team should take care of these automatically.

BR,
Jani.

Quoted 38 lines
---
 drivers/gpu/drm/i915/i915_drv.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.c index ec4d932..169123a 100644

drivers/gpu/drm/i915/i915_drv.c +10 -5
@@ -693,6 +693,16 @@ static int i915_drm_resume(struct drm_device *dev)
 		intel_init_pch_refclk(dev);
 		drm_mode_config_reset(dev);
 
+		/*
+		 * Interrupts have to be enabled before any batches are run.
+		 * If not the GPU will hang. i915_gem_init_hw() will initiate
+		 * batches to update/restore the context.
+		 *
+		 * Modeset enabling in intel_modeset_init_hw() also needs
+		 * working interrupts.
+		 */
+		intel_runtime_pm_enable_interrupts(dev_priv);
+
 		mutex_lock(&dev->struct_mutex);
 		if (i915_gem_init_hw(dev)) {
 			DRM_ERROR("failed to re-initialize GPU, declaring wedged!\n"); @@ 
-700,9 +710,6 @@ static int i915_drm_resume(struct drm_device *dev)
 		}
 		mutex_unlock(&dev->struct_mutex);
 
-		/* We need working interrupts for modeset enabling ... */
-		intel_runtime_pm_enable_interrupts(dev_priv);
-
 		intel_modeset_init_hw(dev);
 
 		spin_lock_irq(&dev_priv->irq_lock);
--

1.9.1

Signature · 3 lines
Jani Nikula, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe stable" in
#3 lore raw
In reply to Jani Nikula
Quoted 7 lines · Jani Nikula
Quoted 6 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89600

[Jani: fixed typo in subject, massaged the comments a bit]
Quoted 5 lines

...although based on the patch context I'm not sure why this needs a separate backport. Does it not cherry-pick cleanly to 4.0? The stable team should take care of these automatically.

stable team said it failed to apply a while back, hence the manual backport. Not sure what exactly upset things, Peter should know if there was anything to resolve.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#4 lore raw

The code moved around. Seems the indenting changed.

Also it was trying to apply the patch to the wrong place, I think the indenting caused it to try to apply to a different function, which it then failed to apply to.

Peter.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Tuesday, June 23, 2015 12:33 PM
To: Nikula, Jani
Cc: Antoine, Peter; stable
Subject: Re: [PATCH] drm/i915: Avoid GPU hang when coming out of s3 or s4

Quoted 7 lines · Jani Nikula
Quoted 6 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89600

[Jani: fixed typo in subject, massaged the comments a bit]
Quoted 5 lines

...although based on the patch context I'm not sure why this needs a separate backport. Does it not cherry-pick cleanly to 4.0? The stable team should take care of these automatically.

stable team said it failed to apply a while back, hence the manual backport. Not sure what exactly upset things, Peter should know if there was anything to resolve. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch