Skip to content

Commit 89a4aac

Browse files
Helen Koikebbrezillon
authored andcommitted
drm: don't block fb changes for async plane updates
In the case of a normal sync update, the preparation of framebuffers (be it calling drm_atomic_helper_prepare_planes() or doing setups with drm_framebuffer_get()) are performed in the new_state and the respective cleanups are performed in the old_state. In the case of async updates, the preparation is also done in the new_state but the cleanups are done in the new_state (because updates are performed in place, i.e. in the current state). The current code blocks async udpates when the fb is changed, turning async updates into sync updates, slowing down cursor updates and introducing regressions in igt tests with errors of type: "CRITICAL: completed 97 cursor updated in a period of 30 flips, we expect to complete approximately 15360 updates, with the threshold set at 7680" Fb changes in async updates were prevented to avoid the following scenario: - Async update, oldfb = NULL, newfb = fb1, prepare fb1, cleanup fb1 - Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb2 - Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2 (wrong) Where we have a single call to prepare fb2 but double cleanup call to fb2. To solve the above problems, instead of blocking async fb changes, we place the old framebuffer in the new_state object, so when the code performs cleanups in the new_state it will cleanup the old_fb and we will have the following scenario instead: - Async update, oldfb = NULL, newfb = fb1, prepare fb1, no cleanup - Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb1 - Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2 Where calls to prepare/cleanup are balanced. Cc: <stable@vger.kernel.org> # v4.14+ Fixes: 25dc194 ("drm: Block fb changes for async plane updates") Suggested-by: Boris Brezillon <boris.brezillon@collabora.com> Signed-off-by: Helen Koike <helen.koike@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190603165610.24614-6-helen.koike@collabora.com
1 parent c16b855 commit 89a4aac

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

‎drivers/gpu/drm/drm_atomic_helper.c‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,15 +1607,6 @@ int drm_atomic_helper_async_check(struct drm_device *dev,
16071607
old_plane_state->crtc != new_plane_state->crtc)
16081608
return -EINVAL;
16091609

1610-
/*
1611-
* FIXME: Since prepare_fb and cleanup_fb are always called on
1612-
* the new_plane_state for async updates we need to block framebuffer
1613-
* changes. This prevents use of a fb that's been cleaned up and
1614-
* double cleanups from occuring.
1615-
*/
1616-
if (old_plane_state->fb != new_plane_state->fb)
1617-
return -EINVAL;
1618-
16191610
funcs = plane->helper_private;
16201611
if (!funcs->atomic_async_update)
16211612
return -EINVAL;
@@ -1646,6 +1637,8 @@ EXPORT_SYMBOL(drm_atomic_helper_async_check);
16461637
* drm_atomic_async_check() succeeds. Async commits are not supposed to swap
16471638
* the states like normal sync commits, but just do in-place changes on the
16481639
* current state.
1640+
*
1641+
* TODO: Implement full swap instead of doing in-place changes.
16491642
*/
16501643
void drm_atomic_helper_async_commit(struct drm_device *dev,
16511644
struct drm_atomic_state *state)
@@ -1656,6 +1649,9 @@ void drm_atomic_helper_async_commit(struct drm_device *dev,
16561649
int i;
16571650

16581651
for_each_new_plane_in_state(state, plane, plane_state, i) {
1652+
struct drm_framebuffer *new_fb = plane_state->fb;
1653+
struct drm_framebuffer *old_fb = plane->state->fb;
1654+
16591655
funcs = plane->helper_private;
16601656
funcs->atomic_async_update(plane, plane_state);
16611657

@@ -1664,11 +1660,17 @@ void drm_atomic_helper_async_commit(struct drm_device *dev,
16641660
* plane->state in-place, make sure at least common
16651661
* properties have been properly updated.
16661662
*/
1667-
WARN_ON_ONCE(plane->state->fb != plane_state->fb);
1663+
WARN_ON_ONCE(plane->state->fb != new_fb);
16681664
WARN_ON_ONCE(plane->state->crtc_x != plane_state->crtc_x);
16691665
WARN_ON_ONCE(plane->state->crtc_y != plane_state->crtc_y);
16701666
WARN_ON_ONCE(plane->state->src_x != plane_state->src_x);
16711667
WARN_ON_ONCE(plane->state->src_y != plane_state->src_y);
1668+
1669+
/*
1670+
* Make sure the FBs have been swapped so that cleanups in the
1671+
* new_state performs a cleanup in the old FB.
1672+
*/
1673+
WARN_ON_ONCE(plane_state->fb != old_fb);
16721674
}
16731675
}
16741676
EXPORT_SYMBOL(drm_atomic_helper_async_commit);

‎include/drm/drm_modeset_helper_vtables.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,14 @@ struct drm_plane_helper_funcs {
11851185
* current one with the new plane configurations in the new
11861186
* plane_state.
11871187
*
1188+
* Drivers should also swap the framebuffers between current plane
1189+
* state (&drm_plane.state) and new_state.
1190+
* This is required since cleanup for async commits is performed on
1191+
* the new state, rather than old state like for traditional commits.
1192+
* Since we want to give up the reference on the current (old) fb
1193+
* instead of our brand new one, swap them in the driver during the
1194+
* async commit.
1195+
*
11881196
* FIXME:
11891197
* - It only works for single plane updates
11901198
* - Async Pageflips are not supported yet

0 commit comments

Comments
 (0)