From: Arun Iyengar Date: Thu, 12 Nov 2026 08:33:05 +0000 Subject: [PATCH v2 1/9] drm/rockchip: vop2: Take the UV plane address from the second GEM object MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261112-vop2-fixes-v2-1-8218c1cf8ac8@gmail.com> References: <20261112-vop2-fixes-v2-0-8218c1cf8ac8@gmail.com> In-Reply-To: <20261112-vop2-fixes-v2-0-8218c1cf8ac8@gmail.com> To: Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Andy Yan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Sascha Hauer Cc: Piotr Zalewski , Chaoyi Chen , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Arun Iyengar , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1794472385; l=1838; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=c6L45VmSkCBmk0ERX5lNSIXdj9a2eckfk+73qA8sDb8=; b=bNeTudL523j6Oh7G+s25KWoAvRH5h9NVLNWYV+GSaMqLiTaDWtX4j2lI+02qf8Y5TtY6yHfN3 3AEArtFHBkpAOJZNZx6SmuxwHhXYzW9/VSt7E2jNe1ayGQUaGNQSjax X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 List-Id: B4 Relay Submissions vop2_plane_atomic_update() computes the address of the chroma plane of a multi-planar YUV framebuffer from fb->obj[0], the object of the luma plane, plus the offset of the chroma plane. A framebuffer may have its planes in different GEM objects though (DRM_IOCTL_MODE_ADDFB2 with two handles, as with an NV12M buffer from a V4L2 decoder imported as two DMA-BUFs). The window then fetches the chroma plane from the luma buffer, at an offset meant for another buffer, which shows a wrong picture or reads past the end of the luma buffer. Use fb->obj[1] for the chroma plane. Single plane YUV formats like DRM_FORMAT_YUV420_8BIT have no second object and keep using fb->obj[0]. This is also what the vendor kernel does. Fixes: 604be85547ce ("drm/rockchip: Add VOP2 driver") Reported-by: Sashiko Closes: https://lore.kernel.org/all/sashiko-outbox-206550@kernel.org/ Cc: stable@vger.kernel.org Signed-off-by: Arun Iyengar --- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index 76d151b8bc52..ea8d837d661f 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -1369,7 +1369,9 @@ static void vop2_plane_atomic_update(struct drm_plane *plane, if ((pstate->rotation & DRM_MODE_REFLECT_Y) && !afbc_en) offset += fb->pitches[1] * ((pstate->src_h >> 16) - 2) / vsub; - rk_obj = to_rockchip_obj(fb->obj[0]); + /* Single plane formats like YUV420_8BIT have no second object */ + if (fb->format->num_planes > 1) + rk_obj = to_rockchip_obj(fb->obj[1]); uv_mst = rk_obj->dma_addr + offset + fb->offsets[1]; } -- 2.55.0