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

drm/amdgpu: Reorganize amdgpu_gmc_flush_gpu_tlb() for kfd to use

Add a flush_type parameter to that series of functions.

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

+22 -20
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
··· 248 248 } 249 249 mb(); 250 250 amdgpu_asic_flush_hdp(adev, NULL); 251 - amdgpu_gmc_flush_gpu_tlb(adev, 0); 251 + amdgpu_gmc_flush_gpu_tlb(adev, 0, 0); 252 252 return 0; 253 253 } 254 254 ··· 331 331 332 332 mb(); 333 333 amdgpu_asic_flush_hdp(adev, NULL); 334 - amdgpu_gmc_flush_gpu_tlb(adev, 0); 334 + amdgpu_gmc_flush_gpu_tlb(adev, 0, 0); 335 335 return 0; 336 336 } 337 337
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
··· 64 64 struct amdgpu_gmc_funcs { 65 65 /* flush the vm tlb via mmio */ 66 66 void (*flush_gpu_tlb)(struct amdgpu_device *adev, 67 - uint32_t vmid); 67 + uint32_t vmid, uint32_t flush_type); 68 68 /* flush the vm tlb via ring */ 69 69 uint64_t (*emit_flush_gpu_tlb)(struct amdgpu_ring *ring, unsigned vmid, 70 70 uint64_t pd_addr); ··· 151 151 struct amdgpu_xgmi xgmi; 152 152 }; 153 153 154 - #define amdgpu_gmc_flush_gpu_tlb(adev, vmid) (adev)->gmc.gmc_funcs->flush_gpu_tlb((adev), (vmid)) 154 + #define amdgpu_gmc_flush_gpu_tlb(adev, vmid, type) (adev)->gmc.gmc_funcs->flush_gpu_tlb((adev), (vmid), (type)) 155 155 #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr)) 156 156 #define amdgpu_gmc_emit_pasid_mapping(r, vmid, pasid) (r)->adev->gmc.gmc_funcs->emit_pasid_mapping((r), (vmid), (pasid)) 157 157 #define amdgpu_gmc_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gmc.gmc_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))
+3 -2
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
··· 358 358 return 0; 359 359 } 360 360 361 - static void gmc_v6_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid) 361 + static void gmc_v6_0_flush_gpu_tlb(struct amdgpu_device *adev, 362 + uint32_t vmid, uint32_t flush_type) 362 363 { 363 364 WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid); 364 365 } ··· 581 580 else 582 581 gmc_v6_0_set_fault_enable_default(adev, true); 583 582 584 - gmc_v6_0_flush_gpu_tlb(adev, 0); 583 + gmc_v6_0_flush_gpu_tlb(adev, 0, 0); 585 584 dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n", 586 585 (unsigned)(adev->gmc.gart_size >> 20), 587 586 (unsigned long long)table_addr);
+3 -2
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
··· 430 430 * 431 431 * Flush the TLB for the requested page table (CIK). 432 432 */ 433 - static void gmc_v7_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid) 433 + static void gmc_v7_0_flush_gpu_tlb(struct amdgpu_device *adev, 434 + uint32_t vmid, uint32_t flush_type) 434 435 { 435 436 /* bits 0-15 are the VM contexts0-15 */ 436 437 WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid); ··· 699 698 WREG32(mmCHUB_CONTROL, tmp); 700 699 } 701 700 702 - gmc_v7_0_flush_gpu_tlb(adev, 0); 701 + gmc_v7_0_flush_gpu_tlb(adev, 0, 0); 703 702 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", 704 703 (unsigned)(adev->gmc.gart_size >> 20), 705 704 (unsigned long long)table_addr);
+2 -2
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
··· 611 611 * Flush the TLB for the requested page table (CIK). 612 612 */ 613 613 static void gmc_v8_0_flush_gpu_tlb(struct amdgpu_device *adev, 614 - uint32_t vmid) 614 + uint32_t vmid, uint32_t flush_type) 615 615 { 616 616 /* bits 0-15 are the VM contexts0-15 */ 617 617 WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid); ··· 920 920 else 921 921 gmc_v8_0_set_fault_enable_default(adev, true); 922 922 923 - gmc_v8_0_flush_gpu_tlb(adev, 0); 923 + gmc_v8_0_flush_gpu_tlb(adev, 0, 0); 924 924 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", 925 925 (unsigned)(adev->gmc.gart_size >> 20), 926 926 (unsigned long long)table_addr);
+10 -10
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 293 293 adev->gmc.vm_fault.funcs = &gmc_v9_0_irq_funcs; 294 294 } 295 295 296 - static uint32_t gmc_v9_0_get_invalidate_req(unsigned int vmid) 296 + static uint32_t gmc_v9_0_get_invalidate_req(unsigned int vmid, 297 + uint32_t flush_type) 297 298 { 298 299 u32 req = 0; 299 300 300 - /* invalidate using legacy mode on vmid*/ 301 301 req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, 302 302 PER_VMID_INVALIDATE_REQ, 1 << vmid); 303 - req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, FLUSH_TYPE, 0); 303 + req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, FLUSH_TYPE, flush_type); 304 304 req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, INVALIDATE_L2_PTES, 1); 305 305 req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, INVALIDATE_L2_PDE0, 1); 306 306 req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, INVALIDATE_L2_PDE1, 1); ··· 362 362 */ 363 363 364 364 /** 365 - * gmc_v9_0_flush_gpu_tlb - gart tlb flush callback 365 + * gmc_v9_0_flush_gpu_tlb - tlb flush with certain type 366 366 * 367 367 * @adev: amdgpu_device pointer 368 368 * @vmid: vm instance to flush 369 + * @flush_type: the flush type 369 370 * 370 - * Flush the TLB for the requested page table. 371 + * Flush the TLB for the requested page table using certain type. 371 372 */ 372 373 static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, 373 - uint32_t vmid) 374 + uint32_t vmid, uint32_t flush_type) 374 375 { 375 - /* Use register 17 for GART */ 376 376 const unsigned eng = 17; 377 377 unsigned i, j; 378 378 int r; 379 379 380 380 for (i = 0; i < AMDGPU_MAX_VMHUBS; ++i) { 381 381 struct amdgpu_vmhub *hub = &adev->vmhub[i]; 382 - u32 tmp = gmc_v9_0_get_invalidate_req(vmid); 382 + u32 tmp = gmc_v9_0_get_invalidate_req(vmid, flush_type); 383 383 384 384 if (adev->gfx.kiq.ring.ready && 385 385 (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev)) && ··· 429 429 { 430 430 struct amdgpu_device *adev = ring->adev; 431 431 struct amdgpu_vmhub *hub = &adev->vmhub[ring->funcs->vmhub]; 432 - uint32_t req = gmc_v9_0_get_invalidate_req(vmid); 432 + uint32_t req = gmc_v9_0_get_invalidate_req(vmid, 0); 433 433 unsigned eng = ring->vm_inv_eng; 434 434 435 435 amdgpu_ring_emit_wreg(ring, hub->ctx0_ptb_addr_lo32 + (2 * vmid), ··· 1122 1122 1123 1123 gfxhub_v1_0_set_fault_enable_default(adev, value); 1124 1124 mmhub_v1_0_set_fault_enable_default(adev, value); 1125 - gmc_v9_0_flush_gpu_tlb(adev, 0); 1125 + gmc_v9_0_flush_gpu_tlb(adev, 0, 0); 1126 1126 1127 1127 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", 1128 1128 (unsigned)(adev->gmc.gart_size >> 20),