drm/i915: flush delayed_resume_work when suspending
Subsystems (2)
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
@@ -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
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_workwas already queued but did not run yet. If it still didn't run afterintel_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 thepm_rpmsystem-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 beforeintel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due todev_priv->rps.work, this strategy didn't work.Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_drv.c +2
-1@@ -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
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
Reviewed-by Rodrigo Vivi <[email protected]>Quoted 47 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
It is possible that, by the time we run
i915_drm_freeze(),delayed_resume_workwas already queued but did not run yet. If it still didn't run afterintel_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 thepm_rpmsystem-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 beforeintel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due todev_priv->rps.work, this strategy didn't work.Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_drv.c +2
-1@@ -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
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
@@ -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
@@ -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
@@ -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
Rodrigo Vivi
Reviewed-byQuoted 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
Reviewed-by Rodrigo Vivi <[email protected]>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_workwas already queued but did not run yet. If it still didn't run afterintel_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 thepm_rpmsystem-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 beforeintel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due todev_priv->rps.work, this strategy didn't work.Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_drv.c +2
-1@@ -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
Quoted 17 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
It is possible that, by the time we run
i915_drm_freeze(),delayed_resume_workwas already queued but did not run yet. If it still didn't run afterintel_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 thepm_rpmsystem-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 beforeintel_runtime_pm_disable_interrupts(), but since that function needs to be called after the interrupts are already disabled, due todev_priv->rps.work, this strategy didn't work.Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517Signed-off-by Paulo Zanoni <[email protected]>
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@@ -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