Skip to contentSkip to conversation

drm/rockchip: vop2: Add 8K support for RK3588 vop2

PATCH New Chaoyi Chen 2 participants 6 messages Nov 16

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover drm/rockchip: vop2: Add 8K support for RK3588 vop2

From: Chaoyi Chen <[email protected]>

Hi,

This series adds support for 8K output on the RK3588 VOP2. HDMI is not ready yet, but I believe many people might be interested in this.

8K output on the RK3588 is done by splicing two VPs together, with VP0 outputting the left half of the screen and VP1 the right half. In addition, 8K planes have to be split in half as well to stay within the width limit of a single plane. Similarly, there are a few post-processing details that need to be handled.

Note that splice mode is not only usable for 8K output. This means the mode can be tested at 4K and even lower resolutions, by simply changing this one line:

-#define VOP2_MAX_VP_OUTPUT_WIDTH 4096
+#define VOP2_MAX_VP_OUTPUT_WIDTH (3840 / 2) /* for 4K test */

And yes, this has been tested at 4K over HDMI on the RK3588 EVB1 :)

Changes in v3:
- Link to v2: https://lore.kernel.org/all/[email protected]/
- Cast the result of drm_format_info_min_pitc() to u32 to avoid 64bit division.
- Rework the left-window splice check to avoid pulling an unrelated CRTC into non-modeset commits, and use the new CRTC mode instead of the stale splice_mode flag(Sashiko).
- Reserve the splice partner window when the partner VP has no CRTC, so it cannot be assigned as another VP's primary plane(Sashiko).
- Only set the partner VP's CFG_DONE while the new state is in splice mode; do not force it when leaving splice mode(Sashiko).
- Program the main and splice video ports in a single layer-mixer pass, and apply the YUV overlay mode to both VPs(Sashiko).

Changes in v2:
- Link to v1: https://lore.kernel.org/all/[email protected]/
- Missing removal of the replaced line(Heiko).
- vop2_win_get_pstate(): use the left window's state only in splice mode(Sashiko).
- Reject splice windows already in use by another CRTC(Sashiko).
- Check the splice partner via drm_atomic_get_crtc_state() instead of the runtime flag and unlocked read(Sashiko).
- Set splice_mode_right/left_vp before the error paths of vop2_crtc_atomic_enable()(Sashiko).
- Validate each split half against the min width 4 and max input width; align NV20/NV30 like NV15(Sashiko).
- Latch overlay registers at the left VP's vsync; don't wait for the partner's own cfg-done(Sashiko).
- Program the color key on the window actually being updated(Sashiko).

Cc Cristian Ciocaltea <[email protected]>
Cc Sebastian Reichel <[email protected]>

Chaoyi Chen (3):
drm/rockchip: vop2: Use drm_format_info_min_pitch() for plane offsets drm/rockchip: vop2: Skip UV plane setup for packed YUV formats drm/rockchip: vop2: Support 8K output by splicing two video ports

 drivers/gpu/drm/rockchip/rockchip_drm_drv.h  |   5 +
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 579 +++++++++++++++++--
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.h |  66 ++-
 drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 370 ++++++++----
 4 files changed, 857 insertions(+), 163 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v3 1/3 drm/rockchip: vop2: Use drm_format_info_min_pitch() for plane offsets

From: Chaoyi Chen <[email protected]>

Use the block aware helper instead of cpp[], the latter aliases char_per_block and is wrong for packed 10-bit formats like NV15, NV20 and NV30.

Tested with modetest[0]:

```
	modetest -s 86:3840x2160 -P \
	59@83:3940x2160~96,0,3840,2160+0+0@NV20 -a
```

fb size (3940x2160), src at (96, 0) with size (3840x2160), dst at (0, 0) with size (3840x2160)

[0]: https://github.com/windowsair/libdrm/tree/src-pos-support

Assisted-by LLM

---
Changes in v3:
- Cast the result of drm_format_info_min_pitc() to u32 to avoid 64bit division.

Changes in v2:
- Missing removal of the replaced line(Heiko).

---
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +2 -2
index bfb384142568..0de038acb56f 100644
@@ -1290,7 +1290,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
 
 	afbc_en = drm_is_afbc(fb->modifier);
 
