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

drm/amdgpu/gmc: move invaliation bitmap setup to common code

So it can be shared with newer GMC versions.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

+42 -41
+40
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
··· 333 333 amdgpu_mmhub_ras_fini(adev); 334 334 amdgpu_xgmi_ras_fini(adev); 335 335 } 336 + 337 + /* 338 + * The latest engine allocation on gfx9 is: 339 + * Engine 2, 3: firmware 340 + * Engine 0, 1, 4~16: amdgpu ring, 341 + * subject to change when ring number changes 342 + * Engine 17: Gart flushes 343 + */ 344 + #define GFXHUB_FREE_VM_INV_ENGS_BITMAP 0x1FFF3 345 + #define MMHUB_FREE_VM_INV_ENGS_BITMAP 0x1FFF3 346 + 347 + int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev) 348 + { 349 + struct amdgpu_ring *ring; 350 + unsigned vm_inv_engs[AMDGPU_MAX_VMHUBS] = 351 + {GFXHUB_FREE_VM_INV_ENGS_BITMAP, MMHUB_FREE_VM_INV_ENGS_BITMAP, 352 + GFXHUB_FREE_VM_INV_ENGS_BITMAP}; 353 + unsigned i; 354 + unsigned vmhub, inv_eng; 355 + 356 + for (i = 0; i < adev->num_rings; ++i) { 357 + ring = adev->rings[i]; 358 + vmhub = ring->funcs->vmhub; 359 + 360 + inv_eng = ffs(vm_inv_engs[vmhub]); 361 + if (!inv_eng) { 362 + dev_err(adev->dev, "no VM inv eng for ring %s\n", 363 + ring->name); 364 + return -EINVAL; 365 + } 366 + 367 + ring->vm_inv_eng = inv_eng - 1; 368 + vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng); 369 + 370 + dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n", 371 + ring->name, ring->vm_inv_eng, ring->funcs->vmhub); 372 + } 373 + 374 + return 0; 375 + }
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
··· 267 267 uint16_t pasid, uint64_t timestamp); 268 268 int amdgpu_gmc_ras_late_init(struct amdgpu_device *adev); 269 269 void amdgpu_gmc_ras_fini(struct amdgpu_device *adev); 270 + int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev); 270 271 271 272 #endif
+1 -31
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 797 797 } 798 798 } 799 799 800 - static int gmc_v9_0_allocate_vm_inv_eng(struct amdgpu_device *adev) 801 - { 802 - struct amdgpu_ring *ring; 803 - unsigned vm_inv_engs[AMDGPU_MAX_VMHUBS] = 804 - {GFXHUB_FREE_VM_INV_ENGS_BITMAP, MMHUB_FREE_VM_INV_ENGS_BITMAP, 805 - GFXHUB_FREE_VM_INV_ENGS_BITMAP}; 806 - unsigned i; 807 - unsigned vmhub, inv_eng; 808 - 809 - for (i = 0; i < adev->num_rings; ++i) { 810 - ring = adev->rings[i]; 811 - vmhub = ring->funcs->vmhub; 812 - 813 - inv_eng = ffs(vm_inv_engs[vmhub]); 814 - if (!inv_eng) { 815 - dev_err(adev->dev, "no VM inv eng for ring %s\n", 816 - ring->name); 817 - return -EINVAL; 818 - } 819 - 820 - ring->vm_inv_eng = inv_eng - 1; 821 - vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng); 822 - 823 - dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n", 824 - ring->name, ring->vm_inv_eng, ring->funcs->vmhub); 825 - } 826 - 827 - return 0; 828 - } 829 - 830 800 static int gmc_v9_0_late_init(void *handle) 831 801 { 832 802 struct amdgpu_device *adev = (struct amdgpu_device *)handle; ··· 805 835 if (!gmc_v9_0_keep_stolen_memory(adev)) 806 836 amdgpu_bo_late_init(adev); 807 837 808 - r = gmc_v9_0_allocate_vm_inv_eng(adev); 838 + r = amdgpu_gmc_allocate_vm_inv_eng(adev); 809 839 if (r) 810 840 return r; 811 841 /* Check if ecc is available */
-10
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h
··· 24 24 #ifndef __GMC_V9_0_H__ 25 25 #define __GMC_V9_0_H__ 26 26 27 - /* 28 - * The latest engine allocation on gfx9 is: 29 - * Engine 2, 3: firmware 30 - * Engine 0, 1, 4~16: amdgpu ring, 31 - * subject to change when ring number changes 32 - * Engine 17: Gart flushes 33 - */ 34 - #define GFXHUB_FREE_VM_INV_ENGS_BITMAP 0x1FFF3 35 - #define MMHUB_FREE_VM_INV_ENGS_BITMAP 0x1FFF3 36 - 37 27 extern const struct amd_ip_funcs gmc_v9_0_ip_funcs; 38 28 extern const struct amdgpu_ip_block_version gmc_v9_0_ip_block; 39 29 #endif