<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Does this patch fix a bug or just make code look more
reasonable? <span style="white-space: pre-wrap">kfd_process_destroy_pdds releases pdd related buffers, not related to operations on vm. So vm tear down dose not affect this function. </span></p>
<p><span style="white-space: pre-wrap">Regards</span></p>
<p><span style="white-space: pre-wrap">Xiaogang
</span></p>
<div class="moz-cite-prefix">On 5/14/2025 12:10 PM, Philip Yang
wrote:<br>
</div>
<blockquote type="cite" cite="mid:20250514171004.4259-4-Philip.Yang@amd.com">
<pre wrap="" class="moz-quote-pre">Release pdd->drm_file may free the vm if this is the last reference,
move it to the last step after memory is unmapped.
Signed-off-by: Philip Yang <a class="moz-txt-link-rfc2396E" href="mailto:Philip.Yang@amd.com"><Philip.Yang@amd.com></a>
---
drivers/gpu/drm/amd/amdkfd/kfd_process.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index e868cc8da46f..b009c852180d 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -1063,9 +1063,6 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)
kfd_process_device_destroy_cwsr_dgpu(pdd);
kfd_process_device_destroy_ib_mem(pdd);
- if (pdd->drm_file)
- fput(pdd->drm_file);
-
if (pdd->qpd.cwsr_kaddr && !pdd->qpd.cwsr_base)
free_pages((unsigned long)pdd->qpd.cwsr_kaddr,
get_order(KFD_CWSR_TBA_TMA_SIZE));
@@ -1088,6 +1085,13 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)
pdd->runtime_inuse = false;
}
+ /*
+ * This may release the vm if application already close the drm node,
+ * do it as last step after memory unmapped.
+ */
+ if (pdd->drm_file)
+ fput(pdd->drm_file);
+
kfree(pdd);
p->pdds[i] = NULL;
}
</pre>
</blockquote>
</body>
</html>