diff options
author | Maxime Ripard <maxime@cerno.tech> | 2021-01-11 09:44:01 +0100 |
---|---|---|
committer | Maxime Ripard <maxime@cerno.tech> | 2021-01-21 12:11:04 +0100 |
commit | b99c2c95412c0b85accdafe9e32ba1e84d240f55 (patch) | |
tree | a9609c83ed6417525188a5389cf777ab7fdb2f25 /drivers/gpu/drm/drm_atomic.c | |
parent | drm/vmwgfx: Make sure we unpin no longer needed buffers (diff) | |
download | linux-b99c2c95412c0b85accdafe9e32ba1e84d240f55.tar.xz linux-b99c2c95412c0b85accdafe9e32ba1e84d240f55.zip |
drm: Introduce a drm_crtc_commit_wait helper
There's currently four users of the same logic to wait for a commit to
be flipped: three for the CRTCs, connectors and planes in
drm_atomic_helper_wait_for_dependencies, and one in vc4.
Let's consolidate this a bit to avoid any code duplication.
Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210111084401.117152-1-maxime@cerno.tech
Diffstat (limited to 'drivers/gpu/drm/drm_atomic.c')
-rw-r--r-- | drivers/gpu/drm/drm_atomic.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index dda60051854b..b1efa9322be2 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -53,6 +53,45 @@ void __drm_crtc_commit_free(struct kref *kref) EXPORT_SYMBOL(__drm_crtc_commit_free); /** + * drm_crtc_commit_wait - Waits for a commit to complete + * @commit: &drm_crtc_commit to wait for + * + * Waits for a given &drm_crtc_commit to be programmed into the + * hardware and flipped to. + * + * Returns: + * + * 0 on success, a negative error code otherwise. + */ +int drm_crtc_commit_wait(struct drm_crtc_commit *commit) +{ + unsigned long timeout = 10 * HZ; + int ret; + + if (!commit) + return 0; + + ret = wait_for_completion_timeout(&commit->hw_done, timeout); + if (!ret) { + DRM_ERROR("hw_done timed out\n"); + return -ETIMEDOUT; + } + + /* + * Currently no support for overwriting flips, hence + * stall for previous one to execute completely. + */ + ret = wait_for_completion_timeout(&commit->flip_done, timeout); + if (!ret) { + DRM_ERROR("flip_done timed out\n"); + return -ETIMEDOUT; + } + + return 0; +} +EXPORT_SYMBOL(drm_crtc_commit_wait); + +/** * drm_atomic_state_default_release - * release memory initialized by drm_atomic_state_init * @state: atomic state |