From 791f2728d4030ec8f453463fba95647ce19767b9 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 23 Jun 2013 09:51:20 +0100 Subject: Convert to use bmm_malloc_aligned_phys() API BMM internally allocates memory by physical address, and then maps it to a virtual address. Rather than using an API which returns the virtual address which then has to be re-translated back to a physical address, use an API which gets us all the information we need in one go. This gets rid of the bmm_get_paddr() step when allocating memory. --- configure.ac | 2 +- vmeta_lib.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index d93af29..5b8ab19 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AC_USE_SYSTEM_EXTENSIONS LT_PREREQ([2.2]) LT_INIT -PKG_CHECK_MODULES(LIBBMM, libbmm) +PKG_CHECK_MODULES(LIBBMM, libbmm >= 1.1.0) AC_SUBST(LIBBMM_CFLAGS) AC_SUBST(LIBBMM_LIBS) diff --git a/vmeta_lib.c b/vmeta_lib.c index 01ae124..0fbe76e 100644 --- a/vmeta_lib.c +++ b/vmeta_lib.c @@ -167,6 +167,7 @@ void vdec_os_api_dma_free(void *ptr) static void *vmeta_bmm_malloc_aligned(UNSG32 size, UNSG32 align, UNSG32 *phys, int attr) { + unsigned long paddr; void *ptr; if (size == 0) @@ -175,16 +176,17 @@ static void *vmeta_bmm_malloc_aligned(UNSG32 size, UNSG32 align, UNSG32 *phys, i dbg_printf(VDEC_DEBUG_MEM, "%s: size 0x%x attr %u align %u\n", __FUNCTION__, size, attr, align); - ptr = bmm_malloc_aligned(size, attr, align); + ptr = bmm_malloc_aligned_phys(size, attr, align, &paddr); if (!ptr) { dbg_printf(VDEC_DEBUG_MEM, "%s: not enough memory\n", __FUNCTION__); return NULL; } - *phys = (UNSG32)bmm_get_paddr(ptr); + *phys = paddr; - dbg_printf(VDEC_DEBUG_MEM, "%s: ptr: 0x%x\n", __FUNCTION__, ptr); + dbg_printf(VDEC_DEBUG_MEM, "%s: virt=%p phys=0x%08lx\n", + __FUNCTION__, ptr, paddr); return ptr; } -- cgit