diff options
author | Monk Liu <Monk.Liu@amd.com> | 2017-09-21 02:59:40 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-09-26 15:14:23 -0400 |
commit | 85f95ad629558b65ab27cce583c683fb9e3da35c (patch) | |
tree | 6816ec9d677be20ec5814702f0f99b2e5251c985 /drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |
parent | 4bd9a67e17b9a2c1b0ca55e7dfc5a711c161373d (diff) |
drm/amdgpu:unmap KCQ in gfx hw_fini(v2)
v2:
move kcq_disable out of SRIOV, make it genearal
Signed-off-by: Monk Liu <Monk.Liu@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/amd/amdgpu/gfx_v8_0.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index 0c4a3b8e8596..dfc10b1baea0 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
@@ -5034,12 +5034,69 @@ static int gfx_v8_0_hw_init(void *handle) | |||
5034 | return r; | 5034 | return r; |
5035 | } | 5035 | } |
5036 | 5036 | ||
5037 | static int gfx_v8_0_kcq_disable(struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring) | ||
5038 | { | ||
5039 | struct amdgpu_device *adev = kiq_ring->adev; | ||
5040 | uint32_t scratch, tmp = 0; | ||
5041 | int r, i; | ||
5042 | |||
5043 | r = amdgpu_gfx_scratch_get(adev, &scratch); | ||
5044 | if (r) { | ||
5045 | DRM_ERROR("Failed to get scratch reg (%d).\n", r); | ||
5046 | return r; | ||
5047 | } | ||
5048 | WREG32(scratch, 0xCAFEDEAD); | ||
5049 | |||
5050 | r = amdgpu_ring_alloc(kiq_ring, 10); | ||
5051 | if (r) { | ||
5052 | DRM_ERROR("Failed to lock KIQ (%d).\n", r); | ||
5053 | amdgpu_gfx_scratch_free(adev, scratch); | ||
5054 | return r; | ||
5055 | } | ||
5056 | |||
5057 | /* unmap queues */ | ||
5058 | amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_UNMAP_QUEUES, 4)); | ||
5059 | amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */ | ||
5060 | PACKET3_UNMAP_QUEUES_ACTION(1) | /* RESET_QUEUES */ | ||
5061 | PACKET3_UNMAP_QUEUES_QUEUE_SEL(0) | | ||
5062 | PACKET3_UNMAP_QUEUES_ENGINE_SEL(0) | | ||
5063 | PACKET3_UNMAP_QUEUES_NUM_QUEUES(1)); | ||
5064 | amdgpu_ring_write(kiq_ring, PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(ring->doorbell_index)); | ||
5065 | amdgpu_ring_write(kiq_ring, 0); | ||
5066 | amdgpu_ring_write(kiq_ring, 0); | ||
5067 | amdgpu_ring_write(kiq_ring, 0); | ||
5068 | /* write to scratch for completion */ | ||
5069 | amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1)); | ||
5070 | amdgpu_ring_write(kiq_ring, (scratch - PACKET3_SET_UCONFIG_REG_START)); | ||
5071 | amdgpu_ring_write(kiq_ring, 0xDEADBEEF); | ||
5072 | amdgpu_ring_commit(kiq_ring); | ||
5073 | |||
5074 | for (i = 0; i < adev->usec_timeout; i++) { | ||
5075 | tmp = RREG32(scratch); | ||
5076 | if (tmp == 0xDEADBEEF) | ||
5077 | break; | ||
5078 | DRM_UDELAY(1); | ||
5079 | } | ||
5080 | if (i >= adev->usec_timeout) { | ||
5081 | DRM_ERROR("KCQ disabled failed (scratch(0x%04X)=0x%08X)\n", scratch, tmp); | ||
5082 | r = -EINVAL; | ||
5083 | } | ||
5084 | amdgpu_gfx_scratch_free(adev, scratch); | ||
5085 | return r; | ||
5086 | } | ||
5087 | |||
5037 | static int gfx_v8_0_hw_fini(void *handle) | 5088 | static int gfx_v8_0_hw_fini(void *handle) |
5038 | { | 5089 | { |
5039 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 5090 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
5091 | int i; | ||
5040 | 5092 | ||
5041 | amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0); | 5093 | amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0); |
5042 | amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0); | 5094 | amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0); |
5095 | |||
5096 | /* disable KCQ to avoid CPC touch memory not valid anymore */ | ||
5097 | for (i = 0; i < adev->gfx.num_compute_rings; i++) | ||
5098 | gfx_v8_0_kcq_disable(&adev->gfx.kiq.ring, &adev->gfx.compute_ring[i]); | ||
5099 | |||
5043 | if (amdgpu_sriov_vf(adev)) { | 5100 | if (amdgpu_sriov_vf(adev)) { |
5044 | pr_debug("For SRIOV client, shouldn't do anything.\n"); | 5101 | pr_debug("For SRIOV client, shouldn't do anything.\n"); |
5045 | return 0; | 5102 | return 0; |