Skip to contentSkip to conversation

drm/i915: flush delayed_resume_work when suspending

PATCH Applied Paulo Zanoni 3 participants 6 messages Jun 27, 2014 – Jul 1, 2014

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

PATCH 1/1 drm/i915: flush delayed_resume_work when suspending

From: Paulo Zanoni <[email protected]>

It is possible that, by the time we run i915_drm_freeze(), delayed_resume_work was already queued but did not run yet. If it still didn't run after intel_runtime_pm_disable_interrupts(), by the time it runs it will try to change the interrupt registers with the interrupts already disabled, which will trigger a WARN. We can reliably reproduce this with the pm_rpm system-suspend test case.

In order to avoid the problem, we have to flush the work before disabling the interrupts. We could also cancel the work instead of flushing it, but that would require us to put a runtime PM reference - and any other resource we may need in the future - in case the work was already queued, so I believe flushing the work is more future-proof, although less efficient. But I can also change this part if someone requests.

Another thing I tried was to move the intel_suspend_gt_powersave() call to before intel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due to dev_priv->rps.work, this strategy didn't work.

Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517

---
 drivers/gpu/drm/i915/i915_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index e64547e..672694b 100644
@@ -524,6 +524,8 @@ static int i915_drm_freeze(struct drm_device *dev)
 			return error;
 		}
 
+		flush_delayed_work(&dev_priv->rps.delayed_resume_work);
+
 		intel_runtime_pm_disable_interrupts(dev);
 		dev_priv->enable_hotplug_processing = false;
 
Signature · 1 line
2.0.0
Reviewed-by on v1 1/1
#1 lore raw

I have the feeling the safest side would be disable rc6 on resume instead of force its enabling... or am I missing something?
why don't you just cancel the work? and put another after resume?

but if the patch really solves the problem and this is what you meant feel free to use:

Quoted 51 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

It is possible that, by the time we run i915_drm_freeze(), delayed_resume_work was already queued but did not run yet. If it still didn't run after intel_runtime_pm_disable_interrupts(), by the time it runs it will try to change the interrupt registers with the interrupts already disabled, which will trigger a WARN. We can reliably reproduce this with the pm_rpm system-suspend test case.

In order to avoid the problem, we have to flush the work before disabling the interrupts. We could also cancel the work instead of flushing it, but that would require us to put a runtime PM reference - and any other resource we may need in the future - in case the work was already queued, so I believe flushing the work is more future-proof, although less efficient. But I can also change this part if someone requests.

Another thing I tried was to move the intel_suspend_gt_powersave() call to before intel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due to dev_priv->rps.work, this strategy didn't work.

Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517

---
 drivers/gpu/drm/i915/i915_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -1
index e64547e..672694b 100644
@@ -524,6 +524,8 @@ static int i915_drm_freeze(struct drm_device *dev)
                        return error;
                }
 
+               flush_delayed_work(&dev_priv->rps.delayed_resume_work);
+
                intel_runtime_pm_disable_interrupts(dev);
                dev_priv->enable_hotplug_processing = false;
 
--

2.0.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

2014-06-27 19:30 GMT-03:00 Rodrigo Vivi <[email protected]>:

Quoted 2 lines

I have the feeling the safest side would be disable rc6 on resume instead of force its enabling... or am I missing something?

It will be enabled, then disabled.

Quoted 4 lines

why don't you just cancel the work? and put another after resume?

but if the patch really solves the problem and this is what you meant feel free to use:

What you're suggesting is the "We could also" case mentioned in the second paragraph of the commit message. I even wrote and tested that patch, but Jesse seemed to prefer the "flush" version instead of the "cancel" one. I'll send the other version to the list, then reviewers and maintainers can decide which one they prefer :)

Quoted 64 lines
Quoted 47 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

It is possible that, by the time we run i915_drm_freeze(), delayed_resume_work was already queued but did not run yet. If it still didn't run after intel_runtime_pm_disable_interrupts(), by the time it runs it will try to change the interrupt registers with the interrupts already disabled, which will trigger a WARN. We can reliably reproduce this with the pm_rpm system-suspend test case.

