drm: Check CRTC compatibility in setplane
authorMatt Roper <matthew.d.roper@intel.com>
Thu, 29 May 2014 15:06:51 +0000 (08:06 -0700)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 5 Jun 2014 06:52:43 +0000 (08:52 +0200)
The DRM core setplane code should check that the plane is usable on the
specified CRTC before calling into the driver.

Prior to this patch, a plane's possible_crtcs field was purely
informational for userspace and was never actually verified at the
kernel level (aside from the primary plane helper).

Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Chon Ming Lee <chon.ming.lee@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Acked-by: Dave Airlie <airlied@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_plane_helper.c

index 43735f38cd17fd4c7eb6dc7851d8508f4c668bba..b8cc4fe0a0f7a94977aced869ca2130b28e5a8c6 100644 (file)
@@ -2178,6 +2178,13 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
                goto out;
        }
 
+       /* Check whether this plane is usable on this CRTC */
+       if (!(plane->possible_crtcs & drm_crtc_mask(crtc))) {
+               DRM_DEBUG_KMS("Invalid crtc for plane\n");
+               ret = -EINVAL;
+               goto out;
+       }
+
        fb = drm_framebuffer_lookup(dev, plane_req->fb_id);
        if (!fb) {
                DRM_DEBUG_KMS("Unknown framebuffer ID %d\n",
index 1b15643b45869414e53ba853d476e4bc97c0ef69..37b9333cee49c6c5ef2359ea95e884e435d4798f 100644 (file)
@@ -145,12 +145,6 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
                return -EINVAL;
        }
 
-       /* Primary planes are locked to their owning CRTC */
-       if (plane->possible_crtcs != drm_crtc_mask(crtc)) {
-               DRM_DEBUG_KMS("Cannot change primary plane CRTC\n");
-               return -EINVAL;
-       }
-
        /* Disallow scaling */
        src_w >>= 16;
        src_h >>= 16;