aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2014-08-06 07:49:44 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-08-06 16:39:22 -0400
commit7ffd7a68511c710b84db3548a1997fd2625f580a (patch)
treef8b84573cb571663684d8d527348064e08737e44
parent21d70354bba9965a098382fc4d7fb17e138111f3 (diff)
drm: Always reject drm_vblank_get() after drm_vblank_off()
Make sure drm_vblank_get() never succeeds when called between drm_vblank_off() and drm_vblank_on(). Borrow a trick from the old drm_vblank_{pre,post}_modeset() functions and just bump the refcount in drm_vblank_off() and drop it in drm_vblank_on(). When drm_vblank_get() encounters a >0 refcount and the vblank interrupt is already disabled it will simply return -EINVAL. Hopefully the use of inmodeset won't conflict badly with drm_vblank_{pre,post}_modeset(). For i915 there's a window between drm_vblank_off() and marking the crtc as inactive where the current code still allows drm_vblank_get(). v2: Describe what drm_vblank_get() does to explain how a simple refcount bump manages to fix things (Daniel) Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/drm_irq.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 0de123afdb34..b16a63622bad 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1039,6 +1039,15 @@ void drm_vblank_off(struct drm_device *dev, int crtc)
1039 } 1039 }
1040 spin_unlock(&dev->event_lock); 1040 spin_unlock(&dev->event_lock);
1041 1041
1042 /*
1043 * Prevent subsequent drm_vblank_get() from re-enabling
1044 * the vblank interrupt by bumping the refcount.
1045 */
1046 if (!dev->vblank[crtc].inmodeset) {
1047 atomic_inc(&dev->vblank[crtc].refcount);
1048 dev->vblank[crtc].inmodeset = 1;
1049 }
1050
1042 spin_unlock_irqrestore(&dev->vbl_lock, irqflags); 1051 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
1043} 1052}
1044EXPORT_SYMBOL(drm_vblank_off); 1053EXPORT_SYMBOL(drm_vblank_off);
@@ -1079,6 +1088,11 @@ void drm_vblank_on(struct drm_device *dev, int crtc)
1079 unsigned long irqflags; 1088 unsigned long irqflags;
1080 1089
1081 spin_lock_irqsave(&dev->vbl_lock, irqflags); 1090 spin_lock_irqsave(&dev->vbl_lock, irqflags);
1091 /* Drop our private "prevent drm_vblank_get" refcount */
1092 if (dev->vblank[crtc].inmodeset) {
1093 atomic_dec(&dev->vblank[crtc].refcount);
1094 dev->vblank[crtc].inmodeset = 0;
1095 }
1082 /* re-enable interrupts if there's are users left */ 1096 /* re-enable interrupts if there's are users left */
1083 if (atomic_read(&dev->vblank[crtc].refcount) != 0) 1097 if (atomic_read(&dev->vblank[crtc].refcount) != 0)
1084 WARN_ON(drm_vblank_enable(dev, crtc)); 1098 WARN_ON(drm_vblank_enable(dev, crtc));