From: Ville Syrj?l? <ville.syrj...@linux.intel.com>

Add a flag to drm_device which will cause the vblank code to bypass the
disable timer and always disable the vblank interrupt immediately when
the last reference is dropped.

Signed-off-by: Ville Syrj?l? <ville.syrjala at linux.intel.com>
---
 drivers/gpu/drm/drm_irq.c |  6 +++---
 include/drm/drmP.h        | 10 ++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 20a4855..b008803 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -994,11 +994,11 @@ void drm_vblank_put(struct drm_device *dev, int crtc)

        /* Last user schedules interrupt disable */
        if (atomic_dec_and_test(&vblank->refcount)) {
-               if (drm_vblank_offdelay > 0)
+               if (dev->vblank_disable_immediate || drm_vblank_offdelay == 0)
+                       vblank_disable_fn((unsigned long)vblank);
+               else if (drm_vblank_offdelay > 0)
                        mod_timer(&vblank->disable_timer,
                                  jiffies + ((drm_vblank_offdelay * HZ)/1000));
-               else if (drm_vblank_offdelay == 0)
-                       vblank_disable_fn((unsigned long)vblank);
        }
 }
 EXPORT_SYMBOL(drm_vblank_put);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 979a498..0944544 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1117,6 +1117,16 @@ struct drm_device {
         */
        bool vblank_disable_allowed;

+       /*
+        * If true, vblank interrupt will be disabled immediately when the
+        * refcount drops to zero, as opposed to via the vblank disable
+        * timer.
+        * This can be set to true it the hardware has a working vblank
+        * counter and the driver uses drm_vblank_on() and drm_vblank_off()
+        * appropriately.
+        */
+       bool vblank_disable_immediate;
+
        /* array of size num_crtcs */
        struct drm_vblank_crtc *vblank;

-- 
1.8.5.5

Reply via email to