Skip to content

drm/vc4: Fix the zpos range of the writeback overlay planes - #7800

Merged
pelwell merged 1 commit into
raspberrypi:rpi-6.18.yfrom
YORROY123:vc4-txp-zpos-range
Nov 26, 2026
Merged

pelwell merged 1 commit into
raspberrypi:rpi-6.18.yfrom
YORROY123:vc4-txp-zpos-range

Conversation

@YORROY123

Copy link
Copy Markdown
Contributor

The 32 writeback (TXP) overlay planes added in 5c85a4b get a default zpos of i + 1 (1..32), but their zpos range is still 1..VC4_NUM_OVERLAY_PLANES + 1 (17). So 15 of them start outside their own range, and reading the value back and setting it again fails with EINVAL.

On a Pi 5 this makes igt kms_properties fail:

(kms_properties) CRITICAL: Failed assertion: value <= values[1]
(kms_properties) CRITICAL: error: 0x12 > 0x11
Subtest get_properties-sanity-non-atomic: FAIL
Subtest get_properties-sanity-atomic: FAIL

The fix uses VC4_NUM_TXP_OVERLAY_PLANES + 1 as the maximum for those planes (one line).

Tested on a Pi 5, 6.18.39, with the patched vc4 module loaded from the initramfs:

  • planes with zpos outside their range: 15 of 56 -> 0 of 56
  • kms_properties: 8 pass / 2 fail -> 10 pass / 0 fail
  • the other KMS tests I ran (kms_atomic, kms_addfb_basic, kms_getfb, kms_prop_blob, kms_lease, kms_writeback, kms_atomic_transition, ...) give the same results as before. kms_flip has the same timing-dependent failures on HDMI-A-1 with and without the change; each of those subtests passes and fails on reruns.

The fix and description were written with help from an AI coding assistant (Claude); the testing was done on real hardware.

The VC4_NUM_TXP_OVERLAY_PLANES (32) overlay planes for the writeback
CRTC are created with a default zpos of i + 1, so 1 to 32, but with the
zpos range of the normal overlay planes, 1 to VC4_NUM_OVERLAY_PLANES + 1
(17). Planes 17 to 31 of that loop therefore start with a zpos outside
their own range, and writing the current value back fails with EINVAL.

On a Pi 5, 15 of the 56 planes have a zpos above their maximum, and the
igt test kms_properties fails on it:

  (kms_properties) CRITICAL: Failed assertion: value <= values[1]
  (kms_properties) CRITICAL: error: 0x12 > 0x11
  Subtest get_properties-sanity-non-atomic: FAIL
  Subtest get_properties-sanity-atomic: FAIL

Use VC4_NUM_TXP_OVERLAY_PLANES + 1 as the maximum for those planes.

Tested on a Pi 5 (6.18.39) with the patched vc4 module loaded from the
initramfs:
- planes with a zpos outside their range: 15 of 56 -> 0 of 56
- kms_properties: 8 pass / 2 fail -> 10 pass / 0 fail
- the other KMS tests run (kms_atomic, kms_addfb_basic, kms_getfb,
  kms_prop_blob, kms_lease, kms_writeback, kms_atomic_transition, ...)
  give the same results as before. kms_flip has the same set of
  timing-dependent failures on HDMI-A-1 with and without this change;
  each of those subtests passes and fails on reruns.

The failure was found with igt-gpu-tools. The fix and this changelog
were written with the help of an AI coding assistant (Claude), and the
testing above was run on real hardware.

Fixes: 5c85a4b ("drm/vc4: Assign 32 overlay planes to writeback only")
Signed-off-by: Roy <rongh7426@gmail.com>
@popcornmix

Copy link
Copy Markdown
Collaborator

Review: drm/vc4: Fix the zpos range of the writeback overlay planes (#7800)

Looks correct. The 32 writeback overlay planes get a default zpos of 1..32 but a max of 17, so the default is out of range for 15 of them. Raising the max to VC4_NUM_TXP_OVERLAY_PLANES + 1 fixes that. Nothing in vc4 indexes by zpos (the HVS uses normalized_zpos), so the larger range is safe.

Optional follow-up: the writeback CRTC's cursor plane still has a zpos range of 1..VC4_NUM_OVERLAY_PLANES + 1 (17). Overlays with zpos 18..33 on that CRTC sit above the cursor, so it can't be put on top. This isn't new (the defaults were already 1..32), but it could be fixed at the same time by giving the cursor plane on txp_crtc VC4_NUM_TXP_OVERLAY_PLANES + 1.

Minor: the copied comment "Max of all the overlays + 1 primary + 1 cursor plane" now matches the code for the writeback loop, but only if the cursor change above is made too.

@6by9 6by9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it's correct.

Commit texts don't need the information about how you've tested it, nor any AI attribution these days. For future patches please put that detail in the PR conversation, or for upstream it would be in the cover letter.

@pelwell
pelwell merged commit fda2f62 into raspberrypi:rpi-6.18.y Nov 26, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants