Skip to content

Commit b928ecf

Browse files
erichuang22alexdeucher
authored andcommitted
Revert "Revert "drm/amdkfd: Add memory sync before TLB flush on unmap""
This reverts commit 4bba567. Revert reason: The issue has been resolved. Signed-off-by: Eric Huang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 3b2b254 commit b928ecf

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,20 +1566,37 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,
15661566
i, args->n_devices);
15671567
goto unmap_memory_from_gpu_failed;
15681568
}
1569-
kfd_flush_tlb(peer_pdd, TLB_FLUSH_HEAVYWEIGHT);
15701569
args->n_success = i+1;
15711570
}
1572-
kfree(devices_arr);
1573-
15741571
mutex_unlock(&p->mutex);
15751572

1573+
err = amdgpu_amdkfd_gpuvm_sync_memory(dev->kgd, (struct kgd_mem *) mem, true);
1574+
if (err) {
1575+
pr_debug("Sync memory failed, wait interrupted by user signal\n");
1576+
goto sync_memory_failed;
1577+
}
1578+
1579+
/* Flush TLBs after waiting for the page table updates to complete */
1580+
for (i = 0; i < args->n_devices; i++) {
1581+
peer = kfd_device_by_id(devices_arr[i]);
1582+
if (WARN_ON_ONCE(!peer))
1583+
continue;
1584+
peer_pdd = kfd_get_process_device_data(peer, p);
1585+
if (WARN_ON_ONCE(!peer_pdd))
1586+
continue;
1587+
kfd_flush_tlb(peer_pdd, TLB_FLUSH_HEAVYWEIGHT);
1588+
}
1589+
1590+
kfree(devices_arr);
1591+
15761592
return 0;
15771593

15781594
bind_process_to_device_failed:
15791595
get_mem_obj_from_handle_failed:
15801596
unmap_memory_from_gpu_failed:
15811597
mutex_unlock(&p->mutex);
15821598
copy_from_user_failed:
1599+
sync_memory_failed:
15831600
kfree(devices_arr);
15841601
return err;
15851602
}

0 commit comments

Comments
 (0)