summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrishna Reddy <vdumpa@nvidia.com>2011-08-30 10:15:44 -0700
committerSimone Willett <swillett@nvidia.com>2011-09-22 10:04:29 -0700
commit30ab4d7479b6edf27495e701a095e6b3102cf5e4 (patch)
tree64ff196e4ef38b998cbdc372f1046933e6f83eeb
parent0e954653476e496979d22c77a3bbe90da42aff52 (diff)
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 <vrex@nvidia.com> Reviewed-by: Krishna Reddy <vdumpa@nvidia.com> Tested-by: Krishna Reddy <vdumpa@nvidia.com>
-rw-r--r--drivers/video/tegra/nvmap/nvmap_handle.c31
-rw-r--r--drivers/video/tegra/nvmap/nvmap_ioctl.c7
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))