AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdkfd: Make all TLB-flushes heavy-weight
@ 2026-04-20 15:58 Felix Kuehling
  2026-04-20 21:32 ` Philip Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Felix Kuehling @ 2026-04-20 15:58 UTC (permalink / raw)
  To: amd-gfx; +Cc: philip.yang, christian.koenig

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>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 16fb39259911..0625104a7693 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index c1f668f12732..8d9bf4334090 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -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
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index 53c26b1a25ca..dc8787dc399b 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -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)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 015eb61f3440..5090f8c15428 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -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;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdkfd: Make all TLB-flushes heavy-weight
  2026-04-20 15:58 [PATCH] drm/amdkfd: Make all TLB-flushes heavy-weight Felix Kuehling
@ 2026-04-20 21:32 ` Philip Yang
  2026-04-27 17:48   ` Felix Kuehling
  0 siblings, 1 reply; 4+ messages in thread
From: Philip Yang @ 2026-04-20 21:32 UTC (permalink / raw)
  To: Felix Kuehling, amd-gfx; +Cc: philip.yang, christian.koenig

[-- Attachment #1: Type: text/plain, Size: 4987 bytes --]



On 2026-04-20 11:58, Felix Kuehling wrote:
> 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>
> ---
>   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
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 16fb39259911..0625104a7693 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -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);
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index c1f668f12732..8d9bf4334090 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -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
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> index 53c26b1a25ca..dc8787dc399b 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> @@ -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)
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 015eb61f3440..5090f8c15428 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -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;

[-- Attachment #2: Type: text/html, Size: 5773 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdkfd: Make all TLB-flushes heavy-weight
  2026-04-20 21:32 ` Philip Yang
@ 2026-04-27 17:48   ` Felix Kuehling
  2026-04-27 20:53     ` Philip Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Felix Kuehling @ 2026-04-27 17:48 UTC (permalink / raw)
  To: Philip Yang, amd-gfx; +Cc: philip.yang, christian.koenig

On 2026-04-20 17:32, Philip Yang wrote:
>
>
> On 2026-04-20 11:58, Felix Kuehling wrote:
>> 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>
>> ---
>>   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);

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


> }
>
> Regards,
> Philip
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> index 16fb39259911..0625104a7693 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> @@ -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);
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
>> index c1f668f12732..8d9bf4334090 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
>> @@ -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
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>> index 53c26b1a25ca..dc8787dc399b 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>> @@ -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)
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>> index 015eb61f3440..5090f8c15428 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>> @@ -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;
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdkfd: Make all TLB-flushes heavy-weight
  2026-04-27 17:48   ` Felix Kuehling
@ 2026-04-27 20:53     ` Philip Yang
  0 siblings, 0 replies; 4+ messages in thread
From: Philip Yang @ 2026-04-27 20:53 UTC (permalink / raw)
  To: Felix Kuehling, amd-gfx; +Cc: philip.yang, christian.koenig

[-- Attachment #1: Type: text/plain, Size: 6569 bytes --]



On 2026-04-27 13:48, Felix Kuehling wrote:
> On 2026-04-20 17:32, Philip Yang wrote:
>>
>>
>> On 2026-04-20 11:58, Felix Kuehling wrote:
>>> 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>
>>> ---
>>>   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);
>
> 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

Reviewed-by: Philip Yang <philip.yang@amd.com>
>
> Thanks,
>   Felix
>
>
>> }
>>
>> Regards,
>> Philip
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> index 16fb39259911..0625104a7693 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> @@ -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);
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
>>> index c1f668f12732..8d9bf4334090 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
>>> @@ -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
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h 
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> index 53c26b1a25ca..dc8787dc399b 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> @@ -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)
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c 
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> index 015eb61f3440..5090f8c15428 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> @@ -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;
>>

[-- Attachment #2: Type: text/html, Size: 12426 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-27 20:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 15:58 [PATCH] drm/amdkfd: Make all TLB-flushes heavy-weight Felix Kuehling
2026-04-20 21:32 ` Philip Yang
2026-04-27 17:48   ` Felix Kuehling
2026-04-27 20:53     ` Philip Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox