author | binqi.zhang <binqi.zhang@amlogic.com> | 2017-09-25 12:36:25 (GMT) |
---|---|---|
committer | binqi.zhang <binqi.zhang@amlogic.com> | 2017-09-26 06:52:32 (GMT) |
commit | 85fc029295b223b7c46c355dfce4cbb74f7e9c54 (patch) | |
tree | 9e43a1eae2045d7e661a22b7ab5f70a59add90cd | |
parent | 6fb782649c2701888ff9ec64a93a5c2a48b70126 (diff) | |
download | gralloc-85fc029295b223b7c46c355dfce4cbb74f7e9c54.zip gralloc-85fc029295b223b7c46c355dfce4cbb74f7e9c54.tar.gz gralloc-85fc029295b223b7c46c355dfce4cbb74f7e9c54.tar.bz2 |
garalloc: avoid allocating buffer from ion chunk heap again and again. [1/1]
PD#151620
avoid allocating buffer from ion chunk heap again and again if the board doesn't support chunk heap
Change-Id: I22caedf795ce0dd847587852823a72046d95edc9
-rw-r--r-- | alloc_ion.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/alloc_ion.cpp b/alloc_ion.cpp index 456844d..aefdb2f 100644 --- a/alloc_ion.cpp +++ b/alloc_ion.cpp @@ -33,18 +33,21 @@ #include "framebuffer_device.h" #include <linux/ion.h> #include <ion/ion.h> +#include <linux/errno.h> #if PLATFORM_SDK_VERSION >= 24 #include "gralloc_usage_ext.h" #endif +bool isChunkHeapAvail = true; + int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle) { private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); ion_user_handle_t ion_hnd; unsigned char *cpu_ptr = NULL; int shared_fd; - int ret; + int ret = -1; unsigned int heap_mask; int ion_flags = 0; static int support_protected = 1; /* initially, assume we support protected memory */ @@ -128,16 +131,21 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand && !(usage & GRALLOC_USAGE_AML_VIDEO_OVERLAY || usage & GRALLOC_USAGE_AML_OMX_OVERLAY)) { layerAllocContinousBuf = true; - ret = ion_alloc(m->ion_client, size, 0, + if (true == isChunkHeapAvail) { + ret = ion_alloc(m->ion_client, size, 0, 1<<ION_HEAP_TYPE_CHUNK, ion_flags, &ion_hnd); + if (ret == -ENODEV) { + isChunkHeapAvail = false; + } + } if (ret != 0) { ALOGV("(%d) Failed to alloc ion chunk mem, alloc from ion cma buffer.", ret); ret = ion_alloc(m->ion_client, size, 0, - 1<<ION_HEAP_TYPE_DMA, ion_flags, &ion_hnd); + 1<<ION_HEAP_TYPE_DMA, ion_flags & (~ION_FLAG_CACHED), &ion_hnd); } if (ret != 0) { layerAllocContinousBuf = false; - ALOGD("(%d) Failed to alloc ion cma mem, alloc from system ion buffer.", ret); + ALOGV("(%d) Failed to alloc ion cma|chunk mem, alloc from system ion buffer.", ret); ret = ion_alloc(m->ion_client, size, 0, heap_mask, ion_flags, &ion_hnd); } |