diff options
| author | Lajos Molnar <molnar@ti.com> | 2011-06-09 19:50:56 -0400 |
|---|---|---|
| committer | Paolo Pisati <paolo.pisati@canonical.com> | 2012-08-17 04:19:05 -0400 |
| commit | 52531661ca5bd3bbc69a36a661b1b02db2f232c1 (patch) | |
| tree | 89fa1da4ced16920f9988674e975f02669599763 /drivers | |
| parent | 9738e24afc9dc2da2e5c3931f5857fd7352a5c4c (diff) | |
OMAP: TILER: Added 1D area allocation + memory pinning operations
Added new tiler kernel methods:
tiler_alloc_block_area() allocates a 1D container area of certain size
tiler_pin_memory() can pin memory-backing to a 1D container area (or replace
its previous mapping)
tiler_unpin_memory() clears the memory-backing of a 1D container area
tiler_free_block() can be still used to free the container area.
Signed-off-by: Lajos Molnar <molnar@ti.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/media/video/tiler/tiler-main.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/drivers/media/video/tiler/tiler-main.c b/drivers/media/video/tiler/tiler-main.c index c6e729d3c57..ede63bfd702 100644 --- a/drivers/media/video/tiler/tiler-main.c +++ b/drivers/media/video/tiler/tiler-main.c | |||
| @@ -558,18 +558,13 @@ static s32 lay_nv12(int n, u16 w, u16 w1, u16 h, struct gid_info *gi, u8 *p) | |||
| 558 | return n; | 558 | return n; |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | /* (must have mutex) free block and any freed areas */ | 561 | static void _m_unpin(struct mem_info *mi) |
| 562 | static s32 _m_free(struct mem_info *mi) | ||
| 563 | { | 562 | { |
| 564 | struct area_info *ai = NULL; | ||
| 565 | struct page *page = NULL; | ||
| 566 | s32 res = 0; | ||
| 567 | u32 i; | ||
| 568 | |||
| 569 | /* release memory */ | 563 | /* release memory */ |
| 570 | if (mi->pa.memtype == TILER_MEM_GOT_PAGES) { | 564 | if (mi->pa.memtype == TILER_MEM_GOT_PAGES) { |
| 565 | int i; | ||
| 571 | for (i = 0; i < mi->pa.num_pg; i++) { | 566 | for (i = 0; i < mi->pa.num_pg; i++) { |
| 572 | page = phys_to_page(mi->pa.mem[i]); | 567 | struct page *page = phys_to_page(mi->pa.mem[i]); |
| 573 | if (page) { | 568 | if (page) { |
| 574 | if (!PageReserved(page)) | 569 | if (!PageReserved(page)) |
| 575 | SetPageDirty(page); | 570 | SetPageDirty(page); |
| @@ -585,7 +580,18 @@ static s32 _m_free(struct mem_info *mi) | |||
| 585 | mi->pa.mem = NULL; | 580 | mi->pa.mem = NULL; |
| 586 | } | 581 | } |
| 587 | kfree(mi->pa.mem); | 582 | kfree(mi->pa.mem); |
| 583 | mi->pa.mem = NULL; | ||
| 584 | mi->pa.num_pg = 0; | ||
| 588 | clear_pat(tmm[tiler_fmt(mi->blk.phys)], &mi->area); | 585 | clear_pat(tmm[tiler_fmt(mi->blk.phys)], &mi->area); |
| 586 | } | ||
| 587 | |||
| 588 | /* (must have mutex) free block and any freed areas */ | ||
| 589 | static s32 _m_free(struct mem_info *mi) | ||
| 590 | { | ||
| 591 | struct area_info *ai = NULL; | ||
| 592 | s32 res = 0; | ||
| 593 | |||
| 594 | _m_unpin(mi); | ||
| 589 | 595 | ||
| 590 | /* safe deletion as list may not have been assigned */ | 596 | /* safe deletion as list may not have been assigned */ |
| 591 | if (mi->global.next) | 597 | if (mi->global.next) |
| @@ -1378,6 +1384,29 @@ void tiler_free_block(tiler_blk_handle block) | |||
| 1378 | } | 1384 | } |
| 1379 | EXPORT_SYMBOL(tiler_free_block); | 1385 | EXPORT_SYMBOL(tiler_free_block); |
| 1380 | 1386 | ||
| 1387 | tiler_blk_handle tiler_alloc_block_area(u32 size) | ||
| 1388 | { | ||
| 1389 | return alloc_block_area(TILFMT_PAGE, size >> PAGE_SHIFT, 1, 0, 0, 0, 0, | ||
| 1390 | __get_pi(0, true)); | ||
| 1391 | } | ||
| 1392 | EXPORT_SYMBOL(tiler_alloc_block_area); | ||
| 1393 | |||
| 1394 | void tiler_unpin_memory(tiler_blk_handle block) | ||
| 1395 | { | ||
| 1396 | mutex_lock(&mtx); | ||
| 1397 | _m_unpin(block); | ||
| 1398 | mutex_unlock(&mtx); | ||
| 1399 | } | ||
| 1400 | EXPORT_SYMBOL(tiler_unpin_memory); | ||
| 1401 | |||
| 1402 | s32 tiler_pin_memory(tiler_blk_handle block, struct tiler_pa_info *pa) | ||
| 1403 | { | ||
| 1404 | struct tiler_pa_info *pa_tmp = kmemdup(pa, sizeof(*pa), GFP_KERNEL); | ||
| 1405 | tiler_unpin_memory(block); | ||
| 1406 | return pin_memory(block, pa_tmp); | ||
| 1407 | } | ||
| 1408 | EXPORT_SYMBOL(tiler_pin_memory); | ||
| 1409 | |||
| 1381 | MODULE_LICENSE("GPL v2"); | 1410 | MODULE_LICENSE("GPL v2"); |
| 1382 | MODULE_AUTHOR("Lajos Molnar <molnar@ti.com>"); | 1411 | MODULE_AUTHOR("Lajos Molnar <molnar@ti.com>"); |
| 1383 | MODULE_AUTHOR("David Sin <davidsin@ti.com>"); | 1412 | MODULE_AUTHOR("David Sin <davidsin@ti.com>"); |