-	offset = (src->x1 >> 16) * fb->format->cpp[0];
+	offset = drm_format_info_min_pitch(fb->format, 0, src->x1 >> 16);
 
 	/*
 	 * AFBC HDR_PTR must set to the zero offset of the framebuffer.
@@ -1309,7 +1309,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
 		int hsub = fb->format->hsub;
 		int vsub = fb->format->vsub;
 
-		offset = (src->x1 >> 16) * fb->format->cpp[1] / hsub;
+		offset = (u32)drm_format_info_min_pitch(fb->format, 1, src->x1 >> 16) / hsub;
 		offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
 
 		if ((pstate->rotation & DRM_MODE_REFLECT_Y) && !afbc_en)
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v3 1/3] drm/rockchip: vop2: Use drm_format_info_min_pitch() for plane offsets

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/rockchip: vop2: unaligned block offset for 10-bit packed YUV in vop2_plane_atomic_update() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/rockchip: vop2: unaligned block offset for 10-bit packed YUV in vop2_plane_atomic_update()
--

commit e065b869dbf756b6652ed995b5a03b6d5409975e
Author: Chaoyi Chen <[email protected]>

drm/rockchip: vop2: Use drm_format_info_min_pitch() for plane offsets

This commit replaces fb->format->cpp[] with drm_format_info_min_pitch() when calculating plane byte offsets in vop2_plane_atomic_update() to support block-packed 10-bit formats such as NV15, NV20, and NV30.

Quoted 14 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +1 -1
index bfb3841425687..0de038acb56fc 100644
@@ -1290,7 +1290,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
 
 	afbc_en = drm_is_afbc(fb->modifier);
 
-	offset = (src->x1 >> 16) * fb->format->cpp[0];
+	offset = drm_format_info_min_pitch(fb->format, 0, src->x1 >> 16);
 
 	/*
 	 * AFBC HDR_PTR must set to the zero offset of the framebuffer.

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c static void vop2_plane_atomic_update(struct drm_plane *plane, · line 1315

Quoted 8 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +1 -1
@@ -1309,7 +1309,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
 		int hsub = fb->format->hsub;
 		int vsub = fb->format->vsub;
 
-		offset = (src->x1 >> 16) * fb->format->cpp[1] / hsub;
+		offset = (u32)drm_format_info_min_pitch(fb->format, 1, src->x1 >> 16) / hsub;
 		offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
 
 		if ((pstate->rotation & DRM_MODE_REFLECT_Y) && !afbc_en)

[Severity: Medium]
Can this compute misaligned yrgb_mst and uv_mst offsets for NV15, NV20, and NV30 when src->x1 >> 16 is not a multiple of 4?

Those formats pack 4 luma pixels and 2 chroma pairs into 5-byte blocks (char_per_block = { 5, 5, 0 }, block_w = { 4, 2, 0 }), but vop2_plane_atomic_check() only requires 2-pixel alignment on src_x for YUV formats:

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c:vop2_plane_atomic_check() {
    ...
	if (fb->format->is_yuv && src_x % 2) {
		drm_dbg_kms(vop2->drm, "Invalid Source: Yuv format not support odd xpos\n");
		return -EINVAL;
	}
    ...
}

When src_x % 4 == 2 (2.5 bytes into a 5-byte block), drm_format_info_min_pitch() rounds plane 0 up via DIV_ROUND_UP_ULL() to a 3-byte offset inside a packed 4-pixel block, while dividing plane 1's 5-byte result by hsub = 2 on NV15 and NV20 truncates uv_mst down to a 2-byte offset. This corrupts scanout and, when src_x + src_w reaches fb->width with src_w % 4 == 2, can cause DMA to read 1 byte past the validated framebuffer pitch on the final scanline. Should vop2_plane_atomic_check() also require src_x to be aligned to drm_format_info_block_width()?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

PATCH v3 2/3 drm/rockchip: vop2: Skip UV plane setup for packed YUV formats

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

Packed YUV formats store chroma interleaved with luma in the same plane, so they have no plane 1 that the UV address registers could point at.

Restrict both the plane 1 offset calculation and the UV register writes to formats with more than one plane.

---
(no changes since v1)

---
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +2 -2
index 0de038acb56f..e811709bdc72 100644
@@ -1305,7 +1305,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
 	rk_obj = to_rockchip_obj(fb->obj[0]);
 
 	yrgb_mst = rk_obj->dma_addr + offset + fb->offsets[0];
-	if (fb->format->is_yuv) {
+	if (fb->format->is_yuv && fb->format->num_planes > 1) {
 		int hsub = fb->format->hsub;
 		int vsub = fb->format->vsub;
 
@@ -1460,7 +1460,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
 	uv_swap = vop2_win_uv_swap(fb->format->format);
 	vop2_win_write(win, VOP2_WIN_UV_SWAP, uv_swap);
 
-	if (fb->format->is_yuv) {
+	if (fb->format->is_yuv && fb->format->num_planes > 1) {
 		vop2_win_write(win, VOP2_WIN_UV_VIR, DIV_ROUND_UP(fb->pitches[1], 4));
 		vop2_win_write(win, VOP2_WIN_UV_MST, uv_mst);
 	}
Signature · 1 line
2.53.0
#4 lore raw

PATCH v3 3/3 drm/rockchip: vop2: Support 8K output by splicing two video ports

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

A single RK3588 video port can only drive 4096 pixels per line, so modes wider than that (e.g. 7680x4320) cannot be output by one video port alone. The VOP2 can instead merge video ports and two windows:
VP0 drives the left half of the screen, VP1 the right half, and each plane of the CRTC is split horizontally between a window pair (Cluster0/1, Cluster2/3, Esmart0/1, Esmart2/3).

Three components need to be configured: the CRTC, the plane and the post-processing block.

1. For CRTC

In splice mode the CRTC reserved for VP1 is taken over, so make the following changes:

vop2_crtc_atomic_check() sets the new splice_mode flag for modes wider than VOP2_MAX_VP_OUTPUT_WIDTH, reserves the partner video port (rejecting the commit if it is already active) and verifies that both video ports have enough layers for the planes of the CRTC. The reserved video port is taken into account when the layers are distributed over the video ports, and it is registered so that its windows exist, but its own CRTC is kept unusable while it serves as the right half.

2. For Plane

To avoid requiring additional userspace changes, the plane split is performed in the driver. Userspace can thereforekeep updating a single plane that is 8K wide. To do so, make the following changes:

vop2_plane_atomic_check() accepts a source width of twice the maximum input width and validates the split: the plane must use a window with the WIN_FEATURE_SPLICE_LEFT flag, must not be rotated or x-mirrored, and cluster windows that scale down may only do so centred on the screen with a factor below 1.2.

vop2_plane_atomic_update() calculates the left and right source and destination rectangles and programs both windows of a plane pair from the same plane state.

3. For post-processing block

The overlay, alpha and layer mixer setup iterate over the window mask of a video port instead of the planes of its CRTC, because the right video port has no planes of its own. A right window resolves its plane state through left_win.

Gamma LUT and background colour setup are applied to the partner video port as well.

For ease of handling, we impose the following restrictions:
- When VP1 is occupied by splice mode, reject acquiring its mode in .mode_valid.
- When splice mode is enabled, the next commit must not disable splice mode and enable VP1 at the same time.

Assisted-by LLM

---
Changes in v3:
- Rework the left-window splice check to avoid pulling an unrelated CRTC into non-modeset commits, and use the new CRTC mode instead of the stale splice_mode flag(Sashiko).
- Reserve the splice partner window when the partner VP has no CRTC, so it cannot be assigned as another VP's primary plane(Sashiko).
- Only set the partner VP's CFG_DONE while the new state is in splice mode; do not force it when leaving splice mode(Sashiko).
- Program the main and splice video ports in a single layer-mixer pass, and apply the YUV overlay mode to both VPs(Sashiko).

Changes in v2:
- vop2_win_get_pstate(): use the left window's state only in splice mode(Sashiko).
- Reject splice windows already in use by another CRTC(Sashiko).
- Check the splice partner via drm_atomic_get_crtc_state() instead of the runtime flag and unlocked read(Sashiko).
- Set splice_mode_right/left_vp before the error paths of vop2_crtc_atomic_enable()(Sashiko).
- Validate each split half against the min width 4 and max input width; align NV20/NV30 like NV15(Sashiko).
- Latch overlay registers at the left VP's vsync; don't wait for the partner's own cfg-done(Sashiko).
- Program the color key on the window actually being updated(Sashiko).

---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h  |   5 +
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 571 +++++++++++++++++--
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.h |  66 ++-
 drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 370 ++++++++----
 4 files changed, 853 insertions(+), 159 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +5 -0
index 4705dc6b8bd7..db4d50dd3dc9 100644
@@ -54,6 +54,11 @@ struct rockchip_crtc_state {
 	int output_flags;
 	bool enable_afbc;
 	bool yuv_overlay;
+	/**
+	 * @splice_mode: two video ports are joined together to drive a
+	 * display that is wider than a single video port can handle.
+	 */
+	bool splice_mode;
 	u32 bus_format;
 	u32 bus_flags;
 	int color_space;
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +537 -34

