Commit 5c2e3448 authored by Daniel Vetter's avatar Daniel Vetter

drm/fb-helper: Push locking into pan_display_atomic|legacy

For the legacy path we'll keep drm_modeset_lock_all, for the atomic
one we drop the use of the magic implicit context and wire it up
properly.

Cc: John Stultz <john.stultz@linaro.org>
Cc: Thierry Reding <treding@nvidia.com>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170704151833.17304-7-daniel.vetter@ffwll.ch
parent 235d3e4f
...@@ -1317,7 +1317,6 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, ...@@ -1317,7 +1317,6 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct drm_fb_helper *fb_helper = info->par; struct drm_fb_helper *fb_helper = info->par;
struct drm_device *dev = fb_helper->dev;
struct drm_mode_set *mode_set; struct drm_mode_set *mode_set;
struct drm_crtc *crtc; struct drm_crtc *crtc;
int ret = 0; int ret = 0;
...@@ -1508,12 +1507,17 @@ static int pan_display_atomic(struct fb_var_screeninfo *var, ...@@ -1508,12 +1507,17 @@ static int pan_display_atomic(struct fb_var_screeninfo *var,
struct drm_plane *plane; struct drm_plane *plane;
int i, ret; int i, ret;
unsigned int plane_mask; unsigned int plane_mask;
struct drm_modeset_acquire_ctx ctx;
drm_modeset_acquire_init(&ctx, 0);
state = drm_atomic_state_alloc(dev); state = drm_atomic_state_alloc(dev);
if (!state) if (!state) {
return -ENOMEM; ret = -ENOMEM;
goto out_ctx;
}
state->acquire_ctx = dev->mode_config.acquire_ctx; state->acquire_ctx = &ctx;
retry: retry:
plane_mask = 0; plane_mask = 0;
for (i = 0; i < fb_helper->crtc_count; i++) { for (i = 0; i < fb_helper->crtc_count; i++) {
...@@ -1526,7 +1530,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var, ...@@ -1526,7 +1530,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var,
ret = __drm_atomic_helper_set_config(mode_set, state); ret = __drm_atomic_helper_set_config(mode_set, state);
if (ret != 0) if (ret != 0)
goto fail; goto out_state;
plane = mode_set->crtc->primary; plane = mode_set->crtc->primary;
plane_mask |= (1 << drm_plane_index(plane)); plane_mask |= (1 << drm_plane_index(plane));
...@@ -1535,23 +1539,27 @@ static int pan_display_atomic(struct fb_var_screeninfo *var, ...@@ -1535,23 +1539,27 @@ static int pan_display_atomic(struct fb_var_screeninfo *var,
ret = drm_atomic_commit(state); ret = drm_atomic_commit(state);
if (ret != 0) if (ret != 0)
goto fail; goto out_state;
info->var.xoffset = var->xoffset; info->var.xoffset = var->xoffset;
info->var.yoffset = var->yoffset; info->var.yoffset = var->yoffset;
fail: out_state:
drm_atomic_clean_old_fb(dev, plane_mask, ret); drm_atomic_clean_old_fb(dev, plane_mask, ret);
if (ret == -EDEADLK) if (ret == -EDEADLK)
goto backoff; goto backoff;
drm_atomic_state_put(state); drm_atomic_state_put(state);
out_ctx:
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
return ret; return ret;
backoff: backoff:
drm_atomic_state_clear(state); drm_atomic_state_clear(state);
drm_atomic_legacy_backoff(state); drm_modeset_backoff(&ctx);
goto retry; goto retry;
} }
...@@ -1564,6 +1572,7 @@ static int pan_display_legacy(struct fb_var_screeninfo *var, ...@@ -1564,6 +1572,7 @@ static int pan_display_legacy(struct fb_var_screeninfo *var,
int ret = 0; int ret = 0;
int i; int i;
drm_modeset_lock_all(fb_helper->dev);
for (i = 0; i < fb_helper->crtc_count; i++) { for (i = 0; i < fb_helper->crtc_count; i++) {
modeset = &fb_helper->crtc_info[i].mode_set; modeset = &fb_helper->crtc_info[i].mode_set;
...@@ -1578,6 +1587,7 @@ static int pan_display_legacy(struct fb_var_screeninfo *var, ...@@ -1578,6 +1587,7 @@ static int pan_display_legacy(struct fb_var_screeninfo *var,
} }
} }
} }
drm_modeset_unlock_all(fb_helper->dev);
return ret; return ret;
} }
...@@ -1603,12 +1613,10 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, ...@@ -1603,12 +1613,10 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
return -EBUSY; return -EBUSY;
} }
drm_modeset_lock_all(dev);
if (drm_drv_uses_atomic_modeset(dev)) if (drm_drv_uses_atomic_modeset(dev))
ret = pan_display_atomic(var, info); ret = pan_display_atomic(var, info);
else else
ret = pan_display_legacy(var, info); ret = pan_display_legacy(var, info);
drm_modeset_unlock_all(dev);
mutex_unlock(&fb_helper->lock); mutex_unlock(&fb_helper->lock);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment