Skip to content

Commit 83d7721

Browse files
chadmedjannau
authored andcommitted
drm: apple: reject plane commit if it will crash DCP
Owing to its origin in mobile devices and the Apple TV, DCP seems to have been designed under the assumption that no one could possibly want a rectangle to clip the screen. If a rectangle's bottom-right edge clips the screen, DCP will instead try to scale the destination rectangle to the best of its ability... until it can't anymore. DCP is not tolerant to faults and will crash if the onscreen portion of the framebuffer ends up smaller than 32x32, or if any dimension ends up entirely offscreen. Use apple_plane_atomic_check() to reject requested plane states that could crash DCP. This is the final piece of the puzzle required to enable preliminary support for overlay planes on Apple Silicon devices. Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
1 parent 7585e9d commit 83d7721

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

drivers/gpu/drm/apple/apple_drv.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ static int apple_plane_atomic_check(struct drm_plane *plane,
9191
if (IS_ERR(crtc_state))
9292
return PTR_ERR(crtc_state);
9393

94+
/*
95+
* DCP does not allow a surface to clip off the screen, and will crash
96+
* if any blended surface is smaller than 32x32. Reject the atomic op
97+
* if the plane will crash DCP.
98+
*
99+
* This is most pertinent to cursors. Userspace should fall back to
100+
* software cursors if the plane check is rejected.
101+
*/
102+
if ((new_plane_state->crtc_x + 32) > crtc_state->mode.hdisplay ||
103+
(new_plane_state->crtc_y + 32) > crtc_state->mode.vdisplay) {
104+
return -EINVAL;
105+
}
106+
94107
/*
95108
* DCP limits downscaling to 2x and upscaling to 4x. Attempting to
96109
* scale outside these bounds errors out when swapping.

0 commit comments

Comments
 (0)