ARM Sunxi Platform Development
 help / color / mirror / Atom feed
* [PATCH] drm/sun4i: mixer: Disable layers of detached planes
@ 2026-12-03 14:38 Daniel Golle
  2026-12-03 14:57 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Golle @ 2026-12-03 14:38 UTC (permalink / raw)
  To: Chen-Yu Tsai, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Samuel Holland,
	dri-devel, linux-arm-kernel, linux-sunxi

Since commit fc9b4e3b78d9 ("drm/sun4i: mixer: Move layer enabling to
atomic_update"), only the atomic_update() of a plane disables its layer.

The driver commits with drm_atomic_helper_commit_tail_rpm(), which skips
the planes of an inactive CRTC, so a plane detached while its CRTC is
off keeps its layer enabled. When the CRTC is enabled again, that layer
scans out the last framebuffer of the plane, which userspace has freed
by then; on H616 this shows as a flood of IOMMU page faults and a
corrupted picture. Disable the layer of every plane which
sun8i_mixer_commit() finds disabled.

Fixes: fc9b4e3b78d9 ("drm/sun4i: mixer: Move layer enabling to atomic_update")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
Disclosure: Issue found by LLM after being observed on real hardware;
LLM has also proposed the fix.

 drivers/gpu/drm/sun4i/sun8i_mixer.c    | 13 ++++++++++++-
 drivers/gpu/drm/sun4i/sun8i_ui_layer.c |  2 +-
 drivers/gpu/drm/sun4i/sun8i_ui_layer.h |  1 +
 drivers/gpu/drm/sun4i/sun8i_vi_layer.c |  2 +-
 drivers/gpu/drm/sun4i/sun8i_vi_layer.h |  1 +
 5 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c
index dbde80b320808..9e8b43a0c622e 100644
--- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
@@ -251,6 +251,14 @@ int sun8i_mixer_drm_format_to_hw(u32 format, u32 *hw_format)
 	return -EINVAL;
 }
 
+static void sun8i_layer_disable(struct sun8i_layer *layer)
+{
+	if (layer->type == SUN8I_LAYER_TYPE_VI)
+		sun8i_vi_layer_disable(layer);
+	else
+		sun8i_ui_layer_disable(layer);
+}
+
 static void sun8i_mixer_commit(struct sunxi_engine *engine,
 			       struct drm_crtc *crtc,
 			       struct drm_atomic_commit *state)
@@ -287,8 +295,11 @@ static void sun8i_mixer_commit(struct sunxi_engine *engine,
 				 plane->base.id, layer->index, layer->overlay,
 				 enable, zpos, x, y, w, h);
 
-		if (!enable)
+		/* a plane detached while the CRTC was off missed atomic_update() */
+		if (!enable) {
+			sun8i_layer_disable(layer);
 			continue;
+		}
 
 		/* Route layer to pipe based on zpos */
 		route |= layer->index << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);
diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
index cf66f676824e6..97c2cb0ae548e 100644
--- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
@@ -26,7 +26,7 @@
 #include "sun8i_ui_scaler.h"
 #include "sun8i_vi_scaler.h"
 
-static void sun8i_ui_layer_disable(struct sun8i_layer *layer)
+void sun8i_ui_layer_disable(struct sun8i_layer *layer)
 {
 	u32 ch_base = sun8i_channel_base(layer);
 
diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.h b/drivers/gpu/drm/sun4i/sun8i_ui_layer.h
index 1581ffc6d4e5c..3ff972ef5225b 100644
--- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.h
+++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.h
@@ -55,4 +55,5 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
 					    int index, int phy_index,
 					    int plane_cnt,
 					    const struct sun8i_layer_cfg *cfg);
+void sun8i_ui_layer_disable(struct sun8i_layer *layer);
 #endif /* _SUN8I_UI_LAYER_H_ */
diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
index 6b19fafd50ad3..28c5b1c2b80af 100644
--- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
@@ -20,7 +20,7 @@
 #include "sun8i_vi_layer.h"
 #include "sun8i_vi_scaler.h"
 
-static void sun8i_vi_layer_disable(struct sun8i_layer *layer)
+void sun8i_vi_layer_disable(struct sun8i_layer *layer)
 {
 	u32 ch_base = sun8i_channel_base(layer);
 
diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.h b/drivers/gpu/drm/sun4i/sun8i_vi_layer.h
index 29cc5573691f9..53bb0c58cc879 100644
--- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.h
+++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.h
@@ -60,4 +60,5 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
 					    int index, int phy_index,
 					    int plane_cnt,
 					    const struct sun8i_layer_cfg *cfg);
+void sun8i_vi_layer_disable(struct sun8i_layer *layer);
 #endif /* _SUN8I_VI_LAYER_H_ */

base-commit: 0810bd27d7bbccb4f579f1fbb1afc98687c4c7c3
-- 
2.56.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-03 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 14:38 [PATCH] drm/sun4i: mixer: Disable layers of detached planes Daniel Golle
2026-12-03 14:57 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox