Commit 01086487 authored by Boris Brezillon's avatar Boris Brezillon Committed by Daniel Vetter

drm: Add drm_atomic_helper_wait_for_flip_done()

Add an helper to wait for all page flips of an atomic state to be done.

v2:
- Pimp kerneldoc as discussed with Boris on irc
- Add missing doc for @dev.
- Use old_state for consitency with wait_for_vblanks

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> (v1)
Acked-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1496392332-8722-2-git-send-email-boris.brezillon@free-electrons.com
parent 2b3d860e
...@@ -1185,9 +1185,13 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_fences); ...@@ -1185,9 +1185,13 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_fences);
* *
* Helper to, after atomic commit, wait for vblanks on all effected * Helper to, after atomic commit, wait for vblanks on all effected
* crtcs (ie. before cleaning up old framebuffers using * crtcs (ie. before cleaning up old framebuffers using
* drm_atomic_helper_cleanup_planes()). It will only wait on crtcs where the * drm_atomic_helper_cleanup_planes()). It will only wait on CRTCs where the
* framebuffers have actually changed to optimize for the legacy cursor and * framebuffers have actually changed to optimize for the legacy cursor and
* plane update use-case. * plane update use-case.
*
* Drivers using the nonblocking commit tracking support initialized by calling
* drm_atomic_helper_setup_commit() should look at
* drm_atomic_helper_wait_for_flip_done() as an alternative.
*/ */
void void
drm_atomic_helper_wait_for_vblanks(struct drm_device *dev, drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
...@@ -1234,6 +1238,43 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev, ...@@ -1234,6 +1238,43 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
} }
EXPORT_SYMBOL(drm_atomic_helper_wait_for_vblanks); EXPORT_SYMBOL(drm_atomic_helper_wait_for_vblanks);
/**
* drm_atomic_helper_wait_for_flip_done - wait for all page flips to be done
* @dev: DRM device
* @old_state: atomic state object with old state structures
*
* Helper to, after atomic commit, wait for page flips on all effected
* crtcs (ie. before cleaning up old framebuffers using
* drm_atomic_helper_cleanup_planes()). Compared to
* drm_atomic_helper_wait_for_vblanks() this waits for the completion of on all
* CRTCs, assuming that cursors-only updates are signalling their completion
* immediately (or using a different path).
*
* This requires that drivers use the nonblocking commit tracking support
* initialized using drm_atomic_helper_setup_commit().
*/
void drm_atomic_helper_wait_for_flip_done(struct drm_device *dev,
struct drm_atomic_state *old_state)
{
struct drm_crtc_state *crtc_state;
struct drm_crtc *crtc;
int i;
for_each_crtc_in_state(old_state, crtc, crtc_state, i) {
struct drm_crtc_commit *commit = old_state->crtcs[i].commit;
int ret;
if (!commit)
continue;
ret = wait_for_completion_timeout(&commit->flip_done, 10 * HZ);
if (ret == 0)
DRM_ERROR("[CRTC:%d:%s] flip_done timed out\n",
crtc->base.id, crtc->name);
}
}
EXPORT_SYMBOL(drm_atomic_helper_wait_for_flip_done);
/** /**
* drm_atomic_helper_commit_tail - commit atomic update to hardware * drm_atomic_helper_commit_tail - commit atomic update to hardware
* @old_state: atomic state object with old state structures * @old_state: atomic state object with old state structures
......
...@@ -52,6 +52,9 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev, ...@@ -52,6 +52,9 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
void drm_atomic_helper_wait_for_vblanks(struct drm_device *dev, void drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
struct drm_atomic_state *old_state); struct drm_atomic_state *old_state);
void drm_atomic_helper_wait_for_flip_done(struct drm_device *dev,
struct drm_atomic_state *old_state);
void void
drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev, drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
struct drm_atomic_state *old_state); struct drm_atomic_state *old_state);
......
...@@ -1169,7 +1169,8 @@ struct drm_mode_config_helper_funcs { ...@@ -1169,7 +1169,8 @@ struct drm_mode_config_helper_funcs {
* After the atomic update is committed to the hardware this hook needs * After the atomic update is committed to the hardware this hook needs
* to call drm_atomic_helper_commit_hw_done(). Then wait for the upate * to call drm_atomic_helper_commit_hw_done(). Then wait for the upate
* to be executed by the hardware, for example using * to be executed by the hardware, for example using
* drm_atomic_helper_wait_for_vblanks(), and then clean up the old * drm_atomic_helper_wait_for_vblanks() or
* drm_atomic_helper_wait_for_flip_done(), and then clean up the old
* framebuffers using drm_atomic_helper_cleanup_planes(). * framebuffers using drm_atomic_helper_cleanup_planes().
* *
* When disabling a CRTC this hook _must_ stall for the commit to * When disabling a CRTC this hook _must_ stall for the commit to
......
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