drm/i915: fix possible RPM ref leaking during RPS disabling
Subsystems (2)
PATCH 1/2 drm/i915: fix possible RPM ref leaking during RPS disabling
In
commit c6df39b5ea6342323a42edfbeeca0a28c643d7ae
Author: Imre Deak <[email protected]> Date: Mon Apr 14 20:24:29 2014 +0300
drm/i915: get a runtime PM ref for the deferred GT powersave enabling
I added an RPM get-ref when enabling RPS from a deferred work, but forgot to add the corresponding put-ref when canceling the work. This may leave RPM disabled.
--- drivers/gpu/drm/i915/intel_pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +3 -1
@@ -4609,7 +4609,9 @@ void intel_disable_gt_powersave(struct drm_device *dev)ironlake_disable_drps (dev);ironlake_disable_rc6 (dev); }else if (IS_GEN6 (dev) ||IS_GEN7 (dev)) { -cancel_delayed_work_sync (&dev_priv->rps.delayed_resume_work); +if (cancel_delayed_work_sync (&dev_priv->rps.delayed_resume_work)) +intel_runtime_pm_put (dev_priv); +cancel_work_sync (&dev_priv->rps.work);mutex_lock (&dev_priv->rps.hw_lock);if (IS_VALLEYVIEW (dev))
Signature · 1 line
1.8.4
PATCH 2/2 drm/i915: disable GT power saving early during system suspend
Atm, we disable GT power saving during the end of the suspend sequence in i915_save_state(). Doing the disabling at that point seems arbitrary. One reason to disable it early though is to have a quiescent HW state before we do anything else (for example save registers). So move the disabling earlier, which also takes care canceling of the deferred RPS enabling work done by intel_disable_gt_powersave().
Note that after the move we'll call intel_disable_gt_powersave() only in case modeset is enabled, but that's anyway the only case where we have it enabled in the first place.
--- drivers/gpu/drm/i915/i915_drv.c | 5 +++-- drivers/gpu/drm/i915/i915_suspend.c | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +3 -2
@@ -468,10 +468,11 @@ static int i915_drm_freeze(struct drm_device *dev)return error; } -cancel_delayed_work_sync (&dev_priv->rps.delayed_resume_work); -drm_irq_uninstall (dev); dev_priv->enable_hotplug_processing = false; + +intel_disable_gt_powersave (dev); +/* * Disable CRTCs directly since we want to preserve sw state * for _thaw.
drivers/gpu/drm/i915/i915_suspend.c +0 -2
@@ -328,8 +328,6 @@ int i915_save_state(struct drm_device *dev) } } -intel_disable_gt_powersave (dev); -/* Cache mode state */ if (INTEL_INFO (dev)->gen <7 ) dev_priv->regfile.saveCACHE_MODE_0 =I915_READ (CACHE_MODE_0 );
Signature · 1 line
1.8.4
Quoted 6 lines · Imre Deak
In
commit
c6df39b5ea6342323a42edfbeeca0a28c643d7aeAuthor: Imre Deak <[email protected]> Date: Mon Apr 14 20:24:29 2014 +0300
Quoted 7 lines
drm/i915: get a runtime PM ref for the deferred GT powersave enabling
I added an RPM get-ref when enabling RPS from a deferred work, but forgot to add the corresponding put-ref when canceling the work. This may leave RPM disabled.
Signed-off-by Imre Deak <[email protected]>
Could we intentionally hit this by e.g. racing a suspend/resume against runtime pm? E.g.
1. disable all outputs, make sure we've entered runtime pm
2. set runtime autosuspend delay to 0
3. suspend/resume
4. autosuspend (hopefully, my understanding is a bit unclear)
->Boom
Would look nice as an igt subtest if it works ;-)
-Daniel
Quoted 26 lines
--- drivers/gpu/drm/i915/intel_pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_pm.c +3
-1@@ -4609,7 +4609,9 @@ void intel_disable_gt_powersave(struct drm_device *dev)ironlake_disable_drps (dev);ironlake_disable_rc6 (dev); }else if (IS_GEN6 (dev) ||IS_GEN7 (dev)) { -cancel_delayed_work_sync (&dev_priv->rps.delayed_resume_work); +if (cancel_delayed_work_sync (&dev_priv->rps.delayed_resume_work)) +intel_runtime_pm_put (dev_priv); +cancel_work_sync (&dev_priv->rps.work);mutex_lock (&dev_priv->rps.hw_lock);if (IS_VALLEYVIEW (dev))Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 22 lines · Daniel Vetter
Quoted 6 lines · Imre Deak
In
commit
c6df39b5ea6342323a42edfbeeca0a28c643d7aeAuthor: Imre Deak <[email protected]> Date: Mon Apr 14 20:24:29 2014 +0300Quoted 7 lines
drm/i915: get a runtime PM ref for the deferred GT powersave enabling
I added an RPM get-ref when enabling RPS from a deferred work, but forgot to add the corresponding put-ref when canceling the work. This may leave RPM disabled.
Signed-off-by Imre Deak <[email protected]>Could we intentionally hit this by e.g. racing a suspend/resume against runtime pm? E.g.
1. disable all outputs, make sure we've entered runtime pm
2. set runtime autosuspend delay to 0
3. suspend/resume
4. autosuspend (hopefully, my understanding is a bit unclear)
Quoted 3 lines
->Boom
Would look nice as an igt subtest if it works ;-)
Yep, works consistently as expected both before and after the fix. I pushed the new subtest, please add here:
Testcase: igt/pm_pc8/system-suspend
--Imre
Quoted 24 lines
-Daniel
Quoted 22 lines
--- drivers/gpu/drm/i915/intel_pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_pm.c +3
-1@@ -4609,7 +4609,9 @@ void intel_disable_gt_powersave(struct drm_device *dev)ironlake_disable_drps (dev);ironlake_disable_rc6 (dev); }else if (IS_GEN6 (dev) ||IS_GEN7 (dev)) { -cancel_delayed_work_sync (&dev_priv->rps.delayed_resume_work); +if (cancel_delayed_work_sync (&dev_priv->rps.delayed_resume_work)) +intel_runtime_pm_put (dev_priv); +cancel_work_sync (&dev_priv->rps.work);mutex_lock (&dev_priv->rps.hw_lock);if (IS_VALLEYVIEW (dev))Signature · 1 line
1.8.4
Quoted 5 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 23 lines · Imre Deak
Quoted 22 lines · Daniel Vetter
Quoted 6 lines · Imre Deak
In
commit
c6df39b5ea6342323a42edfbeeca0a28c643d7aeAuthor: Imre Deak <[email protected]> Date: Mon Apr 14 20:24:29 2014 +0300Quoted 7 lines
drm/i915: get a runtime PM ref for the deferred GT powersave enabling
I added an RPM get-ref when enabling RPS from a deferred work, but forgot to add the corresponding put-ref when canceling the work. This may leave RPM disabled.
Signed-off-by Imre Deak <[email protected]>Could we intentionally hit this by e.g. racing a suspend/resume against runtime pm? E.g.
1. disable all outputs, make sure we've entered runtime pm
2. set runtime autosuspend delay to 0
3. suspend/resume
4. autosuspend (hopefully, my understanding is a bit unclear)
Quoted 7 lines
Quoted 3 lines
->Boom
Would look nice as an igt subtest if it works ;-)
Yep, works consistently as expected both before and after the fix. I pushed the new subtest, please add here:
Testcase: igt/pm_pc8/system-suspend
Now I'm confused: I expected this to blow up without your fix here, and not work with or without it?! Please unconfuse ...
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 26 lines · Daniel Vetter
Quoted 25 lines · Imre Deak
Quoted 24 lines · Daniel Vetter
Quoted 6 lines · Imre Deak
In
commit
c6df39b5ea6342323a42edfbeeca0a28c643d7aeAuthor: Imre Deak <[email protected]> Date: Mon Apr 14 20:24:29 2014 +0300Quoted 7 lines
drm/i915: get a runtime PM ref for the deferred GT powersave enabling
I added an RPM get-ref when enabling RPS from a deferred work, but forgot to add the corresponding put-ref when canceling the work. This may leave RPM disabled.
Signed-off-by Imre Deak <[email protected]>Could we intentionally hit this by e.g. racing a suspend/resume against runtime pm? E.g.
1. disable all outputs, make sure we've entered runtime pm
2. set runtime autosuspend delay to 0
3. suspend/resume
4. autosuspend (hopefully, my understanding is a bit unclear)->Boom
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Would look nice as an igt subtest if it works ;-)
Yep, works consistently as expected both before and after the fix. I pushed the new subtest, please add here:
Testcase: igt/pm_pc8/system-suspendNow I'm confused: I expected this to blow up without your fix here, and not work with or without it?! Please unconfuse ...
Blows up consistently before the fix and passes consistently after.
--Imre
Quoted 1 line
-Daniel
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Robert Beckett
Reviewed-byQuoted 28 lines · Daniel Vetter
Quoted 27 lines · Imre Deak
Quoted 25 lines · Daniel Vetter
Quoted 6 lines · Imre Deak
In
commit
c6df39b5ea6342323a42edfbeeca0a28c643d7aeAuthor: Imre Deak <[email protected]> Date: Mon Apr 14 20:24:29 2014 +0300Quoted 7 lines
drm/i915: get a runtime PM ref for the deferred GT powersave enabling
I added an RPM get-ref when enabling RPS from a deferred work, but forgot to add the corresponding put-ref when canceling the work. This may leave RPM disabled.
Signed-off-by Imre Deak <[email protected]>Could we intentionally hit this by e.g. racing a suspend/resume against runtime pm? E.g.
1. disable all outputs, make sure we've entered runtime pm
2. set runtime autosuspend delay to 0
3. suspend/resume
4. autosuspend (hopefully, my understanding is a bit unclear)->Boom
Would look nice as an igt subtest if it works ;-)
Quoted 8 lines
Quoted 3 lines
Yep, works consistently as expected both before and after the fix. I pushed the new subtest, please add here:
Testcase: igt/pm_pc8/system-suspendNow I'm confused: I expected this to blow up without your fix here, and not work with or without it?! Please unconfuse ...
-Daniel
Im not sure what you are expecting to go boom.
It is pretty difficult to get a race between suspend/resume and runtime pm. During system suspend, the pm core grabs a runtime ref without resume callbacks, and releases it on the resume. (see https://www.kernel.org/doc/Documentation/power/runtime_pm.txt part 6).
Also, as i915_drm_freeze does a runtime pm get, at step 3, it will cause a runtime resume before doing the system suspend. On the system resume, it will do a runtime pm put, which will cause a runtime suspend due to autosuspend delay being 0, and so step 4, autosuspend will occur. This should all work fine (assuming the patch is applied to handle any refcounting between back to back resume->suspend which cancels the enable before it is executed).
It all looks fine to me.
Quoted 43 lines · Robert Beckett
Quoted 28 lines · Daniel Vetter
Quoted 27 lines · Imre Deak
Quoted 25 lines · Daniel Vetter
Quoted 6 lines · Imre Deak
In
commit
c6df39b5ea6342323a42edfbeeca0a28c643d7aeAuthor: Imre Deak <[email protected]> Date: Mon Apr 14 20:24:29 2014 +0300Quoted 7 lines
drm/i915: get a runtime PM ref for the deferred GT powersave enabling
I added an RPM get-ref when enabling RPS from a deferred work, but forgot to add the corresponding put-ref when canceling the work. This may leave RPM disabled.
Signed-off-by Imre Deak <[email protected]>Could we intentionally hit this by e.g. racing a suspend/resume against runtime pm? E.g.
1. disable all outputs, make sure we've entered runtime pm
2. set runtime autosuspend delay to 0
3. suspend/resume
4. autosuspend (hopefully, my understanding is a bit unclear)->Boom
Would look nice as an igt subtest if it works ;-)
Quoted 8 lines
Quoted 3 lines
Yep, works consistently as expected both before and after the fix. I pushed the new subtest, please add here:
Testcase: igt/pm_pc8/system-suspendNow I'm confused: I expected this to blow up without your fix here, and not work with or without it?! Please unconfuse ...
-DanielIm not sure what you are expecting to go boom.
It is pretty difficult to get a race between suspend/resume and runtime pm. During system suspend, the pm core grabs a runtime ref without resume callbacks, and releases it on the resume. (see
https://www.kernel.org/doc/Documentation/power/runtime_pm.txt part 6).
Quoted 7 lines
Also, as
i915_drm_freezedoes a runtime pm get, at step 3, it will cause a runtime resume before doing the system suspend. On the system resume, it will do a runtime pm put, which will cause a runtime suspend due to autosuspend delay being 0, and so step 4, autosuspend will occur. This should all work fine (assuming the patch is applied to handle any refcounting between back to backresume->suspendwhich cancels the enable before it is executed).
Rest assured that Imre's igt goes indeed boom. We run the rps stuff delayed which makes the race possible, as long as you autosuspend quickly enough. You might want to run the testcase to confirm that ;-)
And thanks a lot for mentioning your concerns, this kind of information and questions are exactly what I expect from patch reviewers. I will augment the commit message a bit to make it clear how stuff blows up.
Quoted 3 lines
It all looks fine to me.
Reviewed-by Robert Beckett <[email protected]>
Thanks, Daniel
Quoted 5 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch