Commit e09d4fc8 authored by Oak Zeng's avatar Oak Zeng Committed by Alex Deucher

drm/amdkfd: Allocate gws on device initialization

On device initialization, KFD allocates all (64) gws which
is shared by all KFD processes.
Signed-off-by: default avatarOak Zeng <Oak.Zeng@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent ca66fb8f
...@@ -552,6 +552,13 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, ...@@ -552,6 +552,13 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
} else } else
kfd->max_proc_per_quantum = hws_max_conc_proc; kfd->max_proc_per_quantum = hws_max_conc_proc;
/* Allocate global GWS that is shared by all KFD processes */
if (hws_gws_support && amdgpu_amdkfd_alloc_gws(kfd->kgd,
amdgpu_amdkfd_get_num_gws(kfd->kgd), &kfd->gws)) {
dev_err(kfd_device, "Could not allocate %d gws\n",
amdgpu_amdkfd_get_num_gws(kfd->kgd));
goto out;
}
/* calculate max size of mqds needed for queues */ /* calculate max size of mqds needed for queues */
size = max_num_of_queues_per_device * size = max_num_of_queues_per_device *
kfd->device_info->mqd_size_aligned; kfd->device_info->mqd_size_aligned;
...@@ -575,7 +582,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, ...@@ -575,7 +582,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
&kfd->gtt_start_gpu_addr, &kfd->gtt_start_cpu_ptr, &kfd->gtt_start_gpu_addr, &kfd->gtt_start_cpu_ptr,
false)) { false)) {
dev_err(kfd_device, "Could not allocate %d bytes\n", size); dev_err(kfd_device, "Could not allocate %d bytes\n", size);
goto out; goto alloc_gtt_mem_failure;
} }
dev_info(kfd_device, "Allocated %d bytes on gart\n", size); dev_info(kfd_device, "Allocated %d bytes on gart\n", size);
...@@ -645,6 +652,9 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, ...@@ -645,6 +652,9 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
kfd_gtt_sa_fini(kfd); kfd_gtt_sa_fini(kfd);
kfd_gtt_sa_init_error: kfd_gtt_sa_init_error:
amdgpu_amdkfd_free_gtt_mem(kfd->kgd, kfd->gtt_mem); amdgpu_amdkfd_free_gtt_mem(kfd->kgd, kfd->gtt_mem);
alloc_gtt_mem_failure:
if (hws_gws_support)
amdgpu_amdkfd_free_gws(kfd->kgd, kfd->gws);
dev_err(kfd_device, dev_err(kfd_device,
"device %x:%x NOT added due to errors\n", "device %x:%x NOT added due to errors\n",
kfd->pdev->vendor, kfd->pdev->device); kfd->pdev->vendor, kfd->pdev->device);
...@@ -662,6 +672,8 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd) ...@@ -662,6 +672,8 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd)
kfd_doorbell_fini(kfd); kfd_doorbell_fini(kfd);
kfd_gtt_sa_fini(kfd); kfd_gtt_sa_fini(kfd);
amdgpu_amdkfd_free_gtt_mem(kfd->kgd, kfd->gtt_mem); amdgpu_amdkfd_free_gtt_mem(kfd->kgd, kfd->gtt_mem);
if (hws_gws_support)
amdgpu_amdkfd_free_gws(kfd->kgd, kfd->gws);
} }
kfree(kfd); kfree(kfd);
......
...@@ -289,6 +289,9 @@ struct kfd_dev { ...@@ -289,6 +289,9 @@ struct kfd_dev {
/* Compute Profile ref. count */ /* Compute Profile ref. count */
atomic_t compute_profile; atomic_t compute_profile;
/* Global GWS resource shared b/t processes*/
void *gws;
}; };
enum kfd_mempool { enum kfd_mempool {
......
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