Skip to content

vc4 drm planes should not define all CRTCs as possible #3734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
schauveau opened this issue Jul 18, 2020 · 5 comments
Closed

vc4 drm planes should not define all CRTCs as possible #3734

schauveau opened this issue Jul 18, 2020 · 5 comments

Comments

@schauveau
Copy link

In the current vc4 driver each CRTC is using 3 planes (one of each type) each created with possible_crtcs=0xff
That value comes from the 3rd argument of

ret = drm_universal_plane_init(dev, plane, 0xff,

This is incorrect for 2 reasons.

First, some unused bits are sets. This is unexpected and that could potentially confuse some client implementations that rely on the detection of the last possible crtcs.

Second, and this is the most important, having multiple bits means that the client can freely associate each plane to each CRTC. This is clearly not the intention here. For example, I used a modified version of sway/wlroots to assign the 1st crtc to the 2nd cursor plane and the 2nd crtc to the 1st cursor plane. This is supposed to be a PERFECTLY LEGAL interpretation of the DRM api. On my rpi4 with 2 monitors, the result was that my left screen was showing the right screen cursor (and the other way around).

So my advice is to change vc4_firmware_kms.c as follow:

  1. Add an argument uint32_t possible_crtcs to vc4_fkms_plane_init.
  2. Replace 0xff by possible_crtcs in the call of drm_universal_plane_init.
  3. In each call of vc4_fkms_plane_init, use drm_crtc_mask(ctrc) for the possible_crtrs argument.

See also:
swaywm/wlroots#2333
swaywm/wlroots#1943

6by9 added a commit to 6by9/linux that referenced this issue Jul 20, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

raspberrypi#3734

Signed-off-by: Dave Stevenson <[email protected]>
@6by9
Copy link
Contributor

6by9 commented Jul 20, 2020

You're correct that it is wrong, but the suggested solution isn't going to work.

possible_crtcs should be set for the primary and cursor planes via drm_crtc_init_with_planes but the fact that they are set already skips that.

Plane creation order also makes life trickier.
The Z order is determined by creation order if not overridden by zpos property. We don't have the crtc index to populate into the plane until after drm_crtc_init_with_planes, which wants to take the planes properties. So you have to go back and update all the planes after the drm_crtc_init.

#3740 should hopefully fix the issue.

@6by9
Copy link
Contributor

6by9 commented Jul 20, 2020

pi@raspberrypi:~ $ ./drm/build/tests/modetest/modetest -M vc4 | grep 0,0
87	157	(0,0)	(1920x1200)
151	157	(0,0)	(1280x800)
31	87	157	0,0		0,0	0       	0x00000001
38	0	0	0,0		0,0	0       	0x00000001
45	0	0	0,0		0,0	0       	0x00000001
52	0	0	0,0		0,0	0       	0x00000001
59	0	0	0,0		0,0	0       	0x00000001
66	0	0	0,0		0,0	0       	0x00000001
73	0	0	0,0		0,0	0       	0x00000001
80	0	0	0,0		0,0	0       	0x00000001
95	151	157	0,0		0,0	0       	0x00000002
102	0	0	0,0		0,0	0       	0x00000002
109	0	0	0,0		0,0	0       	0x00000002
116	0	0	0,0		0,0	0       	0x00000002
123	0	0	0,0		0,0	0       	0x00000002
130	0	0	0,0		0,0	0       	0x00000002
137	0	0	0,0		0,0	0       	0x00000002
144	0	0	0,0		0,0	0       	0x00000002

looks hopeful (I increased the number of overlay planes available to 6 per crtc whilst I was in there)

@schauveau
Copy link
Author

If the last columns is possible_ctrcs then that looks good. Thanks.

@6by9
Copy link
Contributor

6by9 commented Jul 20, 2020

If the last columns is possible_ctrcs then that looks good. Thanks.

It is.
Headings for the planes are

Planes:
id      crtc    fb      CRTC x,y        x,y     gamma size      possible crtcs

6by9 added a commit to 6by9/linux that referenced this issue Aug 13, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

raspberrypi#3734

Signed-off-by: Dave Stevenson <[email protected]>
pelwell pushed a commit that referenced this issue Aug 13, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
HiassofT pushed a commit to HiassofT/rpi-linux that referenced this issue Aug 17, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

raspberrypi#3734

Signed-off-by: Dave Stevenson <[email protected]>
HiassofT pushed a commit to HiassofT/rpi-linux that referenced this issue Aug 17, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

raspberrypi#3734

Signed-off-by: Dave Stevenson <[email protected]>
pelwell pushed a commit that referenced this issue Aug 18, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
pelwell pushed a commit that referenced this issue Aug 18, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Aug 19, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Aug 19, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Sep 1, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Sep 1, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
6by9 added a commit to 6by9/linux that referenced this issue Sep 4, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

raspberrypi#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Sep 11, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Sep 15, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Sep 28, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Oct 2, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Oct 7, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Oct 16, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Oct 19, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
popcornmix pushed a commit that referenced this issue Nov 4, 2020
The driver was assigning all planes to crtcs when actually they're
mapped to a specific crtc.

Correct the mask.

#3734

Signed-off-by: Dave Stevenson <[email protected]>
@6by9
Copy link
Contributor

6by9 commented Apr 16, 2021

Patch merged ages ago - closing.

@6by9 6by9 closed this as completed Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants