On Wed, Jul 30, 2014 at 7:42 PM, Benjamin Gaignard benjamin.gaignard@linaro.org wrote:
+static int sti_drm_crtc_page_flip(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
struct drm_pending_vblank_event *event,
uint32_t page_flip_flags)
+{
struct drm_device *drm_dev = crtc->dev;
struct drm_framebuffer *old_fb;
struct sti_mixer *mixer = to_sti_mixer(crtc);
unsigned long flags;
int ret;
DRM_DEBUG_KMS("fb %d --> fb %d\n",
crtc->primary->fb->base.id, fb->base.id);
mutex_lock(&drm_dev->struct_mutex);
struct_mutex locking here is pure cargo-cult. Please remove asap. -Daniel
old_fb = crtc->primary->fb;
crtc->primary->fb = fb;
ret = sti_drm_crtc_mode_set_base(crtc, crtc->x, crtc->y, old_fb);
if (ret) {
DRM_ERROR("failed\n");
crtc->primary->fb = old_fb;
goto out;
}
if (event) {
event->pipe = mixer->id;
ret = drm_vblank_get(drm_dev, event->pipe);
if (ret) {
DRM_ERROR("Cannot get vblank\n");
goto out;
}
spin_lock_irqsave(&drm_dev->event_lock, flags);
if (mixer->pending_event) {
drm_vblank_put(drm_dev, event->pipe);
ret = -EBUSY;
} else {
mixer->pending_event = event;
}
spin_unlock_irqrestore(&drm_dev->event_lock, flags);
}
+out:
mutex_unlock(&drm_dev->struct_mutex);
return ret;
+}