drm: Introduce an atomic_commit_setup function
authorMaxime Ripard <maxime@cerno.tech>
Fri, 4 Dec 2020 15:11:32 +0000 (16:11 +0100)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Fri, 9 Jul 2021 16:48:50 +0000 (17:48 +0100)
commit25b25470ab2bf40a0c1eb8e0a621515702ebda47
treeebe53f7f5d039d016bb39c10dae04a116b762bc7
parent8f42671317d0504008d2ea35110ac8153bab6b3a
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.

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
drivers/gpu/drm/drm_atomic_helper.c
include/drm/drm_modeset_helper_vtables.h