In order to avoid the problem, we have to flush the work before disabling the interrupts. We could also cancel the work instead of flushing it, but that would require us to put a runtime PM reference - and any other resource we may need in the future - in case the work was already queued, so I believe flushing the work is more future-proof, although less efficient. But I can also change this part if someone requests.

Another thing I tried was to move the intel_suspend_gt_powersave() call to before intel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due to dev_priv->rps.work, this strategy didn't work.

Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517

---
 drivers/gpu/drm/i915/i915_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -1
index e64547e..672694b 100644
@@ -524,6 +524,8 @@ static int i915_drm_freeze(struct drm_device *dev)
                        return error;
                }
 
+               flush_delayed_work(&dev_priv->rps.delayed_resume_work);
+
                intel_runtime_pm_disable_interrupts(dev);
                dev_priv->enable_hotplug_processing = false;
 
--

2.0.0

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

Signature · 1 line
Paulo Zanoni
#3 lore raw

PATCH 1/1 drm/i915: cancel delayed_resume_work when suspending

From: Paulo Zanoni <[email protected]>

It is possible that, by the time we run i915_drm_freeze(), delayed_resume_work was already queued but did not run yet. If it still didn't run after intel_runtime_pm_disable_interrupts(), by the time it runs it will try to change the interrupt registers with the interrupts already disabled, which will trigger a WARN. We can reliably reproduce this with the pm_rpm system-suspend test case.

In order to avoid the probelm, we flush the work and put the necessary resources in case the work was already scheduled.

Another thing I tried was to move the intel_suspend_gt_powersave() call to before intel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due to dev_priv->rps.work, this strategy didn't work.

Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517

---
 drivers/gpu/drm/i915/i915_drv.c  | 2 ++
 drivers/gpu/drm/i915/intel_drv.h | 1 +
 drivers/gpu/drm/i915/intel_pm.c  | 8 ++++++++
 3 files changed, 11 insertions(+)

Now the maintainers and reviewers can choose if they prefer the "cancel" or the "flush" version of the patch.

drivers/gpu/drm/i915/i915_drv.c +2 -0
index 6eb45ac..dad7e8b 100644
@@ -520,6 +520,8 @@ static int i915_drm_freeze(struct drm_device *dev)
 			return error;
 		}
 
+		intel_cancel_rps_resume_work(dev_priv);
+
 		intel_runtime_pm_disable_interrupts(dev);
 		dev_priv->enable_hotplug_processing = false;
 
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 5f7c7bd..b122b12 100644
@@ -993,6 +993,7 @@ void intel_enable_gt_powersave(struct drm_device *dev);
 void intel_disable_gt_powersave(struct drm_device *dev);
 void intel_suspend_gt_powersave(struct drm_device *dev);
 void intel_reset_gt_powersave(struct drm_device *dev);
+void intel_cancel_rps_resume_work(struct drm_i915_private *dev_priv);
 void ironlake_teardown_rc6(struct drm_device *dev);
 void gen6_update_ring_freq(struct drm_device *dev);
 void gen6_rps_idle(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_pm.c +8 -0
index a90fdbd..664099f 100644
@@ -4911,6 +4911,14 @@ void intel_disable_gt_powersave(struct drm_device *dev)
 	}
 }
 
