All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/irq: Don't disable vblank interrupts when already disabled
@ 2015-01-28 23:09 Laurent Pinchart
  2015-01-29  3:15 ` Michel Dänzer
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2015-01-28 23:09 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter, Thierry Reding

The .enable_vblank() operation is only called when vblank interrupts are
disabled, but no similar check exists when disabling vblank interrupts.
This leads to .disable_vblank() being called with vblank interrupts
already disabled and the device possibly runtime suspended. As the
operation is called with a spinlock held drivers can't runtime resume
the device there and thus must avoid touching device registers in that
case, requiring vblank refcounting.

As the DRM core tracks whether vblank interrupts are enabled just skip
the .disable_vblank() call when the interrupts are already disabled.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/drm_irq.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

I've tested this patch in my omapdrm development branch available at

	git://linuxtv.org/pinchartl/fbdev.git omapdrm/next

It fixes a crash caused by accessing the hardware registers from the
.disable_vblank() operation with the device runtime suspended.

I'll post the omapdrm patches after completing conversion to the atomic
updates API.

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 4d79dad..cd384b0 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -185,8 +185,15 @@ static void vblank_disable_and_save(struct drm_device *dev, int crtc)
 		return;
 	}
 
-	dev->driver->disable_vblank(dev, crtc);
-	vblank->enabled = false;
+	/*
+	 * Only disable vblank interrupts if they're enabled. This avoids
+	 * calling the ->disable_vblank() operation in atomic context with the
+	 * hardware potentially runtime suspended.
+	 */
+	if (vblank->enabled) {
+		dev->driver->disable_vblank(dev, crtc);
+		vblank->enabled = false;
+	}
 
 	/* No further vblank irq's will be processed after
 	 * this point. Get current hardware vblank count and
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-29 11:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-28 23:09 [PATCH] drm/irq: Don't disable vblank interrupts when already disabled Laurent Pinchart
2015-01-29  3:15 ` Michel Dänzer
2015-01-29 11:50   ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.