drm/amdkfd: start using tlb_seq from the VM subsystem
authorChristian König <christian.koenig@amd.com>
Thu, 17 Mar 2022 08:53:55 +0000 (09:53 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 25 Mar 2022 16:40:51 +0000 (12:40 -0400)
Instead of trying to figure out if a TLB flush is necessary or not use
the information provided by the VM subsystem now.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Philip Yang<Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
drivers/gpu/drm/amd/amdkfd/kfd_process.c

index f36062b..945982a 100644 (file)
@@ -705,6 +705,7 @@ struct kfd_process_device {
        /* VM context for GPUVM allocations */
        struct file *drm_file;
        void *drm_priv;
+       uint64_t tlb_seq;
 
        /* GPUVM allocations storage */
        struct idr alloc_idr;
index 59c04b2..4a8a047 100644 (file)
@@ -1560,6 +1560,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,
                return ret;
        }
        pdd->drm_priv = drm_file->private_data;
+       pdd->tlb_seq = 0;
 
        ret = kfd_process_device_reserve_ib_mem(pdd);
        if (ret)
@@ -1949,8 +1950,14 @@ int kfd_reserved_mem_mmap(struct kfd_dev *dev, struct kfd_process *process,
 
 void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type)
 {
+       struct amdgpu_vm *vm = drm_priv_to_vm(pdd->drm_priv);
+       uint64_t tlb_seq = amdgpu_vm_tlb_seq(vm);
        struct kfd_dev *dev = pdd->dev;
 
+       if (pdd->tlb_seq == tlb_seq)
+               return;
+
+       pdd->tlb_seq = tlb_seq;
        if (dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS) {
                /* Nothing to flush until a VMID is assigned, which
                 * only happens when the first queue is created.