diff options
author | David Sin <davidsin@ti.com> | 2011-04-07 08:41:36 +0100 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2011-04-07 08:41:36 +0100 |
commit | 3fa58ffbdb8eca0903ba8fefd9319510fec979e9 (patch) | |
tree | ba0ccd9835ea84afef292f047ed449a6142b3c0e /drivers/media/video/tiler | |
parent | e994cdba14621ec608a7132723847fb73c8c4894 (diff) |
TILER: Move dma_alloc_coherent call to tiler init
Instead of allocating and freeing PAT page array
memory each time, allocate 128k upfront and reuse the
memory. This will avoid the possibilty of not being
able to obtain the memory after driver initialization.
Signed-off-by: David Sin <davidsin@ti.com>
Diffstat (limited to 'drivers/media/video/tiler')
-rw-r--r-- | drivers/media/video/tiler/tiler-main.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/media/video/tiler/tiler-main.c b/drivers/media/video/tiler/tiler-main.c index 91e1c8540a0..a9ac6db00da 100644 --- a/drivers/media/video/tiler/tiler-main.c +++ b/drivers/media/video/tiler/tiler-main.c @@ -77,6 +77,8 @@ static struct class *tilerdev_class; static struct mutex mtx; static struct tcm *tcm[TILER_FORMATS]; static struct tmm *tmm[TILER_FORMATS]; +static u32 *dmac_va; +static dma_addr_t dmac_pa; /* * TMM connectors @@ -85,34 +87,24 @@ static struct tmm *tmm[TILER_FORMATS]; static s32 refill_pat(struct tmm *tmm, struct tcm_area *area, u32 *ptr) { s32 res = 0; - s32 size = tcm_sizeof(*area) * sizeof(*ptr); - u32 *page; - dma_addr_t page_pa; struct pat_area p_area = {0}; struct tcm_area slice, area_s; - /* must be a 16-byte aligned physical address */ - page = dma_alloc_coherent(NULL, size, &page_pa, GFP_ATOMIC); - if (!page) - return -ENOMEM; - tcm_for_each_slice(slice, *area, area_s) { p_area.x0 = slice.p0.x; p_area.y0 = slice.p0.y; p_area.x1 = slice.p1.x; p_area.y1 = slice.p1.y; - memcpy(page, ptr, sizeof(*ptr) * tcm_sizeof(slice)); + memcpy(dmac_va, ptr, sizeof(*ptr) * tcm_sizeof(slice)); ptr += tcm_sizeof(slice); - if (tmm_map(tmm, p_area, page_pa)) { + if (tmm_map(tmm, p_area, dmac_pa)) { res = -EFAULT; break; } } - dma_free_coherent(NULL, size, page, page_pa); - return res; } @@ -1148,6 +1140,15 @@ static s32 __init tiler_init(void) tmm[TILFMT_32BIT] = tmm_pat; tmm[TILFMT_PAGE] = tmm_pat; + /* + * Array of physical pages for PAT programming, which must be a 16-byte + * aligned physical address. + */ + dmac_va = dma_alloc_coherent(NULL, tiler.width * tiler.height * + sizeof(*dmac_va), &dmac_pa, GFP_ATOMIC); + if (!dmac_va) + return -ENOMEM; + tiler.nv12_packed = tcm[TILFMT_8BIT] == tcm[TILFMT_16BIT]; tiler_device = kmalloc(sizeof(*tiler_device), GFP_KERNEL); @@ -1218,6 +1219,9 @@ static void __exit tiler_exit(void) mutex_unlock(&mtx); + dma_free_coherent(NULL, tiler.width * tiler.height * sizeof(*dmac_va), + dmac_va, dmac_pa); + /* close containers only once */ for (i = TILFMT_MIN; i <= TILFMT_MAX; i++) { /* remove identical containers (tmm is unique per tcm) */ |