From: rmk+kernel@armlinux.org.uk (Russell King)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] drm/arm: hdlcd: properly validate plane state
Date: Fri, 31 Mar 2017 10:51:41 +0100 [thread overview]
Message-ID: <E1cttDZ-000671-Q1@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20170331094937.GO7909@n2100.armlinux.org.uk>
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 <daniel@ffwll.ch>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
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 <drm/drmP.h>
+#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
@@ -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
WARNING: multiple messages have this Message-ID (diff)
From: Russell King <rmk+kernel@armlinux.org.uk>
To: Liviu Dudau <Liviu.Dudau@arm.com>
Cc: "David Airlie" <airlied@linux.ie>,
"Liviu Dudau" <liviu.dudau@arm.com>,
dri-devel@lists.freedesktop.org,
"Mali DP Maintainers" <malidp@foss.arm.com>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
"Brian Starkey" <brian.starkey@arm.com>,
LAKML <linux-arm-kernel@lists.infradead.org>
Subject: [PATCH 1/3] drm/arm: hdlcd: properly validate plane state
Date: Fri, 31 Mar 2017 10:51:41 +0100 [thread overview]
Message-ID: <E1cttDZ-000671-Q1@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20170331094937.GO7909@n2100.armlinux.org.uk>
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 <daniel@ffwll.ch>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
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 <drm/drmP.h>
+#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
@@ -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
next prev parent reply other threads:[~2017-03-31 9:51 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-18 23:37 [BUG] hdlcd gets confused about base address Russell King - ARM Linux
2016-11-18 23:37 ` Russell King - ARM Linux
2016-11-21 9:44 ` Daniel Vetter
2016-11-21 9:44 ` Daniel Vetter
2016-11-21 11:06 ` Liviu Dudau
2016-11-21 11:06 ` Liviu Dudau
2016-11-21 11:20 ` Russell King - ARM Linux
2016-11-21 11:20 ` Russell King - ARM Linux
2016-11-21 11:32 ` Liviu Dudau
2016-11-21 11:32 ` Liviu Dudau
2016-11-21 12:25 ` Russell King - ARM Linux
2016-11-21 12:25 ` Russell King - ARM Linux
2016-11-21 12:56 ` Liviu Dudau
2016-11-21 12:56 ` Liviu Dudau
2016-11-21 13:24 ` Russell King - ARM Linux
2016-11-21 13:24 ` Russell King - ARM Linux
2016-11-21 13:50 ` Liviu Dudau
2016-11-21 13:50 ` Liviu Dudau
2016-11-21 14:03 ` Russell King - ARM Linux
2016-11-21 14:03 ` Russell King - ARM Linux
2016-11-21 17:32 ` Liviu Dudau
2016-11-21 17:32 ` Liviu Dudau
2016-11-21 17:56 ` Russell King - ARM Linux
2016-11-21 17:56 ` Russell King - ARM Linux
2016-11-21 18:16 ` Russell King - ARM Linux
2016-11-21 18:16 ` Russell King - ARM Linux
2016-11-21 18:25 ` Liviu Dudau
2016-11-21 18:25 ` Liviu Dudau
2016-11-21 18:23 ` Liviu Dudau
2016-11-21 18:23 ` Liviu Dudau
2016-11-21 18:43 ` Russell King - ARM Linux
2016-11-21 18:43 ` Russell King - ARM Linux
2016-11-21 14:30 ` Russell King - ARM Linux
2016-11-21 14:30 ` Russell King - ARM Linux
2016-11-21 14:55 ` Russell King - ARM Linux
2016-11-21 14:55 ` Russell King - ARM Linux
2016-11-22 7:02 ` Daniel Vetter
2016-11-22 7:02 ` Daniel Vetter
2017-02-20 12:16 ` Russell King - ARM Linux
2017-02-20 12:16 ` Russell King - ARM Linux
2017-02-20 17:53 ` Liviu Dudau
2017-02-20 17:53 ` Liviu Dudau
2017-02-20 17:57 ` Russell King - ARM Linux
2017-02-20 17:57 ` Russell King - ARM Linux
2017-02-20 18:05 ` Ville Syrjälä
2017-02-20 18:05 ` Ville Syrjälä
2017-02-20 18:59 ` Russell King - ARM Linux
2017-02-20 18:59 ` Russell King - ARM Linux
2017-02-22 15:42 ` Ville Syrjälä
2017-02-22 15:42 ` Ville Syrjälä
2017-02-26 19:31 ` Daniel Vetter
2017-02-26 19:31 ` Daniel Vetter
2017-02-22 15:15 ` Liviu Dudau
2017-02-22 15:15 ` Liviu Dudau
2017-02-22 15:30 ` Ville Syrjälä
2017-02-22 15:30 ` Ville Syrjälä
2017-03-08 16:30 ` [PATCH v2] drm: hdlcd: Fix the calculation of the scanout start address Liviu Dudau
2017-03-08 16:30 ` Liviu Dudau
2017-03-31 9:49 ` Russell King - ARM Linux
2017-03-31 9:49 ` Russell King - ARM Linux
2017-03-31 9:51 ` Russell King [this message]
2017-03-31 9:51 ` [PATCH 1/3] drm/arm: hdlcd: properly validate plane state Russell King
2017-03-31 10:18 ` Liviu Dudau
2017-03-31 10:18 ` Liviu Dudau
2017-03-31 10:20 ` Russell King - ARM Linux
2017-03-31 10:20 ` Russell King - ARM Linux
2017-03-31 10:23 ` Liviu Dudau
2017-03-31 10:23 ` Liviu Dudau
2017-03-31 10:27 ` Russell King - ARM Linux
2017-03-31 10:27 ` Russell King - ARM Linux
2017-03-31 11:41 ` Liviu Dudau
2017-03-31 11:41 ` Liviu Dudau
2017-03-31 12:21 ` Russell King - ARM Linux
2017-03-31 12:21 ` Russell King - ARM Linux
2017-03-31 9:51 ` [PATCH 2/3] drm/arm: hdlcd: fix plane base address calculation Russell King
2017-03-31 9:51 ` Russell King
2017-03-31 13:13 ` Liviu Dudau
2017-03-31 13:13 ` Liviu Dudau
2017-03-31 9:51 ` [PATCH 3/3] drm/arm: hdlcd: check for rotation Russell King
2017-03-31 9:51 ` Russell King
2017-03-31 10:11 ` Ville Syrjälä
2017-03-31 10:11 ` Ville Syrjälä
2017-03-31 10:21 ` Liviu Dudau
2017-03-31 10:21 ` Liviu Dudau
2017-03-31 13:18 ` [PATCH v2] drm: hdlcd: Fix the calculation of the scanout start address Liviu Dudau
2017-03-31 13:18 ` Liviu Dudau
2017-03-31 13:48 ` Russell King - ARM Linux
2017-03-31 13:48 ` Russell King - ARM Linux
2017-04-03 10:31 ` Liviu Dudau
2017-04-03 10:31 ` Liviu Dudau
2017-04-03 13:13 ` Russell King - ARM Linux
2017-04-03 13:13 ` Russell King - ARM Linux
2017-04-03 14:07 ` Liviu Dudau
2017-04-03 14:07 ` Liviu Dudau
2017-04-06 11:07 ` Jani Nikula
2017-04-06 11:07 ` Jani Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1cttDZ-000671-Q1@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.