diff options
author | Lajos Molnar <molnar@ti.com> | 2011-06-09 17:37:41 -0400 |
---|---|---|
committer | Paolo Pisati <paolo.pisati@canonical.com> | 2012-08-17 04:19:04 -0400 |
commit | 5b191eabfebfdb7ae950c73ac325d7857b977e92 (patch) | |
tree | 92a3e7d4673c300ebfaf6e02d0002694af936a37 | |
parent | 0c75b2f788ffc43f5ddd0c75cc9c77ead7bf3abb (diff) |
OMAP: TILER: Pin the correct # of pages to 1D areas.
We may want to pin less pages to a 1D area than the area size, when we
will pre-allocate container areas to map arbitrary 1D memory to (to
make it "physically" contiguous.) This patch makes this work.
Signed-off-by: Lajos Molnar <molnar@ti.com>
-rw-r--r-- | drivers/media/video/tiler/tcm.h | 13 | ||||
-rw-r--r-- | drivers/media/video/tiler/tiler-main.c | 13 |
2 files changed, 25 insertions, 1 deletions
diff --git a/drivers/media/video/tiler/tcm.h b/drivers/media/video/tiler/tcm.h index 68b0d684dd5..11f3fa9fb2d 100644 --- a/drivers/media/video/tiler/tcm.h +++ b/drivers/media/video/tiler/tcm.h | |||
@@ -289,6 +289,19 @@ static inline u16 __tcm_sizeof(struct tcm_area *area) | |||
289 | #define tcm_aheight(area) __tcm_area_height(&(area)) | 289 | #define tcm_aheight(area) __tcm_area_height(&(area)) |
290 | #define tcm_is_in(pt, area) __tcm_is_in(&(pt), &(area)) | 290 | #define tcm_is_in(pt, area) __tcm_is_in(&(pt), &(area)) |
291 | 291 | ||
292 | /* limit a 1D area to the first N pages */ | ||
293 | static inline s32 tcm_1d_limit(struct tcm_area *a, u32 num_pg) | ||
294 | { | ||
295 | if (__tcm_sizeof(a) < num_pg) | ||
296 | return -ENOMEM; | ||
297 | if (!num_pg) | ||
298 | return -EINVAL; | ||
299 | |||
300 | a->p1.x = (a->p0.x + num_pg - 1) % a->tcm->width; | ||
301 | a->p1.y = a->p0.y + ((a->p0.x + num_pg - 1) / a->tcm->width); | ||
302 | return 0; | ||
303 | } | ||
304 | |||
292 | /** | 305 | /** |
293 | * Iterate through 2D slices of a valid area. Behaves | 306 | * Iterate through 2D slices of a valid area. Behaves |
294 | * syntactically as a for(;;) statement. | 307 | * syntactically as a for(;;) statement. |
diff --git a/drivers/media/video/tiler/tiler-main.c b/drivers/media/video/tiler/tiler-main.c index 55ab178af27..93f66777ff1 100644 --- a/drivers/media/video/tiler/tiler-main.c +++ b/drivers/media/video/tiler/tiler-main.c | |||
@@ -952,6 +952,7 @@ static struct mem_info *alloc_block_area(enum tiler_fmt fmt, u32 width, | |||
952 | static s32 pin_memory(struct mem_info *mi, struct tiler_pa_info *pa) | 952 | static s32 pin_memory(struct mem_info *mi, struct tiler_pa_info *pa) |
953 | { | 953 | { |
954 | enum tiler_fmt fmt = tiler_fmt(mi->blk.phys); | 954 | enum tiler_fmt fmt = tiler_fmt(mi->blk.phys); |
955 | struct tcm_area area = mi->area; | ||
955 | 956 | ||
956 | /* ensure we can pin */ | 957 | /* ensure we can pin */ |
957 | if (!tmm_can_map(tmm[fmt])) | 958 | if (!tmm_can_map(tmm[fmt])) |
@@ -961,11 +962,21 @@ static s32 pin_memory(struct mem_info *mi, struct tiler_pa_info *pa) | |||
961 | if (pa->num_pg > tcm_sizeof(mi->area)) | 962 | if (pa->num_pg > tcm_sizeof(mi->area)) |
962 | return -ENOMEM; | 963 | return -ENOMEM; |
963 | 964 | ||
965 | /* for 2D area, pages must fit exactly */ | ||
966 | if (fmt != TILFMT_PAGE && | ||
967 | pa->num_pg != tcm_sizeof(mi->area)) | ||
968 | return -EINVAL; | ||
969 | |||
964 | /* save pages used */ | 970 | /* save pages used */ |
965 | mi->pa = *pa; | 971 | mi->pa = *pa; |
966 | pa->mem = NULL; /* transfered array */ | 972 | pa->mem = NULL; /* transfered array */ |
967 | 973 | ||
968 | return refill_pat(tmm[fmt], &mi->area, mi->pa.mem); | 974 | /* only refill available pages for 1D */ |
975 | if (fmt == TILFMT_PAGE) | ||
976 | tcm_1d_limit(&area, pa->num_pg); | ||
977 | if (mi->pa.num_pg) | ||
978 | return refill_pat(tmm[fmt], &area, mi->pa.mem); | ||
979 | return 0; | ||
969 | } | 980 | } |
970 | 981 | ||
971 | static void free_pa(struct tiler_pa_info *pa) | 982 | static void free_pa(struct tiler_pa_info *pa) |