Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Alex Xie and committed by
Alex Deucher
dd684d31 1410f646

+40 -27
+33
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
··· 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 + */ 161 + static 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 186 * amdgpu_ring_init - init driver ring struct. 157 187 * 158 188 * @adev: amdgpu_device pointer ··· 287 257 if (amdgpu_debugfs_ring_init(adev, ring)) { 288 258 DRM_ERROR("Failed to register debugfs file for rings !\n"); 289 259 } 260 + 261 + amdgpu_ring_check_compute_vm_bug(adev, ring); 262 + 290 263 return 0; 291 264 } 292 265
+6
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
··· 185 185 u64 cond_exe_gpu_addr; 186 186 volatile u32 *cond_exe_cpu_addr; 187 187 unsigned vm_inv_eng; 188 + bool has_compute_vm_bug; 188 189 #if defined(CONFIG_DEBUG_FS) 189 190 struct dentry *ent; 190 191 #endif ··· 206 205 while (i <= ring->buf_mask) 207 206 ring->ring[i++] = ring->funcs->nop; 208 207 208 + } 209 + 210 + static inline bool amdgpu_ring_has_compute_vm_bug(struct amdgpu_ring *ring) 211 + { 212 + return ring->has_compute_vm_bug; 209 213 } 210 214 211 215 #endif
+1 -27
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 656 656 return r; 657 657 } 658 658 659 - static 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 - 685 659 bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring, 686 660 struct amdgpu_job *job) 687 661 { ··· 665 691 struct amdgpu_vm_id *id; 666 692 bool gds_switch_needed; 667 693 bool vm_flush_needed = job->vm_needs_flush || 668 - amdgpu_vm_ring_has_compute_vm_bug(ring); 694 + amdgpu_ring_has_compute_vm_bug(ring); 669 695 670 696 if (job->vm_id == 0) 671 697 return false;