diff options
author | Yong Zhao <Yong.Zhao@amd.com> | 2018-10-12 17:17:05 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-11-05 14:21:15 -0500 |
commit | 2a79d86897afd54778d44019dcc9327e0188e69f (patch) | |
tree | 3c7e7f463e9090153e34793f8b05f58517950647 /drivers | |
parent | a614aae76057955c914de9bc3fc659c164cd5c2c (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 20 |
6 files changed, 22 insertions, 20 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c index 11fea28f8ad3..9a212aa4c177 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | |||
@@ -248,7 +248,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, | |||
248 | } | 248 | } |
249 | mb(); | 249 | mb(); |
250 | amdgpu_asic_flush_hdp(adev, NULL); | 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 | return 0; | 252 | return 0; |
253 | } | 253 | } |
254 | 254 | ||
@@ -331,7 +331,7 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, | |||
331 | 331 | ||
332 | mb(); | 332 | mb(); |
333 | amdgpu_asic_flush_hdp(adev, NULL); | 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 | return 0; | 335 | return 0; |
336 | } | 336 | } |
337 | 337 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h index 6fa7ef446e46..4c5f18cf5b69 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | |||
@@ -64,7 +64,7 @@ struct amdgpu_vmhub { | |||
64 | struct amdgpu_gmc_funcs { | 64 | struct amdgpu_gmc_funcs { |
65 | /* flush the vm tlb via mmio */ | 65 | /* flush the vm tlb via mmio */ |
66 | void (*flush_gpu_tlb)(struct amdgpu_device *adev, | 66 | void (*flush_gpu_tlb)(struct amdgpu_device *adev, |
67 | uint32_t vmid); | 67 | uint32_t vmid, uint32_t flush_type); |
68 | /* flush the vm tlb via ring */ | 68 | /* flush the vm tlb via ring */ |
69 | uint64_t (*emit_flush_gpu_tlb)(struct amdgpu_ring *ring, unsigned vmid, | 69 | uint64_t (*emit_flush_gpu_tlb)(struct amdgpu_ring *ring, unsigned vmid, |
70 | uint64_t pd_addr); | 70 | uint64_t pd_addr); |
@@ -151,7 +151,7 @@ struct amdgpu_gmc { | |||
151 | struct amdgpu_xgmi xgmi; | 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 | #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr)) | 155 | #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr)) |
156 | #define amdgpu_gmc_emit_pasid_mapping(r, vmid, pasid) (r)->adev->gmc.gmc_funcs->emit_pasid_mapping((r), (vmid), (pasid)) | 156 | #define amdgpu_gmc_emit_pasid_mapping(r, vmid, pasid) (r)->adev->gmc.gmc_funcs->emit_pasid_mapping((r), (vmid), (pasid)) |
157 | #define amdgpu_gmc_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gmc.gmc_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags)) | 157 | #define amdgpu_gmc_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gmc.gmc_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags)) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c index e1c2b4e9c7b2..2821d1d846e4 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | |||
@@ -358,7 +358,8 @@ static int gmc_v6_0_mc_init(struct amdgpu_device *adev) | |||
358 | return 0; | 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 | WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid); | 364 | WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid); |
364 | } | 365 | } |
@@ -580,7 +581,7 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) | |||
580 | else | 581 | else |
581 | gmc_v6_0_set_fault_enable_default(adev, true); | 582 | gmc_v6_0_set_fault_enable_default(adev, true); |
582 | 583 | ||
583 | gmc_v6_0_flush_gpu_tlb(adev, 0); | 584 | gmc_v6_0_flush_gpu_tlb(adev, 0, 0); |
584 | dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n", | 585 | dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n", |
585 | (unsigned)(adev->gmc.gart_size >> 20), | 586 | (unsigned)(adev->gmc.gart_size >> 20), |
586 | (unsigned long long)table_addr); | 587 | (unsigned long long)table_addr); |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c index 910c4ce19cb3..761dcfb2fec0 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | |||
@@ -430,7 +430,8 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) | |||
430 | * | 430 | * |
431 | * Flush the TLB for the requested page table (CIK). | 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 | /* bits 0-15 are the VM contexts0-15 */ | 436 | /* bits 0-15 are the VM contexts0-15 */ |
436 | WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid); | 437 | WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid); |
@@ -698,7 +699,7 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) | |||
698 | WREG32(mmCHUB_CONTROL, tmp); | 699 | WREG32(mmCHUB_CONTROL, tmp); |
699 | } | 700 | } |
700 | 701 | ||
701 | gmc_v7_0_flush_gpu_tlb(adev, 0); | 702 | gmc_v7_0_flush_gpu_tlb(adev, 0, 0); |
702 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", | 703 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
703 | (unsigned)(adev->gmc.gart_size >> 20), | 704 | (unsigned)(adev->gmc.gart_size >> 20), |
704 | (unsigned long long)table_addr); | 705 | (unsigned long long)table_addr); |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 1d3265c97b70..531aaf377592 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | |||
@@ -611,7 +611,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev) | |||
611 | * Flush the TLB for the requested page table (CIK). | 611 | * Flush the TLB for the requested page table (CIK). |
612 | */ | 612 | */ |
613 | static void gmc_v8_0_flush_gpu_tlb(struct amdgpu_device *adev, | 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 | /* bits 0-15 are the VM contexts0-15 */ | 616 | /* bits 0-15 are the VM contexts0-15 */ |
617 | WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid); | 617 | WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid); |
@@ -920,7 +920,7 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) | |||
920 | else | 920 | else |
921 | gmc_v8_0_set_fault_enable_default(adev, true); | 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 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", | 924 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
925 | (unsigned)(adev->gmc.gart_size >> 20), | 925 | (unsigned)(adev->gmc.gart_size >> 20), |
926 | (unsigned long long)table_addr); | 926 | (unsigned long long)table_addr); |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index f35d7a554ad5..af786b5513bc 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | |||
@@ -293,14 +293,14 @@ static void gmc_v9_0_set_irq_funcs(struct amdgpu_device *adev) | |||
293 | adev->gmc.vm_fault.funcs = &gmc_v9_0_irq_funcs; | 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 | u32 req = 0; | 299 | u32 req = 0; |
299 | 300 | ||
300 | /* invalidate using legacy mode on vmid*/ | ||
301 | req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, | 301 | req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, |
302 | PER_VMID_INVALIDATE_REQ, 1 << vmid); | 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 | req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, INVALIDATE_L2_PTES, 1); | 304 | req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, INVALIDATE_L2_PTES, 1); |
305 | req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, INVALIDATE_L2_PDE0, 1); | 305 | req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, INVALIDATE_L2_PDE0, 1); |
306 | req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, INVALIDATE_L2_PDE1, 1); | 306 | req = REG_SET_FIELD(req, VM_INVALIDATE_ENG0_REQ, INVALIDATE_L2_PDE1, 1); |
@@ -362,24 +362,24 @@ failed_kiq: | |||
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 | * @adev: amdgpu_device pointer | 367 | * @adev: amdgpu_device pointer |
368 | * @vmid: vm instance to flush | 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 | static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, | 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 | const unsigned eng = 17; | 376 | const unsigned eng = 17; |
377 | unsigned i, j; | 377 | unsigned i, j; |
378 | int r; | 378 | int r; |
379 | 379 | ||
380 | for (i = 0; i < AMDGPU_MAX_VMHUBS; ++i) { | 380 | for (i = 0; i < AMDGPU_MAX_VMHUBS; ++i) { |
381 | struct amdgpu_vmhub *hub = &adev->vmhub[i]; | 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 | if (adev->gfx.kiq.ring.ready && | 384 | if (adev->gfx.kiq.ring.ready && |
385 | (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev)) && | 385 | (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev)) && |
@@ -429,7 +429,7 @@ static uint64_t gmc_v9_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring, | |||
429 | { | 429 | { |
430 | struct amdgpu_device *adev = ring->adev; | 430 | struct amdgpu_device *adev = ring->adev; |
431 | struct amdgpu_vmhub *hub = &adev->vmhub[ring->funcs->vmhub]; | 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 | unsigned eng = ring->vm_inv_eng; | 433 | unsigned eng = ring->vm_inv_eng; |
434 | 434 | ||
435 | amdgpu_ring_emit_wreg(ring, hub->ctx0_ptb_addr_lo32 + (2 * vmid), | 435 | amdgpu_ring_emit_wreg(ring, hub->ctx0_ptb_addr_lo32 + (2 * vmid), |
@@ -1122,7 +1122,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev) | |||
1122 | 1122 | ||
1123 | gfxhub_v1_0_set_fault_enable_default(adev, value); | 1123 | gfxhub_v1_0_set_fault_enable_default(adev, value); |
1124 | mmhub_v1_0_set_fault_enable_default(adev, value); | 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 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", | 1127 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
1128 | (unsigned)(adev->gmc.gart_size >> 20), | 1128 | (unsigned)(adev->gmc.gart_size >> 20), |