<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 2024-04-08 3:55, Christian König
wrote:<br>
</div>
<blockquote type="cite" cite="mid:0bc7bc06-0df8-4b19-b4db-06701c2fa9d1@amd.com">Am
07.04.24 um 06:52 schrieb Lang Yu:
<br>
<blockquote type="cite">When VM is in evicting state,
amdgpu_vm_update_range would return -EBUSY.
<br>
Then restore_process_worker runs into a dead loop.
<br>
<br>
Fixes: 2fdba514ad5a ("drm/amdgpu: Auto-validate DMABuf imports
in compute VMs")
<br>
</blockquote>
<br>
Mhm, while it would be good to have this case handled as error it
should never occur in practice since we should have validated the
VM before validating the DMA-bufs.
<br>
<br>
@Felix isn't that something we have taken care of?
<br>
</blockquote>
<p>The problem I saw when I implemented Auto-validate was, that
migration of a BO invalidates its DMABuf attachments. So I need to
validate the DMABuf attachments after validating the BOs they
attach to. This auto-validation happens in amdgpu_vm_validate. So
I needed to do the VM validation after the BO validation. The
problem now seems to be that the BO validation happens in the same
loop as the page table update. And the page table update fails if
the VM is not valid.</p>
<p>I never saw this problem in my testing, probably because I never
got my page tables evicted?</p>
<p>Anyway, I think the solution is to split the BO validation and
page table update into two separate loops in
amdgpu_amdkfd_restore_process_pos:</p>
<ol>
<li>Validate BOs</li>
<li>Validate VM (and DMABuf attachments)</li>
<li>Update page tables for the BOs validated above<br>
</li>
</ol>
<p>Regards,<br>
Felix</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:0bc7bc06-0df8-4b19-b4db-06701c2fa9d1@amd.com">
<br>
Regards,
<br>
Christian.
<br>
<br>
<br>
<blockquote type="cite">
<br>
Signed-off-by: Lang Yu <a class="moz-txt-link-rfc2396E" href="mailto:Lang.Yu@amd.com"><Lang.Yu@amd.com></a>
<br>
---
<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++++++
<br>
1 file changed, 6 insertions(+)
<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
<br>
index 0ae9fd844623..8c71fe07807a 100644
<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
<br>
@@ -2900,6 +2900,12 @@ int
amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence __rcu *
<br>
amdgpu_sync_create(&sync_obj);
<br>
+ ret = process_validate_vms(process_info, NULL);
<br>
+ if (ret) {
<br>
+ pr_debug("Validating VMs failed, ret: %d\n", ret);
<br>
+ goto validate_map_fail;
<br>
+ }
<br>
+
<br>
/* Validate BOs and map them to GPUVM (update VM page
tables). */
<br>
list_for_each_entry(mem,
&process_info->kfd_bo_list,
<br>
validate_list) {
<br>
</blockquote>
<br>
</blockquote>
</body>
</html>