aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2018-07-19 14:24:33 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-07-20 15:24:55 -0400
commitfe1053b7859dcbe830212de43befe6c7e4f089a8 (patch)
treea9820ef97615e6db0585b168afd3607770ca7fbb /drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
parente7854a038015122538df4777b8c192e03b4eb6c2 (diff)
drm/amdgpu: rework suspend and resume to deal with atomic changes
Use the newly split ip suspend functions to do suspend displays first (to deal with atomic so that FBs can be unpinned before attempting to evict vram), then evict vram, then suspend the other IPs. Also move the non-DC pinning code to only be called in the non-DC cases since atomic should take care of DC. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107065 Fixes: e00fb85 drm: Stop updating plane->crtc/fb/old_fb on atomic drivers Acked-by: Harry Wentland <harry.wentland@amd.com> Reviewed-and-tested-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c86
1 files changed, 45 insertions, 41 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 36426e66964d..61981d0701b5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2709,44 +2709,46 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
2709 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 2709 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
2710 } 2710 }
2711 drm_modeset_unlock_all(dev); 2711 drm_modeset_unlock_all(dev);
2712 } 2712 /* unpin the front buffers and cursors */
2713 2713 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
2714 amdgpu_amdkfd_suspend(adev); 2714 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2715 2715 struct drm_framebuffer *fb = crtc->primary->fb;
2716 /* unpin the front buffers and cursors */ 2716 struct amdgpu_bo *robj;
2717 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 2717
2718 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2718 if (amdgpu_crtc->cursor_bo) {
2719 struct drm_framebuffer *fb = crtc->primary->fb; 2719 struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo);
2720 struct amdgpu_bo *robj; 2720 r = amdgpu_bo_reserve(aobj, true);
2721 2721 if (r == 0) {
2722 if (amdgpu_crtc->cursor_bo) { 2722 amdgpu_bo_unpin(aobj);
2723 struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo); 2723 amdgpu_bo_unreserve(aobj);
2724 r = amdgpu_bo_reserve(aobj, true); 2724 }
2725 if (r == 0) {
2726 amdgpu_bo_unpin(aobj);
2727 amdgpu_bo_unreserve(aobj);
2728 } 2725 }
2729 }
2730 2726
2731 if (fb == NULL || fb->obj[0] == NULL) { 2727 if (fb == NULL || fb->obj[0] == NULL) {
2732 continue; 2728 continue;
2733 } 2729 }
2734 robj = gem_to_amdgpu_bo(fb->obj[0]); 2730 robj = gem_to_amdgpu_bo(fb->obj[0]);
2735 /* don't unpin kernel fb objects */ 2731 /* don't unpin kernel fb objects */
2736 if (!amdgpu_fbdev_robj_is_fb(adev, robj)) { 2732 if (!amdgpu_fbdev_robj_is_fb(adev, robj)) {
2737 r = amdgpu_bo_reserve(robj, true); 2733 r = amdgpu_bo_reserve(robj, true);
2738 if (r == 0) { 2734 if (r == 0) {
2739 amdgpu_bo_unpin(robj); 2735 amdgpu_bo_unpin(robj);
2740 amdgpu_bo_unreserve(robj); 2736 amdgpu_bo_unreserve(robj);
2737 }
2741 } 2738 }
2742 } 2739 }
2743 } 2740 }
2741
2742 amdgpu_amdkfd_suspend(adev);
2743
2744 r = amdgpu_device_ip_suspend_phase1(adev);
2745
2744 /* evict vram memory */ 2746 /* evict vram memory */
2745 amdgpu_bo_evict_vram(adev); 2747 amdgpu_bo_evict_vram(adev);
2746 2748
2747 amdgpu_fence_driver_suspend(adev); 2749 amdgpu_fence_driver_suspend(adev);
2748 2750
2749 r = amdgpu_device_ip_suspend(adev); 2751 r = amdgpu_device_ip_suspend_phase2(adev);
2750 2752
2751 /* evict remaining vram memory 2753 /* evict remaining vram memory
2752 * This second call to evict vram is to evict the gart page table 2754 * This second call to evict vram is to evict the gart page table
@@ -2819,19 +2821,21 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
2819 if (r) 2821 if (r)
2820 return r; 2822 return r;
2821 2823
2822 /* pin cursors */ 2824 if (!amdgpu_device_has_dc_support(adev)) {
2823 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 2825 /* pin cursors */
2824 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2826 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
2825 2827 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2826 if (amdgpu_crtc->cursor_bo) { 2828
2827 struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo); 2829 if (amdgpu_crtc->cursor_bo) {
2828 r = amdgpu_bo_reserve(aobj, true); 2830 struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo);
2829 if (r == 0) { 2831 r = amdgpu_bo_reserve(aobj, true);
2830 r = amdgpu_bo_pin(aobj, AMDGPU_GEM_DOMAIN_VRAM); 2832 if (r == 0) {
2831 if (r != 0) 2833 r = amdgpu_bo_pin(aobj, AMDGPU_GEM_DOMAIN_VRAM);
2832 DRM_ERROR("Failed to pin cursor BO (%d)\n", r); 2834 if (r != 0)
2833 amdgpu_crtc->cursor_addr = amdgpu_bo_gpu_offset(aobj); 2835 DRM_ERROR("Failed to pin cursor BO (%d)\n", r);
2834 amdgpu_bo_unreserve(aobj); 2836 amdgpu_crtc->cursor_addr = amdgpu_bo_gpu_offset(aobj);
2837 amdgpu_bo_unreserve(aobj);
2838 }
2835 } 2839 }
2836 } 2840 }
2837 } 2841 }