Revert "video: nvmap: Only use CPA if enabled in nvmap"
Krishna Reddy [Fri, 8 Nov 2013 06:10:08 +0000 (22:10 -0800)]
This reverts commit 42000f34bb18fc5cc36089003fa32848b8e82ed1.

Change-Id: I3f08b7c4eceb519663d1e4ec833f586660d4e354
Reviewed-on: http://git-master/r/328096
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Tested-by: Krishna Reddy <vdumpa@nvidia.com>

drivers/video/tegra/nvmap/Makefile
drivers/video/tegra/nvmap/nvmap_handle.c
drivers/video/tegra/nvmap/nvmap_ioctl.c
drivers/video/tegra/nvmap/nvmap_mm.c [deleted file]
drivers/video/tegra/nvmap/nvmap_priv.h

index aa3009e..6257951 100644 (file)
@@ -5,4 +5,3 @@ obj-y += nvmap_handle.o
 obj-y += nvmap_heap.o
 obj-y += nvmap_ioctl.o
 obj-y += nvmap_dmabuf.o
-obj-y += nvmap_mm.o
index e0b0c8d..f4a3ca9 100644 (file)
@@ -163,7 +163,7 @@ static int nvmap_page_pool_free(struct nvmap_page_pool *pool, int nr_free)
 
        if (idx) {
                /* This op should never fail. */
-               err = nvmap_set_pages_array_wb(pool->shrink_array, idx);
+               err = set_pages_array_wb(pool->shrink_array, idx);
                BUG_ON(err);
        }
 
@@ -404,7 +404,6 @@ int nvmap_page_pool_init(struct nvmap_page_pool *pool, int flags)
        struct page *page;
        int pages_to_fill;
        int highmem_pages = 0;
-#ifdef CONFIG_NVMAP_CPA
        typedef int (*set_pages_array) (struct page **pages, int addrinarray);
        set_pages_array s_cpa[] = {
                set_pages_array_uc,
@@ -413,7 +412,6 @@ int nvmap_page_pool_init(struct nvmap_page_pool *pool, int flags)
                set_pages_array_wb
        };
 #endif
-#endif
 
        BUG_ON(flags >= NVMAP_NUM_POOLS);
        memset(pool, 0x0, sizeof(*pool));
@@ -482,11 +480,7 @@ int nvmap_page_pool_init(struct nvmap_page_pool *pool, int flags)
                info.totalram, info.freeram, info.totalhigh, info.freehigh);
 do_cpa:
        if (pool->npages) {
-#ifdef CONFIG_NVMAP_CPA
                err = (*s_cpa[flags])(pool->page_array, pool->npages);
-#else
-               err = 0;
-#endif
                BUG_ON(err);
        }
        nvmap_page_pool_unlock(pool);
