diff mbox

[2/3] drm/radeon: unpin cursor BOs on suspend and pin them again on resume

Message ID 1436254050-4104-2-git-send-email-michel@daenzer.net (mailing list archive)
State New, archived
Headers show

Commit Message

Michel Dänzer July 7, 2015, 7:27 a.m. UTC
From: Grigori Goronzy <greg@chown.ath.cx>

Everything is evicted from VRAM before suspend, so we need to make
sure all BOs are unpinned and re-pinned after resume. Fixes broken
mouse cursor after resume introduced by commit b9729b17.

[Michel Dänzer: Add pinning BOs on resume]

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=100541
Cc: stable@vger.kernel.org
Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 drivers/gpu/drm/radeon/radeon_device.c | 36 ++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

Comments

Christian König July 7, 2015, 10:12 a.m. UTC | #1
On 07.07.2015 09:27, Michel Dänzer wrote:
> From: Grigori Goronzy <greg@chown.ath.cx>
>
> Everything is evicted from VRAM before suspend, so we need to make
> sure all BOs are unpinned and re-pinned after resume. Fixes broken
> mouse cursor after resume introduced by commit b9729b17.
>
> [Michel Dänzer: Add pinning BOs on resume]
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=100541
> Cc: stable@vger.kernel.org
> Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
> ---
>   drivers/gpu/drm/radeon/radeon_device.c | 36 ++++++++++++++++++++++++++++++++++
>   1 file changed, 36 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
> index 12a18c8..5a075a9 100644
> --- a/drivers/gpu/drm/radeon/radeon_device.c
> +++ b/drivers/gpu/drm/radeon/radeon_device.c
> @@ -1593,6 +1593,20 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
>   		drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
>   	}
>   
> +	/* unpin cursors */
> +	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {

Didn't we wanted to merge this into the other list_for_each_entry below?

Either way is fine with me and the whole series is Reviewed-by: 
Christian König <christian.koenig@amd.com> anyway.

Regards,
Christian.

> +		struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
> +
> +		if (radeon_crtc->cursor_bo) {
> +			struct radeon_bo *robj = gem_to_radeon_bo(radeon_crtc->cursor_bo);
> +			r = radeon_bo_reserve(robj, false);
> +			if (r == 0) {
> +				radeon_bo_unpin(robj);
> +				radeon_bo_unreserve(robj);
> +			}
> +		}
> +	}
> +
>   	/* unpin the front buffers */
>   	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
>   		struct radeon_framebuffer *rfb = to_radeon_framebuffer(crtc->primary->fb);
> @@ -1660,6 +1674,7 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
>   {
>   	struct drm_connector *connector;
>   	struct radeon_device *rdev = dev->dev_private;
> +	struct drm_crtc *crtc;
>   	int r;
>   
>   	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
> @@ -1699,6 +1714,27 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
>   
>   	radeon_restore_bios_scratch_regs(rdev);
>   
> +	/* pin cursors */
> +	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> +		struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
> +
> +		if (radeon_crtc->cursor_bo) {
> +			struct radeon_bo *robj = gem_to_radeon_bo(radeon_crtc->cursor_bo);
> +			r = radeon_bo_reserve(robj, false);
> +			if (r == 0) {
> +				/* Only 27 bit offset for legacy cursor */
> +				r = radeon_bo_pin_restricted(robj,
> +							     RADEON_GEM_DOMAIN_VRAM,
> +							     ASIC_IS_AVIVO(rdev) ?
> +							     0 : 1 << 27,
> +							     &radeon_crtc->cursor_addr);
> +				if (r != 0)
> +					DRM_ERROR("Failed to pin cursor BO (%d)\n", r);
> +				radeon_bo_unreserve(robj);
> +			}
> +		}
> +	}
> +
>   	/* init dig PHYs, disp eng pll */
>   	if (rdev->is_atom_bios) {
>   		radeon_atom_encoder_init(rdev);
diff mbox

Patch

diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 12a18c8..5a075a9 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1593,6 +1593,20 @@  int radeon_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
 		drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
 	}
 
+	/* unpin cursors */
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+		struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+
+		if (radeon_crtc->cursor_bo) {
+			struct radeon_bo *robj = gem_to_radeon_bo(radeon_crtc->cursor_bo);
+			r = radeon_bo_reserve(robj, false);
+			if (r == 0) {
+				radeon_bo_unpin(robj);
+				radeon_bo_unreserve(robj);
+			}
+		}
+	}
+
 	/* unpin the front buffers */
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 		struct radeon_framebuffer *rfb = to_radeon_framebuffer(crtc->primary->fb);
@@ -1660,6 +1674,7 @@  int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
 {
 	struct drm_connector *connector;
 	struct radeon_device *rdev = dev->dev_private;
+	struct drm_crtc *crtc;
 	int r;
 
 	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
@@ -1699,6 +1714,27 @@  int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
 
 	radeon_restore_bios_scratch_regs(rdev);
 
+	/* pin cursors */
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+		struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+
+		if (radeon_crtc->cursor_bo) {
+			struct radeon_bo *robj = gem_to_radeon_bo(radeon_crtc->cursor_bo);
+			r = radeon_bo_reserve(robj, false);
+			if (r == 0) {
+				/* Only 27 bit offset for legacy cursor */
+				r = radeon_bo_pin_restricted(robj,
+							     RADEON_GEM_DOMAIN_VRAM,
+							     ASIC_IS_AVIVO(rdev) ?
+							     0 : 1 << 27,
+							     &radeon_crtc->cursor_addr);
+				if (r != 0)
+					DRM_ERROR("Failed to pin cursor BO (%d)\n", r);
+				radeon_bo_unreserve(robj);
+			}
+		}
+	}
+
 	/* init dig PHYs, disp eng pll */
 	if (rdev->is_atom_bios) {
 		radeon_atom_encoder_init(rdev);