drm/vc4: crtc: Fix out of order frames during asynchronous page flips
authorMaxime Ripard <maxime@cerno.tech>
Fri, 10 Jun 2022 11:51:48 +0000 (13:51 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Thu, 16 Jun 2022 09:07:52 +0000 (11:07 +0200)
commitd19e00ee06a9abf590b178c34cad637a516752f8
tree376757a1dc1486002fd0d6209ec9f79e9bad2059
parentd87db1c79d6f9ec5505be2ff4ca8811d6e88a667
drm/vc4: crtc: Fix out of order frames during asynchronous page flips

When doing an asynchronous page flip (PAGE_FLIP ioctl with the
DRM_MODE_PAGE_FLIP_ASYNC flag set), the current code waits for the
possible GPU buffer being rendered through a call to
vc4_queue_seqno_cb().

On the BCM2835-37, the GPU driver is part of the vc4 driver and that
function is defined in vc4_gem.c to wait for the buffer to be rendered,
and once it's done, call a callback.

However, on the BCM2711 used on the RaspberryPi4, the GPU driver is
separate (v3d) and that function won't do anything. This was working
because we were going into a path, due to uninitialized variables, that
was always scheduling the callback.

However, we were never actually waiting for the buffer to be rendered
which was resulting in frames being displayed out of order.

The generic API to signal those kind of completion in the kernel are the
DMA fences, and fortunately the v3d drivers supports them and signal
when its job is done. That API also provides an equivalent function that
allows to have a callback being executed when the fence is signalled as
done.

Let's change our driver a bit to rely on the previous function for the
older SoCs, and on DMA fences for the BCM2711.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Melissa Wen <mwen@igalia.com>
Link: https://lore.kernel.org/r/20220610115149.964394-14-maxime@cerno.tech
drivers/gpu/drm/vc4/vc4_crtc.c