diff mbox

[09/11] drm/imx: page flip fixes

Message ID 1349725849-22433-10-git-send-email-rob.clark@linaro.org
State New
Headers show

Commit Message

Rob Clark Oct. 8, 2012, 7:50 p.m. UTC
From: Rob Clark <rob@ti.com>

The 'event' could be null, so don't list_del(&event->base.link)..  and
in fact even if it wasn't null there is no reason to do this.

Also, this looks racy with the irq handler, so throw in a spinlock for
good measure.

Signed-off-by: Rob Clark <rob@ti.com>
---
 drivers/staging/imx-drm/ipuv3-crtc.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c
index 8fa0f4d..6745766 100644
--- a/drivers/staging/imx-drm/ipuv3-crtc.c
+++ b/drivers/staging/imx-drm/ipuv3-crtc.c
@@ -135,23 +135,26 @@  static int ipu_page_flip(struct drm_crtc *crtc,
 		struct drm_pending_vblank_event *event)
 {
 	struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
+	struct drm_device *drm = ipu_crtc->base.dev;
+	unsigned long flags;
 	int ret;
 
 	if (ipu_crtc->newfb)
 		return -EBUSY;
 
+	spin_lock_irqsave(&drm->event_lock, flags);
 	ret = imx_drm_crtc_vblank_get(ipu_crtc->imx_crtc);
 	if (ret) {
 		dev_dbg(ipu_crtc->dev, "failed to acquire vblank counter\n");
-		list_del(&event->base.link);
-
-		return ret;
+		goto out;
 	}
 
 	ipu_crtc->newfb = fb;
 	ipu_crtc->page_flip_event = event;
 
-	return 0;
+out:
+	spin_unlock_irqrestore(&drm->event_lock, flags);
+	return ret;
 }
 
 static const struct drm_crtc_funcs ipu_crtc_funcs = {