* [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups
@ 2025-12-11 20:40 Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON Nicolas Frattaroli
` (7 more replies)
0 siblings, 8 replies; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-11 20:40 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: 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 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: 7b1d0dfc434030b66fd2837f17db5c966a72590e
change-id: 20251206-vop2-atomic-fixups-0c30e0980f85
Best regards,
--
Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON
2025-12-11 20:40 [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
@ 2025-12-11 20:40 ` Nicolas Frattaroli
2025-12-11 22:38 ` David Laight
2025-12-11 20:40 ` [PATCH v4 2/8] drm/rockchip: vop2: Switch impossible pos " Nicolas Frattaroli
` (6 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-11 20:40 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: 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, instead of attempting
to stagger on.
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 related [flat|nested] 15+ messages in thread
* [PATCH v4 2/8] drm/rockchip: vop2: Switch impossible pos conditional to WARN_ON
2025-12-11 20:40 [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON Nicolas Frattaroli
@ 2025-12-11 20:40 ` Nicolas Frattaroli
2025-12-11 22:41 ` David Laight
2025-12-11 20:40 ` [PATCH v4 3/8] drm/rockchip: vop2: Fix Esmart test condition Nicolas Frattaroli
` (5 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-11 20:40 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: 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 | 29 +++++++++-------------------
1 file changed, 9 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..81b3eba07095 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1214,28 +1214,17 @@ 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
+ */
+ 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);
/*
* This is workaround solution for IC design:
--
2.52.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 3/8] drm/rockchip: vop2: Fix Esmart test condition
2025-12-11 20:40 [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 2/8] drm/rockchip: vop2: Switch impossible pos " Nicolas Frattaroli
@ 2025-12-11 20:40 ` Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 4/8] drm/rockchip: vop2: Enforce scaling workaround in plane_check Nicolas Frattaroli
` (4 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-11 20:40 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: 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 81b3eba07095..9d715d7659af 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1230,12 +1230,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 related [flat|nested] 15+ messages in thread
* [PATCH v4 4/8] drm/rockchip: vop2: Enforce scaling workaround in plane_check
2025-12-11 20:40 [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (2 preceding siblings ...)
2025-12-11 20:40 ` [PATCH v4 3/8] drm/rockchip: vop2: Fix Esmart test condition Nicolas Frattaroli
@ 2025-12-11 20:40 ` Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 5/8] drm/rockchip: vop2: Enforce AFBC source alignment " Nicolas Frattaroli
` (3 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-11 20:40 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: 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 9d715d7659af..6d4f22872e67 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;
}
@@ -1226,16 +1237,6 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
WARN_ON(src_w < 4);
WARN_ON(src_h < 4);
- /*
- * 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 related [flat|nested] 15+ messages in thread
* [PATCH v4 5/8] drm/rockchip: vop2: Enforce AFBC source alignment in plane_check
2025-12-11 20:40 [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (3 preceding siblings ...)
2025-12-11 20:40 ` [PATCH v4 4/8] drm/rockchip: vop2: Enforce scaling workaround in plane_check Nicolas Frattaroli
@ 2025-12-11 20:40 ` Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 6/8] drm/rockchip: vop2: Enforce AFBC transform stride align " Nicolas Frattaroli
` (2 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-11 20:40 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: 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 | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 6d4f22872e67..a029ed73dda7 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;
}
@@ -1237,11 +1244,8 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
WARN_ON(src_w < 4);
WARN_ON(src_h < 4);
- 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))
+ WARN_ON(src_w % 4);
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 related [flat|nested] 15+ messages in thread
* [PATCH v4 6/8] drm/rockchip: vop2: Enforce AFBC transform stride align in plane_check
2025-12-11 20:40 [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (4 preceding siblings ...)
2025-12-11 20:40 ` [PATCH v4 5/8] drm/rockchip: vop2: Enforce AFBC source alignment " Nicolas Frattaroli
@ 2025-12-11 20:40 ` Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 7/8] drm/rockchip: vop2: Use drm_is_afbc helper function Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 8/8] drm/rockchip: vop2: Simplify format_mod_supported Nicolas Frattaroli
7 siblings, 0 replies; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-11 20:40 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: 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 a029ed73dda7..1d12e00ec49f 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 related [flat|nested] 15+ messages in thread
* [PATCH v4 7/8] drm/rockchip: vop2: Use drm_is_afbc helper function
2025-12-11 20:40 [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (5 preceding siblings ...)
2025-12-11 20:40 ` [PATCH v4 6/8] drm/rockchip: vop2: Enforce AFBC transform stride align " Nicolas Frattaroli
@ 2025-12-11 20:40 ` Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 8/8] drm/rockchip: vop2: Simplify format_mod_supported Nicolas Frattaroli
7 siblings, 0 replies; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-11 20:40 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: 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 1d12e00ec49f..494f4d48f9fe 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 related [flat|nested] 15+ messages in thread
* [PATCH v4 8/8] drm/rockchip: vop2: Simplify format_mod_supported
2025-12-11 20:40 [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
` (6 preceding siblings ...)
2025-12-11 20:40 ` [PATCH v4 7/8] drm/rockchip: vop2: Use drm_is_afbc helper function Nicolas Frattaroli
@ 2025-12-11 20:40 ` Nicolas Frattaroli
7 siblings, 0 replies; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-11 20:40 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen
Cc: 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 494f4d48f9fe..4659c55d0da4 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 related [flat|nested] 15+ messages in thread
* Re: [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON
2025-12-11 20:40 ` [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON Nicolas Frattaroli
@ 2025-12-11 22:38 ` David Laight
2025-12-12 12:43 ` Nicolas Frattaroli
0 siblings, 1 reply; 15+ messages in thread
From: David Laight @ 2025-12-11 22:38 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel
On Thu, 11 Dec 2025 21:40:31 +0100
Nicolas Frattaroli <nicolas.frattaroli@collabora.com> wrote:
> 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, instead of attempting
> to stagger on.
It doesn't look like you've changed the behaviour.
Except that all the systems with PANIC_ON_WARN set will panic.
I believe that is somewhere over 90% of systems.
David
>
> 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 */
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 2/8] drm/rockchip: vop2: Switch impossible pos conditional to WARN_ON
2025-12-11 20:40 ` [PATCH v4 2/8] drm/rockchip: vop2: Switch impossible pos " Nicolas Frattaroli
@ 2025-12-11 22:41 ` David Laight
2025-12-15 17:57 ` Daniel Stone
0 siblings, 1 reply; 15+ messages in thread
From: David Laight @ 2025-12-11 22:41 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel
On Thu, 11 Dec 2025 21:40:32 +0100
Nicolas Frattaroli <nicolas.frattaroli@collabora.com> wrote:
> 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 | 29 +++++++++-------------------
> 1 file changed, 9 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..81b3eba07095 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> @@ -1214,28 +1214,17 @@ 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
> + */
> + 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);
You need to do something when the tests fail.
Carrying on regardless is never right.
David
>
> /*
> * This is workaround solution for IC design:
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON
2025-12-11 22:38 ` David Laight
@ 2025-12-12 12:43 ` Nicolas Frattaroli
2025-12-15 17:55 ` Daniel Stone
0 siblings, 1 reply; 15+ messages in thread
From: Nicolas Frattaroli @ 2025-12-12 12:43 UTC (permalink / raw)
To: David Laight
Cc: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chaoyi Chen, dri-devel, linux-arm-kernel, linux-rockchip,
linux-kernel, Daniel Stone, kernel
On Thursday, 11 December 2025 23:38:22 Central European Standard Time David Laight wrote:
> On Thu, 11 Dec 2025 21:40:31 +0100
> Nicolas Frattaroli <nicolas.frattaroli@collabora.com> wrote:
>
> > 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, instead of attempting
> > to stagger on.
>
> It doesn't look like you've changed the behaviour.
Yes, the commit message needs to be adjusted.
> Except that all the systems with PANIC_ON_WARN set will panic.
> I believe that is somewhere over 90% of systems.
I also like making up statistics. Warning here is the correct move
in my opinion because this warning being triggered indicates a bug
in the kernel code, and with PANIC_ON_WARN the user explicitly says
they would rather panic in such a case than treat it as an abnormal
condition that is recoverable.
The reason why this condition ever occurring should be treated as an
abnormal condition is because the DRM subsystem should guarantee we
don't get a framebuffer of a format we didn't explicitly declare
support for in the first place. So this condition being hit either
means drm_universal_plane_init is broken, or the array of formats
that's passed to it is out of sync with the conversion code, which
is also a bug. Or someone managed to thoroughly hose DRM's internal
kernel-side data structures, which is precisely the kind of thing
PANIC_ON_WARN users want to abort for.
>
> David
>
> >
> > 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 */
> >
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON
2025-12-12 12:43 ` Nicolas Frattaroli
@ 2025-12-15 17:55 ` Daniel Stone
2025-12-15 18:16 ` David Laight
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Stone @ 2025-12-15 17:55 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: David Laight, Sandy Huang, Heiko Stübner, Andy Yan,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Chaoyi Chen, dri-devel, linux-arm-kernel,
linux-rockchip, linux-kernel, Daniel Stone, kernel
Hi,
On Fri, 12 Dec 2025 at 12:46, Nicolas Frattaroli
<nicolas.frattaroli@collabora.com> wrote:
> On Thursday, 11 December 2025 23:38:22 Central European Standard Time David Laight wrote:
> > Except that all the systems with PANIC_ON_WARN set will panic.
> > I believe that is somewhere over 90% of systems.
>
> I also like making up statistics. Warning here is the correct move
> in my opinion because this warning being triggered indicates a bug
> in the kernel code, and with PANIC_ON_WARN the user explicitly says
> they would rather panic in such a case than treat it as an abnormal
> condition that is recoverable.
>
> The reason why this condition ever occurring should be treated as an
> abnormal condition is because the DRM subsystem should guarantee we
> don't get a framebuffer of a format we didn't explicitly declare
> support for in the first place. So this condition being hit either
> means drm_universal_plane_init is broken, or the array of formats
> that's passed to it is out of sync with the conversion code, which
> is also a bug. Or someone managed to thoroughly hose DRM's internal
> kernel-side data structures, which is precisely the kind of thing
> PANIC_ON_WARN users want to abort for.
Yes, that's exactly it. We make all kinds of load-bearing assumptions
everywhere: that PM code won't pass in a NULL struct device pointer to
the resume handler, that our driver callbacks won't get called whilst
the device is runtime-suspended, etc. We could try to handle every
single one of those with if (clk == NULL) return 0; /* ??? */, or we
could not.
If you'd like, we could just delete every one of these checks and
replace them with comments, explaining what we assume the invariants
to be, and wait for an OOPS due to dereferencing invalid pointers. But
the MISRA style of 'handling' every possible impossible case is not
tractable.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 2/8] drm/rockchip: vop2: Switch impossible pos conditional to WARN_ON
2025-12-11 22:41 ` David Laight
@ 2025-12-15 17:57 ` Daniel Stone
0 siblings, 0 replies; 15+ messages in thread
From: Daniel Stone @ 2025-12-15 17:57 UTC (permalink / raw)
To: David Laight
Cc: Nicolas Frattaroli, Sandy Huang, Heiko Stübner, Andy Yan,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Chaoyi Chen, dri-devel, linux-arm-kernel,
linux-rockchip, linux-kernel, Daniel Stone, kernel
Hi,
On Thu, 11 Dec 2025 at 22:41, David Laight <david.laight.linux@gmail.com> wrote:
> On Thu, 11 Dec 2025 21:40:32 +0100
> Nicolas Frattaroli <nicolas.frattaroli@collabora.com> wrote:
> > - 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
> > + */
> > + 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);
>
> You need to do something when the tests fail.
> Carrying on regardless is never right.
When we arrive at this point, because the load-bearing assumption in
the comment has not been met, our options would be:
* display random incorrect content, and hope that we aren't reading
out of bounds from a buffer that's too small
* turn the display off
* there is no third option
Which are you suggesting?
Cheers,
Daniel
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON
2025-12-15 17:55 ` Daniel Stone
@ 2025-12-15 18:16 ` David Laight
0 siblings, 0 replies; 15+ messages in thread
From: David Laight @ 2025-12-15 18:16 UTC (permalink / raw)
To: Daniel Stone
Cc: Nicolas Frattaroli, Sandy Huang, Heiko Stübner, Andy Yan,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Chaoyi Chen, dri-devel, linux-arm-kernel,
linux-rockchip, linux-kernel, Daniel Stone, kernel
On Mon, 15 Dec 2025 17:55:13 +0000
Daniel Stone <daniel@fooishbar.org> wrote:
> Hi,
>
> On Fri, 12 Dec 2025 at 12:46, Nicolas Frattaroli
> <nicolas.frattaroli@collabora.com> wrote:
> > On Thursday, 11 December 2025 23:38:22 Central European Standard Time David Laight wrote:
> > > Except that all the systems with PANIC_ON_WARN set will panic.
> > > I believe that is somewhere over 90% of systems.
> >
> > I also like making up statistics. Warning here is the correct move
> > in my opinion because this warning being triggered indicates a bug
> > in the kernel code, and with PANIC_ON_WARN the user explicitly says
> > they would rather panic in such a case than treat it as an abnormal
> > condition that is recoverable.
> >
> > The reason why this condition ever occurring should be treated as an
> > abnormal condition is because the DRM subsystem should guarantee we
> > don't get a framebuffer of a format we didn't explicitly declare
> > support for in the first place. So this condition being hit either
> > means drm_universal_plane_init is broken, or the array of formats
> > that's passed to it is out of sync with the conversion code, which
> > is also a bug. Or someone managed to thoroughly hose DRM's internal
> > kernel-side data structures, which is precisely the kind of thing
> > PANIC_ON_WARN users want to abort for.
>
> Yes, that's exactly it. We make all kinds of load-bearing assumptions
> everywhere: that PM code won't pass in a NULL struct device pointer to
> the resume handler, that our driver callbacks won't get called whilst
> the device is runtime-suspended, etc. We could try to handle every
> single one of those with if (clk == NULL) return 0; /* ??? */, or we
> could not.
>
> If you'd like, we could just delete every one of these checks and
> replace them with comments, explaining what we assume the invariants
> to be, and wait for an OOPS due to dereferencing invalid pointers. But
> the MISRA style of 'handling' every possible impossible case is not
> tractable.
Especially since it is often easier to debug the NULL pointer reference
that the work out why a BUG_ON(!ptr) happened.
(In the former case you should have the contents of all the registers
making it easier to backtrack to where the NULL came from.)
David
>
> Cheers,
> Daniel
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2025-12-15 18:16 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 20:40 [PATCH v4 0/8] drm/rockchip: No more post-atomic_check fixups Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 1/8] drm/rockchip: vop2: Switch impossible format conditional to WARN_ON Nicolas Frattaroli
2025-12-11 22:38 ` David Laight
2025-12-12 12:43 ` Nicolas Frattaroli
2025-12-15 17:55 ` Daniel Stone
2025-12-15 18:16 ` David Laight
2025-12-11 20:40 ` [PATCH v4 2/8] drm/rockchip: vop2: Switch impossible pos " Nicolas Frattaroli
2025-12-11 22:41 ` David Laight
2025-12-15 17:57 ` Daniel Stone
2025-12-11 20:40 ` [PATCH v4 3/8] drm/rockchip: vop2: Fix Esmart test condition Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 4/8] drm/rockchip: vop2: Enforce scaling workaround in plane_check Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 5/8] drm/rockchip: vop2: Enforce AFBC source alignment " Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 6/8] drm/rockchip: vop2: Enforce AFBC transform stride align " Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 7/8] drm/rockchip: vop2: Use drm_is_afbc helper function Nicolas Frattaroli
2025-12-11 20:40 ` [PATCH v4 8/8] drm/rockchip: vop2: Simplify format_mod_supported Nicolas Frattaroli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).