drm/omap: check plane size
Subsystems (3)
PATCH 1/1 drm/omap: check plane size
At the moment we don't check the plane input/output sizes, which can lead to DSS HW errors when invalid values are given from the userspace.
Add a check so that the sizes are > 0.
--- drivers/gpu/drm/omapdrm/omap_plane.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/omapdrm/omap_plane.c +6 -0
@@ -168,6 +168,12 @@ static int omap_plane_atomic_check(struct drm_plane *plane,if (IS_ERR (crtc_state))return PTR_ERR (crtc_state); +if (state->src_w ==0 || state->src_h ==0 ) +return -EINVAL ; + +if (state->crtc_w ==0 || state->crtc_h ==0 ) +return -EINVAL ; +if (state->crtc_x <0 || state->crtc_y <0 )return -EINVAL ;
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Tomi,
(CC'ing Daniel)
Thank you for the patch.
Quoted 6 lines · On Tuesday 26 Apr 2016 13:16:42 Tomi Valkeinen wrote:
At the moment we don't check the plane input/output sizes, which can lead to DSS HW errors when invalid values are given from the userspace.
Add a check so that the sizes are > 0.
Signed-off-by Tomi Valkeinen <[email protected]>
I don't think it makes sense to have an empty source or destination rectangle for any driver, not just omapdrm. Shouldn't this check be added to drm_atomic_plane_check() instead ?
Quoted 21 lines
--- drivers/gpu/drm/omapdrm/omap_plane.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/omapdrm/omap_plane.cindex93ee538a99f5..fa9e5086eb65100644drivers/gpu/drm/omapdrm/omap_plane.c +6
-0@@ -168,6 +168,12 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (IS_ERR(crtc_state))return PTR_ERR (crtc_state); +if (state->src_w ==0 || state->src_h ==0 ) +return -EINVAL ; + +if (state->crtc_w ==0 || state->crtc_h ==0 ) +return -EINVAL ; +if (state->crtc_x <0 || state->crtc_y <0 )return -EINVAL ;
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Laurent Pinchart
Hi Tomi,
(CC'ing Daniel)
Thank you for the patch.
Quoted 3 lines · On Tuesday 26 Apr 2016 13:16:42 Tomi Valkeinen wrote:
At the moment we don't check the plane input/output sizes, which can lead to DSS HW errors when invalid values are given from the userspace.
Quoted 7 lines
Quoted 3 lines
Add a check so that the sizes are > 0.
Signed-off-by Tomi Valkeinen <[email protected]>I don't think it makes sense to have an empty source or destination rectangle for any driver, not just omapdrm. Shouldn't this check be added to
drm_atomic_plane_check()instead ?
It's perfectly legal. Just means you're supposed to turn the plane off.
Quoted 32 lines
Quoted 22 lines
--- drivers/gpu/drm/omapdrm/omap_plane.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/omapdrm/omap_plane.cindex93ee538a99f5..fa9e5086eb65100644drivers/gpu/drm/omapdrm/omap_plane.c +6
-0@@ -168,6 +168,12 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (IS_ERR(crtc_state))return PTR_ERR (crtc_state); +if (state->src_w ==0 || state->src_h ==0 ) +return -EINVAL ; + +if (state->crtc_w ==0 || state->crtc_h ==0 ) +return -EINVAL ; +if (state->crtc_x <0 || state->crtc_y <0 )return -EINVAL ;Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Ville,
Quoted 13 lines · On Wednesday 27 Apr 2016 20:29:24 Ville Syrjälä wrote:
Quoted 12 lines · Laurent Pinchart
Hi Tomi,
(CC'ing Daniel)
Thank you for the patch.
Quoted 5 lines · On Tuesday 26 Apr 2016 13:16:42 Tomi Valkeinen wrote:
At the moment we don't check the plane input/output sizes, which can lead to DSS HW errors when invalid values are given from the userspace.
Add a check so that the sizes are > 0.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Tomi Valkeinen <[email protected]>I don't think it makes sense to have an empty source or destination rectangle for any driver, not just omapdrm. Shouldn't this check be added to
drm_atomic_plane_check()instead ?It's perfectly legal. Just means you're supposed to turn the plane off.
Where is that documented ? I thought turning the plane off was done by setting the framebuffer to NULL (in which case the src and crtc coordinates must of course be ignored) ?
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
---
drivers/gpu/drm/omapdrm/omap_plane.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/omapdrm/omap_plane.cindex93ee538a99f5..fa9e5086eb65100644drivers/gpu/drm/omapdrm/omap_plane.c +6
-0@@ -168,6 +168,12 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (IS_ERR(crtc_state))return PTR_ERR (crtc_state); +if (state->src_w ==0 || state->src_h ==0 ) +return -EINVAL ; + +if (state->crtc_w ==0 || state->crtc_h ==0 ) +return -EINVAL ; +if (state->crtc_x <0 || state->crtc_y <0 )return
-EINVAL;
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 18 lines · Laurent Pinchart
Hi Ville,
Quoted 15 lines · On Wednesday 27 Apr 2016 20:29:24 Ville Syrjälä wrote:
Quoted 14 lines · Laurent Pinchart
Hi Tomi,
(CC'ing Daniel)
Thank you for the patch.
Quoted 6 lines · On Tuesday 26 Apr 2016 13:16:42 Tomi Valkeinen wrote:
At the moment we don't check the plane input/output sizes, which can lead to DSS HW errors when invalid values are given from the userspace.
Add a check so that the sizes are > 0.
Signed-off-by Tomi Valkeinen <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
I don't think it makes sense to have an empty source or destination rectangle for any driver, not just omapdrm. Shouldn't this check be added to
drm_atomic_plane_check()instead ?It's perfectly legal. Just means you're supposed to turn the plane off.
Where is that documented ?
Do we have uapi docs?
Quoted 3 lines
I thought turning the plane off was done by setting
the framebuffer to NULL (in which case the src and crtc coordinates must of course be ignored) ?
That's another way. However setting the fb to 0 is a bit different, as then you're not holding a ref on the fb (nor does it get pinned etc.). So eg. if you want to make sure that you really can pin the fb, but want to have the plane disabled for a bit, you could just the clear out the coordinates.
Also from an implementation POV it's no different than the plane just getting clipped away entirely, so supporting this way of disabling a plane has no extra cost really.
Quoted 31 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
---
drivers/gpu/drm/omapdrm/omap_plane.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/omapdrm/omap_plane.cindex93ee538a99f5..fa9e5086eb65100644drivers/gpu/drm/omapdrm/omap_plane.c +6
-0@@ -168,6 +168,12 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (IS_ERR(crtc_state))return PTR_ERR (crtc_state); +if (state->src_w ==0 || state->src_h ==0 ) +return -EINVAL ; + +if (state->crtc_w ==0 || state->crtc_h ==0 ) +return -EINVAL ; +if (state->crtc_x <0 || state->crtc_y <0 )return
-EINVAL;Signature · 3 lines
Regards, Laurent Pinchart
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Ville,
Quoted 16 lines · On Thursday 28 Apr 2016 21:30:18 Ville Syrjälä wrote:
Quoted 15 lines · Laurent Pinchart
Quoted 14 lines · On Wednesday 27 Apr 2016 20:29:24 Ville Syrjälä wrote:
Quoted 12 lines · Laurent Pinchart
Quoted 7 lines · On Tuesday 26 Apr 2016 13:16:42 Tomi Valkeinen wrote:
At the moment we don't check the plane input/output sizes, which can lead to DSS HW errors when invalid values are given from the userspace.
Add a check so that the sizes are > 0.
Signed-off-by Tomi Valkeinen <[email protected]>I don't think it makes sense to have an empty source or destination rectangle for any driver, not just omapdrm. Shouldn't this check be added to
drm_atomic_plane_check()instead ?
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
It's perfectly legal. Just means you're supposed to turn the plane off.
Where is that documented ?
Do we have uapi docs?
My point, really :-)
Quoted 10 lines
Quoted 3 lines
I thought turning the plane off was done by setting
the framebuffer to NULL (in which case the src and crtc coordinates must of course be ignored) ?That's another way. However setting the fb to 0 is a bit different, as then you're not holding a ref on the fb (nor does it get pinned etc.). So eg. if you want to make sure that you really can pin the fb, but want to have the plane disabled for a bit, you could just the clear out the coordinates.
Quoted 3 lines
Also from an implementation POV it's no different than the plane just getting clipped away entirely, so supporting this way of disabling a plane has no extra cost really.
This really needs to be captured in a uapi documentation, this is the first time I hear about that feature, and I'm pretty sure I'm not the only one. We can't expect drivers to implement a consistent behaviour if the expected behaviour isn't documented.
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 12 lines
---
drivers/gpu/drm/omapdrm/omap_plane.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/omapdrm/omap_plane.cindex93ee538a99f5..fa9e5086eb65Quoted 1 line
100644
drivers/gpu/drm/omapdrm/omap_plane.c +0
-0@@ -168,6 +168,12 @@ static int omap_plane_atomic_check(structQuoted 1 line
drm_plane*plane, if (
IS_ERR(crtc_state))Quoted 13 lines
drivers/gpu/drm/omapdrm/omap_plane.c +6
-0return PTR_ERR (crtc_state); +if (state->src_w ==0 || state->src_h ==0 ) +return -EINVAL ; + +if (state->crtc_w ==0 || state->crtc_h ==0 ) +return -EINVAL ; +if (state->crtc_x <0 || state->crtc_y <0 )return -EINVAL ;
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Laurent Pinchart
Quoted 10 lines
Quoted 3 lines
I thought turning the plane off was done by setting
the framebuffer to NULL (in which case the src and crtc coordinates must of course be ignored) ?That's another way. However setting the fb to 0 is a bit different, as then you're not holding a ref on the fb (nor does it get pinned etc.). So eg. if you want to make sure that you really can pin the fb, but want to have the plane disabled for a bit, you could just the clear out the coordinates.
Quoted 8 lines
Quoted 3 lines
Also from an implementation POV it's no different than the plane just getting clipped away entirely, so supporting this way of disabling a plane has no extra cost really.
This really needs to be captured in a uapi documentation, this is the first time I hear about that feature, and I'm pretty sure I'm not the only one. We can't expect drivers to implement a consistent behaviour if the expected behaviour isn't documented.
I think we also have some room for better helpers. There's one to validate plane state, but it was written back for legacy planes and so takes slightly different arguments than what drm_plane_state provides. Doing an atomic version of that would likely get rid of lots of duplicated boilerplate all over drivers. And that helper does compute bool visible how Ville explained here.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel