]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdkfd: Make all TLB-flushes heavy-weight
authorFelix Kuehling <felix.kuehling@amd.com>
Mon, 20 Apr 2026 15:55:57 +0000 (11:55 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 5 May 2026 14:13:54 +0000 (10:13 -0400)
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 <felix.kuehling@amd.com>
Reviewed-by: Philip Yang <philip.yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit c1a3ff1d327820cd9a52bc1056b98681fc088949)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
drivers/gpu/drm/amd/amdkfd/kfd_svm.c

index f829d65a79b43e6c50a577dfdd888b12d0e466d0..f95bf6d9553463737754e95030aa041c7961ceb1 100644 (file)
@@ -1360,7 +1360,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);
 
@@ -1455,7 +1455,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);
index ab3b2e7be9bd045f5639e73d6da1531414e96802..9185ebe4c079a802dd259025ab1d588d28952634 100644 (file)
@@ -572,7 +572,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,
@@ -610,7 +610,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);
@@ -1284,7 +1284,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
index 163d665a6074cc05d34b2aeab82f446660c11604..7b5b12206919874747c86775d80d20fc7a39f98d 100644 (file)
@@ -1554,13 +1554,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)
index 38085a0a0f58eedfd18777e6eed52d4e4d5679da..35ec67d9739bdd72bda911e8a8345947fcc53e99 100644 (file)
@@ -1424,7 +1424,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;
@@ -1571,7 +1571,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;