* [PATCH v3 0/2] drm/amdkfd: Add TLB flush after MES queue eviction/suspension
@ 2026-08-14 16:18 Priya Hosur
2026-08-14 16:18 ` [PATCH v3 1/2] " Priya Hosur
2026-08-14 16:18 ` [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap Priya Hosur
0 siblings, 2 replies; 12+ messages in thread
From: Priya Hosur @ 2026-08-14 16:18 UTC (permalink / raw)
To: amd-gfx, Alexander.Deucher, Sunil.Khatri, Felix.Kuehling,
Shaoyun.Liu, Lijo.Lazar, Mario.Limonciello, Christian.Koenig
Cc: Pratik.Vishwakarma, Veerabadhran.Gopalakrishnan, Priya.Hosur
This patch series adds heavy-weight TLB flush after MES queue eviction/suspension
to fix SVM page migration hangs on gfx1151 with XNACK mode enabled.
v3:
- Split into 2 patches per Alex's review
- Added userq TLB flush in amdgpu_userq_unmap_helper() (amdgpu_userq.c)
v2:
- Removed "SDMA" from comment as this affects all in-flight memory
accesses, not just SDMA (Felix Kuehling)
- Added Reviewed-by tag
Priya Hosur (2):
drm/amdkfd: Add TLB flush after MES queue eviction/suspension
drm/amdgpu: Add TLB flush after MES user queue unmap
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++
.../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 13 ++++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
--
2.43.0
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH v3 1/2] drm/amdkfd: Add TLB flush after MES queue eviction/suspension 2026-08-14 16:18 [PATCH v3 0/2] drm/amdkfd: Add TLB flush after MES queue eviction/suspension Priya Hosur @ 2026-08-14 16:18 ` Priya Hosur 2026-08-14 16:18 ` [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap Priya Hosur 1 sibling, 0 replies; 12+ messages in thread From: Priya Hosur @ 2026-08-14 16:18 UTC (permalink / raw) To: amd-gfx, Alexander.Deucher, Sunil.Khatri, Felix.Kuehling, Shaoyun.Liu, Lijo.Lazar, Mario.Limonciello, Christian.Koenig Cc: Pratik.Vishwakarma, Veerabadhran.Gopalakrishnan, Priya.Hosur, Felix Kuehling MES (Micro Engine Scheduler) does not perform heavy-weight TLB invalidation after unmapping queues, unlike HWS which does this automatically. This causes a race condition where in-flight DMA descriptors can access memory that has been unmapped, leading to page faults and GPU queue hangs during SVM page migration. The issue manifests as KFDSVMRangeTest.MultiThreadMigrationTest failures on gfx1151 (Strix Point) with XNACK mode 1 enabled - the GPU compute queue hangs with packets submitted but never consumed. Add kfd_flush_tlb() calls after MES queue removal in two locations: - evict_process_queues_cpsch(): after all queues removed during eviction - suspend_queues(): after debug/criu queue suspension (with mem_fence barrier) This ensures all in-flight memory accesses from unmapped queues are flushed before memory is freed or migrated. Change-Id: Iaa884d4a7ad1199446bc45f4ad8a9a179ab386e6 Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> --- .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 a23384571193..6002c8a65fbe 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -1450,6 +1450,14 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm, dqm_evict_mqd_bo(dqm, q); } + /* + * Heavy-weight TLB flush after MES removes queues to ensure + * in-flight memory accesses complete before memory is freed/migrated. + * HWS does this automatically, MES does not. + */ + if (dqm->dev->kfd->shared_resources.enable_mes) + kfd_flush_tlb(pdd); + if (!dqm->dev->kfd->shared_resources.enable_mes) { pdd->last_evict_timestamp = get_jiffies_64(); retval = execute_queues_cpsch(dqm, @@ -3736,8 +3744,11 @@ int suspend_queues(struct kfd_process *p, if (!per_device_suspended) { dqm_unlock(dqm); mutex_unlock(&p->event_mutex); - if (total_suspended) + if (total_suspended) { amdgpu_amdkfd_debug_mem_fence(dqm->dev->adev); + /* Heavy-weight TLB flush after MES suspends queues */ + kfd_flush_tlb(pdd); + } continue; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-14 16:18 [PATCH v3 0/2] drm/amdkfd: Add TLB flush after MES queue eviction/suspension Priya Hosur 2026-08-14 16:18 ` [PATCH v3 1/2] " Priya Hosur @ 2026-08-14 16:18 ` Priya Hosur 2026-08-14 16:29 ` Lazar, Lijo 2026-08-24 7:39 ` Christian König 1 sibling, 2 replies; 12+ messages in thread From: Priya Hosur @ 2026-08-14 16:18 UTC (permalink / raw) To: amd-gfx, Alexander.Deucher, Sunil.Khatri, Felix.Kuehling, Shaoyun.Liu, Lijo.Lazar, Mario.Limonciello, Christian.Koenig Cc: Pratik.Vishwakarma, Veerabadhran.Gopalakrishnan, Priya.Hosur Similar to the KFD fix, MES does not perform heavy-weight TLB invalidation after unmapping user queues. Add amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in amdgpu_userq_unmap_helper() to ensure in-flight memory accesses complete before memory is freed or migrated. Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c index 6d3ed55e9ab4..9fcf15d69b7b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) } else { trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); queue->state = AMDGPU_USERQ_STATE_UNMAPPED; + /* + * Heavy-weight TLB flush after MES unmaps queue to ensure + * in-flight memory accesses complete before memory is freed/migrated. + * MES does not do this automatically unlike HWS. + */ + amdgpu_gmc_flush_gpu_tlb_pasid(adev, queue->vm->pasid, 2, true, 0); } } -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-14 16:18 ` [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap Priya Hosur @ 2026-08-14 16:29 ` Lazar, Lijo 2026-08-14 16:47 ` Kuehling, Felix 2026-08-24 7:39 ` Christian König 1 sibling, 1 reply; 12+ messages in thread From: Lazar, Lijo @ 2026-08-14 16:29 UTC (permalink / raw) To: Hosur, Priya, amd-gfx@lists.freedesktop.org, Deucher, Alexander, Khatri, Sunil, Kuehling, Felix, Liu, Shaoyun, Limonciello, Mario, Koenig, Christian Cc: Vishwakarma, Pratik, Gopalakrishnan, Veerabadhran (Veera), Hosur, Priya [-- Attachment #1: Type: text/plain, Size: 2253 bytes --] AMD General Hi, Shouldn't this be a FW fix? Thanks, Lijo ________________________________ From: Priya Hosur <Priya.Hosur@amd.com> Sent: Friday, 14 August 2026 21:48:40 To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> Subject: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap Similar to the KFD fix, MES does not perform heavy-weight TLB invalidation after unmapping user queues. Add amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in amdgpu_userq_unmap_helper() to ensure in-flight memory accesses complete before memory is freed or migrated. Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c index 6d3ed55e9ab4..9fcf15d69b7b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) } else { trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); queue->state = AMDGPU_USERQ_STATE_UNMAPPED; + /* + * Heavy-weight TLB flush after MES unmaps queue to ensure + * in-flight memory accesses complete before memory is freed/migrated. + * MES does not do this automatically unlike HWS. + */ + amdgpu_gmc_flush_gpu_tlb_pasid(adev, queue->vm->pasid, 2, true, 0); } } -- 2.43.0 [-- Attachment #2: Type: text/html, Size: 5659 bytes --] ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-14 16:29 ` Lazar, Lijo @ 2026-08-14 16:47 ` Kuehling, Felix 2026-08-14 17:25 ` Lazar, Lijo 0 siblings, 1 reply; 12+ messages in thread From: Kuehling, Felix @ 2026-08-14 16:47 UTC (permalink / raw) To: Lazar, Lijo, Hosur, Priya, amd-gfx@lists.freedesktop.org, Deucher, Alexander, Khatri, Sunil, Liu, Shaoyun, Limonciello, Mario, Koenig, Christian Cc: Vishwakarma, Pratik, Gopalakrishnan, Veerabadhran (Veera) [-- Attachment #1: Type: text/plain, Size: 3663 bytes --] AMD General We don't need to flush TLBs after every queue unmap. We only need to do it if there is an expectation that memory access is quiesced after unmapping. In the case of KFD, we are doing it when we're unmapping all queues, e.g. in MMU notifiers, evictions or when the debugger needs to stop the queues and look at memory contents. We only need one TLB flush after unmapping many queues. Therefore, MES should flush TLBs after every queue unmap. OTOH, MES must flush TLBs by itself when it switches VMIDs. This is not under driver control. I don't know what the requirements are for quiescing memory access after unmapping amdgpu user mode queues. Regards, Felix ________________________________ From: Lazar, Lijo <Lijo.Lazar@amd.com> Sent: Friday, August 14, 2026 12:29 To: Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap AMD General Hi, Shouldn't this be a FW fix? Thanks, Lijo ________________________________ From: Priya Hosur <Priya.Hosur@amd.com> Sent: Friday, 14 August 2026 21:48:40 To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> Subject: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap Similar to the KFD fix, MES does not perform heavy-weight TLB invalidation after unmapping user queues. Add amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in amdgpu_userq_unmap_helper() to ensure in-flight memory accesses complete before memory is freed or migrated. Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c index 6d3ed55e9ab4..9fcf15d69b7b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) } else { trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); queue->state = AMDGPU_USERQ_STATE_UNMAPPED; + /* + * Heavy-weight TLB flush after MES unmaps queue to ensure + * in-flight memory accesses complete before memory is freed/migrated. + * MES does not do this automatically unlike HWS. + */ + amdgpu_gmc_flush_gpu_tlb_pasid(adev, queue->vm->pasid, 2, true, 0); } } -- 2.43.0 [-- Attachment #2: Type: text/html, Size: 8989 bytes --] ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-14 16:47 ` Kuehling, Felix @ 2026-08-14 17:25 ` Lazar, Lijo 2026-08-16 17:07 ` Hosur, Priya 0 siblings, 1 reply; 12+ messages in thread From: Lazar, Lijo @ 2026-08-14 17:25 UTC (permalink / raw) To: Kuehling, Felix, Hosur, Priya, amd-gfx@lists.freedesktop.org, Deucher, Alexander, Khatri, Sunil, Liu, Shaoyun, Limonciello, Mario, Koenig, Christian Cc: Vishwakarma, Pratik, Gopalakrishnan, Veerabadhran (Veera) [-- Attachment #1: Type: text/plain, Size: 4510 bytes --] AMD General Thanks for the details. Didn't realise that it is one by one removal. I thought it was something like unmap-all for a PAS id. Thanks, Lijo ________________________________ From: Kuehling, Felix <Felix.Kuehling@amd.com> Sent: Friday, 14 August 2026 22:17:50 To: Lazar, Lijo <Lijo.Lazar@amd.com>; Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap AMD General We don't need to flush TLBs after every queue unmap. We only need to do it if there is an expectation that memory access is quiesced after unmapping. In the case of KFD, we are doing it when we're unmapping all queues, e.g. in MMU notifiers, evictions or when the debugger needs to stop the queues and look at memory contents. We only need one TLB flush after unmapping many queues. Therefore, MES should flush TLBs after every queue unmap. OTOH, MES must flush TLBs by itself when it switches VMIDs. This is not under driver control. I don't know what the requirements are for quiescing memory access after unmapping amdgpu user mode queues. Regards, Felix ________________________________ From: Lazar, Lijo <Lijo.Lazar@amd.com> Sent: Friday, August 14, 2026 12:29 To: Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap AMD General Hi, Shouldn't this be a FW fix? Thanks, Lijo ________________________________ From: Priya Hosur <Priya.Hosur@amd.com> Sent: Friday, 14 August 2026 21:48:40 To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> Subject: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap Similar to the KFD fix, MES does not perform heavy-weight TLB invalidation after unmapping user queues. Add amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in amdgpu_userq_unmap_helper() to ensure in-flight memory accesses complete before memory is freed or migrated. Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c index 6d3ed55e9ab4..9fcf15d69b7b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) } else { trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); queue->state = AMDGPU_USERQ_STATE_UNMAPPED; + /* + * Heavy-weight TLB flush after MES unmaps queue to ensure + * in-flight memory accesses complete before memory is freed/migrated. + * MES does not do this automatically unlike HWS. + */ + amdgpu_gmc_flush_gpu_tlb_pasid(adev, queue->vm->pasid, 2, true, 0); } } -- 2.43.0 [-- Attachment #2: Type: text/html, Size: 11333 bytes --] ^ permalink raw reply related [flat|nested] 12+ messages in thread
* RE: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-14 17:25 ` Lazar, Lijo @ 2026-08-16 17:07 ` Hosur, Priya 2026-08-17 14:19 ` Alex Deucher 0 siblings, 1 reply; 12+ messages in thread From: Hosur, Priya @ 2026-08-16 17:07 UTC (permalink / raw) To: Lazar, Lijo, Kuehling, Felix, Deucher, Alexander, amd-gfx@lists.freedesktop.org Cc: Vishwakarma, Pratik, Gopalakrishnan, Veerabadhran (Veera), Khatri, Sunil, Liu, Shaoyun, Limonciello, Mario, Koenig, Christian [-- Attachment #1: Type: text/plain, Size: 5576 bytes --] AMD General Hi Felix, Lijo, Thanks for the clarification. I understand now - TLB flush is only needed after batch queue unmapping (eviction/suspension), not after each individual queue unmap. Alex - based on Felix's feedback, the userq unmap path doesn't need the same fix since it's per-queue unmap rather than batch unmap. I'll drop patch 2/2 (userq fix) and send v4 with only the KFD fix. Thanks and Regards, Priya Hosur From: Lazar, Lijo <Lijo.Lazar@amd.com> Sent: Friday, August 14, 2026 10:56 PM To: Kuehling, Felix <Felix.Kuehling@amd.com>; Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap AMD General Thanks for the details. Didn't realise that it is one by one removal. I thought it was something like unmap-all for a PAS id. Thanks, Lijo ________________________________ From: Kuehling, Felix <Felix.Kuehling@amd.com> Sent: Friday, 14 August 2026 22:17:50 To: Lazar, Lijo <Lijo.Lazar@amd.com>; Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap AMD General We don't need to flush TLBs after every queue unmap. We only need to do it if there is an expectation that memory access is quiesced after unmapping. In the case of KFD, we are doing it when we're unmapping all queues, e.g. in MMU notifiers, evictions or when the debugger needs to stop the queues and look at memory contents. We only need one TLB flush after unmapping many queues. Therefore, MES should flush TLBs after every queue unmap. OTOH, MES must flush TLBs by itself when it switches VMIDs. This is not under driver control. I don't know what the requirements are for quiescing memory access after unmapping amdgpu user mode queues. Regards, Felix ________________________________ From: Lazar, Lijo <Lijo.Lazar@amd.com> Sent: Friday, August 14, 2026 12:29 To: Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap AMD General Hi, Shouldn't this be a FW fix? Thanks, Lijo ________________________________ From: Priya Hosur <Priya.Hosur@amd.com> Sent: Friday, 14 August 2026 21:48:40 To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> Subject: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap Similar to the KFD fix, MES does not perform heavy-weight TLB invalidation after unmapping user queues. Add amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in amdgpu_userq_unmap_helper() to ensure in-flight memory accesses complete before memory is freed or migrated. Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c index 6d3ed55e9ab4..9fcf15d69b7b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) } else { trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); queue->state = AMDGPU_USERQ_STATE_UNMAPPED; + /* + * Heavy-weight TLB flush after MES unmaps queue to ensure + * in-flight memory accesses complete before memory is freed/migrated. + * MES does not do this automatically unlike HWS. + */ + amdgpu_gmc_flush_gpu_tlb_pasid(adev, queue->vm->pasid, 2, true, 0); } } -- 2.43.0 [-- Attachment #2: Type: text/html, Size: 13364 bytes --] ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-16 17:07 ` Hosur, Priya @ 2026-08-17 14:19 ` Alex Deucher 2026-08-17 14:25 ` Khatri, Sunil 0 siblings, 1 reply; 12+ messages in thread From: Alex Deucher @ 2026-08-17 14:19 UTC (permalink / raw) To: Hosur, Priya Cc: Lazar, Lijo, Kuehling, Felix, Deucher, Alexander, amd-gfx@lists.freedesktop.org, Vishwakarma, Pratik, Gopalakrishnan, Veerabadhran (Veera), Khatri, Sunil, Liu, Shaoyun, Limonciello, Mario, Koenig, Christian On Sun, Aug 16, 2026 at 1:25 PM Hosur, Priya <Priya.Hosur@amd.com> wrote: > > AMD General > > > Hi Felix, Lijo, > > > > Thanks for the clarification. I understand now - TLB flush is only needed after batch queue unmapping (eviction/suspension), not after each individual queue unmap. > > > > Alex - based on Felix's feedback, the userq unmap path doesn't need the same fix since it's per-queue unmap rather than batch unmap. > I think it's still needed when we evict all KGD userqs for a process (technically per GPU VM instance). E.g., the eviction fence case. Alex > > > I'll drop patch 2/2 (userq fix) and send v4 with only the KFD fix. > > > > Thanks and Regards, > Priya Hosur > > > > From: Lazar, Lijo <Lijo.Lazar@amd.com> > Sent: Friday, August 14, 2026 10:56 PM > To: Kuehling, Felix <Felix.Kuehling@amd.com>; Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> > Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> > Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap > > > > AMD General > > > > Thanks for the details. Didn't realise that it is one by one removal. I thought it was something like unmap-all for a PAS id. > > > > Thanks, > > Lijo > > ________________________________ > > From: Kuehling, Felix <Felix.Kuehling@amd.com> > Sent: Friday, 14 August 2026 22:17:50 > To: Lazar, Lijo <Lijo.Lazar@amd.com>; Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> > Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> > Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap > > > > AMD General > > > > We don't need to flush TLBs after every queue unmap. We only need to do it if there is an expectation that memory access is quiesced after unmapping. In the case of KFD, we are doing it when we're unmapping all queues, e.g. in MMU notifiers, evictions or when the debugger needs to stop the queues and look at memory contents. We only need one TLB flush after unmapping many queues. > > > > Therefore, MES should flush TLBs after every queue unmap. OTOH, MES must flush TLBs by itself when it switches VMIDs. This is not under driver control. > > > > I don't know what the requirements are for quiescing memory access after unmapping amdgpu user mode queues. > > > > Regards, > > Felix > > ________________________________ > > From: Lazar, Lijo <Lijo.Lazar@amd.com> > Sent: Friday, August 14, 2026 12:29 > To: Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> > Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> > Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap > > > > AMD General > > > > Hi, > > > > Shouldn't this be a FW fix? > > > > Thanks, > > Lijo > > ________________________________ > > From: Priya Hosur <Priya.Hosur@amd.com> > Sent: Friday, 14 August 2026 21:48:40 > To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> > Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> > Subject: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap > > > > Similar to the KFD fix, MES does not perform heavy-weight TLB > invalidation after unmapping user queues. Add > amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in > amdgpu_userq_unmap_helper() to ensure in-flight memory accesses > complete before memory is freed or migrated. > > Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a > Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > index 6d3ed55e9ab4..9fcf15d69b7b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) > } else { > trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); > queue->state = AMDGPU_USERQ_STATE_UNMAPPED; > + /* > + * Heavy-weight TLB flush after MES unmaps queue to ensure > + * in-flight memory accesses complete before memory is freed/migrated. > + * MES does not do this automatically unlike HWS. > + */ > + amdgpu_gmc_flush_gpu_tlb_pasid(adev, queue->vm->pasid, 2, true, 0); > } > } > > -- > 2.43.0 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-17 14:19 ` Alex Deucher @ 2026-08-17 14:25 ` Khatri, Sunil 0 siblings, 0 replies; 12+ messages in thread From: Khatri, Sunil @ 2026-08-17 14:25 UTC (permalink / raw) To: Alex Deucher, Hosur, Priya Cc: Lazar, Lijo, Kuehling, Felix, Deucher, Alexander, amd-gfx@lists.freedesktop.org, Vishwakarma, Pratik, Gopalakrishnan, Veerabadhran (Veera), Khatri, Sunil, Liu, Shaoyun, Limonciello, Mario, Koenig, Christian On 17-08-2026 07:49 pm, Alex Deucher wrote: > On Sun, Aug 16, 2026 at 1:25 PM Hosur, Priya <Priya.Hosur@amd.com> wrote: >> AMD General >> >> >> Hi Felix, Lijo, >> >> >> >> Thanks for the clarification. I understand now - TLB flush is only needed after batch queue unmapping (eviction/suspension), not after each individual queue unmap. >> >> >> >> Alex - based on Felix's feedback, the userq unmap path doesn't need the same fix since it's per-queue unmap rather than batch unmap. >> > I think it's still needed when we evict all KGD userqs for a process > (technically per GPU VM instance). E.g., the eviction fence case. @priya, i am looking into this in the KGD userqueues. It's ok if you drop that as it need some more insight to understand how well it fits the KGD queues.. Regards Sunil Khatri > > Alex > >> >> I'll drop patch 2/2 (userq fix) and send v4 with only the KFD fix. >> >> >> >> Thanks and Regards, >> Priya Hosur >> >> >> >> From: Lazar, Lijo <Lijo.Lazar@amd.com> >> Sent: Friday, August 14, 2026 10:56 PM >> To: Kuehling, Felix <Felix.Kuehling@amd.com>; Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> >> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> >> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap >> >> >> >> AMD General >> >> >> >> Thanks for the details. Didn't realise that it is one by one removal. I thought it was something like unmap-all for a PAS id. >> >> >> >> Thanks, >> >> Lijo >> >> ________________________________ >> >> From: Kuehling, Felix <Felix.Kuehling@amd.com> >> Sent: Friday, 14 August 2026 22:17:50 >> To: Lazar, Lijo <Lijo.Lazar@amd.com>; Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> >> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> >> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap >> >> >> >> AMD General >> >> >> >> We don't need to flush TLBs after every queue unmap. We only need to do it if there is an expectation that memory access is quiesced after unmapping. In the case of KFD, we are doing it when we're unmapping all queues, e.g. in MMU notifiers, evictions or when the debugger needs to stop the queues and look at memory contents. We only need one TLB flush after unmapping many queues. >> >> >> >> Therefore, MES should flush TLBs after every queue unmap. OTOH, MES must flush TLBs by itself when it switches VMIDs. This is not under driver control. >> >> >> >> I don't know what the requirements are for quiescing memory access after unmapping amdgpu user mode queues. >> >> >> >> Regards, >> >> Felix >> >> ________________________________ >> >> From: Lazar, Lijo <Lijo.Lazar@amd.com> >> Sent: Friday, August 14, 2026 12:29 >> To: Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> >> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> >> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap >> >> >> >> AMD General >> >> >> >> Hi, >> >> >> >> Shouldn't this be a FW fix? >> >> >> >> Thanks, >> >> Lijo >> >> ________________________________ >> >> From: Priya Hosur <Priya.Hosur@amd.com> >> Sent: Friday, 14 August 2026 21:48:40 >> To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com>; Koenig, Christian <Christian.Koenig@amd.com> >> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com>; Hosur, Priya <Priya.Hosur@amd.com> >> Subject: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap >> >> >> >> Similar to the KFD fix, MES does not perform heavy-weight TLB >> invalidation after unmapping user queues. Add >> amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in >> amdgpu_userq_unmap_helper() to ensure in-flight memory accesses >> complete before memory is freed or migrated. >> >> Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a >> Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> >> --- >> drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c >> index 6d3ed55e9ab4..9fcf15d69b7b 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c >> @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) >> } else { >> trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); >> queue->state = AMDGPU_USERQ_STATE_UNMAPPED; >> + /* >> + * Heavy-weight TLB flush after MES unmaps queue to ensure >> + * in-flight memory accesses complete before memory is freed/migrated. >> + * MES does not do this automatically unlike HWS. >> + */ >> + amdgpu_gmc_flush_gpu_tlb_pasid(adev, queue->vm->pasid, 2, true, 0); >> } >> } >> >> -- >> 2.43.0 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-14 16:18 ` [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap Priya Hosur 2026-08-14 16:29 ` Lazar, Lijo @ 2026-08-24 7:39 ` Christian König 2026-08-25 6:47 ` Khatri, Sunil 1 sibling, 1 reply; 12+ messages in thread From: Christian König @ 2026-08-24 7:39 UTC (permalink / raw) To: Priya Hosur, amd-gfx, Alexander.Deucher, Sunil.Khatri, Felix.Kuehling, Shaoyun.Liu, Lijo.Lazar, Mario.Limonciello Cc: Pratik.Vishwakarma, Veerabadhran.Gopalakrishnan On 8/14/26 18:18, Priya Hosur wrote: > Similar to the KFD fix, MES does not perform heavy-weight TLB > invalidation after unmapping user queues. Add > amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in > amdgpu_userq_unmap_helper() to ensure in-flight memory accesses > complete before memory is freed or migrated. > > Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a > Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > index 6d3ed55e9ab4..9fcf15d69b7b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) > } else { > trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); > queue->state = AMDGPU_USERQ_STATE_UNMAPPED; > + /* > + * Heavy-weight TLB flush after MES unmaps queue to ensure > + * in-flight memory accesses complete before memory is freed/migrated. > + * MES does not do this automatically unlike HWS. > + */ > + amdgpu_gmc_flush_gpu_tlb_pasid(adev, queue->vm->pasid, 2, true, 0); Absolutely clear NAK to this. The MES *must* guarantee that in flight memory accesses are completed before it unmaps the queue or otherwise we run into massive problems. Flushing out any VM changes by invalidating the TLB doesn't change anything on that. Regards, Christian. > } > } > ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-24 7:39 ` Christian König @ 2026-08-25 6:47 ` Khatri, Sunil 2026-08-25 10:36 ` Hosur, Priya 0 siblings, 1 reply; 12+ messages in thread From: Khatri, Sunil @ 2026-08-25 6:47 UTC (permalink / raw) To: Koenig, Christian, Hosur, Priya, amd-gfx@lists.freedesktop.org, Deucher, Alexander, Kuehling, Felix, Liu, Shaoyun, Lazar, Lijo, Limonciello, Mario Cc: Vishwakarma, Pratik, Gopalakrishnan, Veerabadhran (Veera) AMD General -----Original Message----- From: Koenig, Christian <Christian.Koenig@amd.com> Sent: Monday, August 24, 2026 1:09 PM To: Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap On 8/14/26 18:18, Priya Hosur wrote: > Similar to the KFD fix, MES does not perform heavy-weight TLB > invalidation after unmapping user queues. Add > amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in > amdgpu_userq_unmap_helper() to ensure in-flight memory accesses > complete before memory is freed or migrated. > > Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a > Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > index 6d3ed55e9ab4..9fcf15d69b7b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) > } else { > trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); > queue->state = AMDGPU_USERQ_STATE_UNMAPPED; > + /* > + * Heavy-weight TLB flush after MES unmaps queue to ensure > + * in-flight memory accesses complete before memory is freed/migrated. > + * MES does not do this automatically unlike HWS. > + */ > + amdgpu_gmc_flush_gpu_tlb_pasid(adev, queue->vm->pasid, 2, true, > +0); Absolutely clear NAK to this. The MES *must* guarantee that in flight memory accesses are completed before it unmaps the queue or otherwise we run into massive problems. Flushing out any VM changes by invalidating the TLB doesn't change anything on that. I tried this change during suspend but it dint help the case of tlb invalidation issues that we are facing. regards Sunil Khatri Regards, Christian. > } > } > ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap 2026-08-25 6:47 ` Khatri, Sunil @ 2026-08-25 10:36 ` Hosur, Priya 0 siblings, 0 replies; 12+ messages in thread From: Hosur, Priya @ 2026-08-25 10:36 UTC (permalink / raw) To: Khatri, Sunil, Koenig, Christian, amd-gfx@lists.freedesktop.org, Deucher, Alexander, Kuehling, Felix, Liu, Shaoyun, Lazar, Lijo, Limonciello, Mario Cc: Vishwakarma, Pratik, Gopalakrishnan, Veerabadhran (Veera) AMD General Hi all, Thanks for the feedback and for testing this during suspend — since it doesn't resolve the TLB invalidation issue there either, this clearly needs deeper analysis. For now, I'll pick patch 1 (the KFD-related fix) only and drop patch 2 (this amdgpu_userq.c TLB flush). Thanks, Priya -----Original Message----- From: Khatri, Sunil <Sunil.Khatri@amd.com> Sent: Tuesday, August 25, 2026 12:17 PM To: Koenig, Christian <Christian.Koenig@amd.com>; Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> Subject: RE: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap AMD General -----Original Message----- From: Koenig, Christian <Christian.Koenig@amd.com> Sent: Monday, August 24, 2026 1:09 PM To: Hosur, Priya <Priya.Hosur@amd.com>; amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Limonciello, Mario <Mario.Limonciello@amd.com> Cc: Vishwakarma, Pratik <Pratik.Vishwakarma@amd.com>; Gopalakrishnan, Veerabadhran (Veera) <Veerabadhran.Gopalakrishnan@amd.com> Subject: Re: [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap On 8/14/26 18:18, Priya Hosur wrote: > Similar to the KFD fix, MES does not perform heavy-weight TLB > invalidation after unmapping user queues. Add > amdgpu_gmc_flush_gpu_tlb_pasid() after MES unmap succeeds in > amdgpu_userq_unmap_helper() to ensure in-flight memory accesses > complete before memory is freed or migrated. > > Change-Id: I94fe2c84547723b6b73816ce8d727a54bd773a6a > Signed-off-by: Priya Hosur <Priya.Hosur@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > index 6d3ed55e9ab4..9fcf15d69b7b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > @@ -375,6 +375,12 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue) > } else { > trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_UNMAPPED); > queue->state = AMDGPU_USERQ_STATE_UNMAPPED; > + /* > + * Heavy-weight TLB flush after MES unmaps queue to ensure > + * in-flight memory accesses complete before memory is freed/migrated. > + * MES does not do this automatically unlike HWS. > + */ > + amdgpu_gmc_flush_gpu_tlb_pasid(adev, > +queue->vm->pasid, 2, true, 0); Absolutely clear NAK to this. The MES *must* guarantee that in flight memory accesses are completed before it unmaps the queue or otherwise we run into massive problems. Flushing out any VM changes by invalidating the TLB doesn't change anything on that. I tried this change during suspend but it dint help the case of tlb invalidation issues that we are facing. regards Sunil Khatri Regards, Christian. > } > } > ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-08-25 10:36 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-14 16:18 [PATCH v3 0/2] drm/amdkfd: Add TLB flush after MES queue eviction/suspension Priya Hosur 2026-08-14 16:18 ` [PATCH v3 1/2] " Priya Hosur 2026-08-14 16:18 ` [PATCH v3 2/2] drm/amdgpu: Add TLB flush after MES user queue unmap Priya Hosur 2026-08-14 16:29 ` Lazar, Lijo 2026-08-14 16:47 ` Kuehling, Felix 2026-08-14 17:25 ` Lazar, Lijo 2026-08-16 17:07 ` Hosur, Priya 2026-08-17 14:19 ` Alex Deucher 2026-08-17 14:25 ` Khatri, Sunil 2026-08-24 7:39 ` Christian König 2026-08-25 6:47 ` Khatri, Sunil 2026-08-25 10:36 ` Hosur, Priya
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.