dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arun Iyengar" <aiyengar1990@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/rockchip: vop2: Give each RK3588 video port its own cluster
Date: Sat, 21 Nov 2026 08:15:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-226823@kernel.org> (raw)
In-Reply-To: <20261121-vop2-axi-primary-v1-1-8d5c74905207@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/rockchip: vop2: default zpos inversion for overlays in
  vop2_create_crtcs()
- [Medium] drm/rockchip: vop2: overlay planes and VP0+VP1 still violate
  AXI separation
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] drm/rockchip: vop2: port node leak and UAF on error in
  vop2_create_crtcs() [1]
--

commit 7cc91c6d385e03fd7bff780807113fe9561a15db
Author: Arun Iyengar <aiyengar1990@gmail.com>

drm/rockchip: vop2: Give each RK3588 video port its own cluster

This commit assigns Cluster N as the primary plane for video port N on
RK3588 so that VP0 and VP2 do not share AXI0 for their primary planes.

> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> index 76d151b8bc52b..303d9b987a7c5 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> @@ -2583,6 +2583,12 @@ static bool vop2_is_mirror_win(struct vop2_win *win)
>  	}
>  }
>  
> +/* RK3588 primary per video port; Cluster0/1 on AXI0, Cluster2/3 on AXI1. */
> +static const u8 rk3588_vp_primary[] = {
> +	ROCKCHIP_VOP2_CLUSTER0, ROCKCHIP_VOP2_CLUSTER1,
> +	ROCKCHIP_VOP2_CLUSTER2, ROCKCHIP_VOP2_CLUSTER3,
> +};
> +
>  static int vop2_create_crtcs(struct vop2 *vop2)
>  {
>  	const struct vop2_data *vop2_data = vop2->data;
> @@ -2655,6 +2661,10 @@ static int vop2_create_crtcs(struct vop2 *vop2)
>  			if (!(win->data->possible_vp_mask & BIT(vp->id)))
>  				continue;
>  
> +			if (vop2->version == VOP_VERSION_RK3588 &&
> +			    win->data->phys_id != rk3588_vp_primary[vp->id])
> +				continue;
> +
>  			if (vop2_is_mirror_win(win))
>  				continue;

[Severity: Medium]
When an earlier video port is unused (such as VP0 + VP2 without VP1), does
skipping Cluster1-win0 here give the first overlay plane a lower default
zpos than VP2's primary plane?

vop2_win_init() assigns win->win_id sequentially (Cluster0..3 get 0..3),
and vop2_plane_init() sets each plane's initial zpos to win->win_id:

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c:vop2_plane_init() {
	...
	drm_plane_create_zpos_property(&win->base, win->win_id, 0,
				       vop2->registered_num_wins - 1);
	...
}

When VP1 is disabled, VP2 claims Cluster2-win0 (default zpos 2) as its
primary plane, while the unclaimed Cluster1-win0 (default zpos 1) is
registered as the first DRM_PLANE_TYPE_OVERLAY plane in the loop below. If
userspace enables that overlay plane on VP2 or VP3 without explicitly
setting zpos, drm_atomic_normalize_zpos() places the overlay underneath the
primary plane.

[Severity: Medium]
Does filtering only the primary plane loop actually keep a video port's
layers on one AXI bus, or avoid AXI0 sharing on VP0 + VP1 boards?

In the overlay loop right below, possible_crtcs is still computed solely
from win->data->possible_vp_mask (BIT(0) | BIT(1) | BIT(2) | BIT(3) for all
eight windows in rk3588_vop_win_data[]), and neither possible_crtcs nor
atomic_check restricts a video port's planes to one axi_bus_id. On a board
with VP0 and VP2 active and VP1 disabled, the skipped Cluster1-win0
(axi_bus_id 0) becomes the first overlay plane and can be attached directly
to VP2 alongside its Cluster2-win0 (axi_bus_id 1) primary plane, as can
Esmart0/1.

In addition, because rk3588_vp_primary[] maps VP0 to Cluster0 and VP1 to
Cluster1, dual-display RK3588 boards wired to VP0 and VP1 (such as Rock 5B,
Orange Pi 5 Plus/Max, and NanoPC-T6) still put both 4K primary planes on
AXI0.

[Severity: High]
This problem wasn't introduced by this patch, but if vop2_create_crtcs()
fails after acquiring port nodes or initializing planes or CRTCs [1],
does the early return leak vp->crtc.port references and leave freed planes
and CRTCs linked in drm->mode_config?

In the first loop, of_graph_get_port_by_id() stores a device_node reference
in vp->crtc.port, and the following loops link embedded win->base and
vp->crtc objects into drm->mode_config.plane_list and crtc_list. Returning
an error without calling vop2_destroy_crtcs() leaks the port nodes and
lets component_bind() free the devm-allocated struct vop2 while its planes
and CRTCs remain on drm_device, causing a use-after-free when
rockchip_drm_bind() unwinds through drm_mode_config_cleanup().

[1] https://sashiko.dev/#/bug/linux-81b4737a-b947-4652-ad38-8f28fe971257

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-vop2-axi-primary-v1-1-8d5c74905207@gmail.com?part=1

      reply	other threads:[~2026-11-21  8:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  7:55 [PATCH] drm/rockchip: vop2: Give each RK3588 video port its own cluster Arun Iyengar via B4 Relay
2026-11-21  8:15 ` sashiko-bot [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=sashiko-outbox-226823@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aiyengar1990@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).