+/* This function needs to put/clear any resources that the
+ * rps.delayed_resume_work function puts/clears. */
+void intel_cancel_rps_resume_work(struct drm_i915_private *dev_priv)
+{
+	if (cancel_delayed_work_sync(&dev_priv->rps.delayed_resume_work))
+		intel_runtime_pm_put(dev_priv);
+}
+
 static void intel_gen6_powersave_work(struct work_struct *work)
 {
 	struct drm_i915_private *dev_priv =
Signature · 1 line
2.0.0
Reviewed-by
#4 lore raw
In reply to Paulo Zanoni
Quoted 7 lines · Paulo Zanoni

2014-06-27 19:30 GMT-03:00 Rodrigo Vivi <[email protected]>:

Quoted 1 line

I have the feeling the safest side would be disable rc6 on resume

instead of

Quoted 1 line

force its enabling... or am I missing something?

It will be enabled, then disabled.

oh that's true!

Quoted 10 lines
Quoted 4 lines

why don't you just cancel the work? and put another after resume?

but if the patch really solves the problem and this is what you meant

feel

Quoted 1 line

free to use:

What you're suggesting is the "We could also" case mentioned in the second paragraph of the commit message. I even wrote and tested that patch,

Yeah, reading again this is exactly what I had in mind.

Quoted 4 lines

but Jesse seemed to prefer the "flush" version instead of the "cancel" one. I'll send the other version to the list, then reviewers and maintainers can decide which one they prefer :)

I don't have stronger preferences. So, feel free to use:

Thanks for the explanations,
Rodrigo.

Quoted 72 lines
Quoted 6 lines

On Fri, Jun 27, 2014 at 2:51 PM, Paulo Zanoni <[email protected]>

Quoted 47 lines · wrote:
Quoted 47 lines

From: Paulo Zanoni <[email protected]>

It is possible that, by the time we run i915_drm_freeze(), delayed_resume_work was already queued but did not run yet. If it still didn't run after intel_runtime_pm_disable_interrupts(), by the time it runs it will try to change the interrupt registers with the interrupts already disabled, which will trigger a WARN. We can reliably reproduce this with the pm_rpm system-suspend test case.

In order to avoid the problem, we have to flush the work before disabling the interrupts. We could also cancel the work instead of flushing it, but that would require us to put a runtime PM reference - and any other resource we may need in the future - in case the work was already queued, so I believe flushing the work is more future-proof, although less efficient. But I can also change this part if someone requests.

Another thing I tried was to move the intel_suspend_gt_powersave() call to before intel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due to dev_priv->rps.work, this strategy didn't work.

Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517

---
 drivers/gpu/drm/i915/i915_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -1
index e64547e..672694b 100644
@@ -524,6 +524,8 @@ static int i915_drm_freeze(struct drm_device *dev)
                        return error;
                }
 
+               flush_delayed_work(&dev_priv->rps.delayed_resume_work);
+
                intel_runtime_pm_disable_interrupts(dev);
                dev_priv->enable_hotplug_processing = false;
 
--

2.0.0

Quoted 12 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

--
Paulo Zanoni

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer Applied
#5 lore raw
In reply to Paulo Zanoni
Quoted 17 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

It is possible that, by the time we run i915_drm_freeze(), delayed_resume_work was already queued but did not run yet. If it still didn't run after intel_runtime_pm_disable_interrupts(), by the time it runs it will try to change the interrupt registers with the interrupts already disabled, which will trigger a WARN. We can reliably reproduce this with the pm_rpm system-suspend test case.

In order to avoid the problem, we have to flush the work before disabling the interrupts. We could also cancel the work instead of flushing it, but that would require us to put a runtime PM reference - and any other resource we may need in the future - in case the work was already queued, so I believe flushing the work is more future-proof, although less efficient. But I can also change this part if someone requests.

Quoted 8 lines

Another thing I tried was to move the intel_suspend_gt_powersave() call to before intel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due to dev_priv->rps.work, this strategy didn't work.

Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517

Pushed to dinq, thanks for the patch and review.

BR,
Jani.

Quoted 24 lines
---
 drivers/gpu/drm/i915/i915_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index e64547e..672694b 100644
@@ -524,6 +524,8 @@ static int i915_drm_freeze(struct drm_device *dev)
 			return error;
 		}
 
+		flush_delayed_work(&dev_priv->rps.delayed_resume_work);
+
 		intel_runtime_pm_disable_interrupts(dev);
 		dev_priv->enable_hotplug_processing = false;
 
Signature · 6 lines
2.0.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center