From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmk+kernel@armlinux.org.uk (Russell King) Date: Fri, 31 Mar 2017 10:51:41 +0100 Subject: [PATCH 1/3] drm/arm: hdlcd: properly validate plane state In-Reply-To: <20170331094937.GO7909@n2100.armlinux.org.uk> References: <20170331094937.GO7909@n2100.armlinux.org.uk> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org The hdlcd crtc is unable to place planes in arbitary positions and sizes within the active area. Use drm_plane_helper_check_state() to validate the requested state. Suggested-by: Daniel Vetter Signed-off-by: Russell King --- drivers/gpu/drm/arm/hdlcd_crtc.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c index 7d4e5aa77195..ba68fa2b5701 100644 --- a/drivers/gpu/drm/arm/hdlcd_crtc.c +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -205,13 +206,30 @@ static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = { static int hdlcd_plane_atomic_check(struct drm_plane *plane, struct drm_plane_state *state) { - u32 src_w, src_h; + struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc; + struct drm_rect clip = { 0 }; + int ret; + + crtc = state->crtc; + if (!crtc) + return 0; - src_w = state->src_w >> 16; - src_h = state->src_h >> 16; + crtc_state = drm_atomic_get_existing_crtc_state(state->state, crtc); + if (!crtc_state->enable) + return -EINVAL; + + clip.x2 = crtc_state->adjusted_mode.hdisplay; + clip.y2 = crtc_state->adjusted_mode.vdisplay; + + ret = drm_plane_helper_check_state(state, &clip, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING, + false, true); + if (ret) + return ret; - /* we can't do any scaling of the plane source */ - if ((src_w != state->crtc_w) || (src_h != state->crtc_h)) + if (!state->visible) return -EINVAL; return 0; -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Russell King Subject: [PATCH 1/3] drm/arm: hdlcd: properly validate plane state Date: Fri, 31 Mar 2017 10:51:41 +0100 Message-ID: References: <20170331094937.GO7909@n2100.armlinux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170331094937.GO7909@n2100.armlinux.org.uk> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Liviu Dudau Cc: David Airlie , Liviu Dudau , dri-devel@lists.freedesktop.org, Mali DP Maintainers , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Brian Starkey , LAKML List-Id: dri-devel@lists.freedesktop.org The hdlcd crtc is unable to place planes in arbitary positions and sizes within the active area. Use drm_plane_helper_check_state() to validate the requested state. Suggested-by: Daniel Vetter Signed-off-by: Russell King --- drivers/gpu/drm/arm/hdlcd_crtc.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c index 7d4e5aa77195..ba68fa2b5701 100644 --- a/drivers/gpu/drm/arm/hdlcd_crtc.c +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -205,13 +206,30 @@ static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = { static int hdlcd_plane_atomic_check(struct drm_plane *plane, struct drm_plane_state *state) { - u32 src_w, src_h; + struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc; + struct drm_rect clip = { 0 }; + int ret; + + crtc = state->crtc; + if (!crtc) + return 0; - src_w = state->src_w >> 16; - src_h = state->src_h >> 16; + crtc_state = drm_atomic_get_existing_crtc_state(state->state, crtc); + if (!crtc_state->enable) + return -EINVAL; + + clip.x2 = crtc_state->adjusted_mode.hdisplay; + clip.y2 = crtc_state->adjusted_mode.vdisplay; + + ret = drm_plane_helper_check_state(state, &clip, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING, + false, true); + if (ret) + return ret; - /* we can't do any scaling of the plane source */ - if ((src_w != state->crtc_w) || (src_h != state->crtc_h)) + if (!state->visible) return -EINVAL; return 0; -- 2.7.4