OSDN Git Service

drm/amdkfd: Add sync after creating vram bo
authorEric Huang <jinhuieric.huang@amd.com>
Mon, 9 Jan 2023 19:16:42 +0000 (14:16 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 10 Jan 2023 23:04:38 +0000 (18:04 -0500)
There will be data corruption on vram allocated by svm
if the initialization is not complete and application is
writting on the memory. Adding sync to wait for the
initialization completion is to resolve this issue.

Signed-off-by: Eric Huang <jinhuieric.huang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_svm.c

index 814f998..b94d2c1 100644 (file)
@@ -570,6 +570,15 @@ svm_range_vram_node_new(struct amdgpu_device *adev, struct svm_range *prange,
                goto reserve_bo_failed;
        }
 
+       if (clear) {
+               r = amdgpu_bo_sync_wait(bo, AMDGPU_FENCE_OWNER_KFD, false);
+               if (r) {
+                       pr_debug("failed %d to sync bo\n", r);
+                       amdgpu_bo_unreserve(bo);
+                       goto reserve_bo_failed;
+               }
+       }
+
        r = dma_resv_reserve_fences(bo->tbo.base.resv, 1);
        if (r) {
                pr_debug("failed %d to reserve bo\n", r);