drm: don't warn unconditionally in drm_vblank_cleanup about enabled vblanks

Submitted by Lucas Stach on Aug. 12, 2016, 9:04 a.m.

Details

Message ID 1470992678-6432-1-git-send-email-l.stach@pengutronix.de
State New
Headers show
Series "drm: don't warn unconditionally in drm_vblank_cleanup about enabled vblanks" ( rev: 1 ) in DRI devel

Not browsing as part of any series.

Commit Message

Lucas Stach Aug. 12, 2016, 9:04 a.m.
On drivers without immediate vblank disabling drm_vblank_cleanup() may be
called before the delayed vblank disable timer has fired. Instead of spitting
out a warning unconditionally in this case, run the vblank disable function
immediately.

Only warn if vblanks are still enabled and there was no timer pending to
disable them.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/gpu/drm/drm_irq.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 77f357b2c386..e6eb5024341d 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -335,10 +335,15 @@  void drm_vblank_cleanup(struct drm_device *dev)
 	for (pipe = 0; pipe < dev->num_crtcs; pipe++) {
 		struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
-		WARN_ON(vblank->enabled &&
-			drm_core_check_feature(dev, DRIVER_MODESET));
-
-		del_timer_sync(&vblank->disable_timer);
+		if (del_timer_sync(&vblank->disable_timer))
+			/*
+			 * If we deactivated a pending timer, make sure to
+			 * disable the vblank now.
+			 */
+			vblank_disable_fn((unsigned long)vblank);
+		else
+			WARN_ON(vblank->enabled &&
+				drm_core_check_feature(dev, DRIVER_MODESET));
 	}
 
 	kfree(dev->vblank);

Comments

On Fri, Aug 12, 2016 at 11:04:38AM +0200, Lucas Stach wrote:
> On drivers without immediate vblank disabling drm_vblank_cleanup() may be
> called before the delayed vblank disable timer has fired. Instead of spitting
> out a warning unconditionally in this case, run the vblank disable function
> immediately.
> 
> Only warn if vblanks are still enabled and there was no timer pending to
> disable them.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

I think this needs a Fixes: line + Cc: of the people who broke things?
-Daniel

> ---
>  drivers/gpu/drm/drm_irq.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 77f357b2c386..e6eb5024341d 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -335,10 +335,15 @@ void drm_vblank_cleanup(struct drm_device *dev)
>  	for (pipe = 0; pipe < dev->num_crtcs; pipe++) {
>  		struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
>  
> -		WARN_ON(vblank->enabled &&
> -			drm_core_check_feature(dev, DRIVER_MODESET));
> -
> -		del_timer_sync(&vblank->disable_timer);
> +		if (del_timer_sync(&vblank->disable_timer))
> +			/*
> +			 * If we deactivated a pending timer, make sure to
> +			 * disable the vblank now.
> +			 */
> +			vblank_disable_fn((unsigned long)vblank);
> +		else
> +			WARN_ON(vblank->enabled &&
> +				drm_core_check_feature(dev, DRIVER_MODESET));
>  	}
>  
>  	kfree(dev->vblank);
> -- 
> 2.8.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel