* [PATCH] drm/i915: Clamp cursor coordinates to int16_t range
@ 2013-10-21 16:01 ville.syrjala
2013-10-21 16:13 ` Chris Wilson
2013-10-21 16:15 ` Daniel Vetter
0 siblings, 2 replies; 5+ messages in thread
From: ville.syrjala @ 2013-10-21 16:01 UTC (permalink / raw)
To: intel-gfx
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
We store cursor_x/y as int16_t internally, but the user provided
coordinates are int32_t. Clamp the coordinates so that they don't
overflow the int16_t. Since the cursor is only 64x64 in size, the
clamping can't cause any visual changes.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/i915/intel_display.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index d4a480c..8f554f3 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -7272,8 +7272,8 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
{
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
- intel_crtc->cursor_x = x;
- intel_crtc->cursor_y = y;
+ intel_crtc->cursor_x = clamp_t(int, x, SHRT_MIN, SHRT_MAX);
+ intel_crtc->cursor_y = clamp_t(int, y, SHRT_MIN, SHRT_MAX);
if (intel_crtc->active)
intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL);
--
1.8.1.5
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Clamp cursor coordinates to int16_t range
2013-10-21 16:01 [PATCH] drm/i915: Clamp cursor coordinates to int16_t range ville.syrjala
@ 2013-10-21 16:13 ` Chris Wilson
2013-10-28 17:01 ` Daniel Vetter
2013-10-21 16:15 ` Daniel Vetter
1 sibling, 1 reply; 5+ messages in thread
From: Chris Wilson @ 2013-10-21 16:13 UTC (permalink / raw)
To: ville.syrjala; +Cc: intel-gfx
On Mon, Oct 21, 2013 at 07:01:58PM +0300, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> We store cursor_x/y as int16_t internally, but the user provided
> coordinates are int32_t. Clamp the coordinates so that they don't
> overflow the int16_t. Since the cursor is only 64x64 in size, the
> clamping can't cause any visual changes.
EINVAL? That would appear to be a nuisance as we don't already tell the
user off for being silly with the cursor position.
Bump the internal range? Future proof against tomorrow's 64k
super-ultra-high definition monitors?
The valid range for cursor is currently (-64, 8192) and we don't compute
relative cursor position, so we will be fine for a few years yet with
int16_t.
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Clamp cursor coordinates to int16_t range
2013-10-21 16:01 [PATCH] drm/i915: Clamp cursor coordinates to int16_t range ville.syrjala
2013-10-21 16:13 ` Chris Wilson
@ 2013-10-21 16:15 ` Daniel Vetter
2013-10-21 16:24 ` Ville Syrjälä
1 sibling, 1 reply; 5+ messages in thread
From: Daniel Vetter @ 2013-10-21 16:15 UTC (permalink / raw)
To: Syrjala, Ville; +Cc: intel-gfx
On Mon, Oct 21, 2013 at 6:01 PM, <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> We store cursor_x/y as int16_t internally, but the user provided
> coordinates are int32_t. Clamp the coordinates so that they don't
> overflow the int16_t. Since the cursor is only 64x64 in size, the
> clamping can't cause any visual changes.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
For shits&giggles: You've bothered with a subtest for this in your crc
cursor test? Should be a one-liner and would neatly test whether QA
catches it ...
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Clamp cursor coordinates to int16_t range
2013-10-21 16:15 ` Daniel Vetter
@ 2013-10-21 16:24 ` Ville Syrjälä
0 siblings, 0 replies; 5+ messages in thread
From: Ville Syrjälä @ 2013-10-21 16:24 UTC (permalink / raw)
To: Daniel Vetter; +Cc: intel-gfx
On Mon, Oct 21, 2013 at 06:15:06PM +0200, Daniel Vetter wrote:
> On Mon, Oct 21, 2013 at 6:01 PM, <ville.syrjala@linux.intel.com> wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > We store cursor_x/y as int16_t internally, but the user provided
> > coordinates are int32_t. Clamp the coordinates so that they don't
> > overflow the int16_t. Since the cursor is only 64x64 in size, the
> > clamping can't cause any visual changes.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>
> For shits&giggles: You've bothered with a subtest for this in your crc
> cursor test? Should be a one-liner and would neatly test whether QA
> catches it ...
Yeah it's there. Actually I added the test before I knew the bug
existed. The test is what found the bug for me.
It's not a specific subtest though, but part of all the bigger
cursor-offscreen subtests. The subtest split I'm using there isn't
very fine grained. Maybe I should change that actually. It would
help in pinpointing the failing cases more accurately.
--
Ville Syrjälä
Intel OTC
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Clamp cursor coordinates to int16_t range
2013-10-21 16:13 ` Chris Wilson
@ 2013-10-28 17:01 ` Daniel Vetter
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2013-10-28 17:01 UTC (permalink / raw)
To: Chris Wilson, ville.syrjala, intel-gfx
On Mon, Oct 21, 2013 at 05:13:43PM +0100, Chris Wilson wrote:
> On Mon, Oct 21, 2013 at 07:01:58PM +0300, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > We store cursor_x/y as int16_t internally, but the user provided
> > coordinates are int32_t. Clamp the coordinates so that they don't
> > overflow the int16_t. Since the cursor is only 64x64 in size, the
> > clamping can't cause any visual changes.
>
> EINVAL? That would appear to be a nuisance as we don't already tell the
> user off for being silly with the cursor position.
>
> Bump the internal range? Future proof against tomorrow's 64k
> super-ultra-high definition monitors?
>
> The valid range for cursor is currently (-64, 8192) and we don't compute
> relative cursor position, so we will be fine for a few years yet with
> int16_t.
>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Queued for -next, thanks for the patch.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-28 17:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-21 16:01 [PATCH] drm/i915: Clamp cursor coordinates to int16_t range ville.syrjala
2013-10-21 16:13 ` Chris Wilson
2013-10-28 17:01 ` Daniel Vetter
2013-10-21 16:15 ` Daniel Vetter
2013-10-21 16:24 ` Ville Syrjälä
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox