Skip to contentSkip to conversation

drm/msm/dpu: set possible_crtcs on cursor planes

RFC In review Erik Tagirov 3 participants 4 messages Nov 18

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 drm/msm/dpu: set possible_crtcs on cursor planes

I am using a lesser known wayland compositor that uses the possible_crtcs field of a plane to detect which one to use for the cursor. On the Lenovo T14s two cursor planes are created, each with possible_crtcs set to 0xff. Which from my understanding means that they can be used with any crtc.

However, the compositor picks the wrong cursor plane which results in a lag of ~17ms on each DRM_IOCTL_MODE_SETPLANE call. Making the cursor movements sluggish.

After some investigation, I found out that this is due to the legacy_cursor_update flag not being set in drm_atomic_helper_update_plane() which has an impact in msm_atomic_commit_tail() where the fallback branch is taken.

The lag is solved with the patch below.

Best regards
- Erik Tagirov

The cursor plane must be used with the correct crtc to ensure an asynchronous commit

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +3 -0
index da3556eb6ecc..4e0e9c2d8062 100644
@@ -877,6 +877,9 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 			ret = PTR_ERR(crtc);
 			return ret;
 		}
+		/* Ensure that cursor planes are commited asynchronously */
+		if (cursor_planes[i])
+			cursor_planes[i]->possible_crtcs = drm_crtc_mask(crtc);
 	}
 
 	/* All CRTCs are compatible with all encoders */
Signature · 1 line
2.49.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] drm/msm/dpu: missing Signed-off-by trailer and email text in commit message - [Medium] drm/msm/dpu…

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [High] drm/msm/dpu: missing Signed-off-by trailer and email text in commit message
- [Medium] drm/msm/dpu: restricting cursor possible_crtcs starves higher CRTCs of cursors
- [Low] drm/msm/dpu: missing Fixes trailer for cursor plane possible_crtcs bug
--

commit ca8af36e450982d481b162e2cd26c19bfc3c443d
Author: Erik Tagirov <[email protected]>

Quoted 13 lines

drm/msm/dpu: set possible_crtcs on cursor planes

I am using a lesser known wayland compositor that uses the possible_crtcs field of a plane to detect which one to use for the cursor. On the Lenovo T14s two cursor planes are created, each with possible_crtcs set to 0xff. Which from my understanding means that they can be used with any crtc.

However, the compositor picks the wrong cursor plane which results in a lag of ~17ms on each DRM_IOCTL_MODE_SETPLANE call. Making the cursor movements sluggish.

After some investigation, I found out that this is due to the legacy_cursor_update flag not being set in drm_atomic_helper_update_plane() which has an impact in msm_atomic_commit_tail() where the fallback branch is taken.

Quoted 7 lines

The lag is solved with the patch below.

Best regards
- Erik Tagirov

The cursor plane must be used with the correct crtc to ensure an asynchronous commit

[Severity: High]
This commit is missing a Signed-off-by: trailer from the patch author to certify the Developer's Certificate of Origin. The commit message also retains conversational email sign-off text ("The lag is solved with the patch below. Best regards - Erik Tagirov") followed by a trailing sentence fragment that should be folded into the commit description.

[Severity: Low]
This fixes the cursor plane possible_crtcs mask set when cursor planes were enabled on DPU. Should this include:

Fixes 07ca1fc0f8a0 ("drm/msm/dpu: enable cursor plane on dpu")

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) · line 883

Quoted 12 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +3 -0
index 1b6286dccfc00..ae14e146ec112 100644
@@ -877,6 +877,9 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 			ret = PTR_ERR(crtc);
 			return ret;
 		}
+		/* Ensure that cursor planes are commited asynchronously */
+		if (cursor_planes[i])
+			cursor_planes[i]->possible_crtcs = drm_crtc_mask(crtc);
 	}

[Severity: Medium]
Does restricting cursor_planes[i]->possible_crtcs to drm_crtc_mask(crtc) prevent higher-numbered CRTCs from using any hardware cursor plane?

Earlier in _dpu_kms_drm_obj_init(), DRM_PLANE_TYPE_CURSOR planes are only created for catalog SSPPs that have BIT(DPU_SSPP_CURSOR) set:

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c:_dpu_kms_drm_obj_init() {
    ...
		if ((catalog->sspp[i].features & BIT(DPU_SSPP_CURSOR))
			&& cursor_planes_idx < max_crtc_count)
			type = DRM_PLANE_TYPE_CURSOR;
    ...
}

