]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: nvmap: allow zeroing memory
authorKrishna Reddy <vdumpa@nvidia.com>
Wed, 5 Mar 2014 22:10:12 +0000 (14:10 -0800)
committerKrishna Reddy <vdumpa@nvidia.com>
Fri, 7 Mar 2014 06:13:42 +0000 (22:13 -0800)
allow zeroing memory based on module param.
this would allow analyzing the use case perf.

Change-Id: I1049cc37b2cf16045e404f52ed5bc79b3bca4315
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/378039

drivers/video/tegra/nvmap/nvmap_handle.c

index 5db3962030e66c51896d5c8e0b5e5387abd66b85..068b33110817b5c6c1bbfe615ddf6231c29b95e2 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/dma-buf.h>
+#include <linux/moduleparam.h>
 #include <linux/nvmap.h>
 #include <linux/tegra-soc.h>
 
@@ -40,6 +41,8 @@
 #include "nvmap_priv.h"
 #include "nvmap_ioctl.h"
 
+static bool zero_memory;
+module_param(zero_memory, bool, 0644);
 u32 nvmap_max_handle_count;
 
 #define NVMAP_SECURE_HEAPS     (NVMAP_HEAP_CARVEOUT_IRAM | NVMAP_HEAP_IOVMM | \
@@ -159,7 +162,7 @@ static int handle_page_alloc(struct nvmap_client *client,
        unsigned long kaddr;
        pte_t **pte = NULL;
 
-       if (h->userflags & NVMAP_HANDLE_ZEROED_PAGES) {
+       if (h->userflags & NVMAP_HANDLE_ZEROED_PAGES || zero_memory) {
                gfp |= __GFP_ZERO;
                prot = nvmap_pgprot(h, PG_PROT_KERNEL);
                pte = nvmap_alloc_pte(nvmap_dev, (void **)&kaddr);
@@ -191,7 +194,8 @@ static int handle_page_alloc(struct nvmap_client *client,
                        pages[i] = nvmap_page_pool_alloc(pool);
                        if (!pages[i])
                                break;
-                       if (h->userflags & NVMAP_HANDLE_ZEROED_PAGES) {
+                       if (h->userflags & NVMAP_HANDLE_ZEROED_PAGES ||
+                           zero_memory) {
                                /*
                                 * Just memset low mem pages; they will for
                                 * sure have a virtual address. Otherwise, build
@@ -230,7 +234,7 @@ static int handle_page_alloc(struct nvmap_client *client,
        if (err)
                goto fail;
 
-       if (h->userflags & NVMAP_HANDLE_ZEROED_PAGES)
+       if (h->userflags & NVMAP_HANDLE_ZEROED_PAGES || zero_memory)
                nvmap_free_pte(nvmap_dev, pte);
        h->size = size;
        h->pgalloc.pages = pages;
@@ -238,7 +242,7 @@ static int handle_page_alloc(struct nvmap_client *client,
        return 0;
 
 fail:
-       if (h->userflags & NVMAP_HANDLE_ZEROED_PAGES)
+       if (h->userflags & NVMAP_HANDLE_ZEROED_PAGES || zero_memory)
                nvmap_free_pte(nvmap_dev, pte);
        while (i--)
                __free_page(pages[i]);