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

drm/amdkfd: Use functions from amdgpu to invalidate vmid in kfd

As part of the change, we stop taking the srbm lock, and start to use
the same invalidation engine and software lock as amdgpu.

Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
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>

authored by

Yong Zhao and committed by
Alex Deucher
afd545f6 2a79d868

+1 -36
+1 -36
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
··· 48 48 #include "soc15d.h" 49 49 #include "gmc_v9_0.h" 50 50 51 - /* HACK: MMHUB and GC both have VM-related register with the same 52 - * names but different offsets. Define the MMHUB register we need here 53 - * with a prefix. A proper solution would be to move the functions 54 - * programming these registers into gfx_v9_0.c and mmhub_v1_0.c 55 - * respectively. 56 - */ 57 - #define mmMMHUB_VM_INVALIDATE_ENG16_REQ 0x06f3 58 - #define mmMMHUB_VM_INVALIDATE_ENG16_REQ_BASE_IDX 0 59 - 60 - #define mmMMHUB_VM_INVALIDATE_ENG16_ACK 0x0705 61 - #define mmMMHUB_VM_INVALIDATE_ENG16_ACK_BASE_IDX 0 62 51 63 52 #define V9_PIPE_PER_MEC (4) 64 53 #define V9_QUEUES_PER_PIPE_MEC (8) ··· 731 742 static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid) 732 743 { 733 744 struct amdgpu_device *adev = (struct amdgpu_device *) kgd; 734 - uint32_t req = (1 << vmid) | 735 - (0 << VM_INVALIDATE_ENG16_REQ__FLUSH_TYPE__SHIFT) | /* legacy */ 736 - VM_INVALIDATE_ENG16_REQ__INVALIDATE_L2_PTES_MASK | 737 - VM_INVALIDATE_ENG16_REQ__INVALIDATE_L2_PDE0_MASK | 738 - VM_INVALIDATE_ENG16_REQ__INVALIDATE_L2_PDE1_MASK | 739 - VM_INVALIDATE_ENG16_REQ__INVALIDATE_L2_PDE2_MASK | 740 - VM_INVALIDATE_ENG16_REQ__INVALIDATE_L1_PTES_MASK; 741 - 742 - mutex_lock(&adev->srbm_mutex); 743 745 744 746 /* Use legacy mode tlb invalidation. 745 747 * ··· 747 767 * TODO 2: support range-based invalidation, requires kfg2kgd 748 768 * interface change 749 769 */ 750 - WREG32(SOC15_REG_OFFSET(GC, 0, mmVM_INVALIDATE_ENG16_REQ), req); 751 - 752 - WREG32(SOC15_REG_OFFSET(MMHUB, 0, mmMMHUB_VM_INVALIDATE_ENG16_REQ), 753 - req); 754 - 755 - while (!(RREG32(SOC15_REG_OFFSET(GC, 0, mmVM_INVALIDATE_ENG16_ACK)) & 756 - (1 << vmid))) 757 - cpu_relax(); 758 - 759 - while (!(RREG32(SOC15_REG_OFFSET(MMHUB, 0, 760 - mmMMHUB_VM_INVALIDATE_ENG16_ACK)) & 761 - (1 << vmid))) 762 - cpu_relax(); 763 - 764 - mutex_unlock(&adev->srbm_mutex); 765 - 770 + amdgpu_gmc_flush_gpu_tlb(adev, vmid, 0); 766 771 } 767 772 768 773 static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)