From: Shirong Zhao <shxzhaosr@163.com>
To: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
dri-devel@lists.freedesktop.org,
linux-amlogic@lists.infradead.org, stable@vger.kernel.org,
Shirong Zhao <shxzhaosr@163.com>
Subject: [PATCH v2] drm/meson: disable OSD1 for invisible planes in atomic_update
Date: Sat, 5 Dec 2026 10:41:23 +0800 [thread overview]
Message-ID: <20261205024123.19-1-shxzhaosr@163.com> (raw)
In-Reply-To: <20261205021754.64-1-shxzhaosr@163.com>
meson_plane_atomic_update() computes the scaler phase steps as
hf_phase_step = ((src_w << 18) / dst_w) << 6;
vf_phase_step = (src_h << 20) / dst_h;
using the plane destination size. When a plane becomes invisible (for
example a zero destination size submitted through the atomic ioctl),
drm_atomic_helper_commit_planes() does not call ->atomic_disable() for a
plane that keeps its CRTC; it calls ->atomic_update() instead, so dst_w or
dst_h can be 0 and the divisions raise a divide error.
Handling only the division is not enough: returning early would leave OSD1
enabled and still scanning out the previous buffer's DMA address, so a
commit that replaced the framebuffer and freed the old GEM buffer would
become a DMA use-after-free. Call meson_plane_atomic_disable(), which
clears priv->viu.osd1_enabled and disables OSD1, and return.
Fixes: 7db647aa8b13 ("drm/meson: Add primary plane scaling")
Signed-off-by: Shirong Zhao <shxzhaosr@163.com>
---
drivers/gpu/drm/meson/meson_plane.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
index 76eb8b8..f836c8f 100644
--- a/drivers/gpu/drm/meson/meson_plane.c
+++ b/drivers/gpu/drm/meson/meson_plane.c
@@ -131,6 +131,9 @@ static u32 meson_g12a_afbcd_line_stride(struct meson_drm *priv)
return ((line_stride + 1) >> 1) << 1;
}
+static void meson_plane_atomic_disable(struct drm_plane *plane,
+ struct drm_atomic_commit *state);
+
static void meson_plane_atomic_update(struct drm_plane *plane,
struct drm_atomic_commit *state)
{
@@ -152,6 +155,17 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
int vf_bank_len;
u8 canvas_id_osd1;
+ /*
+ * A zero destination size makes the plane invisible and
+ * drm_atomic_helper_commit_planes() still calls ->atomic_update() for a
+ * plane that keeps its CRTC. Disable OSD1 instead of dividing by a zero
+ * dst_w/dst_h below, and to avoid leaving it scanning out a stale buffer.
+ */
+ if (!new_state->visible) {
+ meson_plane_atomic_disable(plane, state);
+ return;
+ }
+
/*
* Update Coordinates
* Update Formats
--
2.53.0
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
prev parent reply other threads:[~2026-12-05 2:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 2:17 [PATCH] drm/meson: skip " Shirong Zhao
2026-12-05 2:34 ` sashiko-bot
2026-12-05 2:41 ` Shirong Zhao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261205024123.19-1-shxzhaosr@163.com \
--to=shxzhaosr@163.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®