From d5526536c378a58eeb34a96421bf2944d6b444ba Mon Sep 17 00:00:00 2001 From: Roy Date: Sun, 29 Nov 2026 11:24:00 +0800 Subject: [PATCH] drm/vc4: Give the writeback cursor plane the full zpos range Commit fda2f62fe65e ("drm/vc4: Fix the zpos range of the writeback overlay planes") raised the zpos range of the 32 writeback overlay planes to 1..VC4_NUM_TXP_OVERLAY_PLANES + 1 (33), but every CRTC's cursor plane is still created with a zpos and maximum of VC4_NUM_OVERLAY_PLANES + 1 (17). On the writeback CRTC, overlays with a zpos from 18 to 33 therefore sit above the cursor, and the cursor can't be moved on top of them. Use VC4_NUM_TXP_OVERLAY_PLANES + 1 as the default and maximum zpos of the cursor plane on the writeback CRTC, so it starts on top again as it does on the other CRTCs. The other CRTCs keep VC4_NUM_OVERLAY_PLANES + 1. Tested on a Raspberry Pi 5 (6.18.39, vc4 module with fda2f62fe65e and this change, loaded from the initramfs): - writeback CRTC cursor plane: zpos 17, range 1..17 before; zpos 33, range 1..33 after - the cursor planes of the other three CRTCs are unchanged (17, 1..17) - no plane has a zpos outside its range (0 of 56) - igt kms_properties 10 pass / 0 fail; kms_writeback, kms_atomic, kms_plane_multiple and kms_cursor_legacy give the same results as before Suggested by popcornmix in the review of #7800. This change and its description were written with the help of an AI coding assistant (Claude); the testing above was done on real hardware. Fixes: 5c85a4b91634 ("drm/vc4: Assign 32 overlay planes to writeback only") Signed-off-by: Roy --- drivers/gpu/drm/vc4/vc4_plane.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 95487b964313ed..76ba68f1b8d5b3 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -2984,6 +2984,11 @@ int vc4_plane_create_additional_planes(struct drm_device *drm) } drm_for_each_crtc(crtc, drm) { + /* The writeback CRTC has its own, larger set of overlays */ + unsigned int max_zpos = crtc == txp_crtc ? + VC4_NUM_TXP_OVERLAY_PLANES + 1 : + VC4_NUM_OVERLAY_PLANES + 1; + /* Set up the legacy cursor after overlay initialization, * since the zpos fallback is that planes are rendered by plane * ID order, and that then puts the cursor on top. @@ -2993,10 +2998,8 @@ int vc4_plane_create_additional_planes(struct drm_device *drm) if (!IS_ERR(cursor_plane)) { crtc->cursor = cursor_plane; - drm_plane_create_zpos_property(cursor_plane, - VC4_NUM_OVERLAY_PLANES + 1, - 1, - VC4_NUM_OVERLAY_PLANES + 1); + drm_plane_create_zpos_property(cursor_plane, max_zpos, + 1, max_zpos); } }