Commit c4749c9a authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Jani Nikula

drm/atomic: Fix bookkeeping with TEST_ONLY, v3.

Commit ec9f932e
"drm/atomic: Cleanup on error properly in the atomic ioctl."
cleaned up some error paths, but didn't fix the TEST_ONLY path.
In the check only case plane->fb shouldn't be updated, and
the vblank events should be cleared as on failure.

Changes since v1:
- Fix -EDEADLK handling of vblank events too.
- Free state last with CHECK_ONLY.
Changes since v2:
- Add comment about freeing crtc_state->event with TEST_ONLY.
  (Daniel Stone)
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarDaniel Stone <daniels@collabora.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 879a37d0
...@@ -1515,7 +1515,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1515,7 +1515,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
copied_props++; copied_props++;
} }
if (obj->type == DRM_MODE_OBJECT_PLANE && count_props) { if (obj->type == DRM_MODE_OBJECT_PLANE && count_props &&
!(arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
plane = obj_to_plane(obj); plane = obj_to_plane(obj);
plane_mask |= (1 << drm_plane_index(plane)); plane_mask |= (1 << drm_plane_index(plane));
plane->old_fb = plane->fb; plane->old_fb = plane->fb;
...@@ -1537,10 +1538,11 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1537,10 +1538,11 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
} }
if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) { if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) {
/*
* Unlike commit, check_only does not clean up state.
* Below we call drm_atomic_state_free for it.
*/
ret = drm_atomic_check_only(state); ret = drm_atomic_check_only(state);
/* _check_only() does not free state, unlike _commit() */
if (!ret)
drm_atomic_state_free(state);
} else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) { } else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) {
ret = drm_atomic_async_commit(state); ret = drm_atomic_async_commit(state);
} else { } else {
...@@ -1567,14 +1569,13 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1567,14 +1569,13 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
plane->old_fb = NULL; plane->old_fb = NULL;
} }
if (ret == -EDEADLK) { if (ret && arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
drm_atomic_state_clear(state); /*
drm_modeset_backoff(&ctx); * TEST_ONLY and PAGE_FLIP_EVENT are mutually exclusive,
goto retry; * if they weren't, this code should be called on success
} * for TEST_ONLY too.
*/
if (ret) {
if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
for_each_crtc_in_state(state, crtc, crtc_state, i) { for_each_crtc_in_state(state, crtc, crtc_state, i) {
if (!crtc_state->event) if (!crtc_state->event)
continue; continue;
...@@ -1584,9 +1585,15 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1584,9 +1585,15 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
} }
} }
drm_atomic_state_free(state); if (ret == -EDEADLK) {
drm_atomic_state_clear(state);
drm_modeset_backoff(&ctx);
goto retry;
} }
if (ret || arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
drm_atomic_state_free(state);
drm_modeset_drop_locks(&ctx); drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx); drm_modeset_acquire_fini(&ctx);
......
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