drm: Introduce an atomic_commit_setup function
authorMaxime Ripard <maxime@cerno.tech>
Fri, 4 Dec 2020 15:11:32 +0000 (16:11 +0100)
committerMaxime Ripard <maxime@cerno.tech>
Tue, 15 Dec 2020 10:33:08 +0000 (11:33 +0100)
commitddadd40892f31a6653cf104e274f7d2ae764eabb
treea2bce041f5b789cfe67dab749677b62769a0b995
parentae75a0431f822273ce5d3a574863c67503db5775
drm: Introduce an atomic_commit_setup function

Private objects storing a state shared across all CRTCs need to be
carefully handled to avoid a use-after-free issue.

The proper way to do this to track all the commits using that shared
state and wait for the previous commits to be done before going on with
the current one to avoid the reordering of commits that could occur.

However, this commit setup needs to be done after
drm_atomic_helper_setup_commit(), because before the CRTC commit
structure hasn't been allocated before, and before the workqueue is
scheduled, because we would be potentially reordered already otherwise.

That means that drivers currently have to roll their own
drm_atomic_helper_commit() function, even though it would be identical
if not for the commit setup.

Let's introduce a hook to do so that would be called as part of
drm_atomic_helper_commit, allowing us to reuse the atomic helpers.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20201204151138.1739736-2-maxime@cerno.tech
drivers/gpu/drm/drm_atomic_helper.c
include/drm/drm_modeset_helper_vtables.h