* [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path
@ 2026-11-18 15:10 Xiaogang.Chen
2026-11-18 15:10 ` [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize Xiaogang.Chen
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Xiaogang.Chen @ 2026-11-18 15:10 UTC (permalink / raw)
To: amd-gfx; +Cc: Xiaogang Chen
From: Xiaogang Chen <xiaogang.chen@amd.com>
The destination pages were freed while SDMA copies queued earlier
could still be writing into them, and while they were still DMA
mapped. The mappings were only removed later by the caller's
svm_range_dma_unmap_dev().
With swiotlb, the BIDIRECTIONAL unmap copies the bounce buffer back into
a page that may already be reused.
With an IOMM, the GPU still has a valid bus address that points at a page
now maybe owned by another user. Any SDMA write still in flight, corrupts
that page.
So, wait on the fence first, then dma unmap before release buffer.
svm_range_dma_unmap_dev() sets each entry to 0 after unmapping it,
so the caller's later svm_range_dma_unmap_dev call skips them.
Not drop the fence there. *mfence still belongs to the caller. Later
svm_migrate_copy_done() puts it and second wait there returns immediately.
Signed-off-by: Xiaogang Chen <xiaogang.chen@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
index 8b96e1fe741a..78a2aab81c17 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -716,6 +716,18 @@ svm_migrate_copy_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
put_page(dpage);
}
+ /*
+ * Copies queued before the failure may still be writing into
+ * the destination pages. Wait for the last SDMA fence (copies
+ * on the entity complete in order), then remove the device DMA
+ * mappings, before the pages go back to the allocator. The
+ * caller's svm_migrate_copy_done() still puts the fence, and
+ * its svm_range_dma_unmap_dev() skips the entries zeroed here.
+ */
+ if (*mfence)
+ dma_fence_wait(*mfence, false);
+ svm_range_dma_unmap_dev(dev, dst, 0, npages);
+
/* release previous allocated sys pages and unmap dma address */
while (i--) {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize
2026-11-18 15:10 [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path Xiaogang.Chen
@ 2026-11-18 15:10 ` Xiaogang.Chen
2026-11-18 15:25 ` sashiko-bot
2026-11-18 17:48 ` Philip Yang
2026-11-18 15:22 ` [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path sashiko-bot
2026-11-18 17:43 ` Philip Yang
2 siblings, 2 replies; 7+ messages in thread
From: Xiaogang.Chen @ 2026-11-18 15:10 UTC (permalink / raw)
To: amd-gfx; +Cc: Xiaogang Chen
From: Xiaogang Chen <xiaogang.chen@amd.com>
svm_migrate_vma_to_vram() on success: migrate_vma_finalize() releases the old
system-RAM source pages. Only after that they are DMA-unmapped.
svm_migrate_vma_to_ram() for slots that failed to migrate: finalize frees the
newly allocated dpages, and the unmap comes afterwards.
Every mapping uses DMA_BIDIRECTIONAL. With swiotlb, that kind of unmap copies
the bounce buffer back into the original page, and by then the page may belong
to someone else. With an IOMMU, the IOVA stays valid for a short window after
the page is freed. During the window GPU may write into the pages that may
belong to someone else.
So, swap svm_range_dma_unmap_dev and migrate_vma_finalize at both migration
direction to make dma unmap happen before sys ram pages got released.
Signed-off-by: Xiaogang Chen <xiaogang.chen@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
index 78a2aab81c17..4bcdedd91d2e 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -494,14 +494,13 @@ svm_migrate_vma_to_vram(struct kfd_node *node, struct svm_range *prange,
migrate_vma_pages(&migrate);
svm_migrate_copy_done(adev, mfence);
+ svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
migrate_vma_finalize(&migrate);
mpages = svm_migrate_successful_pages(&migrate);
pr_debug("migrated/collected/requested 0x%lx/0x%lx/0x%lx\n",
mpages, cpages, migrate.npages);
- svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
-
out_free:
kvfree(buf);
kfd_smi_event_migration_end(node, p->lead_thread,
@@ -838,9 +837,8 @@ svm_migrate_vma_to_ram(struct kfd_node *node, struct svm_range *prange,
mpages, cpages, migrate.npages);
svm_migrate_copy_done(adev, mfence);
- migrate_vma_finalize(&migrate);
-
svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
+ migrate_vma_finalize(&migrate);
out_free:
kvfree(buf);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path
2026-11-18 15:10 [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path Xiaogang.Chen
2026-11-18 15:10 ` [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize Xiaogang.Chen
@ 2026-11-18 15:22 ` sashiko-bot
2026-11-18 17:43 ` Philip Yang
2 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-18 15:22 UTC (permalink / raw)
To: Xiaogang.Chen, amd-gfx
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] drm/amdkfd: redundant DMA unmap in svm_migrate_copy_to_ram()
error path
- [Low] drm/amdkfd: missing Fixes trailer on svm_migrate_copy_to_ram()
fix
--
commit 04e6170d8b5365de5f3b17fda44a17daca9153e9
Author: Xiaogang Chen <xiaogang.chen@amd.com>
> drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path
>
> The destination pages were freed while SDMA copies queued earlier
> could still be writing into them, and while they were still DMA
> mapped. The mappings were only removed later by the caller's
> svm_range_dma_unmap_dev().
>
> With swiotlb, the BIDIRECTIONAL unmap copies the bounce buffer back into
> a page that may already be reused.
>
> With an IOMM, the GPU still has a valid bus address that points at a page
> now maybe owned by another user. Any SDMA write still in flight, corrupts
> that page.
>
> So, wait on the fence first, then dma unmap before release buffer.
>
> svm_range_dma_unmap_dev() sets each entry to 0 after unmapping it,
> so the caller's later svm_range_dma_unmap_dev call skips them.
>
> Not drop the fence there. *mfence still belongs to the caller. Later
> svm_migrate_copy_done() puts it and second wait there returns immediately.
>
> Signed-off-by: Xiaogang Chen <xiaogang.chen@amd.com>
[Severity: Low]
Should this bug fix include Fixes tags for the commits that introduced and
updated the error cleanup path in svm_migrate_copy_to_ram()?
Fixes: 48ff079b28d8 ("drm/amdkfd: HMM migrate vram to ram")
Fixes: 960c4a8069bf ("drm/amdkfd: Fix error path at svm_migrate_copy_to_ram")
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> index 1eb92ac6eb058..481091ae30947 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> @@ -726,6 +726,18 @@ svm_migrate_copy_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
> put_page(dpage);
> }
>
> + /*
> + * Copies queued before the failure may still be writing into
> + * the destination pages. Wait for the last SDMA fence (copies
> + * on the entity complete in order), then remove the device DMA
> + * mappings, before the pages go back to the allocator. The
> + * caller's svm_migrate_copy_done() still puts the fence, and
> + * its svm_range_dma_unmap_dev() skips the entries zeroed here.
> + */
> + if (*mfence)
> + dma_fence_wait(*mfence, false);
> + svm_range_dma_unmap_dev(dev, dst, 0, npages);
> +
> /* release previous allocated sys pages and unmap dma address */
> while (i--) {
[Severity: Low]
This isn't a bug, but commit 960c4a8069bf ("drm/amdkfd: Fix error path at
svm_migrate_copy_to_ram") already added dma_unmap_page() and zeroed dst[i]
inside the while (i--) loop right below this:
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c:svm_migrate_copy_to_ram() {
...
while (i--) {
if (dst[i]) {
dma_unmap_page(dev, dst[i], PAGE_SIZE,
DMA_BIDIRECTIONAL);
dst[i] = 0;
}
...
}
Because dst is zero-initialized and dst[i] is cleared on dma_map_page()
failure before jumping to out_oom, only entries below i hold mappings.
Calling svm_range_dma_unmap_dev(dev, dst, 0, npages) beforehand unmaps and
zeroes all of dst[], leaving the dma_unmap_page() block in the while (i--)
loop dead code, and the commit message's statement that mappings were only
removed later by the caller's svm_range_dma_unmap_dev() no longer matches
the code.
Wait on *mfence before the while (i--) loop and either drop the new
svm_range_dma_unmap_dev() call or remove the duplicate dma_unmap_page()
block inside the loop.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118151045.134908-1-xiaogang.chen@amd.com?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize
2026-11-18 15:10 ` [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize Xiaogang.Chen
@ 2026-11-18 15:25 ` sashiko-bot
2026-11-18 17:48 ` Philip Yang
1 sibling, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-18 15:25 UTC (permalink / raw)
To: Xiaogang.Chen, amd-gfx
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/amdkfd: missing Fixes: trailers for DMA unmap ordering bug
fix
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] drm/amdkfd: unhandled SDMA fence error in
svm_migrate_copy_done() [1]
--
commit ccdfb551849cc8856e631a5865cff36ff2c4ceb7
Author: Xiaogang Chen <xiaogang.chen@amd.com>
> drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize
>
> svm_migrate_vma_to_vram() on success: migrate_vma_finalize() releases the old
> system-RAM source pages. Only after that they are DMA-unmapped.
>
> svm_migrate_vma_to_ram() for slots that failed to migrate: finalize frees the
> newly allocated dpages, and the unmap comes afterwards.
>
> Every mapping uses DMA_BIDIRECTIONAL. With swiotlb, that kind of unmap copies
> the bounce buffer back into the original page, and by then the page may belong
> to someone else. With an IOMMU, the IOVA stays valid for a short window after
> the page is freed. During the window GPU may write into the pages that may
> belong to someone else.
>
> So, swap svm_range_dma_unmap_dev and migrate_vma_finalize at both migration
> direction to make dma unmap happen before sys ram pages got released.
>
> Signed-off-by: Xiaogang Chen <xiaogang.chen@amd.com>
[Severity: Low]
Should this bug fix include Fixes: tags for the commits that introduced
the unmap ordering in both migration directions?
Fixes: 0b0e518d61af ("drm/amdkfd: HMM migrate ram to vram")
Fixes: 48ff079b28d8 ("drm/amdkfd: HMM migrate vram to ram")
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> index 481091ae30947..b1e457851a5df 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> @@ -504,14 +504,13 @@ svm_migrate_vma_to_vram(struct kfd_node *node, struct svm_range *prange,
> migrate_vma_pages(&migrate);
>
> svm_migrate_copy_done(adev, mfence);
> + svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
> migrate_vma_finalize(&migrate);
[Severity: Critical]
This problem wasn't introduced by this patch, but can
svm_migrate_vma_to_vram() and svm_migrate_vma_to_ram() commit uninitialized
destination pages when the SDMA copy job fails [1]?
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c:svm_migrate_copy_done() {
if (mfence) {
r = dma_fence_wait(mfence, false);
dma_fence_put(mfence);
pr_debug("sdma copy memory fence done\n");
}
}
dma_fence_wait() returns 0 whenever the fence signals, even if the SDMA job
aborted with mfence->error set (for example during a GPU reset), and
neither svm_migrate_copy_done() nor its callers inspect the fence error or
return value before migrate_vma_finalize() installs the new page table
entries, exposing stale or uninitialized memory to userspace.
[1] https://sashiko.dev/#/bug/linux-bdb6e388-a490-42f9-a491-9e9b540c6920
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118151045.134908-1-xiaogang.chen@amd.com?part=2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path
2026-11-18 15:10 [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path Xiaogang.Chen
2026-11-18 15:10 ` [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize Xiaogang.Chen
2026-11-18 15:22 ` [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path sashiko-bot
@ 2026-11-18 17:43 ` Philip Yang
2 siblings, 0 replies; 7+ messages in thread
From: Philip Yang @ 2026-11-18 17:43 UTC (permalink / raw)
To: Xiaogang.Chen, amd-gfx
[-- Attachment #1: Type: text/plain, Size: 2530 bytes --]
On 2026-11-18 10:10, Xiaogang.Chen wrote:
> From: Xiaogang Chen<xiaogang.chen@amd.com>
>
> The destination pages were freed while SDMA copies queued earlier
> could still be writing into them, and while they were still DMA
> mapped. The mappings were only removed later by the caller's
> svm_range_dma_unmap_dev().
>
> With swiotlb, the BIDIRECTIONAL unmap copies the bounce buffer back into
> a page that may already be reused.
>
> With an IOMM, the GPU still has a valid bus address that points at a page
> now maybe owned by another user. Any SDMA write still in flight, corrupts
> that page.
>
> So, wait on the fence first, then dma unmap before release buffer.
>
> svm_range_dma_unmap_dev() sets each entry to 0 after unmapping it,
> so the caller's later svm_range_dma_unmap_dev call skips them.
>
> Not drop the fence there. *mfence still belongs to the caller. Later
> svm_migrate_copy_done() puts it and second wait there returns immediately.
>
> Signed-off-by: Xiaogang Chen<xiaogang.chen@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> index 8b96e1fe741a..78a2aab81c17 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> @@ -716,6 +716,18 @@ svm_migrate_copy_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
> put_page(dpage);
> }
>
> + /*
> + * Copies queued before the failure may still be writing into
> + * the destination pages. Wait for the last SDMA fence (copies
> + * on the entity complete in order), then remove the device DMA
> + * mappings, before the pages go back to the allocator. The
> + * caller's svm_migrate_copy_done() still puts the fence, and
> + * its svm_range_dma_unmap_dev() skips the entries zeroed here.
> + */
> + if (*mfence)
> + dma_fence_wait(*mfence, false);
wait fence is good, but I perfer to add dma_fence_put() here to free the
fence, then in caller, only wait for fence if copy return 0.
if (!r)
svm_migrate_copy_done(adev, mfence);
> + svm_range_dma_unmap_dev(dev, dst, 0, npages);
> +
This is not needed, as the below loop unmap dma address and free sys pages.
And add this in caller
if (!r)
svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
Regards,
Philip
> /* release previous allocated sys pages and unmap dma address */
> while (i--) {
>
[-- Attachment #2: Type: text/html, Size: 3522 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize
2026-11-18 15:10 ` [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize Xiaogang.Chen
2026-11-18 15:25 ` sashiko-bot
@ 2026-11-18 17:48 ` Philip Yang
2026-11-18 18:02 ` Chen, Xiaogang
1 sibling, 1 reply; 7+ messages in thread
From: Philip Yang @ 2026-11-18 17:48 UTC (permalink / raw)
To: Xiaogang.Chen, amd-gfx
[-- Attachment #1: Type: text/plain, Size: 2445 bytes --]
On 2026-11-18 10:10, Xiaogang.Chen wrote:
> From: Xiaogang Chen<xiaogang.chen@amd.com>
>
> svm_migrate_vma_to_vram() on success: migrate_vma_finalize() releases the old
> system-RAM source pages. Only after that they are DMA-unmapped.
>
> svm_migrate_vma_to_ram() for slots that failed to migrate: finalize frees the
> newly allocated dpages, and the unmap comes afterwards.
>
> Every mapping uses DMA_BIDIRECTIONAL. With swiotlb, that kind of unmap copies
> the bounce buffer back into the original page, and by then the page may belong
> to someone else. With an IOMMU, the IOVA stays valid for a short window after
> the page is freed. During the window GPU may write into the pages that may
> belong to someone else.
>
> So, swap svm_range_dma_unmap_dev and migrate_vma_finalize at both migration
> direction to make dma unmap happen before sys ram pages got released.
>
> Signed-off-by: Xiaogang Chen<xiaogang.chen@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> index 78a2aab81c17..4bcdedd91d2e 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> @@ -494,14 +494,13 @@ svm_migrate_vma_to_vram(struct kfd_node *node, struct svm_range *prange,
> migrate_vma_pages(&migrate);
>
> svm_migrate_copy_done(adev, mfence);
> + svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
> migrate_vma_finalize(&migrate);
>
> mpages = svm_migrate_successful_pages(&migrate);
> pr_debug("migrated/collected/requested 0x%lx/0x%lx/0x%lx\n",
> mpages, cpages, migrate.npages);
>
> - svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
> -
> out_free:
> kvfree(buf);
> kfd_smi_event_migration_end(node, p->lead_thread,
> @@ -838,9 +837,8 @@ svm_migrate_vma_to_ram(struct kfd_node *node, struct svm_range *prange,
> mpages, cpages, migrate.npages);
>
> svm_migrate_copy_done(adev, mfence);
> - migrate_vma_finalize(&migrate);
> -
> svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
> + migrate_vma_finalize(&migrate);
With the suggested change in patch 1, this will be
if (!r) {
svm_migrate_copy_done(adev, mfence); svm_range_dma_unmap_dev(adev->dev,
scratch, 0, npages);
}
migrate_vma_finalize(&migrate);
Regards,
Philip
>
> out_free:
> kvfree(buf);
[-- Attachment #2: Type: text/html, Size: 3302 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize
2026-11-18 17:48 ` Philip Yang
@ 2026-11-18 18:02 ` Chen, Xiaogang
0 siblings, 0 replies; 7+ messages in thread
From: Chen, Xiaogang @ 2026-11-18 18:02 UTC (permalink / raw)
To: Philip Yang, amd-gfx
On 11/18/2026 11:48 AM, Philip Yang wrote:
>
>
> On 2026-11-18 10:10, Xiaogang.Chen wrote:
>> From: Xiaogang Chen<xiaogang.chen@amd.com>
>>
>> svm_migrate_vma_to_vram() on success: migrate_vma_finalize() releases
>> the old
>> system-RAM source pages. Only after that they are DMA-unmapped.
>>
>> svm_migrate_vma_to_ram() for slots that failed to migrate: finalize
>> frees the
>> newly allocated dpages, and the unmap comes afterwards.
>>
>> Every mapping uses DMA_BIDIRECTIONAL. With swiotlb, that kind of
>> unmap copies
>> the bounce buffer back into the original page, and by then the page
>> may belong
>> to someone else. With an IOMMU, the IOVA stays valid for a short
>> window after
>> the page is freed. During the window GPU may write into the pages
>> that may
>> belong to someone else.
>>
>> So, swap svm_range_dma_unmap_dev and migrate_vma_finalize at both
>> migration
>> direction to make dma unmap happen before sys ram pages got released.
>>
>> Signed-off-by: Xiaogang Chen<xiaogang.chen@amd.com>
>> ---
>> drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
>> b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
>> index 78a2aab81c17..4bcdedd91d2e 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
>> @@ -494,14 +494,13 @@ svm_migrate_vma_to_vram(struct kfd_node *node,
>> struct svm_range *prange,
>> migrate_vma_pages(&migrate);
>> svm_migrate_copy_done(adev, mfence);
>> + svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
>> migrate_vma_finalize(&migrate);
>> mpages = svm_migrate_successful_pages(&migrate);
>> pr_debug("migrated/collected/requested 0x%lx/0x%lx/0x%lx\n",
>> mpages, cpages, migrate.npages);
>> - svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
>> -
>> out_free:
>> kvfree(buf);
>> kfd_smi_event_migration_end(node, p->lead_thread,
>> @@ -838,9 +837,8 @@ svm_migrate_vma_to_ram(struct kfd_node *node,
>> struct svm_range *prange,
>> mpages, cpages, migrate.npages);
>> svm_migrate_copy_done(adev, mfence);
>> - migrate_vma_finalize(&migrate);
>> -
>> svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
>> + migrate_vma_finalize(&migrate);
> With the suggested change in patch 1, this will be
>
> if (!r) {
> svm_migrate_copy_done(adev, mfence);
> svm_range_dma_unmap_dev(adev->dev, scratch, 0, npages);
> }
>
It is sys->vram path. There is no dma_wait at error path.
Regards
Xiaogang
> migrate_vma_finalize(&migrate);
>
> Regards,
> Philip
>> out_free:
>> kvfree(buf);
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-18 18:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 15:10 [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path Xiaogang.Chen
2026-11-18 15:10 ` [PATCH 2/2] drm/amdkfd: Swap order of svm_range_dma_unmap_dev and migrate_vma_finalize Xiaogang.Chen
2026-11-18 15:25 ` sashiko-bot
2026-11-18 17:48 ` Philip Yang
2026-11-18 18:02 ` Chen, Xiaogang
2026-11-18 15:22 ` [PATCH 1/2] drm/amdkfd: Fix a race issue at svm_migrate_copy_to_ram() error path sashiko-bot
2026-11-18 17:43 ` Philip Yang
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.