Skip to content

Commit

Permalink
drm/lease: Make sure implicit planes are leased
Browse files Browse the repository at this point in the history
commit 204f640da6914844b3270b41b29c84f6e3b74083 upstream.

If userspace doesn't enable universal planes, then we automatically
add the primary and cursor planes. But for universal userspace there's
no such check (and maybe we only want to give the lessee one plane,
maybe not even the primary one), hence we need to check for the
implied plane.

v2: don't forget setcrtc ioctl.

v3: Still allow disabling of the crtc in SETCRTC.

Cc: [email protected]
Cc: Keith Packard <[email protected]>
Reviewed-by: Boris Brezillon <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
danvet authored and gregkh committed Jun 9, 2019
1 parent 699f0e9 commit 390a0fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/gpu/drm/drm_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,

plane = crtc->primary;

/* allow disabling with the primary plane leased */
if (crtc_req->mode_valid && !drm_lease_held(file_priv, plane->base.id))
return -EACCES;

mutex_lock(&crtc->dev->mode_config.mutex);
drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
retry:
Expand Down
8 changes: 8 additions & 0 deletions drivers/gpu/drm/drm_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,11 @@ static int drm_mode_cursor_common(struct drm_device *dev,
if (ret)
goto out;

if (!drm_lease_held(file_priv, crtc->cursor->base.id)) {
ret = -EACCES;
goto out;
}

ret = drm_mode_cursor_universal(crtc, req, file_priv, &ctx);
goto out;
}
Expand Down Expand Up @@ -1042,6 +1047,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,

plane = crtc->primary;

if (!drm_lease_held(file_priv, plane->base.id))
return -EACCES;

if (crtc->funcs->page_flip_target) {
u32 current_vblank;
int r;
Expand Down

0 comments on commit 390a0fd

Please sign in to comment.