Commit cc9d82fc authored by Yang Wang's avatar Yang Wang Committed by Alex Deucher

drm/amdkfd: use kvcalloc() instead of kvmalloc() in kfd_migrate

simplify programming with existing functions.
Signed-off-by: default avatarYang Wang <KevinYang.Wang@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e15c9d06
...@@ -410,7 +410,6 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange, ...@@ -410,7 +410,6 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange,
struct migrate_vma migrate; struct migrate_vma migrate;
unsigned long cpages = 0; unsigned long cpages = 0;
dma_addr_t *scratch; dma_addr_t *scratch;
size_t size;
void *buf; void *buf;
int r = -ENOMEM; int r = -ENOMEM;
...@@ -421,9 +420,9 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange, ...@@ -421,9 +420,9 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange,
migrate.flags = MIGRATE_VMA_SELECT_SYSTEM; migrate.flags = MIGRATE_VMA_SELECT_SYSTEM;
migrate.pgmap_owner = SVM_ADEV_PGMAP_OWNER(adev); migrate.pgmap_owner = SVM_ADEV_PGMAP_OWNER(adev);
size = 2 * sizeof(*migrate.src) + sizeof(uint64_t) + sizeof(dma_addr_t); buf = kvcalloc(npages,
size *= npages; 2 * sizeof(*migrate.src) + sizeof(uint64_t) + sizeof(dma_addr_t),
buf = kvmalloc(size, GFP_KERNEL | __GFP_ZERO); GFP_KERNEL);
if (!buf) if (!buf)
goto out; goto out;
...@@ -665,7 +664,6 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange, ...@@ -665,7 +664,6 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
struct dma_fence *mfence = NULL; struct dma_fence *mfence = NULL;
struct migrate_vma migrate; struct migrate_vma migrate;
dma_addr_t *scratch; dma_addr_t *scratch;
size_t size;
void *buf; void *buf;
int r = -ENOMEM; int r = -ENOMEM;
...@@ -676,9 +674,10 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange, ...@@ -676,9 +674,10 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
migrate.flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE; migrate.flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE;
migrate.pgmap_owner = SVM_ADEV_PGMAP_OWNER(adev); migrate.pgmap_owner = SVM_ADEV_PGMAP_OWNER(adev);
size = 2 * sizeof(*migrate.src) + sizeof(uint64_t) + sizeof(dma_addr_t); buf = kvcalloc(npages,
size *= npages; 2 * sizeof(*migrate.src) + sizeof(uint64_t) + sizeof(dma_addr_t),
buf = kvmalloc(size, GFP_KERNEL | __GFP_ZERO); GFP_KERNEL);
if (!buf) if (!buf)
goto out; goto out;
......
...@@ -149,8 +149,7 @@ svm_range_dma_map_dev(struct amdgpu_device *adev, struct svm_range *prange, ...@@ -149,8 +149,7 @@ svm_range_dma_map_dev(struct amdgpu_device *adev, struct svm_range *prange,
int i, r; int i, r;
if (!addr) { if (!addr) {
addr = kvmalloc_array(prange->npages, sizeof(*addr), addr = kvcalloc(prange->npages, sizeof(*addr), GFP_KERNEL);
GFP_KERNEL | __GFP_ZERO);
if (!addr) if (!addr)
return -ENOMEM; return -ENOMEM;
prange->dma_addr[gpuidx] = addr; prange->dma_addr[gpuidx] = addr;
......
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