aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMonk Liu <Monk.Liu@amd.com>2017-09-21 02:59:40 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-09-26 15:14:23 -0400
commit85f95ad629558b65ab27cce583c683fb9e3da35c (patch)
tree6816ec9d677be20ec5814702f0f99b2e5251c985
parent4bd9a67e17b9a2c1b0ca55e7dfc5a711c161373d (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>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c57
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c58
2 files changed, 115 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
5037static 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
5037static int gfx_v8_0_hw_fini(void *handle) 5088static 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;
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index e2ae00df1d52..9945218a5489 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -2895,12 +2895,70 @@ static int gfx_v9_0_hw_init(void *handle)
2895 return r; 2895 return r;
2896} 2896}
2897 2897
2898static int gfx_v9_0_kcq_disable(struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring)
2899{
2900 struct amdgpu_device *adev = kiq_ring->adev;
2901 uint32_t scratch, tmp = 0;
2902 int r, i;
2903
2904 r = amdgpu_gfx_scratch_get(adev, &scratch);
2905 if (r) {
2906 DRM_ERROR("Failed to get scratch reg (%d).\n", r);
2907 return r;
2908 }
2909 WREG32(scratch, 0xCAFEDEAD);
2910
2911 r = amdgpu_ring_alloc(kiq_ring, 10);
2912 if (r) {
2913 DRM_ERROR("Failed to lock KIQ (%d).\n", r);
2914 amdgpu_gfx_scratch_free(adev, scratch);
2915 return r;
2916 }
2917
2918 /* unmap queues */
2919 amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_UNMAP_QUEUES, 4));
2920 amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */
2921 PACKET3_UNMAP_QUEUES_ACTION(1) | /* RESET_QUEUES */
2922 PACKET3_UNMAP_QUEUES_QUEUE_SEL(0) |
2923 PACKET3_UNMAP_QUEUES_ENGINE_SEL(0) |
2924 PACKET3_UNMAP_QUEUES_NUM_QUEUES(1));
2925 amdgpu_ring_write(kiq_ring, PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(ring->doorbell_index));
2926 amdgpu_ring_write(kiq_ring, 0);
2927 amdgpu_ring_write(kiq_ring, 0);
2928 amdgpu_ring_write(kiq_ring, 0);
2929 /* write to scratch for completion */
2930 amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1));
2931 amdgpu_ring_write(kiq_ring, (scratch - PACKET3_SET_UCONFIG_REG_START));
2932 amdgpu_ring_write(kiq_ring, 0xDEADBEEF);
2933 amdgpu_ring_commit(kiq_ring);
2934
2935 for (i = 0; i < adev->usec_timeout; i++) {
2936 tmp = RREG32(scratch);
2937 if (tmp == 0xDEADBEEF)
2938 break;
2939 DRM_UDELAY(1);
2940 }
2941 if (i >= adev->usec_timeout) {
2942 DRM_ERROR("KCQ disabled failed (scratch(0x%04X)=0x%08X)\n", scratch, tmp);
2943 r = -EINVAL;
2944 }
2945 amdgpu_gfx_scratch_free(adev, scratch);
2946 return r;
2947}
2948
2949
2898static int gfx_v9_0_hw_fini(void *handle) 2950static int gfx_v9_0_hw_fini(void *handle)
2899{ 2951{
2900 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 2952 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
2953 int i;
2901 2954
2902 amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0); 2955 amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0);
2903 amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0); 2956 amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0);
2957
2958 /* disable KCQ to avoid CPC touch memory not valid anymore */
2959 for (i = 0; i < adev->gfx.num_compute_rings; i++)
2960 gfx_v9_0_kcq_disable(&adev->gfx.kiq.ring, &adev->gfx.compute_ring[i]);
2961
2904 if (amdgpu_sriov_vf(adev)) { 2962 if (amdgpu_sriov_vf(adev)) {
2905 pr_debug("For SRIOV client, shouldn't do anything.\n"); 2963 pr_debug("For SRIOV client, shouldn't do anything.\n");
2906 return 0; 2964 return 0;