From 30ab4d7479b6edf27495e701a095e6b3102cf5e4 Mon Sep 17 00:00:00 2001 From: Krishna Reddy Date: Tue, 30 Aug 2011 10:15:44 -0700 Subject: video: tegra: nvmap: Set page attributes as per request. After allocating pages, Set page attributes as per mem type requested. (cherry picked from commit e4862709dd7fb9799072576569fd532e0a597f31) Change-Id: If5e119366ffe6daaab78dc5915fa864d6932d464 Reviewed-on: http://git-master/r/53828 Reviewed-by: Vinod Rex Reviewed-by: Krishna Reddy Tested-by: Krishna Reddy --- drivers/video/tegra/nvmap/nvmap_handle.c | 31 ++++++++++++++++++++++--------- drivers/video/tegra/nvmap/nvmap_ioctl.c | 7 ++----- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/video/tegra/nvmap/nvmap_handle.c b/drivers/video/tegra/nvmap/nvmap_handle.c index 4eef6a5fd61f..57502171b25e 100644 --- a/drivers/video/tegra/nvmap/nvmap_handle.c +++ b/drivers/video/tegra/nvmap/nvmap_handle.c @@ -105,6 +105,12 @@ void _nvmap_handle_free(struct nvmap_handle *h) nvmap_mru_remove(nvmap_get_share_from_dev(dev), h); + // Restore page attributes. + if (h->flags == NVMAP_HANDLE_WRITE_COMBINE || + h->flags == NVMAP_HANDLE_UNCACHEABLE || + h->flags == NVMAP_HANDLE_INNER_CACHEABLE) + set_pages_array_wb(h->pgalloc.pages, nr_page); + if (h->pgalloc.area) tegra_iovmm_free_vm(h->pgalloc.area); @@ -147,7 +153,6 @@ static int handle_page_alloc(struct nvmap_client *client, pgprot_t prot; unsigned int i = 0; struct page **pages; - bool flush_inner = true; unsigned long base; pages = altalloc(nr_page * sizeof(*pages)); @@ -190,18 +195,26 @@ static int handle_page_alloc(struct nvmap_client *client, #endif } - /* Flush the cache for allocated pages*/ - if (size >= FLUSH_CLEAN_BY_SET_WAY_THRESHOLD) { - inner_flush_cache_all(); - flush_inner = false; - } + // Update the pages mapping in kernel page table. + if (h->flags == NVMAP_HANDLE_WRITE_COMBINE) + set_pages_array_wc(pages, nr_page); + else if (h->flags == NVMAP_HANDLE_UNCACHEABLE) + set_pages_array_uc(pages, nr_page); + else if (h->flags == NVMAP_HANDLE_INNER_CACHEABLE) + set_pages_array_iwb(pages, nr_page); + else + goto skip_cache_flush; + + /* Flush the cache for allocated high mem pages only */ for (i = 0; i < nr_page; i++) { - if (flush_inner) + if (PageHighMem(pages[i])) { __flush_dcache_page(page_mapping(pages[i]), pages[i]); - base = page_to_phys(pages[i]); - outer_flush_range(base, base + PAGE_SIZE); + base = page_to_phys(pages[i]); + outer_flush_range(base, base + PAGE_SIZE); + } } +skip_cache_flush: h->size = size; h->pgalloc.pages = pages; h->pgalloc.contig = contiguous; diff --git a/drivers/video/tegra/nvmap/nvmap_ioctl.c b/drivers/video/tegra/nvmap/nvmap_ioctl.c index 44cd7b72fe27..26ff0818b124 100644 --- a/drivers/video/tegra/nvmap/nvmap_ioctl.c +++ b/drivers/video/tegra/nvmap/nvmap_ioctl.c @@ -582,11 +582,8 @@ static int cache_maint(struct nvmap_client *client, struct nvmap_handle *h, } wmb(); -#if defined(CONFIG_ARCH_TEGRA_2x_SOC) - if (h->flags == NVMAP_HANDLE_WRITE_COMBINE) - goto out; -#endif - if (h->flags == NVMAP_HANDLE_UNCACHEABLE || start == end) + if (h->flags == NVMAP_HANDLE_UNCACHEABLE || + h->flags == NVMAP_HANDLE_WRITE_COMBINE || start == end) goto out; if (fast_cache_maint(client, h, start, end, op)) -- cgit v1.2.3