aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorAndrey Grodzovsky <andrey.grodzovsky@amd.com>2018-03-28 08:01:53 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-04-03 13:52:58 -0400
commit326aa996a6681dca76477337b66f5e303aa8953e (patch)
treef1b3782e0b0ef95e565a245e6724427d75e12d77 /drivers/gpu/drm
parentfd8d415148ccf5af1ca87d7e38fd2902cc7d8904 (diff)
drm/amdgpu: Fix KIQ hang on bare metal for device unbind/bind back v2.
Problem: When unbind and then bind back the device KIQ hangs on Vega after mapping KCQs request. Fix: Adding deinitialzie code from CAIL during HW fini solves the hang. v2: use srbm_mutex around soc15_grbm_select() Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 1ae3de1094f9..ae90c95e36af 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -2757,6 +2757,45 @@ static int gfx_v9_0_kiq_init_register(struct amdgpu_ring *ring)
2757 return 0; 2757 return 0;
2758} 2758}
2759 2759
2760static int gfx_v9_0_kiq_fini_register(struct amdgpu_ring *ring)
2761{
2762 struct amdgpu_device *adev = ring->adev;
2763 int j;
2764
2765 /* disable the queue if it's active */
2766 if (RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1) {
2767
2768 WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 1);
2769
2770 for (j = 0; j < adev->usec_timeout; j++) {
2771 if (!(RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1))
2772 break;
2773 udelay(1);
2774 }
2775
2776 if (adev->usec_timeout == AMDGPU_MAX_USEC_TIMEOUT) {
2777 DRM_DEBUG("KIQ dequeue request failed.\n");
2778
2779 WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE, 0);
2780 }
2781
2782 /* Manual disable if dequeue request times out */
2783 WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST,
2784 0);
2785 }
2786
2787 WREG32_SOC15(GC, 0, mmCP_HQD_IQ_TIMER, 0);
2788 WREG32_SOC15(GC, 0, mmCP_HQD_IB_CONTROL, 0);
2789 WREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE, 0);
2790 WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, 0x40000000);
2791 WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, 0);
2792 WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR, 0);
2793 WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI, 0);
2794 WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO, 0);
2795
2796 return 0;
2797}
2798
2760static int gfx_v9_0_kiq_init_queue(struct amdgpu_ring *ring) 2799static int gfx_v9_0_kiq_init_queue(struct amdgpu_ring *ring)
2761{ 2800{
2762 struct amdgpu_device *adev = ring->adev; 2801 struct amdgpu_device *adev = ring->adev;
@@ -3010,7 +3049,6 @@ static int gfx_v9_0_kcq_disable(struct amdgpu_ring *kiq_ring,struct amdgpu_ring
3010 return r; 3049 return r;
3011} 3050}
3012 3051
3013
3014static int gfx_v9_0_hw_fini(void *handle) 3052static int gfx_v9_0_hw_fini(void *handle)
3015{ 3053{
3016 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 3054 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -3033,6 +3071,20 @@ static int gfx_v9_0_hw_fini(void *handle)
3033 WREG32_FIELD15(GC, 0, CP_PQ_WPTR_POLL_CNTL, EN, 0); 3071 WREG32_FIELD15(GC, 0, CP_PQ_WPTR_POLL_CNTL, EN, 0);
3034 return 0; 3072 return 0;
3035 } 3073 }
3074
3075 /* Use deinitialize sequence from CAIL when unbinding device from driver,
3076 * otherwise KIQ is hanging when binding back
3077 */
3078 if (!adev->in_gpu_reset && !adev->gfx.in_suspend) {
3079 mutex_lock(&adev->srbm_mutex);
3080 soc15_grbm_select(adev, adev->gfx.kiq.ring.me,
3081 adev->gfx.kiq.ring.pipe,
3082 adev->gfx.kiq.ring.queue, 0);
3083 gfx_v9_0_kiq_fini_register(&adev->gfx.kiq.ring);
3084 soc15_grbm_select(adev, 0, 0, 0, 0);
3085 mutex_unlock(&adev->srbm_mutex);
3086 }
3087
3036 gfx_v9_0_cp_enable(adev, false); 3088 gfx_v9_0_cp_enable(adev, false);
3037 gfx_v9_0_rlc_stop(adev); 3089 gfx_v9_0_rlc_stop(adev);
3038 3090