Across the DPU hardware catalogs, at most 1 or 2 SSPPs set DPU_SSPP_CURSOR (for example, X1E80100 on the Lenovo T14s defines 2 cursor SSPPs, while max_crtc_count can be up to 5), so cursor_planes[i] is NULL for i >= cursor_planes_idx. Because DPU SSPPs (and virtual planes when dpu_use_virtual_planes is enabled) can be routed to any CRTC's Layer Mixer, pinning the 1 or 2 cursor planes exclusively to CRTC 0 and CRTC 1 causes __setplane_check() and drm_atomic_plane_check() to reject attaching a cursor plane to any CRTC with index >= cursor_planes_idx, even when CRTC 0 and CRTC 1 are disabled.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/av4OfY5sML97l2F_@oasis?part=1
#2 lore raw
In reply to Erik Tagirov
Quoted 27 lines · Erik Tagirov

I am using a lesser known wayland compositor that uses the possible_crtcs field of a plane to detect which one to use for the cursor. On the Lenovo T14s two cursor planes are created, each with possible_crtcs set to 0xff. Which from my understanding means that they can be used with any crtc.

However, the compositor picks the wrong cursor plane which results in a lag of ~17ms on each DRM_IOCTL_MODE_SETPLANE call. Making the cursor movements sluggish.

After some investigation, I found out that this is due to the legacy_cursor_update flag not being set in drm_atomic_helper_update_plane() which has an impact in msm_atomic_commit_tail() where the fallback branch is taken.

The lag is solved with the patch below.

Best regards
- Erik Tagirov

The cursor plane must be used with the correct crtc to ensure an asynchronous commit

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -0
index da3556eb6ecc..4e0e9c2d8062 100644

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) · line 882

Quoted 6 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +3 -0
@@ -877,6 +877,9 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 			ret = PTR_ERR(crtc);
 			return ret;
 		}
+		/* Ensure that cursor planes are commited asynchronously */
+		if (cursor_planes[i])
+			cursor_planes[i]->possible_crtcs = drm_crtc_mask(crtc);

Here you are setting that the plane can only be used on a particular CRTC. This is not true for these planes (even being cursor, it still can be used on all the CRTCs).

Quoted 6 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -0
 	}
 
 	/* All CRTCs are compatible with all encoders */
Signature · 1 line
2.49.0
Signature · 2 lines
With best wishes
Dmitry
#3 lore raw
Quoted 23 lines · Dmitry Baryshkov
Quoted 22 lines · Erik Tagirov

I am using a lesser known wayland compositor that uses the possible_crtcs field of a plane to detect which one to use for the cursor. On the Lenovo T14s two cursor planes are created, each with possible_crtcs set to 0xff. Which from my understanding means that they can be used with any crtc.

However, the compositor picks the wrong cursor plane which results in a lag of ~17ms on each DRM_IOCTL_MODE_SETPLANE call. Making the cursor movements sluggish.

After some investigation, I found out that this is due to the legacy_cursor_update flag not being set in drm_atomic_helper_update_plane() which has an impact in msm_atomic_commit_tail() where the fallback branch is taken.

The lag is solved with the patch below.

Best regards
- Erik Tagirov

The cursor plane must be used with the correct crtc to ensure an asynchronous commit

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 16 lines

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) · line 882

Quoted 11 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +3 -0
index da3556eb6ecc..4e0e9c2d8062 100644
@@ -877,6 +877,9 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 			ret = PTR_ERR(crtc);
 			return ret;
 		}
+		/* Ensure that cursor planes are commited asynchronously */
+		if (cursor_planes[i])
+			cursor_planes[i]->possible_crtcs = drm_crtc_mask(crtc);

Here you are setting that the plane can only be used on a particular CRTC. This is not true for these planes (even being cursor, it still can be used on all the CRTCs).

Thank you for the quick reply, I understand that the hardware supports universal planes, so this is not a good solution.

I will see how I can solve this from userspace instead, need to look
more closely at the DRM API maybe there is another way to determine what
plane belongs to what CRTC.
The current implementation does not work, because the possible_crtcs is set to 0xff and the compositor picks the cursor plane that comes first in the list which is used by crtc109 instead of one used by crtc108. This why the legacy_cursor_update flag is not set in drm_atomic_helper_update_plane()

BR
- Erik

Quoted 10 lines
Quoted 6 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -0
 	}
 
 	/* All CRTCs are compatible with all encoders */
Signature · 1 line
2.49.0
Signature · 2 lines
With best wishes
Dmitry