drm/amdkfd: Make all TLB-flushes heavy-weight
Subsystems (3)
Felix Kuehling
maintainerPATCH 1/1 drm/amdkfd: Make all TLB-flushes heavy-weight
With only one sequence number we cannot track the need for legacy vs heavy-weight flushes reliably. Always use heavy-weight.
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++-- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -2
@@ -1358,7 +1358,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, peer_pdd =kfd_process_device_data_by_id (p, devices_arr[i]);if (WARN_ON_ONCE (!peer_pdd))continue ; -kfd_flush_tlb (peer_pdd,TLB_FLUSH_LEGACY ); +kfd_flush_tlb (peer_pdd); }kfree (devices_arr);
@@ -1453,7 +1453,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,if (WARN_ON_ONCE (!peer_pdd))continue ;if (flush_tlb) -kfd_flush_tlb (peer_pdd,TLB_FLUSH_HEAVYWEIGHT ); +kfd_flush_tlb (peer_pdd);/* Remove dma mapping after tlb flush to avoid IO_PAGE_FAULT */ err =amdgpu_amdkfd_gpuvm_dmaunmap_mem (mem, peer_pdd->drm_priv);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3 -3
@@ -595,7 +595,7 @@ static int allocate_vmid(struct device_queue_manager *dqm, qpd->vmid, qpd->page_table_base);/* invalidate the VM context after pasid and vmid mapping is set up */ -kfd_flush_tlb (qpd_to_pdd (qpd),TLB_FLUSH_LEGACY ); +kfd_flush_tlb (qpd_to_pdd (qpd));if (dqm->dev->kfd2kgd->set_scratch_backing_va) dqm->dev->kfd2kgd->set_scratch_backing_va(dqm->dev->adev,
@@ -633,7 +633,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm,if (flush_texture_cache_nocpsch (q->device, qpd))dev_err (dev,"Failed to flush TC\n" ); -kfd_flush_tlb (qpd_to_pdd (qpd),TLB_FLUSH_LEGACY ); +kfd_flush_tlb (qpd_to_pdd (qpd));/* Release the vmid mapping */ set_pasid_vmid_mapping (dqm,0 , qpd->vmid);
@@ -1307,7 +1307,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, dqm->dev->adev, qpd->vmid, qpd->page_table_base); -kfd_flush_tlb (pdd,TLB_FLUSH_LEGACY ); +kfd_flush_tlb (pdd); }/* Take a safe reference to the mm_struct, which may otherwise
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +3 -3
@@ -1559,13 +1559,13 @@ void kfd_signal_reset_event(struct kfd_node *dev);void kfd_signal_poison_consumed_event (struct kfd_node *dev,u32 pasid);void kfd_signal_process_terminate_event (struct kfd_process *p); -static inline void kfd_flush_tlb (struct kfd_process_device *pdd, -enum TLB_FLUSH_TYPE type) +static inline void kfd_flush_tlb (struct kfd_process_device *pdd) {struct amdgpu_device *adev = pdd->dev->adev;struct amdgpu_vm *vm =drm_priv_to_vm (pdd->drm_priv); -amdgpu_vm_flush_compute_tlb (adev, vm, type, pdd->dev->xcc_mask); +amdgpu_vm_flush_compute_tlb (adev, vm,TLB_FLUSH_HEAVYWEIGHT , + pdd->dev->xcc_mask); }static inline bool kfd_flush_tlb_after_unmap (struct kfd_dev *dev)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2 -2
@@ -1418,7 +1418,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,if (r)break ; } -kfd_flush_tlb (pdd,TLB_FLUSH_HEAVYWEIGHT ); +kfd_flush_tlb (pdd); }return r;
@@ -1560,7 +1560,7 @@ svm_range_map_to_gpus(struct svm_range *prange, unsigned long offset, } } -kfd_flush_tlb (pdd,TLB_FLUSH_LEGACY ); +kfd_flush_tlb (pdd); }return r;
Signature · 1 line
2.43.0
Quoted 10 lines · Felix Kuehling
With only one sequence number we cannot track the need for legacy vs heavy-weight flushes reliably. Always use heavy-weight.
Signed-off-by Felix Kuehling<[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++-- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-)
Probably change to heavy-weight flush in this path, other changes look good to me.
amdgpu_gem_va_update_vm()
{
....
if (vm->is_compute_context) {
.....
r = amdgpu_vm_flush_compute_tlb(adev, vm, TLB_FLUSH_LEGACY,
xcc_mask);
}
Regards,
Philip
Quoted 96 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2
-2@@ -1358,7 +1358,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, peer_pdd =kfd_process_device_data_by_id (p, devices_arr[i]);if (WARN_ON_ONCE (!peer_pdd))continue ; -kfd_flush_tlb (peer_pdd,TLB_FLUSH_LEGACY ); +kfd_flush_tlb (peer_pdd); }kfree (devices_arr);@@ -1453,7 +1453,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,if (WARN_ON_ONCE (!peer_pdd))continue ;if (flush_tlb) -kfd_flush_tlb (peer_pdd,TLB_FLUSH_HEAVYWEIGHT ); +kfd_flush_tlb (peer_pdd);/* Remove dma mapping after tlb flush to avoid IO_PAGE_FAULT */ err =amdgpu_amdkfd_gpuvm_dmaunmap_mem (mem, peer_pdd->drm_priv);drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3
-3@@ -595,7 +595,7 @@ static int allocate_vmid(struct device_queue_manager *dqm, qpd->vmid, qpd->page_table_base);/* invalidate the VM context after pasid and vmid mapping is set up */ -kfd_flush_tlb (qpd_to_pdd (qpd),TLB_FLUSH_LEGACY ); +kfd_flush_tlb (qpd_to_pdd (qpd));if (dqm->dev->kfd2kgd->set_scratch_backing_va) dqm->dev->kfd2kgd->set_scratch_backing_va(dqm->dev->adev,@@ -633,7 +633,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm,if (flush_texture_cache_nocpsch (q->device, qpd))dev_err (dev,"Failed to flush TC\n" ); -kfd_flush_tlb (qpd_to_pdd (qpd),TLB_FLUSH_LEGACY ); +kfd_flush_tlb (qpd_to_pdd (qpd));/* Release the vmid mapping */ set_pasid_vmid_mapping (dqm,0 , qpd->vmid);@@ -1307,7 +1307,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, dqm->dev->adev, qpd->vmid, qpd->page_table_base); -kfd_flush_tlb (pdd,TLB_FLUSH_LEGACY ); +kfd_flush_tlb (pdd); }/* Take a safe reference to the mm_struct, which may otherwise drivers/gpu/drm/amd/amdkfd/kfd_priv.h +3
-3@@ -1559,13 +1559,13 @@ void kfd_signal_reset_event(struct kfd_node *dev);void kfd_signal_poison_consumed_event (struct kfd_node *dev,u32 pasid);void kfd_signal_process_terminate_event (struct kfd_process *p); -static inline void kfd_flush_tlb (struct kfd_process_device *pdd, -enum TLB_FLUSH_TYPE type) +static inline void kfd_flush_tlb (struct kfd_process_device *pdd) {struct amdgpu_device *adev = pdd->dev->adev;struct amdgpu_vm *vm =drm_priv_to_vm (pdd->drm_priv); -amdgpu_vm_flush_compute_tlb (adev, vm, type, pdd->dev->xcc_mask); +amdgpu_vm_flush_compute_tlb (adev, vm,TLB_FLUSH_HEAVYWEIGHT , + pdd->dev->xcc_mask); }static inline bool kfd_flush_tlb_after_unmap (struct kfd_dev *dev)drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2
-2@@ -1418,7 +1418,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,if (r)break ; } -kfd_flush_tlb (pdd,TLB_FLUSH_HEAVYWEIGHT ); +kfd_flush_tlb (pdd); }return r;@@ -1560,7 +1560,7 @@ svm_range_map_to_gpus(struct svm_range *prange, unsigned long offset, } } -kfd_flush_tlb (pdd,TLB_FLUSH_LEGACY ); +kfd_flush_tlb (pdd); }return r;
Felix Kuehling
maintainerQuoted 15 lines · Philip Yang
Quoted 10 lines · Felix Kuehling
With only one sequence number we cannot track the need for legacy vs heavy-weight flushes reliably. Always use heavy-weight.
Signed-off-by Felix Kuehling<[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++-- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-)Probably change to heavy-weight flush in this path, other changes look good to me.
Quoted 8 lines
amdgpu_gem_va_update_vm()
{
....
if (vm->is_compute_context) {
.....
r = amdgpu_vm_flush_compute_tlb(adev, vm,TLB_FLUSH_LEGACY,
xcc_mask);
This code doesn't exist on the amd-staging-drm-next branch that this patch is intended for. I'll need to make a separate patch for the DKMS branch that includes this one.
Can I get your R-b for this patch?
Thanks,
Felix
Quoted 101 lines
}
Regards,
PhilipQuoted 96 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2
-2@@ -1358,7 +1358,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, peer_pdd =kfd_process_device_data_by_id (p, devices_arr[i]);if (WARN_ON_ONCE (!peer_pdd))continue ; -kfd_flush_tlb (peer_pdd,TLB_FLUSH_LEGACY ); +kfd_flush_tlb (peer_pdd); }kfree (devices_arr);@@ -1453,7 +1453,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,if (WARN_ON_ONCE (!peer_pdd))continue ;if (flush_tlb) -kfd_flush_tlb (peer_pdd,TLB_FLUSH_HEAVYWEIGHT ); +kfd_flush_tlb (peer_pdd);/* Remove dma mapping after tlb flush to avoid IO_PAGE_FAULT */ err =amdgpu_amdkfd_gpuvm_dmaunmap_mem (mem, peer_pdd->drm_priv);drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3
-3@@ -595,7 +595,7 @@ static int allocate_vmid(struct device_queue_manager *dqm, qpd->vmid, qpd->page_table_base);/* invalidate the VM context after pasid and vmid mapping is set up */ -kfd_flush_tlb (qpd_to_pdd (qpd),TLB_FLUSH_LEGACY ); +kfd_flush_tlb (qpd_to_pdd (qpd));if (dqm->dev->kfd2kgd->set_scratch_backing_va) dqm->dev->kfd2kgd->set_scratch_backing_va(dqm->dev->adev,@@ -633,7 +633,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm,if (flush_texture_cache_nocpsch (q->device, qpd))dev_err (dev,"Failed to flush TC\n" ); -kfd_flush_tlb (qpd_to_pdd (qpd),TLB_FLUSH_LEGACY ); +kfd_flush_tlb (qpd_to_pdd (qpd));/* Release the vmid mapping */ set_pasid_vmid_mapping (dqm,0 , qpd->vmid);@@ -1307,7 +1307,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, dqm->dev->adev, qpd->vmid, qpd->page_table_base); -kfd_flush_tlb (pdd,TLB_FLUSH_LEGACY ); +kfd_flush_tlb (pdd); }/* Take a safe reference to the mm_struct, which may otherwise drivers/gpu/drm/amd/amdkfd/kfd_priv.h +3
-3@@ -1559,13 +1559,13 @@ void kfd_signal_reset_event(struct kfd_node *dev);void kfd_signal_poison_consumed_event (struct kfd_node *dev,u32 pasid);void kfd_signal_process_terminate_event (struct kfd_process *p); -static inline void kfd_flush_tlb (struct kfd_process_device *pdd, -enum TLB_FLUSH_TYPE type) +static inline void kfd_flush_tlb (struct kfd_process_device *pdd) {struct amdgpu_device *adev = pdd->dev->adev;struct amdgpu_vm *vm =drm_priv_to_vm (pdd->drm_priv); -amdgpu_vm_flush_compute_tlb (adev, vm, type, pdd->dev->xcc_mask); +amdgpu_vm_flush_compute_tlb (adev, vm,TLB_FLUSH_HEAVYWEIGHT , + pdd->dev->xcc_mask); }static inline bool kfd_flush_tlb_after_unmap (struct kfd_dev *dev)drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2
-2@@ -1418,7 +1418,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,if (r)break ; } -kfd_flush_tlb (pdd,TLB_FLUSH_HEAVYWEIGHT ); +kfd_flush_tlb (pdd); }return r;@@ -1560,7 +1560,7 @@ svm_range_map_to_gpus(struct svm_range *prange, unsigned long offset, } } -kfd_flush_tlb (pdd,TLB_FLUSH_LEGACY ); +kfd_flush_tlb (pdd); }return r;
Philip Yang
Reviewed-byQuoted 25 lines · Felix Kuehling
Quoted 15 lines · Philip Yang
Quoted 10 lines · Felix Kuehling
With only one sequence number we cannot track the need for legacy vs heavy-weight flushes reliably. Always use heavy-weight.
Signed-off-by Felix Kuehling<[email protected]>---
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++--drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c| 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ++--4 files changed, 10 insertions(+), 10 deletions(-)Probably change to heavy-weight flush in this path, other changes look good to me.
Quoted 8 lines
amdgpu_gem_va_update_vm()
{
....
if (vm->is_compute_context) {
.....
r = amdgpu_vm_flush_compute_tlb(adev, vm,TLB_FLUSH_LEGACY,
xcc_mask);
Quoted 3 lines
This code doesn't exist on the amd-staging-drm-next branch that this patch is intended for. I'll need to make a separate patch for the DKMS branch that includes this one.
Can I get your R-b for this patch?
ohh, I checked the DKMS branch as I am working on it. For amd-staging-drm-next branch, this patch is
Quoted 101 lines
Thanks,
FelixQuoted 96 lines
}
Regards,
PhilipQuoted 91 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1
-1@@ -1358,7 +1358,7 @@ static int kfd_ioctl_map_memory_to_gpu(structfile *filep, peer_pdd = kfd_process_device_data_by_id(p, devices_arr[i]); if (WARN_ON_ONCE(!peer_pdd)) continue; - kfd_flush_tlb(peer_pdd, TLB_FLUSH_LEGACY); + kfd_flush_tlb(peer_pdd); } kfree(devices_arr);@@ -1453,7 +1453,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, if (
WARN_ON_ONCE(!peer_pdd))
continue;
if (flush_tlb)
-kfd_flush_tlb(peer_pdd, TLB_FLUSH_HEAVYWEIGHT);
+kfd_flush_tlb(peer_pdd);
/* Remove dma mapping after tlb flush to avoidIO_PAGE_FAULT*/ err =amdgpu_amdkfd_gpuvm_dmaunmap_mem(mem, peer_pdd->drm_priv);drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3
-2@@ -595,7 +595,7 @@ static int allocate_vmid(structdevice_queue_manager *dqm, qpd->vmid, qpd->page_table_base); /* invalidate the VM context after pasid and vmid mapping is set up */ - kfd_flush_tlb(qpd_to_pdd(qpd), TLB_FLUSH_LEGACY); + kfd_flush_tlb(qpd_to_pdd(qpd)); if (dqm->dev->kfd2kgd->set_scratch_backing_va) dqm->dev->kfd2kgd->set_scratch_backing_va(dqm->dev->adev,@@ -633,7 +633,7 @@ static void deallocate_vmid(structdevice_queue_manager *dqm, if (flush_texture_cache_nocpsch(q->device, qpd)) dev_err(dev, "Failed to flush TC\n"); - kfd_flush_tlb(qpd_to_pdd(qpd), TLB_FLUSH_LEGACY); + kfd_flush_tlb(qpd_to_pdd(qpd)); /* Release the vmid mapping */ set_pasid_vmid_mapping(dqm, 0, qpd->vmid);@@ -1307,7 +1307,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, dqm->dev->adev, qpd->vmid, qpd->page_table_base); - kfd_flush_tlb(pdd, TLB_FLUSH_LEGACY); + kfd_flush_tlb(pdd); } /* Take a safe reference to the mm_struct, which may otherwisedrivers/gpu/drm/amd/amdkfd/kfd_priv.h +3
-1@@ -1559,13 +1559,13 @@ void kfd_signal_reset_event(struct kfd_node *dev); void kfd_signal_poison_consumed_event(struct kfd_node *dev, u32 pasid); void kfd_signal_process_terminate_event(struct kfd_process *p); -static inline void kfd_flush_tlb(struct kfd_process_device *pdd, - enum TLB_FLUSH_TYPE type) +static inline void kfd_flush_tlb (struct kfd_process_device *pdd) { struct amdgpu_device *adev = pdd->dev->adev; struct amdgpu_vm *vm = drm_priv_to_vm(pdd->drm_priv); - amdgpu_vm_flush_compute_tlb(adev, vm, type, pdd->dev->xcc_mask); + amdgpu_vm_flush_compute_tlb(adev, vm, TLB_FLUSH_HEAVYWEIGHT, + pdd->dev->xcc_mask); } static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2
-1@@ -1418,7 +1418,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start, if (r) break; } - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT); + kfd_flush_tlb(pdd); } return r;@@ -1560,7 +1560,7 @@ svm_range_map_to_gpus(struct svm_range *prange, unsigned long offset, } } - kfd_flush_tlb(pdd, TLB_FLUSH_LEGACY); + kfd_flush_tlb(pdd); } return r;