drm/vc4: kms: Store the unassigned channel list in the state
authorMaxime Ripard <maxime@cerno.tech>
Fri, 20 Nov 2020 14:42:44 +0000 (15:42 +0100)
committerMaxime Ripard <maxime@cerno.tech>
Mon, 23 Nov 2020 16:59:23 +0000 (17:59 +0100)
commitf2df84e096a8254ddb18c531b185fc2a45879077
tree56bac36b1c90847f04ce35bc73b0cb3d01b89ab7
parent9fa1d7e60ad5ad2f7859ea8912d7b0b57821a5b7
drm/vc4: kms: Store the unassigned channel list in the state

If a CRTC is enabled but not active, and that we're then doing a page
flip on another CRTC, drm_atomic_get_crtc_state will bring the first
CRTC state into the global state, and will make us wait for its vblank
as well, even though that might never occur.

Instead of creating the list of the free channels each time atomic_check
is called, and calling drm_atomic_get_crtc_state to retrieve the
allocated channels, let's create a private state object in the main
atomic state, and use it to store the available channels.

Since vc4 has a semaphore (with a value of 1, so a lock) in its commit
implementation to serialize all the commits, even the nonblocking ones, we
are free from the use-after-free race if two subsequent commits are not ran
in their submission order.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Reviewed-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201120144245.398711-2-maxime@cerno.tech
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_kms.c