* [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups
@ 2025-12-15 14:09 Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON Nicolas Frattaroli
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Nicolas Frattaroli @ 2025-12-15 14:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: David Laight, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel, Nicolas Frattaroli
I'm taking over this series to get it across the finish line. Original
cover letter from Daniel Stone on v1:
> Hi,
> This series is a pretty small and consistent one for VOP2. The atomic
> uAPI very clearly specifies that drivers should either do what userspace
> requested (on a successful commit), or fail atomic_check if it is not
> for any reason possible to do what userspace requested.
>
> VOP2 is unfortunately littered with a bunch of cases where it will apply
> fixups after atomic_check - doing something different to what userspace
> requested, e.g. clipping or aligning regions - or throw error messages
> into the log when userspace does request a condition which can't be met.
>
> Doing something different to what was requested is bad because it
> results in unexpected visual output which can look like artifacts.
> Throwing errors into the log is bad because generic userspace will
> reasonably attempt to try any configuration it can. For example,
> throwing an error message on a plane not being aligned to a 16 pixel
> boundary can result in 15 frames' worth of error output in the log when
> a window is being animated across a screen.
>
> This series removes all post-check fixups - failing the check if the
> configuration cannot be applied - and also demotes all messages about
> unsupported configurations to DEBUG_KMS.
>
> Cheers,
> Daniel
---
Changes in v5:
- Reword message in "Switch impossible format conditional to WARN_ON" to
remove the reference to "staggering on", as it previously didn't do
that either.
- Return from atomic_update if any of the WARN_ON conditionals came
true.
- Link to v4: https://lore.kernel.org/r/20251211-vop2-atomic-fixups-v4-0-5d50eda26bf8@collabora.com
Changes in v4:
- s/64-byte/64-pixel/
- Link to v3: https://lore.kernel.org/r/20251209-vop2-atomic-fixups-v3-0-07c48f0f1f0d@collabora.com
Changes in v3:
- Change the AFBC source rectangle debug message to talk about 4-pixel
alignment instead of 4-byte alignment.
- Fix another eSmart->Esmart casing case in a debug message
- Link to v2: https://lore.kernel.org/r/20251206-vop2-atomic-fixups-v2-0-7fb45bbfbebd@collabora.com
Changes in v2:
- Dropped patches [1, 5] as they were already applied.
- Changed the patch subject to use prefix "drm/rockchip: vop2:" for the
remaining ones.
- Fixed a checkpatch nag about commenting style in "Switch impossible
pos conditional to WARN_ON".
- Reworded "eSmart" to "Esmart" for consistency, and to avoid drawing
Tim Apple's ire.
- Make the hopefully impossible WARN_ON format conditional in
vop2_plane_atomic_check still bubble the error up to userspace,
instead of continuing on.
- Use dest_w instead of dsp_w in patch "Enforce scaling workaround
in plane_check", to avoid a compiler error.
- Only reject non-multiple-of-4-pixel-wide framebuffers on
RK3566/RK3568, as the other SoCs have no such limitation. (Thank you
to Andy Yan for doing the research to confirm this!)
- Consequently also only WARN_ON if this condition is violated in
atomic_update on those SoCs.
- Link to v1: https://lore.kernel.org/dri-devel/20251015110042.41273-1-daniels@collabora.com/
Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
To: Chaoyi Chen <chaoyi.chen@rock-chips.com>
To: Sandy Huang <hjc@rock-chips.com>
To: Heiko Stübner <heiko@sntech.de>
To: Andy Yan <andy.yan@rock-chips.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Maxime Ripard <mripard@kernel.org>
To: Thomas Zimmermann <tzimmermann@suse.de>
To: David Airlie <airlied@gmail.com>
To: Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: kernel@collabora.com
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
Daniel Stone (8):
drm/rockchip: vop2: Switch impossible format conditional to WARN_ON
drm/rockchip: vop2: Switch impossible pos conditional to WARN_ON
drm/rockchip: vop2: Fix Esmart test condition
drm/rockchip: vop2: Enforce scaling workaround in plane_check
drm/rockchip: vop2: Enforce AFBC source alignment in plane_check
drm/rockchip: vop2: Enforce AFBC transform stride align in plane_check
drm/rockchip: vop2: Use drm_is_afbc helper function
drm/rockchip: vop2: Simplify format_mod_supported
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 137 ++++++++++++---------------
1 file changed, 62 insertions(+), 75 deletions(-)
---
base-commit: 3e7f562e20ee87a25e104ef4fce557d39d62fa85
change-id: 20251206-vop2-atomic-fixups-0c30e0980f85
Best regards,
--
Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
@ 2025-12-15 14:09 ` Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 2/8] drm/rockchip: vop2: Switch impossible pos " Nicolas Frattaroli
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Nicolas Frattaroli @ 2025-12-15 14:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: David Laight, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel, Nicolas Frattaroli
From: Daniel Stone <daniels@collabora.com>
We should never be able to create a framebuffer with an unsupported
format, so throw a warning if this ever happens.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 498df0ce4680..20b49209ddcd 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1030,7 +1030,8 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
return 0;
format = vop2_convert_format(fb->format->format);
- if (format < 0)
+ /* We shouldn't be able to create a fb for an unsupported format */
+ if (WARN_ON(format < 0))
return format;
/* Co-ordinates have now been clipped */
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 2/8] drm/rockchip: vop2: Switch impossible pos conditional to WARN_ON
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON Nicolas Frattaroli
@ 2025-12-15 14:09 ` Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 3/8] drm/rockchip: vop2: Fix Esmart test condition Nicolas Frattaroli
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Nicolas Frattaroli @ 2025-12-15 14:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: David Laight, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel, Nicolas Frattaroli
From: Daniel Stone <daniels@collabora.com>
We already clip the plane to the display bounds in atomic_check, and
ensure that it is sufficiently sized. Instead of trying to catch this
and adjust for it in atomic_update, just assert that atomic_check has
done its job.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 20b49209ddcd..1cad5a8ece61 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1214,28 +1214,16 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
src_w = drm_rect_width(src) >> 16;
src_h = drm_rect_height(src) >> 16;
dsp_w = drm_rect_width(dest);
-
- if (dest->x1 + dsp_w > adjusted_mode->hdisplay) {
- drm_dbg_kms(vop2->drm,
- "vp%d %s dest->x1[%d] + dsp_w[%d] exceed mode hdisplay[%d]\n",
- vp->id, win->data->name, dest->x1, dsp_w, adjusted_mode->hdisplay);
- dsp_w = adjusted_mode->hdisplay - dest->x1;
- if (dsp_w < 4)
- dsp_w = 4;
- src_w = dsp_w * src_w / drm_rect_width(dest);
- }
-
dsp_h = drm_rect_height(dest);
- if (dest->y1 + dsp_h > adjusted_mode->vdisplay) {
- drm_dbg_kms(vop2->drm,
- "vp%d %s dest->y1[%d] + dsp_h[%d] exceed mode vdisplay[%d]\n",
- vp->id, win->data->name, dest->y1, dsp_h, adjusted_mode->vdisplay);
- dsp_h = adjusted_mode->vdisplay - dest->y1;
- if (dsp_h < 4)
- dsp_h = 4;
- src_h = dsp_h * src_h / drm_rect_height(dest);
- }
+ /* drm_atomic_helper_check_plane_state calls drm_rect_clip_scaled for
+ * us, which keeps our planes bounded within the CRTC active area
+ */
+ if (WARN_ON(dest->x1 + dsp_w > adjusted_mode->hdisplay) ||
+ WARN_ON(dest->y1 + dsp_h > adjusted_mode->vdisplay) ||
+ WARN_ON(dsp_w < 4) || WARN_ON(dsp_h < 4) ||
+ WARN_ON(src_w < 4) || WARN_ON(src_h < 4))
+ return;
/*
* This is workaround solution for IC design:
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 3/8] drm/rockchip: vop2: Fix Esmart test condition
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 2/8] drm/rockchip: vop2: Switch impossible pos " Nicolas Frattaroli
@ 2025-12-15 14:09 ` Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 4/8] drm/rockchip: vop2: Enforce scaling workaround in plane_check Nicolas Frattaroli
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Nicolas Frattaroli @ 2025-12-15 14:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: David Laight, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel, Nicolas Frattaroli
From: Daniel Stone <daniels@collabora.com>
If we want to find out if a window is Esmart or not, test for not being
a cluster window, rather than AFBDC presence.
No functional effect as only cluster windows support AFBC decode.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 1cad5a8ece61..fbcc655cb583 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1229,12 +1229,10 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
* This is workaround solution for IC design:
* esmart can't support scale down when src_w % 16 == 1.
*/
- if (!(win->data->feature & WIN_FEATURE_AFBDC)) {
- if (src_w > dsp_w && (src_w & 0xf) == 1) {
- drm_dbg_kms(vop2->drm, "vp%d %s act_w[%d] MODE 16 == 1\n",
- vp->id, win->data->name, src_w);
- src_w -= 1;
- }
+ if (!vop2_cluster_window(win) && src_w > dsp_w && (src_w & 1)) {
+ drm_dbg_kms(vop2->drm, "vp%d %s act_w[%d] MODE 16 == 1\n",
+ vp->id, win->data->name, src_w);
+ src_w -= 1;
}
if (afbc_en && src_w % 4) {
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 4/8] drm/rockchip: vop2: Enforce scaling workaround in plane_check
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (2 preceding siblings ...)
2025-12-15 14:09 ` [PATCH v5 3/8] drm/rockchip: vop2: Fix Esmart test condition Nicolas Frattaroli
@ 2025-12-15 14:09 ` Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 5/8] drm/rockchip: vop2: Enforce AFBC source alignment " Nicolas Frattaroli
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Nicolas Frattaroli @ 2025-12-15 14:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: David Laight, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel, Nicolas Frattaroli
From: Daniel Stone <daniels@collabora.com>
It seems only cluster windows are capable of applying downscaling when
the source region has an odd width. Instead of applying a workaround
inside atomic_update, fail the plane check if this is requested.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index fbcc655cb583..ded8b9952c6d 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -998,6 +998,7 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
struct drm_crtc *crtc = pstate->crtc;
struct drm_crtc_state *cstate;
struct vop2_video_port *vp;
+ struct vop2_win *win = to_vop2_win(plane);
struct vop2 *vop2;
const struct vop2_data *vop2_data;
struct drm_rect *dest = &pstate->dst;
@@ -1065,6 +1066,16 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
return -EINVAL;
}
+ /*
+ * This is workaround solution for IC design:
+ * esmart can't support scale down when src_w % 16 == 1.
+ */
+ if (!vop2_cluster_window(win) && src_w > dest_w && (src_w & 1)) {
+ drm_dbg_kms(vop2->drm,
+ "Esmart windows cannot downscale odd-width source regions\n");
+ return -EINVAL;
+ }
+
return 0;
}
@@ -1225,16 +1236,6 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
WARN_ON(src_w < 4) || WARN_ON(src_h < 4))
return;
- /*
- * This is workaround solution for IC design:
- * esmart can't support scale down when src_w % 16 == 1.
- */
- if (!vop2_cluster_window(win) && src_w > dsp_w && (src_w & 1)) {
- drm_dbg_kms(vop2->drm, "vp%d %s act_w[%d] MODE 16 == 1\n",
- vp->id, win->data->name, src_w);
- src_w -= 1;
- }
-
if (afbc_en && src_w % 4) {
drm_dbg_kms(vop2->drm, "vp%d %s src_w[%d] not 4 pixel aligned\n",
vp->id, win->data->name, src_w);
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 5/8] drm/rockchip: vop2: Enforce AFBC source alignment in plane_check
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (3 preceding siblings ...)
2025-12-15 14:09 ` [PATCH v5 4/8] drm/rockchip: vop2: Enforce scaling workaround in plane_check Nicolas Frattaroli
@ 2025-12-15 14:09 ` Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 6/8] drm/rockchip: vop2: Enforce AFBC transform stride align " Nicolas Frattaroli
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Nicolas Frattaroli @ 2025-12-15 14:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: David Laight, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel, Nicolas Frattaroli
From: Daniel Stone <daniels@collabora.com>
Planes can only source AFBC framebuffers at multiples of 4px wide on
RK3566/RK3568. Instead of clipping on all SoCs when the user asks for an
unaligned source rectangle, reject the configuration in the plane's
atomic check on RK3566/RK3568 only.
Signed-off-by: Daniel Stone <daniels@collabora.com>
[Make RK3566/RK3568 specific, reword message, s/byte/pixel/]
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index ded8b9952c6d..0eab3370f088 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1076,6 +1076,13 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
return -EINVAL;
}
+ if (vop2->version == VOP_VERSION_RK3568 && drm_is_afbc(fb->modifier) && src_w % 4) {
+ drm_dbg_kms(vop2->drm,
+ "AFBC source rectangles must be 4-pixel aligned; is %d\n",
+ src_w);
+ return -EINVAL;
+ }
+
return 0;
}
@@ -1236,11 +1243,9 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
WARN_ON(src_w < 4) || WARN_ON(src_h < 4))
return;
- if (afbc_en && src_w % 4) {
- drm_dbg_kms(vop2->drm, "vp%d %s src_w[%d] not 4 pixel aligned\n",
- vp->id, win->data->name, src_w);
- src_w = ALIGN_DOWN(src_w, 4);
- }
+ if (vop2->version == VOP_VERSION_RK3568 && drm_is_afbc(fb->modifier))
+ if (WARN_ON(src_w % 4))
+ return;
act_info = (src_h - 1) << 16 | ((src_w - 1) & 0xffff);
dsp_info = (dsp_h - 1) << 16 | ((dsp_w - 1) & 0xffff);
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 6/8] drm/rockchip: vop2: Enforce AFBC transform stride align in plane_check
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (4 preceding siblings ...)
2025-12-15 14:09 ` [PATCH v5 5/8] drm/rockchip: vop2: Enforce AFBC source alignment " Nicolas Frattaroli
@ 2025-12-15 14:09 ` Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 7/8] drm/rockchip: vop2: Use drm_is_afbc helper function Nicolas Frattaroli
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Nicolas Frattaroli @ 2025-12-15 14:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: David Laight, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel, Nicolas Frattaroli
From: Daniel Stone <daniels@collabora.com>
Make sure we can't break the hardware by requesting an unsupported
configuration.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 0eab3370f088..7591a34ba912 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1083,6 +1083,15 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
return -EINVAL;
}
+ if (drm_is_afbc(fb->modifier) &&
+ pstate->rotation &
+ (DRM_MODE_REFLECT_X | DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_270) &&
+ (fb->pitches[0] << 3) / vop2_get_bpp(fb->format) % 64) {
+ drm_dbg_kms(vop2->drm,
+ "AFBC buffers must be 64-pixel aligned for horizontal rotation or mirroring\n");
+ return -EINVAL;
+ }
+
return 0;
}
@@ -1290,9 +1299,6 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
* with WIN_VIR_STRIDE.
*/
stride = (fb->pitches[0] << 3) / bpp;
- if ((stride & 0x3f) && (xmirror || rotate_90 || rotate_270))
- drm_dbg_kms(vop2->drm, "vp%d %s stride[%d] not 64 pixel aligned\n",
- vp->id, win->data->name, stride);
/* It's for head stride, each head size is 16 byte */
stride = ALIGN(stride, block_w) / block_w * 16;
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 7/8] drm/rockchip: vop2: Use drm_is_afbc helper function
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (5 preceding siblings ...)
2025-12-15 14:09 ` [PATCH v5 6/8] drm/rockchip: vop2: Enforce AFBC transform stride align " Nicolas Frattaroli
@ 2025-12-15 14:09 ` Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 8/8] drm/rockchip: vop2: Simplify format_mod_supported Nicolas Frattaroli
2026-01-08 19:04 ` [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Heiko Stuebner
8 siblings, 0 replies; 10+ messages in thread
From: Nicolas Frattaroli @ 2025-12-15 14:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: David Laight, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel, Nicolas Frattaroli
From: Daniel Stone <daniels@collabora.com>
We don't need to do a long open-coded walk here; we can simply check the
modifier value.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 7591a34ba912..707b48c7e9d8 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1207,7 +1207,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
return;
}
- afbc_en = rockchip_afbc(plane, fb->modifier);
+ afbc_en = drm_is_afbc(fb->modifier);
offset = (src->x1 >> 16) * fb->format->cpp[0];
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 8/8] drm/rockchip: vop2: Simplify format_mod_supported
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (6 preceding siblings ...)
2025-12-15 14:09 ` [PATCH v5 7/8] drm/rockchip: vop2: Use drm_is_afbc helper function Nicolas Frattaroli
@ 2025-12-15 14:09 ` Nicolas Frattaroli
2026-01-08 19:04 ` [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Heiko Stuebner
8 siblings, 0 replies; 10+ messages in thread
From: Nicolas Frattaroli @ 2025-12-15 14:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: David Laight, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel, Nicolas Frattaroli
From: Daniel Stone <daniels@collabora.com>
Make it a little less convoluted, and just directly check if the
combination of plane + format + modifier is supported.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 56 +++++++++++-----------------
1 file changed, 22 insertions(+), 34 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 707b48c7e9d8..a0099e4dd4ea 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -367,59 +367,47 @@ static bool is_yuv_output(u32 bus_format)
}
}
-static bool rockchip_afbc(struct drm_plane *plane, u64 modifier)
-{
- int i;
-
- if (modifier == DRM_FORMAT_MOD_LINEAR)
- return false;
-
- for (i = 0 ; i < plane->modifier_count; i++)
- if (plane->modifiers[i] == modifier)
- return true;
-
- return false;
-}
-
static bool rockchip_vop2_mod_supported(struct drm_plane *plane, u32 format,
u64 modifier)
{
struct vop2_win *win = to_vop2_win(plane);
struct vop2 *vop2 = win->vop2;
+ int i;
+ /* No support for implicit modifiers */
if (modifier == DRM_FORMAT_MOD_INVALID)
return false;
- if (vop2->version == VOP_VERSION_RK3568) {
- if (vop2_cluster_window(win)) {
- if (modifier == DRM_FORMAT_MOD_LINEAR) {
- drm_dbg_kms(vop2->drm,
- "Cluster window only supports format with afbc\n");
- return false;
- }
- }
+ /* The cluster window on 3568 is AFBC-only */
+ if (vop2->version == VOP_VERSION_RK3568 && vop2_cluster_window(win) &&
+ !drm_is_afbc(modifier)) {
+ drm_dbg_kms(vop2->drm,
+ "Cluster window only supports format with afbc\n");
+ return false;
}
- if (format == DRM_FORMAT_XRGB2101010 || format == DRM_FORMAT_XBGR2101010) {
- if (vop2->version == VOP_VERSION_RK3588) {
- if (!rockchip_afbc(plane, modifier)) {
- drm_dbg_kms(vop2->drm, "Only support 32 bpp format with afbc\n");
- return false;
- }
- }
+ /* 10bpc formats on 3588 are AFBC-only */
+ if (vop2->version == VOP_VERSION_RK3588 && !drm_is_afbc(modifier) &&
+ (format == DRM_FORMAT_XRGB2101010 || format == DRM_FORMAT_XBGR2101010)) {
+ drm_dbg_kms(vop2->drm, "Only support 10bpc format with afbc\n");
+ return false;
}
+ /* Linear is otherwise supported everywhere */
if (modifier == DRM_FORMAT_MOD_LINEAR)
return true;
- if (!rockchip_afbc(plane, modifier)) {
- drm_dbg_kms(vop2->drm, "Unsupported format modifier 0x%llx\n",
- modifier);
-
+ /* Not all format+modifier combinations are allowable */
+ if (vop2_convert_afbc_format(format) == VOP2_AFBC_FMT_INVALID)
return false;
+
+ /* Different windows have different format/modifier support */
+ for (i = 0; i < plane->modifier_count; i++) {
+ if (plane->modifiers[i] == modifier)
+ return true;
}
- return vop2_convert_afbc_format(format) >= 0;
+ return false;
}
/*
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (7 preceding siblings ...)
2025-12-15 14:09 ` [PATCH v5 8/8] drm/rockchip: vop2: Simplify format_mod_supported Nicolas Frattaroli
@ 2026-01-08 19:04 ` Heiko Stuebner
8 siblings, 0 replies; 10+ messages in thread
From: Heiko Stuebner @ 2026-01-08 19:04 UTC (permalink / raw)
To: Sandy Huang, Andy Yan, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Chaoyi Chen,
Nicolas Frattaroli
Cc: Heiko Stuebner, David Laight, dri-devel, linux-arm-kernel,
linux-rockchip, linux-kernel, Daniel Stone, kernel
On Mon, 15 Dec 2025 15:09:16 +0100, Nicolas Frattaroli wrote:
> I'm taking over this series to get it across the finish line. Original
> cover letter from Daniel Stone on v1:
>
> > Hi,
> > This series is a pretty small and consistent one for VOP2. The atomic
> > uAPI very clearly specifies that drivers should either do what userspace
> > requested (on a successful commit), or fail atomic_check if it is not
> > for any reason possible to do what userspace requested.
> >
> > VOP2 is unfortunately littered with a bunch of cases where it will apply
> > fixups after atomic_check - doing something different to what userspace
> > requested, e.g. clipping or aligning regions - or throw error messages
> > into the log when userspace does request a condition which can't be met.
> >
> > Doing something different to what was requested is bad because it
> > results in unexpected visual output which can look like artifacts.
> > Throwing errors into the log is bad because generic userspace will
> > reasonably attempt to try any configuration it can. For example,
> > throwing an error message on a plane not being aligned to a 16 pixel
> > boundary can result in 15 frames' worth of error output in the log when
> > a window is being animated across a screen.
> >
> > This series removes all post-check fixups - failing the check if the
> > configuration cannot be applied - and also demotes all messages about
> > unsupported configurations to DEBUG_KMS.
> >
> > Cheers,
> > Daniel
>
> [...]
Applied, thanks!
[1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON
commit: 78de5d28d7207f816565fa43ec44e6735c319ddf
[2/8] drm/rockchip: vop2: Switch impossible pos conditional to WARN_ON
commit: 2f4e3f2bef45d1eb4d8204c5f204cf274e8a6ca6
[3/8] drm/rockchip: vop2: Fix Esmart test condition
commit: f403945d240417761d404cb1ce8fa2c1ec02daf5
[4/8] drm/rockchip: vop2: Enforce scaling workaround in plane_check
commit: dfb673c71fc0039a6495731d0c0fcefa8a97541d
[5/8] drm/rockchip: vop2: Enforce AFBC source alignment in plane_check
commit: 8cdd4d858d7aaeb583ae2b4e5a0378936b18f0f0
[6/8] drm/rockchip: vop2: Enforce AFBC transform stride align in plane_check
commit: 081676de4a22341a877ce81c4d5364737d167859
[7/8] drm/rockchip: vop2: Use drm_is_afbc helper function
commit: c8c85c0a7fc2a545749da1ab8dc866de025c2314
[8/8] drm/rockchip: vop2: Simplify format_mod_supported
commit: 28c2490458ca935b2d793ec0e6c22265855255a2
Best regards,
--
Heiko Stuebner <heiko@sntech.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-01-08 19:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-15 14:09 [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 2/8] drm/rockchip: vop2: Switch impossible pos " Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 3/8] drm/rockchip: vop2: Fix Esmart test condition Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 4/8] drm/rockchip: vop2: Enforce scaling workaround in plane_check Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 5/8] drm/rockchip: vop2: Enforce AFBC source alignment " Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 6/8] drm/rockchip: vop2: Enforce AFBC transform stride align " Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 7/8] drm/rockchip: vop2: Use drm_is_afbc helper function Nicolas Frattaroli
2025-12-15 14:09 ` [PATCH v5 8/8] drm/rockchip: vop2: Simplify format_mod_supported Nicolas Frattaroli
2026-01-08 19:04 ` [PATCH v5 0/8] drm/rockchip: No more post-atomic_check fixups Heiko Stuebner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®