dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Icenowy Zheng" <zhengxingda@iscas.ac.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/verisilicon: remove ARGB formats from primary plane
Date: Thu, 10 Sep 2026 10:01:53 +0000	[thread overview]
Message-ID: <20260910100153.6538B1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910095000.3505878-2-zhengxingda@iscas.ac.cn>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [Medium] Unintentional removal of 10-bit color formats from the primary plane.

Pre-existing issues:
- [High] Plane `atomic_disable` crashes when called on a previously disabled plane.
- [High] Primary plane `atomic_disable` mistakenly enables the plane in the hardware register.
--

commit 53c18bf18dd1a86e14f16784c764ae73c2637d54
Author: Icenowy Zheng <zhengxingda@iscas.ac.cn>

drm/verisilicon: remove ARGB formats from primary plane
    
As the blending of the primary plane is currently explicitly disabled
(and it's not possible on DC8000), remove the ARGB formats from the
primary plane format tables.

> diff --git a/drivers/gpu/drm/verisilicon/vs_hwdb.c b/drivers/gpu/drm/verisilicon/vs_hwdb.c
> index 56aa450443068..ebf6f843bc885 100644
> --- a/drivers/gpu/drm/verisilicon/vs_hwdb.c
> +++ b/drivers/gpu/drm/verisilicon/vs_hwdb.c
> @@ -15,32 +15,16 @@ static const u32 vs_primary_formats_array_no_yuv444[] = {
[ ... ]
>  	DRM_FORMAT_XRGB8888,
>  	DRM_FORMAT_XBGR8888,
>  	DRM_FORMAT_RGBX8888,
>  	DRM_FORMAT_BGRX8888,
> -	DRM_FORMAT_ARGB8888,
> -	DRM_FORMAT_ABGR8888,
> -	DRM_FORMAT_RGBA8888,
> -	DRM_FORMAT_BGRA8888,
> -	DRM_FORMAT_ARGB2101010,
> -	DRM_FORMAT_ABGR2101010,
> -	DRM_FORMAT_RGBA1010102,
> -	DRM_FORMAT_BGRA1010102,

[Severity: Medium]
Does the removal of DRM_FORMAT_ARGB2101010 and its variants drop all 10-bit
color support from the primary plane?

Since the opaque 10-bit counterparts (like DRM_FORMAT_XRGB2101010) are
missing from vs_primary_formats_array_no_yuv444, any userspace compositor
attempting to use 10-bit color will find no supported formats and fail.

>  	/* TODO: non-RGB formats */
>  };
>  
> @@ -49,32 +33,16 @@ static const u32 vs_primary_formats_array_with_yuv444[] = {
[ ... ]
>  	DRM_FORMAT_XRGB8888,
>  	DRM_FORMAT_XBGR8888,
>  	DRM_FORMAT_RGBX8888,
>  	DRM_FORMAT_BGRX8888,
> -	DRM_FORMAT_ARGB8888,
> -	DRM_FORMAT_ABGR8888,
> -	DRM_FORMAT_RGBA8888,
> -	DRM_FORMAT_BGRA8888,
> -	DRM_FORMAT_ARGB2101010,
> -	DRM_FORMAT_ABGR2101010,
> -	DRM_FORMAT_RGBA1010102,
> -	DRM_FORMAT_BGRA1010102,

[Severity: Medium]
Will this also remove 10-bit color support from the secondary array
vs_primary_formats_array_with_yuv444?

Just like the array above, the opaque 10-bit formats were not added,
removing 10-bit color support for userspace compositors on this plane.

>  	/* TODO: non-RGB formats */
>  };

[Severity: High]
This isn't a bug introduced by this patch, but can
vs_primary_plane_atomic_disable() crash when called on a previously disabled
plane?

drivers/gpu/drm/verisilicon/vs_primary_plane.c:vs_primary_plane_atomic_disable() {
	struct drm_plane_state *state = drm_atomic_get_old_plane_state(atomic_state,
								       plane);
	struct drm_crtc *crtc = state->crtc;
	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
	unsigned int output = vcrtc->id;
        ...

If a userspace process performs an atomic commit that targets a disabled plane
and keeps it disabled or moves it out of bounds (!state->visible), DRM helpers
may call atomic_update. The driver's atomic_update unconditionally calls
atomic_disable for invisible planes.

When atomic_disable retrieves old_plane_state->crtc, it is NULL since the
plane was already disabled. Would this result in a NULL pointer dereference
at vcrtc->id?

This exact same pattern exists in the cursor plane's disable path in
drivers/gpu/drm/verisilicon/vs_cursor_plane.c for
vs_cursor_plane_atomic_disable():

drivers/gpu/drm/verisilicon/vs_cursor_plane.c:vs_cursor_plane_atomic_disable() {
	struct drm_plane_state *state = drm_atomic_get_old_plane_state(atomic_state,
								       plane);
	struct drm_crtc *crtc = state->crtc;
	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
	unsigned int output = vcrtc->id;
        ...

[Severity: High]
This is a pre-existing issue, but does vs_primary_plane_atomic_disable()
mistakenly enable the plane in the hardware register instead of disabling it?

drivers/gpu/drm/verisilicon/vs_primary_plane.c:vs_primary_plane_atomic_disable() {
    ...
	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
			VSDC_FB_CONFIG_EX_FB_EN);
    ...
}

Whenever the primary plane is disabled (e.g., DPMS off, mode set, or
compositor exit), this code uses regmap_set_bits with VSDC_FB_CONFIG_EX_FB_EN.
This leaves the hardware plane active instead of disabling it.

When the DRM core subsequently frees the framebuffer memory, the display
controller hardware will continue to DMA read from the freed memory. Can this
cause a Use-After-Free and potential memory corruption or IOMMU faults?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910095000.3505878-1-zhengxingda@iscas.ac.cn?part=2

  reply	other threads:[~2026-09-10 10:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  9:49 [PATCH 1/2] drm/verisilicon: add primary modifier for format tables Icenowy Zheng
2026-09-10  9:50 ` [PATCH 2/2] drm/verisilicon: remove ARGB formats from primary plane Icenowy Zheng
2026-09-10 10:01   ` sashiko-bot [this message]
2026-09-10 11:03 ` [PATCH 1/2] drm/verisilicon: add primary modifier for format tables Thomas Zimmermann

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=20260910100153.6538B1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhengxingda@iscas.ac.cn \
    /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