drm/i915: fix hpd work vs. flush_work in the pageflip code deadlock
Subsystems (2)
PATCH 1/1 drm/i915: fix hpd work vs. flush_work in the pageflip code deadlock
Historically we've run our own driver hotplug handling in our own work-queue, which then launched the drm core hotplug handling in the system workqueue. This is important since we flush our own driver workqueue in the pageflip code while hodling modeset locks, and only the drm hotplug code grabbed these locks. But with
commit 69787f7da6b2adc4054357a661aaa1701a9ca76f
Author: Daniel Vetter <[email protected]> Date: Tue Oct 23 18:23:34 2012 +0000
drm: run the hpd irq event code directly
this was changed and now we could deadlock in our flip handler if there's a hotplug work blocking the progress of the crucial unpin works. So this broke the careful deadlock avoidance implemented in
commit b4a98e57fc27854b5938fc8b08b68e5e68b91e1f
Author: Chris Wilson <[email protected]> Date: Thu Nov 1 09:26:26 2012 +0000
drm/i915: Flush outstanding unpin tasks before pageflipping
Since the rule thus far has been that work items on our own workqueue may never grab modeset locks simply restore that rule again.
References: http://permalink.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/26239
--- drivers/gpu/drm/i915/i915_irq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +1 -2
@@ -1027,8 +1027,7 @@ static inline void intel_hpd_irq_handler(struct drm_device *dev, dev_priv->display.hpd_irq_setup (dev);spin_unlock (&dev_priv->irq_lock); -queue_work (dev_priv->wq, - &dev_priv->hotplug_work); +schedule_work (&dev_priv->hotplug_work); }static void gmbus_irq_handler (struct drm_device *dev)
Signature · 1 line
1.8.4.rc3
Quoted 25 lines · Daniel Vetter
Historically we've run our own driver hotplug handling in our own work-queue, which then launched the drm core hotplug handling in the system workqueue. This is important since we flush our own driver workqueue in the pageflip code while hodling modeset locks, and only the drm hotplug code grabbed these locks. But with
commit
69787f7da6b2adc4054357a661aaa1701a9ca76fAuthor: Daniel Vetter <[email protected]> Date: Tue Oct 23 18:23:34 2012 +0000drm: run the hpd irq event code directly
this was changed and now we could deadlock in our flip handler if there's a hotplug work blocking the progress of the crucial unpin works. So this broke the careful deadlock avoidance implemented in
commit
b4a98e57fc27854b5938fc8b08b68e5e68b91e1fAuthor: Chris Wilson <[email protected]> Date: Thu Nov 1 09:26:26 2012 +0000drm/i915: Flush outstanding unpin tasks before pageflipping
Since the rule thus far has been that work items on our own workqueue may never grab modeset locks simply restore that rule again.
Quoted 6 lines
Cc Chris Wilson <[email protected]>Cc Stuart Abercrombie <[email protected]>Reported-by Stuart Abercrombie <[email protected]>References: http://permalink.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/26239
Signed-off-by Daniel Vetter <[email protected]>
That wins for simplicity, and it is indeed the only caller that requires mode_config.lock, so
Bonus would a reminder in i915_drv.h to say that we cannot put items that require mode_config.lock onto the wq, and that they should go onto the global workqueue instead.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 1/1 drm/i915: fix hpd work vs. flush_work in the pageflip code deadlock
Historically we've run our own driver hotplug handling in our own work-queue, which then launched the drm core hotplug handling in the system workqueue. This is important since we flush our own driver workqueue in the pageflip code while hodling modeset locks, and only the drm hotplug code grabbed these locks. But with
commit 69787f7da6b2adc4054357a661aaa1701a9ca76f
Author: Daniel Vetter <[email protected]> Date: Tue Oct 23 18:23:34 2012 +0000
drm: run the hpd irq event code directly
this was changed and now we could deadlock in our flip handler if there's a hotplug work blocking the progress of the crucial unpin works. So this broke the careful deadlock avoidance implemented in
commit b4a98e57fc27854b5938fc8b08b68e5e68b91e1f
Author: Chris Wilson <[email protected]> Date: Thu Nov 1 09:26:26 2012 +0000
drm/i915: Flush outstanding unpin tasks before pageflipping
Since the rule thus far has been that work items on our own workqueue may never grab modeset locks simply restore that rule again.
v2: Add a comment to the declaration of dev_priv->wq to warn readers about the tricky implications of using it. Suggested by Chris Wilson.
References: http://permalink.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/26239
--- drivers/gpu/drm/i915/i915_drv.h | 7 +++++++ drivers/gpu/drm/i915/i915_irq.c | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +7 -0
@@ -1248,6 +1248,13 @@ typedef struct drm_i915_private {unsigned int fsb_freq, mem_freq, is_ddr3; +/** +* wq - Driver workqueue for GEM. +* +* NOTE: Work items scheduled here are not allowed to grab any modeset +* locks, for otherwise the flushing done in the pageflip code will +* result in deadlocks. +*/ struct workqueue_struct *wq;/* Display functions */
drivers/gpu/drm/i915/i915_irq.c +1 -2
@@ -1027,8 +1027,7 @@ static inline void intel_hpd_irq_handler(struct drm_device *dev, dev_priv->display.hpd_irq_setup (dev);spin_unlock (&dev_priv->irq_lock); -queue_work (dev_priv->wq, - &dev_priv->hotplug_work); +schedule_work (&dev_priv->hotplug_work); }static void gmbus_irq_handler (struct drm_device *dev)
Signature · 1 line
1.8.4.rc3
Daniel Vetter
AppliedQuoted 33 lines · Chris Wilson
Quoted 25 lines · Daniel Vetter
Historically we've run our own driver hotplug handling in our own work-queue, which then launched the drm core hotplug handling in the system workqueue. This is important since we flush our own driver workqueue in the pageflip code while hodling modeset locks, and only the drm hotplug code grabbed these locks. But with
commit
69787f7da6b2adc4054357a661aaa1701a9ca76fAuthor: Daniel Vetter <[email protected]> Date: Tue Oct 23 18:23:34 2012 +0000drm: run the hpd irq event code directly
this was changed and now we could deadlock in our flip handler if there's a hotplug work blocking the progress of the crucial unpin works. So this broke the careful deadlock avoidance implemented in
commit
b4a98e57fc27854b5938fc8b08b68e5e68b91e1fAuthor: Chris Wilson <[email protected]> Date: Thu Nov 1 09:26:26 2012 +0000drm/i915: Flush outstanding unpin tasks before pageflipping
Since the rule thus far has been that work items on our own workqueue may never grab modeset locks simply restore that rule again.
Quoted 6 lines
Cc Chris Wilson <[email protected]>Cc Stuart Abercrombie <[email protected]>Reported-by Stuart Abercrombie <[email protected]>References: http://permalink.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/26239
Signed-off-by Daniel Vetter <[email protected]>
Quoted 8 lines
That wins for simplicity, and it is indeed the only caller that requires mode_config.lock, so
Reviewed-by Chris Wilson <[email protected]>Bonus would a reminder in
i915_drv.hto say that we cannot put items that require mode_config.lock onto the wq, and that they should go onto the global workqueue instead.
I've merged the updated version, thanks for your review. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch