drm/omap: protect omap_crtc's event with event_lock spinlock
authorArchit Taneja <archit@ti.com>
Fri, 11 Apr 2014 07:23:35 +0000 (12:53 +0530)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 15 Apr 2014 10:35:29 +0000 (13:35 +0300)
The vblank_cb callback and the page_flip ioctl can occur together in different
CPU contexts. vblank_cb uses takes tje drm device's event_lock spinlock when
sending the vblank event and updating omap_crtc->event and omap_crtc->od_fb.

Use the same spinlock in page_flip, to make sure the above omap_crtc parameters
are configured sequentially.

Signed-off-by: Archit Taneja <archit@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/omapdrm/omap_crtc.c

index 00798247190bce86c879a4433eb46f40e0a19ad0..e3c47a8005ff149e07b5770f38cdaf1b9aba394f 100644 (file)
@@ -350,11 +350,15 @@ static int omap_crtc_page_flip_locked(struct drm_crtc *crtc,
        struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
        struct drm_plane *primary = crtc->primary;
        struct drm_gem_object *bo;
+       unsigned long flags;
 
        DBG("%d -> %d (event=%p)", primary->fb ? primary->fb->base.id : -1,
                        fb->base.id, event);
 
+       spin_lock_irqsave(&dev->event_lock, flags);
+
        if (omap_crtc->old_fb) {
+               spin_unlock_irqrestore(&dev->event_lock, flags);
                dev_err(dev->dev, "already a pending flip\n");
                return -EINVAL;
        }
@@ -362,6 +366,8 @@ static int omap_crtc_page_flip_locked(struct drm_crtc *crtc,
        omap_crtc->event = event;
        omap_crtc->old_fb = primary->fb = fb;
 
+       spin_unlock_irqrestore(&dev->event_lock, flags);
+
        /*
         * Hold a reference temporarily until the crtc is updated
         * and takes the reference to the bo.  This avoids it