aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu
diff options
context:
space:
mode:
authorAlex Xie <AlexBin.Xie@amd.com>2017-05-30 17:10:16 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-05-31 14:16:38 -0400
commitdd684d313e280c3bad2ebb7b33e7688ab5409bc9 (patch)
tree4963987a0c85ab514b9c317944ed5fc369c46ef9 /drivers/gpu/drm/amd/amdgpu
parent1410f64651e35411b4bb7a10f32eb6225925110a (diff)
drm/amdgpu: Optimize a function called by every IB sheduling
Move several if statements and a loop statment from run time to initialization time. Signed-off-by: Alex Xie <AlexBin.Xie@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c33
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c28
3 files changed, 40 insertions, 27 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 6a85db0c0bc3..7d95435fad16 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -153,6 +153,36 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring)
153} 153}
154 154
155/** 155/**
156 * amdgpu_ring_check_compute_vm_bug - check whether this ring has compute vm bug
157 *
158 * @adev: amdgpu_device pointer
159 * @ring: amdgpu_ring structure holding ring information
160 */
161static void amdgpu_ring_check_compute_vm_bug(struct amdgpu_device *adev,
162 struct amdgpu_ring *ring)
163{
164 const struct amdgpu_ip_block *ip_block;
165
166 ring->has_compute_vm_bug = false;
167
168 if (ring->funcs->type != AMDGPU_RING_TYPE_COMPUTE)
169 /* only compute rings */
170 return;
171
172 ip_block = amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX);
173 if (!ip_block)
174 return;
175
176 /* Compute ring has a VM bug for GFX version < 7.
177 And compute ring has a VM bug for GFX 8 MEC firmware version < 673.*/
178 if (ip_block->version->major <= 7) {
179 ring->has_compute_vm_bug = true;
180 } else if (ip_block->version->major == 8)
181 if (adev->gfx.mec_fw_version < 673)
182 ring->has_compute_vm_bug = true;
183}
184
185/**
156 * amdgpu_ring_init - init driver ring struct. 186 * amdgpu_ring_init - init driver ring struct.
157 * 187 *
158 * @adev: amdgpu_device pointer 188 * @adev: amdgpu_device pointer
@@ -257,6 +287,9 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
257 if (amdgpu_debugfs_ring_init(adev, ring)) { 287 if (amdgpu_debugfs_ring_init(adev, ring)) {
258 DRM_ERROR("Failed to register debugfs file for rings !\n"); 288 DRM_ERROR("Failed to register debugfs file for rings !\n");
259 } 289 }
290
291 amdgpu_ring_check_compute_vm_bug(adev, ring);
292
260 return 0; 293 return 0;
261} 294}
262 295
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
index a9223a8de8c2..334307efac8b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
@@ -185,6 +185,7 @@ struct amdgpu_ring {
185 u64 cond_exe_gpu_addr; 185 u64 cond_exe_gpu_addr;
186 volatile u32 *cond_exe_cpu_addr; 186 volatile u32 *cond_exe_cpu_addr;
187 unsigned vm_inv_eng; 187 unsigned vm_inv_eng;
188 bool has_compute_vm_bug;
188#if defined(CONFIG_DEBUG_FS) 189#if defined(CONFIG_DEBUG_FS)
189 struct dentry *ent; 190 struct dentry *ent;
190#endif 191#endif
@@ -207,4 +208,9 @@ static inline void amdgpu_ring_clear_ring(struct amdgpu_ring *ring)
207 208
208} 209}
209 210
211static inline bool amdgpu_ring_has_compute_vm_bug(struct amdgpu_ring *ring)
212{
213 return ring->has_compute_vm_bug;
214}
215
210#endif 216#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index b2384b8536b9..7a323f91a10b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -656,32 +656,6 @@ unlock:
656 return r; 656 return r;
657} 657}
658 658
659static bool amdgpu_vm_ring_has_compute_vm_bug(struct amdgpu_ring *ring)
660{
661 struct amdgpu_device *adev = ring->adev;
662 const struct amdgpu_ip_block *ip_block;
663
664 if (ring->funcs->type != AMDGPU_RING_TYPE_COMPUTE)
665 /* only compute rings */
666 return false;
667
668 ip_block = amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX);
669 if (!ip_block)
670 return false;
671
672 if (ip_block->version->major <= 7) {
673 /* gfx7 has no workaround */
674 return true;
675 } else if (ip_block->version->major == 8) {
676 if (adev->gfx.mec_fw_version >= 673)
677 /* gfx8 is fixed in MEC firmware 673 */
678 return false;
679 else
680 return true;
681 }
682 return false;
683}
684
685bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring, 659bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
686 struct amdgpu_job *job) 660 struct amdgpu_job *job)
687{ 661{
@@ -691,7 +665,7 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
691 struct amdgpu_vm_id *id; 665 struct amdgpu_vm_id *id;
692 bool gds_switch_needed; 666 bool gds_switch_needed;
693 bool vm_flush_needed = job->vm_needs_flush || 667 bool vm_flush_needed = job->vm_needs_flush ||
694 amdgpu_vm_ring_has_compute_vm_bug(ring); 668 amdgpu_ring_has_compute_vm_bug(ring);
695 669
696 if (job->vm_id == 0) 670 if (job->vm_id == 0)
697 return false; 671 return false;