* [PATCH 1/3] drm/radeon: Also call cursor_move_locked when the cursor size changes
@ 2016-10-27 7:59 Michel Dänzer
[not found] ` <20161027075944.4476-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Michel Dänzer @ 2016-10-27 7:59 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Takashi Iwai, Tomáš Chvátal
From: Michel Dänzer <michel.daenzer@amd.com>
The cursor size also affects the register programming.
Cc: stable@vger.kernel.org
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
drivers/gpu/drm/radeon/radeon_cursor.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index 2a10e24..99a1c8e 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -297,12 +297,11 @@ int radeon_crtc_cursor_set2(struct drm_crtc *crtc,
return ret;
}
- radeon_crtc->cursor_width = width;
- radeon_crtc->cursor_height = height;
-
radeon_lock_cursor(crtc, true);
- if (hot_x != radeon_crtc->cursor_hot_x ||
+ if (width != radeon_crtc->cursor_width ||
+ height != radeon_crtc->cursor_height ||
+ hot_x != radeon_crtc->cursor_hot_x ||
hot_y != radeon_crtc->cursor_hot_y) {
int x, y;
@@ -311,6 +310,8 @@ int radeon_crtc_cursor_set2(struct drm_crtc *crtc,
radeon_cursor_move_locked(crtc, x, y);
+ radeon_crtc->cursor_width = width;
+ radeon_crtc->cursor_height = height;
radeon_crtc->cursor_hot_x = hot_x;
radeon_crtc->cursor_hot_y = hot_y;
}
--
2.10.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] drm/radeon: Always store CRTC relative radeon_crtc->cursor_x/y values
[not found] ` <20161027075944.4476-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-10-27 7:59 ` Michel Dänzer
2016-10-27 7:59 ` [PATCH 3/3] drm/radeon: Hide the HW cursor while it's out of bounds Michel Dänzer
1 sibling, 0 replies; 4+ messages in thread
From: Michel Dänzer @ 2016-10-27 7:59 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Takashi Iwai, Tomáš Chvátal
From: Michel Dänzer <michel.daenzer@amd.com>
We were storing viewport relative coordinates for AVIVO/DCE display
engines. However, radeon_crtc_cursor_set2 and radeon_cursor_reset pass
radeon_crtc->cursor_x/y as the x/y parameters of
radeon_cursor_move_locked, which would break if the CRTC isn't located
at (0, 0).
Cc: stable@vger.kernel.org
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
drivers/gpu/drm/radeon/radeon_cursor.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index 99a1c8e..a3405fc 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -143,6 +143,9 @@ static int radeon_cursor_move_locked(struct drm_crtc *crtc, int x, int y)
int xorigin = 0, yorigin = 0;
int w = radeon_crtc->cursor_width;
+ radeon_crtc->cursor_x = x;
+ radeon_crtc->cursor_y = y;
+
if (ASIC_IS_AVIVO(rdev)) {
/* avivo cursor are offset into the total surface */
x += crtc->x;
@@ -229,9 +232,6 @@ static int radeon_cursor_move_locked(struct drm_crtc *crtc, int x, int y)
yorigin * 256);
}
- radeon_crtc->cursor_x = x;
- radeon_crtc->cursor_y = y;
-
return 0;
}
--
2.10.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] drm/radeon: Hide the HW cursor while it's out of bounds
[not found] ` <20161027075944.4476-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-10-27 7:59 ` [PATCH 2/3] drm/radeon: Always store CRTC relative radeon_crtc->cursor_x/y values Michel Dänzer
@ 2016-10-27 7:59 ` Michel Dänzer
[not found] ` <20161027075944.4476-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
1 sibling, 1 reply; 4+ messages in thread
From: Michel Dänzer @ 2016-10-27 7:59 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Takashi Iwai, Tomáš Chvátal
From: Michel Dänzer <michel.daenzer@amd.com>
Fixes hangs in that case under some circumstances.
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1000433
Cc: stable@vger.kernel.org
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
drivers/gpu/drm/radeon/radeon_cursor.c | 66 +++++++++++++++++++++-------------
drivers/gpu/drm/radeon/radeon_mode.h | 1 +
2 files changed, 42 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index a3405fc..baf632a 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -90,6 +90,9 @@ static void radeon_show_cursor(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct radeon_device *rdev = crtc->dev->dev_private;
+ if (radeon_crtc->cursor_out_of_bounds)
+ return;
+
if (ASIC_IS_DCE4(rdev)) {
WREG32(EVERGREEN_CUR_SURFACE_ADDRESS_HIGH + radeon_crtc->crtc_offset,
upper_32_bits(radeon_crtc->cursor_addr));
@@ -146,21 +149,14 @@ static int radeon_cursor_move_locked(struct drm_crtc *crtc, int x, int y)
radeon_crtc->cursor_x = x;
radeon_crtc->cursor_y = y;
- if (ASIC_IS_AVIVO(rdev)) {
- /* avivo cursor are offset into the total surface */
- x += crtc->x;
- y += crtc->y;
- }
- DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y);
-
- if (x < 0) {
+ if (x < 0)
xorigin = min(-x, radeon_crtc->max_cursor_width - 1);
- x = 0;
- }
- if (y < 0) {
+ if (y < 0)
yorigin = min(-y, radeon_crtc->max_cursor_height - 1);
- y = 0;
- }
+
+ x += crtc->x;
+ y += crtc->y;
+ DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y);
/* fixed on DCE6 and newer */
if (ASIC_IS_AVIVO(rdev) && !ASIC_IS_DCE6(rdev)) {
@@ -183,27 +179,31 @@ static int radeon_cursor_move_locked(struct drm_crtc *crtc, int x, int y)
if (i > 1) {
int cursor_end, frame_end;
- cursor_end = x - xorigin + w;
+ cursor_end = x + w;
frame_end = crtc->x + crtc->mode.crtc_hdisplay;
if (cursor_end >= frame_end) {
w = w - (cursor_end - frame_end);
if (!(frame_end & 0x7f))
w--;
- } else {
- if (!(cursor_end & 0x7f))
- w--;
+ } else if (cursor_end <= 0) {
+ goto out_of_bounds;
+ } else if (!(cursor_end & 0x7f)) {
+ w--;
}
if (w <= 0) {
- w = 1;
- cursor_end = x - xorigin + w;
- if (!(cursor_end & 0x7f)) {
- x--;
- WARN_ON_ONCE(x < 0);
- }
+ goto out_of_bounds;
}
}
}
+ if (x <= (crtc->x - w) || y <= (crtc->y - radeon_crtc->cursor_height) ||
+ x >= (crtc->x + crtc->mode.crtc_hdisplay) ||
+ y >= (crtc->y + crtc->mode.crtc_vdisplay))
+ goto out_of_bounds;
+
+ x += xorigin;
+ y += yorigin;
+
if (ASIC_IS_DCE4(rdev)) {
WREG32(EVERGREEN_CUR_POSITION + radeon_crtc->crtc_offset, (x << 16) | y);
WREG32(EVERGREEN_CUR_HOT_SPOT + radeon_crtc->crtc_offset, (xorigin << 16) | yorigin);
@@ -215,6 +215,9 @@ static int radeon_cursor_move_locked(struct drm_crtc *crtc, int x, int y)
WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset,
((w - 1) << 16) | (radeon_crtc->cursor_height - 1));
} else {
+ x -= crtc->x;
+ y -= crtc->y;
+
if (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN)
y *= 2;
@@ -232,6 +235,19 @@ static int radeon_cursor_move_locked(struct drm_crtc *crtc, int x, int y)
yorigin * 256);
}
+ if (radeon_crtc->cursor_out_of_bounds) {
+ radeon_crtc->cursor_out_of_bounds = false;
+ if (radeon_crtc->cursor_bo)
+ radeon_show_cursor(crtc);
+ }
+
+ return 0;
+
+ out_of_bounds:
+ if (!radeon_crtc->cursor_out_of_bounds) {
+ radeon_hide_cursor(crtc);
+ radeon_crtc->cursor_out_of_bounds = true;
+ }
return 0;
}
@@ -308,12 +324,12 @@ int radeon_crtc_cursor_set2(struct drm_crtc *crtc,
x = radeon_crtc->cursor_x + radeon_crtc->cursor_hot_x - hot_x;
y = radeon_crtc->cursor_y + radeon_crtc->cursor_hot_y - hot_y;
- radeon_cursor_move_locked(crtc, x, y);
-
radeon_crtc->cursor_width = width;
radeon_crtc->cursor_height = height;
radeon_crtc->cursor_hot_x = hot_x;
radeon_crtc->cursor_hot_y = hot_y;
+
+ radeon_cursor_move_locked(crtc, x, y);
}
radeon_show_cursor(crtc);
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index bb75201a..f1da484 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -330,6 +330,7 @@ struct radeon_crtc {
u16 lut_r[256], lut_g[256], lut_b[256];
bool enabled;
bool can_tile;
+ bool cursor_out_of_bounds;
uint32_t crtc_offset;
struct drm_gem_object *cursor_bo;
uint64_t cursor_addr;
--
2.10.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH 3/3] drm/radeon: Hide the HW cursor while it's out of bounds
[not found] ` <20161027075944.4476-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-10-27 14:21 ` Deucher, Alexander
0 siblings, 0 replies; 4+ messages in thread
From: Deucher, Alexander @ 2016-10-27 14:21 UTC (permalink / raw)
To: 'Michel Dänzer', amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Takashi Iwai, Tomáš Chvátal
> -----Original Message-----
> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf
> Of Michel Dänzer
> Sent: Thursday, October 27, 2016 4:00 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Takashi Iwai; Tomáš Chvátal
> Subject: [PATCH 3/3] drm/radeon: Hide the HW cursor while it's out of
> bounds
>
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> Fixes hangs in that case under some circumstances.
>
> Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1000433
> Cc: stable@vger.kernel.org
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
For the series:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/radeon/radeon_cursor.c | 66 +++++++++++++++++++++--
> -----------
> drivers/gpu/drm/radeon/radeon_mode.h | 1 +
> 2 files changed, 42 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c
> b/drivers/gpu/drm/radeon/radeon_cursor.c
> index a3405fc..baf632a 100644
> --- a/drivers/gpu/drm/radeon/radeon_cursor.c
> +++ b/drivers/gpu/drm/radeon/radeon_cursor.c
> @@ -90,6 +90,9 @@ static void radeon_show_cursor(struct drm_crtc *crtc)
> struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
> struct radeon_device *rdev = crtc->dev->dev_private;
>
> + if (radeon_crtc->cursor_out_of_bounds)
> + return;
> +
> if (ASIC_IS_DCE4(rdev)) {
> WREG32(EVERGREEN_CUR_SURFACE_ADDRESS_HIGH +
> radeon_crtc->crtc_offset,
> upper_32_bits(radeon_crtc->cursor_addr));
> @@ -146,21 +149,14 @@ static int radeon_cursor_move_locked(struct
> drm_crtc *crtc, int x, int y)
> radeon_crtc->cursor_x = x;
> radeon_crtc->cursor_y = y;
>
> - if (ASIC_IS_AVIVO(rdev)) {
> - /* avivo cursor are offset into the total surface */
> - x += crtc->x;
> - y += crtc->y;
> - }
> - DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y);
> -
> - if (x < 0) {
> + if (x < 0)
> xorigin = min(-x, radeon_crtc->max_cursor_width - 1);
> - x = 0;
> - }
> - if (y < 0) {
> + if (y < 0)
> yorigin = min(-y, radeon_crtc->max_cursor_height - 1);
> - y = 0;
> - }
> +
> + x += crtc->x;
> + y += crtc->y;
> + DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y);
>
> /* fixed on DCE6 and newer */
> if (ASIC_IS_AVIVO(rdev) && !ASIC_IS_DCE6(rdev)) {
> @@ -183,27 +179,31 @@ static int radeon_cursor_move_locked(struct
> drm_crtc *crtc, int x, int y)
> if (i > 1) {
> int cursor_end, frame_end;
>
> - cursor_end = x - xorigin + w;
> + cursor_end = x + w;
> frame_end = crtc->x + crtc->mode.crtc_hdisplay;
> if (cursor_end >= frame_end) {
> w = w - (cursor_end - frame_end);
> if (!(frame_end & 0x7f))
> w--;
> - } else {
> - if (!(cursor_end & 0x7f))
> - w--;
> + } else if (cursor_end <= 0) {
> + goto out_of_bounds;
> + } else if (!(cursor_end & 0x7f)) {
> + w--;
> }
> if (w <= 0) {
> - w = 1;
> - cursor_end = x - xorigin + w;
> - if (!(cursor_end & 0x7f)) {
> - x--;
> - WARN_ON_ONCE(x < 0);
> - }
> + goto out_of_bounds;
> }
> }
> }
>
> + if (x <= (crtc->x - w) || y <= (crtc->y - radeon_crtc->cursor_height) ||
> + x >= (crtc->x + crtc->mode.crtc_hdisplay) ||
> + y >= (crtc->y + crtc->mode.crtc_vdisplay))
> + goto out_of_bounds;
> +
> + x += xorigin;
> + y += yorigin;
> +
> if (ASIC_IS_DCE4(rdev)) {
> WREG32(EVERGREEN_CUR_POSITION + radeon_crtc-
> >crtc_offset, (x << 16) | y);
> WREG32(EVERGREEN_CUR_HOT_SPOT + radeon_crtc-
> >crtc_offset, (xorigin << 16) | yorigin);
> @@ -215,6 +215,9 @@ static int radeon_cursor_move_locked(struct
> drm_crtc *crtc, int x, int y)
> WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset,
> ((w - 1) << 16) | (radeon_crtc->cursor_height - 1));
> } else {
> + x -= crtc->x;
> + y -= crtc->y;
> +
> if (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN)
> y *= 2;
>
> @@ -232,6 +235,19 @@ static int radeon_cursor_move_locked(struct
> drm_crtc *crtc, int x, int y)
> yorigin * 256);
> }
>
> + if (radeon_crtc->cursor_out_of_bounds) {
> + radeon_crtc->cursor_out_of_bounds = false;
> + if (radeon_crtc->cursor_bo)
> + radeon_show_cursor(crtc);
> + }
> +
> + return 0;
> +
> + out_of_bounds:
> + if (!radeon_crtc->cursor_out_of_bounds) {
> + radeon_hide_cursor(crtc);
> + radeon_crtc->cursor_out_of_bounds = true;
> + }
> return 0;
> }
>
> @@ -308,12 +324,12 @@ int radeon_crtc_cursor_set2(struct drm_crtc *crtc,
> x = radeon_crtc->cursor_x + radeon_crtc->cursor_hot_x -
> hot_x;
> y = radeon_crtc->cursor_y + radeon_crtc->cursor_hot_y -
> hot_y;
>
> - radeon_cursor_move_locked(crtc, x, y);
> -
> radeon_crtc->cursor_width = width;
> radeon_crtc->cursor_height = height;
> radeon_crtc->cursor_hot_x = hot_x;
> radeon_crtc->cursor_hot_y = hot_y;
> +
> + radeon_cursor_move_locked(crtc, x, y);
> }
>
> radeon_show_cursor(crtc);
> diff --git a/drivers/gpu/drm/radeon/radeon_mode.h
> b/drivers/gpu/drm/radeon/radeon_mode.h
> index bb75201a..f1da484 100644
> --- a/drivers/gpu/drm/radeon/radeon_mode.h
> +++ b/drivers/gpu/drm/radeon/radeon_mode.h
> @@ -330,6 +330,7 @@ struct radeon_crtc {
> u16 lut_r[256], lut_g[256], lut_b[256];
> bool enabled;
> bool can_tile;
> + bool cursor_out_of_bounds;
> uint32_t crtc_offset;
> struct drm_gem_object *cursor_bo;
> uint64_t cursor_addr;
> --
> 2.10.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-27 14:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 7:59 [PATCH 1/3] drm/radeon: Also call cursor_move_locked when the cursor size changes Michel Dänzer
[not found] ` <20161027075944.4476-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-10-27 7:59 ` [PATCH 2/3] drm/radeon: Always store CRTC relative radeon_crtc->cursor_x/y values Michel Dänzer
2016-10-27 7:59 ` [PATCH 3/3] drm/radeon: Hide the HW cursor while it's out of bounds Michel Dänzer
[not found] ` <20161027075944.4476-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-10-27 14:21 ` Deucher, Alexander
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.