msm: kgsl: Fix kvcalloc() calls

Depending on user input the size of the page struct that we try to
allocate with kvcalloc() could be way too big. Add __GFP_NOWARN and
__GFP_NORETRY to keep from invoking the OOM killer in these cases.

Also remove an unneeded usage of kvmalloc() since the maximum allocation
size for the HFI command will only be 1k as enforced on the previous
line.

Change-Id: Ic0dedbad8d09544bdc0070b9b797616ee1f672d4
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
This commit is contained in:
Jordan Crouse 2020-09-10 09:59:48 -06:00
commit c5f2680903
3 changed files with 6 additions and 4 deletions

View file

@ -1200,7 +1200,7 @@ int a6xx_hwsched_submit_cmdobj(struct adreno_device *adreno_dev,
if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE))
return -EMSGSIZE;
cmd = kvmalloc(cmd_sizebytes, GFP_KERNEL);
cmd = kmalloc(cmd_sizebytes, GFP_KERNEL);
if (cmd == NULL)
return -ENOMEM;
@ -1264,7 +1264,7 @@ skipib:
adreno_profile_submit_time(&time);
free:
kvfree(cmd);
kfree(cmd);
return ret;
}

View file

@ -2346,7 +2346,8 @@ static int memdesc_sg_virt(struct kgsl_memdesc *memdesc, struct file *vmfile)
if (sglen == 0 || sglen >= LONG_MAX)
return -EINVAL;
pages = kvcalloc(sglen, sizeof(*pages), GFP_KERNEL);
pages = kvcalloc(sglen, sizeof(*pages),
GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
if (pages == NULL)
return -ENOMEM;

View file

@ -442,7 +442,8 @@ int kgsl_pool_alloc_pages(u64 size, struct page ***pages, struct device *dev)
{
int count = 0;
int npages = size >> PAGE_SHIFT;
struct page **local = kvcalloc(npages, sizeof(*local), GFP_KERNEL);
struct page **local = kvcalloc(npages, sizeof(*local),
GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
u32 page_size, align;
u64 len = size;