Commit 95de7f26 authored by Ramesh Errabolu's avatar Ramesh Errabolu Committed by Alex Deucher

drm/amdkfd: Access gpuvm_export_dmabuf() API to get Dmabuf

Directly invoking the function amdgpu_gem_prime_export() from within
KFD is not correct. By utilizing the KFD API to obtain Dmabuf, the
implementation can prevent the creation of multiple instances of
struct dma_buf.
Signed-off-by: default avatarRamesh Errabolu <Ramesh.Errabolu@amd.com>
Reviewed-by: default avatarDavid Francis <David.Francis@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent a90d36a4
...@@ -1852,15 +1852,14 @@ static uint32_t get_process_num_bos(struct kfd_process *p) ...@@ -1852,15 +1852,14 @@ static uint32_t get_process_num_bos(struct kfd_process *p)
return num_of_bos; return num_of_bos;
} }
static int criu_get_prime_handle(struct drm_gem_object *gobj, int flags, static int criu_get_prime_handle(struct kgd_mem *mem, int flags,
u32 *shared_fd) u32 *shared_fd)
{ {
struct dma_buf *dmabuf; struct dma_buf *dmabuf;
int ret; int ret;
dmabuf = amdgpu_gem_prime_export(gobj, flags); ret = amdgpu_amdkfd_gpuvm_export_dmabuf(mem, &dmabuf);
if (IS_ERR(dmabuf)) { if (ret) {
ret = PTR_ERR(dmabuf);
pr_err("dmabuf export failed for the BO\n"); pr_err("dmabuf export failed for the BO\n");
return ret; return ret;
} }
...@@ -1940,7 +1939,7 @@ static int criu_checkpoint_bos(struct kfd_process *p, ...@@ -1940,7 +1939,7 @@ static int criu_checkpoint_bos(struct kfd_process *p,
} }
if (bo_bucket->alloc_flags if (bo_bucket->alloc_flags
& (KFD_IOC_ALLOC_MEM_FLAGS_VRAM | KFD_IOC_ALLOC_MEM_FLAGS_GTT)) { & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM | KFD_IOC_ALLOC_MEM_FLAGS_GTT)) {
ret = criu_get_prime_handle(&dumper_bo->tbo.base, ret = criu_get_prime_handle(kgd_mem,
bo_bucket->alloc_flags & bo_bucket->alloc_flags &
KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ? DRM_RDWR : 0, KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ? DRM_RDWR : 0,
&bo_bucket->dmabuf_fd); &bo_bucket->dmabuf_fd);
...@@ -2402,7 +2401,7 @@ static int criu_restore_bo(struct kfd_process *p, ...@@ -2402,7 +2401,7 @@ static int criu_restore_bo(struct kfd_process *p,
/* create the dmabuf object and export the bo */ /* create the dmabuf object and export the bo */
if (bo_bucket->alloc_flags if (bo_bucket->alloc_flags
& (KFD_IOC_ALLOC_MEM_FLAGS_VRAM | KFD_IOC_ALLOC_MEM_FLAGS_GTT)) { & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM | KFD_IOC_ALLOC_MEM_FLAGS_GTT)) {
ret = criu_get_prime_handle(&kgd_mem->bo->tbo.base, DRM_RDWR, ret = criu_get_prime_handle(kgd_mem, DRM_RDWR,
&bo_bucket->dmabuf_fd); &bo_bucket->dmabuf_fd);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment