From: Philip Yang <yangp@amd.com>
To: Felix Kuehling <felix.kuehling@amd.com>, amd-gfx@lists.freedesktop.org
Cc: philip.yang@amd.com, christian.koenig@amd.com
Subject: Re: [PATCH] drm/amdkfd: Make all TLB-flushes heavy-weight
Date: Mon, 20 Apr 2026 17:32:04 -0400 [thread overview]
Message-ID: <f2f17b8e-ce73-4d96-b5df-29d235f9ffca@amd.com> (raw)
In-Reply-To: <20260420155822.718805-1-felix.kuehling@amd.com>
[-- 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 --]
next prev parent reply other threads:[~2026-04-20 21:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 15:58 [PATCH] drm/amdkfd: Make all TLB-flushes heavy-weight Felix Kuehling
2026-04-20 21:32 ` Philip Yang [this message]
2026-04-27 17:48 ` Felix Kuehling
2026-04-27 20:53 ` Philip Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2f17b8e-ce73-4d96-b5df-29d235f9ffca@amd.com \
--to=yangp@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=felix.kuehling@amd.com \
--cc=philip.yang@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox