Skip to content

Commit

Permalink
drm/omap: protect omap_crtc's event with event_lock spinlock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Archit Taneja authored and Tomi Valkeinen committed Apr 15, 2014
1 parent bc905ac commit 38e5597
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/gpu/drm/omapdrm/omap_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,18 +350,24 @@ 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;
}

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
Expand Down

0 comments on commit 38e5597

Please sign in to comment.