diff options
author | Rex Zhu <Rex.Zhu@amd.com> | 2018-08-17 04:45:16 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-08-27 16:11:49 -0400 |
commit | ffabea84c55b1c6446b2245b87cdf6827b22e366 (patch) | |
tree | 3757d719f574129cad023e6483d547c4a5382c83 | |
parent | 841cf911fb9e4abd7b8bac2776943c60da9069f4 (diff) |
drm/amdgpu: Refine gfx_v9_0_kcq_disable function
Send all kcq unmap_queue packets and then wait for
complete.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index 37c95c479002..21e66f86de92 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | |||
@@ -3216,28 +3216,29 @@ static int gfx_v9_0_hw_init(void *handle) | |||
3216 | return r; | 3216 | return r; |
3217 | } | 3217 | } |
3218 | 3218 | ||
3219 | static int gfx_v9_0_kcq_disable(struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring) | 3219 | static int gfx_v9_0_kcq_disable(struct amdgpu_device *adev) |
3220 | { | 3220 | { |
3221 | int r; | 3221 | int r, i; |
3222 | struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring; | ||
3222 | 3223 | ||
3223 | r = amdgpu_ring_alloc(kiq_ring, 6); | 3224 | r = amdgpu_ring_alloc(kiq_ring, 6 * adev->gfx.num_compute_rings); |
3224 | if (r) { | 3225 | if (r) |
3225 | DRM_ERROR("Failed to lock KIQ (%d).\n", r); | 3226 | DRM_ERROR("Failed to lock KIQ (%d).\n", r); |
3226 | return r; | ||
3227 | } | ||
3228 | 3227 | ||
3229 | /* unmap queues */ | 3228 | for (i = 0; i < adev->gfx.num_compute_rings; i++) { |
3230 | amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_UNMAP_QUEUES, 4)); | 3229 | struct amdgpu_ring *ring = &adev->gfx.compute_ring[i]; |
3231 | amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */ | 3230 | |
3231 | amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_UNMAP_QUEUES, 4)); | ||
3232 | amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */ | ||
3232 | PACKET3_UNMAP_QUEUES_ACTION(1) | /* RESET_QUEUES */ | 3233 | PACKET3_UNMAP_QUEUES_ACTION(1) | /* RESET_QUEUES */ |
3233 | PACKET3_UNMAP_QUEUES_QUEUE_SEL(0) | | 3234 | PACKET3_UNMAP_QUEUES_QUEUE_SEL(0) | |
3234 | PACKET3_UNMAP_QUEUES_ENGINE_SEL(0) | | 3235 | PACKET3_UNMAP_QUEUES_ENGINE_SEL(0) | |
3235 | PACKET3_UNMAP_QUEUES_NUM_QUEUES(1)); | 3236 | PACKET3_UNMAP_QUEUES_NUM_QUEUES(1)); |
3236 | amdgpu_ring_write(kiq_ring, PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(ring->doorbell_index)); | 3237 | amdgpu_ring_write(kiq_ring, PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(ring->doorbell_index)); |
3237 | amdgpu_ring_write(kiq_ring, 0); | 3238 | amdgpu_ring_write(kiq_ring, 0); |
3238 | amdgpu_ring_write(kiq_ring, 0); | 3239 | amdgpu_ring_write(kiq_ring, 0); |
3239 | amdgpu_ring_write(kiq_ring, 0); | 3240 | amdgpu_ring_write(kiq_ring, 0); |
3240 | 3241 | } | |
3241 | r = amdgpu_ring_test_ring(kiq_ring); | 3242 | r = amdgpu_ring_test_ring(kiq_ring); |
3242 | if (r) | 3243 | if (r) |
3243 | DRM_ERROR("KCQ disable failed\n"); | 3244 | DRM_ERROR("KCQ disable failed\n"); |
@@ -3248,14 +3249,12 @@ static int gfx_v9_0_kcq_disable(struct amdgpu_ring *kiq_ring,struct amdgpu_ring | |||
3248 | static int gfx_v9_0_hw_fini(void *handle) | 3249 | static int gfx_v9_0_hw_fini(void *handle) |
3249 | { | 3250 | { |
3250 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 3251 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
3251 | int i; | ||
3252 | 3252 | ||
3253 | amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0); | 3253 | amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0); |
3254 | amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0); | 3254 | amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0); |
3255 | 3255 | ||
3256 | /* disable KCQ to avoid CPC touch memory not valid anymore */ | 3256 | /* disable KCQ to avoid CPC touch memory not valid anymore */ |
3257 | for (i = 0; i < adev->gfx.num_compute_rings; i++) | 3257 | gfx_v9_0_kcq_disable(adev); |
3258 | gfx_v9_0_kcq_disable(&adev->gfx.kiq.ring, &adev->gfx.compute_ring[i]); | ||
3259 | 3258 | ||
3260 | if (amdgpu_sriov_vf(adev)) { | 3259 | if (amdgpu_sriov_vf(adev)) { |
3261 | gfx_v9_0_cp_gfx_enable(adev, false); | 3260 | gfx_v9_0_cp_gfx_enable(adev, false); |