From 10cb2c44e19693b5c7943a0a9cd944ee7c4ca50d Mon Sep 17 00:00:00 2001 From: Lan Xiao Date: Fri, 23 Jun 2017 16:06:48 -0400 Subject: [PATCH 1302/4131] drm/amd: Implement parallel memory mapping on mGPUs Alter the KFD-KGD interface to optimize multi-GPU memory mappings to work concurrently instead of sequentially. Return the fences during the process, wait for all fences after the mappings are done. The fences are stored in the associated kgd_mem object. This change also enables interruptible waiting with proper signal handling Change-Id: I9ae7f4bd54165b14dd5b37df5df6516aa80cba83 Signed-off-by: Lan Xiao --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 7 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 64a4373..dbc3afd 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1398,6 +1398,12 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, pr_err("Failed to map\n"); } + err = dev->kfd2kgd->sync_memory(dev->kgd, (struct kgd_mem *) mem, true); + if (err) { + pr_debug("Sync memory failed, wait interrupted by user signal\n"); + goto sync_memory_failed; + } + if (args->device_ids_array_size > 0 && devices_arr) kfree(devices_arr); @@ -1407,6 +1413,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, up_write(&p->lock); get_mem_obj_from_handle_failed: copy_from_user_failed: +sync_memory_failed: kfree(devices_arr); return err; } diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index d1ef118..f5e2282 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -136,6 +136,13 @@ static int kfd_process_alloc_gpuvm(struct kfd_process *p, if (err) goto err_map_mem; + err = kdev->kfd2kgd->sync_memory(kdev->kgd, (struct kgd_mem *) mem, + true); + if (err) { + pr_debug("Sync memory failed, wait interrupted by user signal\n"); + goto sync_memory_failed; + } + /* Create an obj handle so kfd_process_device_remove_obj_handle * will take care of the bo removal when the process finishes. * We do not need to take p->lock, because the process is just @@ -151,6 +158,7 @@ static int kfd_process_alloc_gpuvm(struct kfd_process *p, return err; free_gpuvm: +sync_memory_failed: kfd_process_free_gpuvm(mem, pdd); return err; -- 2.7.4