drm/vc4: kms: Sort the CRTCs by output before assigning them
authorMaxime Ripard <maxime@cerno.tech>
Wed, 23 Nov 2022 15:25:52 +0000 (16:25 +0100)
committerMaxime Ripard <maxime@cerno.tech>
Mon, 28 Nov 2022 10:50:42 +0000 (11:50 +0100)
commite3479398bcf4f92c1ee513a277f5d3732a90e9f1
treeb474ddc16845732d5c0f3a8958fe5f304d14e647
parente818ee689986ea82a6e46e4128adbf94268d6d20
drm/vc4: kms: Sort the CRTCs by output before assigning them

On the vc4 devices (and later), the blending is done by a single device
called the HVS. The HVS has three FIFO that can operate in parallel, and
route their output to 6 CRTCs and 7 encoders on the BCM2711.

Each of these CRTCs and encoders have some constraints on which FIFO
they can feed from, so we need some code to take all those constraints
into account and assign FIFOs to CRTCs.

The problem can be simplified by assigning those FIFOs to CRTCs by
ascending output index number. We had a comment mentioning it already,
but we were never actually enforcing it.

It was working still in most situations because the probe order is
roughly equivalent, except for the (optional, and fairly rarely used on
the Pi4) VEC which was last in the probe order sequence, but one of the
earliest device to assign.

This resulted in configurations that were rejected by our code but were
still valid with a different assignment.

We can fix this by making sure we assign CRTCs to FIFOs by ordering
them by ascending HVS output index.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20221123-rpi-kunit-tests-v1-10-051a0bb60a16@cerno.tech
drivers/gpu/drm/vc4/vc4_kms.c