@@ -567,7 +561,7 @@ void _nvmap_handle_free(struct nvmap_handle *h)
            h->flags == NVMAP_HANDLE_UNCACHEABLE ||
            h->flags == NVMAP_HANDLE_INNER_CACHEABLE) {
                /* This op should never fail. */
-               err = nvmap_set_pages_array_wb(&h->pgalloc.pages[page_index],
+               err = set_pages_array_wb(&h->pgalloc.pages[page_index],
                                nr_page - page_index);
                BUG_ON(err);
        }
@@ -688,13 +682,13 @@ static int handle_page_alloc(struct nvmap_client *client,
 
        /* Update the pages mapping in kernel page table. */
        if (h->flags == NVMAP_HANDLE_WRITE_COMBINE)
-               err = nvmap_set_pages_array_wc(&pages[page_index],
+               err = set_pages_array_wc(&pages[page_index],
                                        nr_page - page_index);
        else if (h->flags == NVMAP_HANDLE_UNCACHEABLE)
-               err = nvmap_set_pages_array_uc(&pages[page_index],
+               err = set_pages_array_uc(&pages[page_index],
                                        nr_page - page_index);
        else if (h->flags == NVMAP_HANDLE_INNER_CACHEABLE)
-               err = nvmap_set_pages_array_iwb(&pages[page_index],
+               err = set_pages_array_iwb(&pages[page_index],
                                        nr_page - page_index);
 
        if (err)
@@ -712,7 +706,7 @@ fail:
        if (h->userflags & NVMAP_HANDLE_ZEROED_PAGES)
                nvmap_free_pte(nvmap_dev, pte);
        if (i) {
-               err = nvmap_set_pages_array_wb(pages, i);
+               err = set_pages_array_wb(pages, i);
                BUG_ON(err);
        }
        while (i--)
index 53c26d0..5a32e5f 100644 (file)
@@ -535,11 +535,9 @@ int nvmap_map_into_caller_ptr(struct file *filp, void __user *arg)
                         */
                        if (cache_flags == NVMAP_HANDLE_INNER_CACHEABLE &&
                                h->heap_pgalloc)
-                               nvmap_set_pages_array_iwb(h->pgalloc.pages,
-                                                         nr_page);
+                               set_pages_array_iwb(h->pgalloc.pages, nr_page);
                        else if (h->heap_pgalloc)
-                               nvmap_set_pages_array_wb(h->pgalloc.pages,
-                                                        nr_page);
+                               set_pages_array_wb(h->pgalloc.pages, nr_page);
                }
        }
        vma->vm_page_prot = nvmap_pgprot(h, vma->vm_page_prot);
diff --git a/drivers/video/tegra/nvmap/nvmap_mm.c b/drivers/video/tegra/nvmap/nvmap_mm.c
deleted file mode 100644 (file)
index 742d3bb..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * drivers/video/tegra/nvmap/nvmap_mm.c
- *
- * Some MM related functionality specific to nvmap.
- *
- * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#include "nvmap_priv.h"
-
-void inner_flush_cache_all(void)
-{
-#ifdef CONFIG_NVMAP_CACHE_MAINT_BY_SET_WAYS_ON_ONE_CPU
-       v7_flush_kern_cache_all();
-#else
-       on_each_cpu(v7_flush_kern_cache_all, NULL, 1);
-#endif
-}
-
-void inner_clean_cache_all(void)
-{
-#ifdef CONFIG_NVMAP_CACHE_MAINT_BY_SET_WAYS_ON_ONE_CPU
-       v7_clean_kern_cache_all(NULL);
-#else
-       on_each_cpu(v7_clean_kern_cache_all, NULL, 1);
-#endif
-}
-
-#ifndef CONFIG_NVMAP_CPA
-static void flush_cache(struct page **pages, int numpages)
-{
-       unsigned int i;
-       bool flush_inner = true;
-       unsigned long base;
-
-#if defined(CONFIG_NVMAP_CACHE_MAINT_BY_SET_WAYS)
-       if (numpages >= (cache_maint_inner_threshold >> PAGE_SHIFT)) {
-               inner_flush_cache_all();
-               flush_inner = false;
-       }
-#endif
-
-       for (i = 0; i < numpages; i++) {
-               if (flush_inner)
-                       __flush_dcache_page(page_mapping(pages[i]), pages[i]);
-               base = page_to_phys(pages[i]);
-               outer_flush_range(base, base + PAGE_SIZE);
-       }
-}
-#endif
-
-int nvmap_set_pages_array_uc(struct page **pages, int addrinarray)
-{
-#ifdef CONFIG_NVMAP_CPA
-       return set_pages_array_uc(pages, addrinarray);
-#else
-       flush_cache(pages, addrinarray);
-       return 0;
-#endif
-}
-
-int nvmap_set_pages_array_wc(struct page **pages, int addrinarray)
-{
-#ifdef CONFIG_NVMAP_CPA
-       return set_pages_array_wc(pages, addrinarray);
-#else
-       flush_cache(pages, addrinarray);
-       return 0;
-#endif
-}
-
-int nvmap_set_pages_array_iwb(struct page **pages, int addrinarray)
-{
-#ifdef CONFIG_NVMAP_CPA
-       return set_pages_array_iwb(pages, addrinarray);
-#else
-       flush_cache(pages, addrinarray);
-       return 0;
-#endif
-}
-
-int nvmap_set_pages_array_wb(struct page **pages, int addrinarray)
-{
-#ifdef CONFIG_NVMAP_CPA
-       return set_pages_array_wb(pages, addrinarray);
-#else
-       return 0;
-#endif
-}
index 989a864..ee4f38d 100644 (file)
@@ -354,20 +354,29 @@ static inline void nvmap_flush_tlb_kernel_page(unsigned long kaddr)
 #endif
 }
 
-/* MM definitions. */
+extern void v7_clean_kern_cache_all(void *);
+
 extern size_t cache_maint_outer_threshold;
-extern int inner_cache_maint_threshold;
 
-extern void v7_flush_kern_cache_all(void);
-extern void v7_clean_kern_cache_all(void *);
-extern void __flush_dcache_page(struct address_space *, struct page *);
+static inline void inner_flush_cache_all(void)
+{
+#ifdef CONFIG_NVMAP_CACHE_MAINT_BY_SET_WAYS_ON_ONE_CPU
+       v7_flush_kern_cache_all();
+#else
+       on_each_cpu(v7_flush_kern_cache_all, NULL, 1);
+#endif
+}
 
-void inner_flush_cache_all(void);
-void inner_clean_cache_all(void);
-int nvmap_set_pages_array_uc(struct page **pages, int addrinarray);
-int nvmap_set_pages_array_wc(struct page **pages, int addrinarray);
-int nvmap_set_pages_array_iwb(struct page **pages, int addrinarray);
-int nvmap_set_pages_array_wb(struct page **pages, int addrinarray);
+static inline void inner_clean_cache_all(void)
+{
+#ifdef CONFIG_NVMAP_CACHE_MAINT_BY_SET_WAYS_ON_ONE_CPU
+       v7_clean_kern_cache_all(NULL);
+#else
+       on_each_cpu(v7_clean_kern_cache_all, NULL, 1);
+#endif
+}
+
+extern void __flush_dcache_page(struct address_space *, struct page *);
 
 /* Internal API to support dmabuf */
 struct dma_buf *__nvmap_dmabuf_export(struct nvmap_client *client,