859 lines not on this page · raw message

drivers/gpu/drm/rockchip/rockchip_drm_vop2.h +65 -1

132 lines not on this page · raw message

drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +246 -124

614 lines not on this page · raw message

Signature · 1 line
2.53.0
#5 lore raw

Re: [PATCH v3 3/3] drm/rockchip: vop2: Support 8K output by splicing two video ports

Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] drm/rockchip: vop2: vop2_plane_atomic_check() skips splice check if invisible - [High] drm/rockchip…

Thank you for your contribution! Sashiko AI review found 4 potential issues to consider:
- [High] drm/rockchip: vop2: vop2_plane_atomic_check() skips splice check if invisible
- [High] drm/rockchip: vop2: vop2_plane_atomic_update() leaks enabled splice_win
- [Medium] drm/rockchip: vop2: vop2_plane_left_in_splice() ignores old plane/CRTC state
- [Medium] drm/rockchip: vop2: unaligned Esmart downscale and NV15/20/30 split rects
--

commit d894ca3d47163eb563dfd331fbbaf4120ecda639
Author: Chaoyi Chen <[email protected]>

drm/rockchip: vop2: Support 8K output by splicing two video ports

This commit adds splice mode support to the VOP2 driver so that modes wider than 4096 pixels on RK3588 are split horizontally across two video ports and paired hardware windows.

