drm/amdkfd: avoid double alloc by ioctl_alloc and svm
Subsystems (3)
PATCH 1/1 drm/amdkfd: avoid double alloc by ioctl_alloc and svm
[Why]
Avoid duplicated memory allocation for address ranges that have been already allocated by either ioctl_alloc_memory_of_gpu or SVM mechanisms first.
[How]
For SVM first allocations
Check if the address range passed into ioctl memory alloc does not exist already in the kfd_process svms->objects interval tree.
For ioctl_alloc_memory_of_gpu first allocations Look for the address range into the interval tree VA from the VM inside of each pdds used in a kfd_process.
Signed-off-by Alex Sierra <[email protected]>
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 11 +++++ drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 63 ++++++++++++++++++------ 2 files changed, 59 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +11 -0
@@ -1259,6 +1259,17 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,if (args->size ==0 )return -EINVAL ; +#if IS_ENABLED (CONFIG_HSA_AMD_SVM ) +struct svm_range_list *svms = &p->svms; + +if (interval_tree_iter_first (&svms->objects, + args->va_addr >>PAGE_SHIFT , + (args->va_addr + args->size -1 ) >>PAGE_SHIFT )) { +pr_info ("Address: 0x%llx already allocated by SVM\n" , + args->va_addr); +return -EADDRINUSE ; + } +#endif dev =kfd_device_by_id (args->gpu_id);if (!dev)return -EINVAL ;
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +48 -15
109 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx