From 720003e70b07bffdae677d501f6063bd1da2125b Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 23 Oct 2012 14:17:45 +0100 Subject: Convert to use bmm_malloc_aligned() The bmm subsystem can now provide us with pre-aligned memory allocations, so let's use the new interface to avoid having to do our own alignment in the vmeta library. --- vmeta_lib.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/vmeta_lib.c b/vmeta_lib.c index 8d5bb96..81a8abc 100644 --- a/vmeta_lib.c +++ b/vmeta_lib.c @@ -163,39 +163,26 @@ void *vdec_os_api_vmalloc(UNSG32 size, UNSG32 align) void vdec_os_api_dma_free(void *ptr) { - unsigned int offset; - unsigned int *paddr; - - paddr = ptr; - offset = *(paddr - 1); - paddr = (unsigned int *)((unsigned int)paddr - offset); - bmm_free((void *)paddr); + bmm_free(ptr); } static void *vmeta_bmm_malloc_aligned(UNSG32 size, UNSG32 align, UNSG32 *phys, int attr) { - unsigned int tmp, *ptr; + void *ptr; if (size == 0) return NULL; - dbg_printf(VDEC_DEBUG_MEM, "%s: size 0x%x attr %u\n", - __FUNCTION__, size, attr); + dbg_printf(VDEC_DEBUG_MEM, "%s: size 0x%x attr %u align %u\n", + __FUNCTION__, size, attr, align); - align = ALIGN(align, sizeof(int)); - size += align; - ptr = bmm_malloc(size, attr); + ptr = bmm_malloc_aligned(size, attr, align); if (!ptr) { dbg_printf(VDEC_DEBUG_MEM, "%s: not enough memory\n", __FUNCTION__); return NULL; } - tmp = (unsigned int)((unsigned int)(ptr) & (align - 1)); - tmp = (unsigned int)(align - tmp); - ptr = (unsigned int *)((unsigned int)ptr + tmp); - *(ptr - 1) = tmp; - *phys = (UNSG32)bmm_get_paddr(ptr); dbg_printf(VDEC_DEBUG_MEM, "%s: ptr: 0x%x\n", __FUNCTION__, ptr); -- cgit