Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/radeon: unpin cursor BOs on suspend and pin them again on resume (v2)

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]

v2:
[Alex Deucher: merge cursor unpin into fb unpin loop]

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=100541
Cc: stable@vger.kernel.org
Reviewed-by: Christian König <christian.koenig@amd.com> (v1)
Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Grigori Goronzy and committed by
Alex Deucher
f3cbb17b cd404af0

+33 -1
+33 -1
drivers/gpu/drm/radeon/radeon_device.c
··· 1578 1578 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 1579 1579 } 1580 1580 1581 - /* unpin the front buffers */ 1581 + /* unpin the front buffers and cursors */ 1582 1582 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 1583 + struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 1583 1584 struct radeon_framebuffer *rfb = to_radeon_framebuffer(crtc->primary->fb); 1584 1585 struct radeon_bo *robj; 1586 + 1587 + if (radeon_crtc->cursor_bo) { 1588 + struct radeon_bo *robj = gem_to_radeon_bo(radeon_crtc->cursor_bo); 1589 + r = radeon_bo_reserve(robj, false); 1590 + if (r == 0) { 1591 + radeon_bo_unpin(robj); 1592 + radeon_bo_unreserve(robj); 1593 + } 1594 + } 1585 1595 1586 1596 if (rfb == NULL || rfb->obj == NULL) { 1587 1597 continue; ··· 1655 1645 { 1656 1646 struct drm_connector *connector; 1657 1647 struct radeon_device *rdev = dev->dev_private; 1648 + struct drm_crtc *crtc; 1658 1649 int r; 1659 1650 1660 1651 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) ··· 1694 1683 } 1695 1684 1696 1685 radeon_restore_bios_scratch_regs(rdev); 1686 + 1687 + /* pin cursors */ 1688 + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 1689 + struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 1690 + 1691 + if (radeon_crtc->cursor_bo) { 1692 + struct radeon_bo *robj = gem_to_radeon_bo(radeon_crtc->cursor_bo); 1693 + r = radeon_bo_reserve(robj, false); 1694 + if (r == 0) { 1695 + /* Only 27 bit offset for legacy cursor */ 1696 + r = radeon_bo_pin_restricted(robj, 1697 + RADEON_GEM_DOMAIN_VRAM, 1698 + ASIC_IS_AVIVO(rdev) ? 1699 + 0 : 1 << 27, 1700 + &radeon_crtc->cursor_addr); 1701 + if (r != 0) 1702 + DRM_ERROR("Failed to pin cursor BO (%d)\n", r); 1703 + radeon_bo_unreserve(robj); 1704 + } 1705 + } 1706 + } 1697 1707 1698 1708 /* init dig PHYs, disp eng pll */ 1699 1709 if (rdev->is_atom_bios) {