Quoted 4 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +0 -0
index e811709bdc725..c8bf397da7059 100644

[ ... ]

Quoted 66 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +62 -0
@@ -1064,6 +1092,244 @@ static void vop2_crtc_atomic_disable(struct drm_crtc *crtc,
 	}
 }
 
+static bool vop2_vp_uses_splice(struct vop2_video_port *vp,
+				struct drm_crtc_state *cstate)
+{
+	if (!(vp->vop2->data->feature & VOP2_FEATURE_SPLICE))
+		return false;
+
+	return cstate->adjusted_mode.hdisplay > VOP2_MAX_VP_OUTPUT_WIDTH;
+}
+
+static struct vop2_video_port *
+vop2_find_left_splice_vp(struct vop2 *vop2, int right_vp_id)
+{
+	const struct vop2_data *vop2_data = vop2->data;
+	int i;
+
+	if (!(vop2_data->feature & VOP2_FEATURE_SPLICE))
+		return NULL;
+
+	for (i = 0; i < vop2_data->nr_vps; i++) {
+		const struct vop2_video_port_data *vp_data = &vop2_data->vp[i];
+
+		if (vp_data->max_output.width <= VOP2_MAX_VP_OUTPUT_WIDTH)
+			continue;
+
+		if (vp_data->splice_vp_id == right_vp_id)
+			return &vop2->vps[i];
+	}
+
+	return NULL;
+}
+
+static int vop2_calc_splice_rects(struct drm_plane_state *pstate,
+				  struct drm_crtc_state *cstate,
+				  struct drm_rect *left_src,
+				  struct drm_rect *left_dst,
+				  struct drm_rect *right_src,
+				  struct drm_rect *right_dst)
+{
+	struct drm_rect *src = &pstate->src;
+	struct drm_rect *dst = &pstate->dst;
+	struct drm_framebuffer *fb = pstate->fb;
+	int half_hdisplay = cstate->adjusted_mode.crtc_hdisplay >> 1;
+	int hscale = drm_rect_calc_hscale(src, dst, 0, INT_MAX);
+	int dst_w = drm_rect_width(dst);
+	int src_w = drm_rect_width(src) >> 16;
+	int left_dst_w, left_src_w, right_dst_w;
+
+	if (hscale < 0)
+		return hscale;
+
+	left_dst_w = min(half_hdisplay, dst->x2) - dst->x1;
+	if (left_dst_w < 0)
+		left_dst_w = 0;
+	right_dst_w = dst_w - left_dst_w;
+
+	if (!right_dst_w)
+		left_src_w = src_w;
+	else
+		left_src_w = (left_dst_w * hscale) >> 16;
+
+	/*
+	 * Make sure the yrgb/uv mst of the right window are byte aligned

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c static void vop2_crtc_atomic_disable(struct drm_crtc *crtc, · line 1166

Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +10 -0
+	 * with full pixel.
+	 */
+	if (right_dst_w) {
+		if (fb->format->format == DRM_FORMAT_NV15 ||
+		    fb->format->format == DRM_FORMAT_NV20 ||
+		    fb->format->format == DRM_FORMAT_NV30)
+			left_src_w &= ~0x7;
+		else if (fb->format->is_yuv)
+			left_src_w &= ~0x1;
+	}

[Severity: Medium]
Can vop2_calc_splice_rects() produce odd-width source rectangles when downscaling RGB planes on Esmart windows, or misaligned DMA start addresses for NV15, NV20 and NV30?

vop2_plane_atomic_check() rejects odd src_w when downscaling on Esmart windows, but only checks the unsplit src_w. Because left_src_w &= ~0x1 is only applied when fb->format->is_yuv, an even RGB source width split across two Esmart windows can still give both halves odd widths.

Also, for NV15, NV20 and NV30 (where 8 luma pixels pack into 10 bytes), masking left_src_w with ~0x7 only aligns right_src->x1 = src->x1 + (left_src_w << 16) when src->x1 >> 16 is already a multiple of 8, whereas vop2_plane_atomic_check() only enforces src_x % 2 == 0. A src_x of 2, 4 or 6 leaves both windows' yrgb_mst and uv_mst unaligned.

[ ... ]

Quoted 31 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +31 -0
+static int vop2_plane_left_in_splice(struct drm_plane *plane,
+				     struct drm_atomic_commit *state)
+{
+	struct vop2_win *win = to_vop2_win(plane);
+	struct drm_plane_state *lstate;
+	struct drm_crtc_state *lcstate;
+	struct drm_crtc *lcrtc;
+	int ret;
+
+	if (!win->left_win)
+		return 0;
+
+	lstate = drm_atomic_get_new_plane_state(state, &win->left_win->base);
+	if (!lstate) {
+		ret = drm_modeset_lock(&win->left_win->base.mutex,
+				       state->acquire_ctx);
+		if (ret && ret != -EALREADY)
+			return ret;
+
+		lstate = win->left_win->base.state;
+	}
+
+	if (!lstate || !lstate->crtc)
+		return 0;
+
+	lcrtc = lstate->crtc;
+
+	lcstate = drm_atomic_get_new_crtc_state(state, lcrtc);
+	if (!lcstate) {
+		ret = drm_modeset_lock(&lcrtc->mutex, state->acquire_ctx);
+		if (ret && ret != -EALREADY)

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c static void vop2_crtc_atomic_disable(struct drm_crtc *crtc, · line 1331

Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +10 -0
+			return ret;
+
+		lcstate = lcrtc->state;
+	}
+
+	if (!lcstate || !lcstate->enable)
+		return 0;
+
+	return vop2_vp_uses_splice(to_vop2_video_port(lcrtc), lcstate);
+}

[Severity: Medium]
Does vop2_plane_left_in_splice() miss the case where win->left_win was active in splice mode in the old state and is being disabled or detached in the same commit that enables win on another CRTC?

Unlike vop2_crtc_atomic_check(), which checks both rstate->crtc and old_rstate->crtc when entering splice mode, vop2_plane_left_in_splice() only checks the new plane and CRTC states. If a single commit detaches win->left_win from the spliced CRTC and enables win on another CRTC, the second CRTC's atomic_begin() runs before vop2_plane_atomic_disable(), so rk3568_vop2_setup_layer_mixer() overwrites RK3568_OVL_CTRL__LAYERSEL_REGDONE_SEL and migrates win's port mux in RK3568_OVL_PORT_SEL while win is still enabled with the spliced CRTC's buffer.

[ ... ]

Quoted 25 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +12 -5
@@ -1122,15 +1389,33 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	}
 
-	if (src_w > vop2_data->max_input.width ||
-	    src_h > vop2_data->max_input.height) {
+	max_src_w = vop2_data->max_input.width;
+	if (vop2_vp_uses_splice(vp, cstate))
+		max_src_w *= 2;
+
+	if (src_w > max_src_w || src_h > vop2_data->max_input.height) {
 		drm_dbg_kms(vop2->drm, "Invalid source: %dx%d. max input: %dx%d\n",
-			    src_w, src_h,
-			    vop2_data->max_input.width,
-			    vop2_data->max_input.height);
+			    src_w, src_h, max_src_w, vop2_data->max_input.height);
 		return -EINVAL;
 	}
 
+	if (vop2_vp_uses_splice(vp, cstate)) {
+		ret = vop2_plane_splice_check(pstate, cstate);
+		if (ret)
+			return ret;
+	}
+

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c static int vop2_plane_atomic_check(struct drm_plane *plane, · line 1417

Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +10 -0
+	if (win->left_win) {
+		ret = vop2_plane_left_in_splice(plane, astate);
+		if (ret < 0)
+			return ret;
+		if (ret) {
+			drm_dbg_kms(vop2->drm, "%s is in use by %s in splice mode\n",
+				    win->left_win->data->name, win->data->name);
+			return -EBUSY;
+		}
+	}

[Severity: High]
Can an off-screen plane bypass vop2_plane_left_in_splice() and vop2_plane_splice_check()?

vop2_plane_atomic_check() returns 0 when !pstate->visible before reaching these checks, even though pstate->crtc is set and the plane remains in cstate->plane_mask. If a right-half splice window is attached to another CRTC at off-screen coordinates while splice mode is active, rk3568_vop2_setup_overlay() still iterates over crtc->state->plane_mask and reassigns the window's port and layer muxing in RK3568_OVL_PORT_SEL and RK3568_OVL_LAYER_SEL, and vop2_plane_atomic_update() then calls vop2_plane_atomic_disable(), turning off the active right-half window.

[ ... ]

Quoted 21 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +17 -0
@@ -1487,6 +1780,45 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
 	}
 }
 
