Commit d0e63b34 authored by Kent Russell's avatar Kent Russell Committed by Alex Deucher

drm/amdkfd: Use kvmalloc instead of kmalloc for VCRAT

Since we're dynamically allocating the CPU VCRAT, use kvmalloc in case
the allocation size is huge.
Signed-off-by: default avatarKent Russell <kent.russell@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e8f58ee1
...@@ -797,7 +797,8 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size) ...@@ -797,7 +797,8 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)
return -ENODATA; return -ENODATA;
} }
pcrat_image = kmemdup(crat_table, crat_table->length, GFP_KERNEL); pcrat_image = kvmalloc(crat_table->length, GFP_KERNEL);
memcpy(pcrat_image, crat_table, crat_table->length);
if (!pcrat_image) if (!pcrat_image)
return -ENOMEM; return -ENOMEM;
...@@ -1383,7 +1384,7 @@ int kfd_create_crat_image_virtual(void **crat_image, size_t *size, ...@@ -1383,7 +1384,7 @@ int kfd_create_crat_image_virtual(void **crat_image, size_t *size,
num_nodes * (sizeof(struct crat_subtype_computeunit) + num_nodes * (sizeof(struct crat_subtype_computeunit) +
sizeof(struct crat_subtype_memory) + sizeof(struct crat_subtype_memory) +
(num_nodes - 1) * sizeof(struct crat_subtype_iolink)); (num_nodes - 1) * sizeof(struct crat_subtype_iolink));
pcrat_image = kmalloc(dyn_size, GFP_KERNEL); pcrat_image = kvmalloc(dyn_size, GFP_KERNEL);
if (!pcrat_image) if (!pcrat_image)
return -ENOMEM; return -ENOMEM;
*size = dyn_size; *size = dyn_size;
...@@ -1393,7 +1394,7 @@ int kfd_create_crat_image_virtual(void **crat_image, size_t *size, ...@@ -1393,7 +1394,7 @@ int kfd_create_crat_image_virtual(void **crat_image, size_t *size,
case COMPUTE_UNIT_GPU: case COMPUTE_UNIT_GPU:
if (!kdev) if (!kdev)
return -EINVAL; return -EINVAL;
pcrat_image = kmalloc(VCRAT_SIZE_FOR_GPU, GFP_KERNEL); pcrat_image = kvmalloc(VCRAT_SIZE_FOR_GPU, GFP_KERNEL);
if (!pcrat_image) if (!pcrat_image)
return -ENOMEM; return -ENOMEM;
*size = VCRAT_SIZE_FOR_GPU; *size = VCRAT_SIZE_FOR_GPU;
...@@ -1412,7 +1413,7 @@ int kfd_create_crat_image_virtual(void **crat_image, size_t *size, ...@@ -1412,7 +1413,7 @@ int kfd_create_crat_image_virtual(void **crat_image, size_t *size,
if (!ret) if (!ret)
*crat_image = pcrat_image; *crat_image = pcrat_image;
else else
kfree(pcrat_image); kvfree(pcrat_image);
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