mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: fix buddy_allocator_init size=0 bug
Previously initializing buddy_allocator with size=0 initialized large memory block. With fixes in buddy_allocator_init() function, size = 0 triggered segmentation fault and so size was temporarily updated to fixed value. This patch updates buddy_allocator_init() function to return error if requested size of buddy_allocator is zero. As kernel VMA is absent for VGPU, this patch also updates nvgpu_vm_do_init() function to not allocate kernel VMA with size = 0. Jira NVGPU-3005 Change-Id: I568fbbff6ac2c66395d1dc5a4b35304c7f4002fb Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2113190 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
a4a7366d8d
commit
cfd6d0a97c
@@ -1325,10 +1325,8 @@ int nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Needs to be fixed, return -EINVAL*/
|
|
||||||
if (size == 0U) {
|
if (size == 0U) {
|
||||||
/* Setting to fixed size 1G to avoid further issues */
|
return -EINVAL;
|
||||||
size = 0x40000000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this is to manage a GVA space we need a VM. */
|
/* If this is to manage a GVA space we need a VM. */
|
||||||
|
|||||||
@@ -503,21 +503,25 @@ int nvgpu_vm_do_init(struct mm_gk20a *mm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Kernel VMA. Must always exist for an address space.
|
* Kernel VMA.
|
||||||
|
* Note: Kernel VMA does not exist for VGPU.
|
||||||
*/
|
*/
|
||||||
(void) strcpy(alloc_name, "gk20a_");
|
if (kernel_vma_start < kernel_vma_limit) {
|
||||||
(void) strcat(alloc_name, name);
|
(void) strcpy(alloc_name, "gk20a_");
|
||||||
(void) strcat(alloc_name, "-sys");
|
(void) strcat(alloc_name, name);
|
||||||
err = nvgpu_allocator_init(g, &vm->kernel,
|
(void) strcat(alloc_name, "-sys");
|
||||||
vm, alloc_name,
|
err = nvgpu_allocator_init(g, &vm->kernel,
|
||||||
kernel_vma_start,
|
vm, alloc_name,
|
||||||
kernel_vma_limit - kernel_vma_start,
|
kernel_vma_start,
|
||||||
SZ_4K,
|
kernel_vma_limit -
|
||||||
GPU_BALLOC_MAX_ORDER,
|
kernel_vma_start,
|
||||||
kernel_vma_flags,
|
SZ_4K,
|
||||||
BUDDY_ALLOCATOR);
|
GPU_BALLOC_MAX_ORDER,
|
||||||
if (err != 0) {
|
kernel_vma_flags,
|
||||||
goto clean_up_allocators;
|
BUDDY_ALLOCATOR);
|
||||||
|
if (err != 0) {
|
||||||
|
goto clean_up_allocators;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vm->mapped_buffers = NULL;
|
vm->mapped_buffers = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user