aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sin <davidsin@ti.com>2010-07-01 12:11:49 -0400
committerPaolo Pisati <paolo.pisati@canonical.com>2012-08-17 04:18:59 -0400
commit7b2a1fc64d491dc81ded5dc4aaa5db9954d454fc (patch)
tree5adcf16d287784048abb6f4e3beae1cf25f6d930
parent0f0cbb2ac635158cfb0eb0abe4b0edec07428242 (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>
-rw-r--r--drivers/media/video/tiler/tiler-main.c28
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;
77static struct mutex mtx; 77static struct mutex mtx;
78static struct tcm *tcm[TILER_FORMATS]; 78static struct tcm *tcm[TILER_FORMATS];
79static struct tmm *tmm[TILER_FORMATS]; 79static struct tmm *tmm[TILER_FORMATS];
80static u32 *dmac_va;
81static dma_addr_t dmac_pa;
80 82
81/* 83/*
82 * TMM connectors 84 * TMM connectors
@@ -85,34 +87,24 @@ static struct tmm *tmm[TILER_FORMATS];
85static s32 refill_pat(struct tmm *tmm, struct tcm_area *area, u32 *ptr) 87static s32 refill_pat(struct tmm *tmm, struct tcm_area *area, u32 *ptr)
86{ 88{
87 s32 res = 0; 89 s32 res = 0;
88 s32 size = tcm_sizeof(*area) * sizeof(*ptr);
89 u32 *page;
90 dma_addr_t page_pa;
91 struct pat_area p_area = {0}; 90 struct pat_area p_area = {0};
92 struct tcm_area slice, area_s; 91 struct tcm_area slice, area_s;
93 92
94 /* must be a 16-byte aligned physical address */
95 page = dma_alloc_coherent(NULL, size, &page_pa, GFP_ATOMIC);
96 if (!page)
97 return -ENOMEM;
98
99 tcm_for_each_slice(slice, *area, area_s) { 93 tcm_for_each_slice(slice, *area, area_s) {
100 p_area.x0 = slice.p0.x; 94 p_area.x0 = slice.p0.x;
101 p_area.y0 = slice.p0.y; 95 p_area.y0 = slice.p0.y;
102 p_area.x1 = slice.p1.x; 96 p_area.x1 = slice.p1.x;
103 p_area.y1 = slice.p1.y; 97 p_area.y1 = slice.p1.y;
104 98
105 memcpy(page, ptr, sizeof(*ptr) * tcm_sizeof(slice)); 99 memcpy(dmac_va, ptr, sizeof(*ptr) * tcm_sizeof(slice));
106 ptr += tcm_sizeof(slice); 100 ptr += tcm_sizeof(slice);
107 101
108 if (tmm_map(tmm, p_area, page_pa)) { 102 if (tmm_map(tmm, p_area, dmac_pa)) {
109 res = -EFAULT; 103 res = -EFAULT;
110 break; 104 break;
111 } 105 }
112 } 106 }
113 107
114 dma_free_coherent(NULL, size, page, page_pa);
115
116 return res; 108 return res;
117} 109}
118 110
@@ -1148,6 +1140,15 @@ static s32 __init tiler_init(void)
1148 tmm[TILFMT_32BIT] = tmm_pat; 1140 tmm[TILFMT_32BIT] = tmm_pat;
1149 tmm[TILFMT_PAGE] = tmm_pat; 1141 tmm[TILFMT_PAGE] = tmm_pat;
1150 1142
1143 /*
1144 * Array of physical pages for PAT programming, which must be a 16-byte
1145 * aligned physical address.
1146 */
1147 dmac_va = dma_alloc_coherent(NULL, tiler.width * tiler.height *
1148 sizeof(*dmac_va), &dmac_pa, GFP_ATOMIC);
1149 if (!dmac_va)
1150 return -ENOMEM;
1151
1151 tiler.nv12_packed = tcm[TILFMT_8BIT] == tcm[TILFMT_16BIT]; 1152 tiler.nv12_packed = tcm[TILFMT_8BIT] == tcm[TILFMT_16BIT];
1152 1153
1153 tiler_device = kmalloc(sizeof(*tiler_device), GFP_KERNEL); 1154 tiler_device = kmalloc(sizeof(*tiler_device), GFP_KERNEL);
@@ -1218,6 +1219,9 @@ static void __exit tiler_exit(void)
1218 1219
1219 mutex_unlock(&mtx); 1220 mutex_unlock(&mtx);
1220 1221
1222 dma_free_coherent(NULL, tiler.width * tiler.height * sizeof(*dmac_va),
1223 dmac_va, dmac_pa);
1224
1221 /* close containers only once */ 1225 /* close containers only once */
1222 for (i = TILFMT_MIN; i <= TILFMT_MAX; i++) { 1226 for (i = TILFMT_MIN; i <= TILFMT_MAX; i++) {
1223 /* remove identical containers (tmm is unique per tcm) */ 1227 /* remove identical containers (tmm is unique per tcm) */