Commit cac9f420 authored by Timo Aaltonen's avatar Timo Aaltonen Committed by Kamal Mostafa

UBUNTU: SAUCE: drm: Introduce drm_malloc_gfp()

BugLink: http://bugs.launchpad.net/bugs/1599109

Backport header bits of

commit f2a85e19
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Apr 8 12:11:13 2016 +0100

    drm,i915: Introduce drm_malloc_gfp()
Signed-off-by: default avatarTimo Aaltonen <timo.aaltonen@canonical.com>
Acked-by: default avatarTim Gardner <tim.gardner@canonical.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent d8e25b5c
......@@ -54,6 +54,25 @@ static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size)
GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
}
static __inline__ void *drm_malloc_gfp(size_t nmemb, size_t size, gfp_t gfp)
{
if (size != 0 && nmemb > SIZE_MAX / size)
return NULL;
if (size * nmemb <= PAGE_SIZE)
return kmalloc(nmemb * size, gfp);
if (gfp & __GFP_RECLAIMABLE) {
void *ptr = kmalloc(nmemb * size,
gfp | __GFP_NOWARN | __GFP_NORETRY);
if (ptr)
return ptr;
}
return __vmalloc(size * nmemb,
gfp | __GFP_HIGHMEM, PAGE_KERNEL);
}
static __inline void drm_free_large(void *ptr)
{
kvfree(ptr);
......
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