+static void vop2_plane_atomic_update(struct drm_plane *plane,
+				     struct drm_atomic_commit *state)
+{
+	struct drm_plane_state *pstate = plane->state;
+	struct drm_crtc *crtc = pstate->crtc;
+	struct vop2_win *win = to_vop2_win(plane);
+	struct drm_crtc_state *cstate;
+	struct rockchip_crtc_state *vcstate;
+	struct drm_rect left_src, left_dst, right_src, right_dst;
+
+	if (WARN_ON(!crtc))
+		return;
+
+	if (!pstate->visible) {
+		vop2_plane_atomic_disable(plane, state);
+		return;
+	}

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c static void vop2_plane_atomic_update(struct drm_plane *plane, · line 1809

Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +10 -0
+
+	cstate = drm_atomic_get_new_crtc_state(state, crtc);
+	if (!cstate)
+		cstate = crtc->state;
+	vcstate = to_rockchip_crtc_state(cstate);
+
+	if (!vcstate->splice_mode) {
+		vop2_win_atomic_update(win, &pstate->src, &pstate->dst, pstate);
+		return;
+	}

[Severity: High]
Does vop2_plane_atomic_update() leave win->splice_win enabled when a visible plane moves from a spliced CRTC to a non-spliced CRTC, or when its CRTC switches out of splice mode?

When the plane stays visible across the commit, vop2_plane_atomic_disable() is not called. vop2_plane_atomic_update() sees !vcstate->splice_mode on the new CRTC state, updates only win, and returns without disabling win->splice_win, leaving the right-half window enabled and scanning out the old framebuffer DMA address after the old framebuffer is unreferenced and freed.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3