Skip to content

Commit f99159f

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 <[email protected]>
1 parent 597a89b commit f99159f

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
@@ -90,6 +90,19 @@ static int apple_plane_atomic_check(struct drm_plane *plane,
9090
if (IS_ERR(crtc_state))
9191
return PTR_ERR(crtc_state);
9292

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

0 commit comments

Comments
 (0)