nvmap: combine two methods of requesting zeroed memory
Colin Cross [Mon, 11 Aug 2014 21:25:20 +0000 (14:25 -0700)]
Combine CONFIG_NVMAP_FORCE_ZEROED_USER_PAGES and the zero_memory
modparam into a single option by forcing zero_memory=1 when
CONFIG_NVMAP_FORCE_ZEROED_USER_PAGES is set, and always using
zero_memory to decided whether to zero or not.

Change-Id: I9ce0106cfaea950bd9494b697916fbc2a03329ea
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/664672
GVS: Gerrit_Virtual_Submit
Reviewed-on: http://git-master/r/736426
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Tested-by: Alex Waterman <alexw@nvidia.com>

drivers/video/tegra/nvmap/nvmap_handle.c
drivers/video/tegra/nvmap/nvmap_priv.h

index 3dd2c3c..59bb6db 100644 (file)
 #include "nvmap_priv.h"
 #include "nvmap_ioctl.h"
 
+#ifdef CONFIG_NVMAP_FORCE_ZEROED_USER_PAGES
+bool zero_memory = true;
+#define ZERO_MEMORY_PERMS 0444
+#else
 bool zero_memory;
+#define ZERO_MEMORY_PERMS 0644
+#endif
 
 static int zero_memory_set(const char *arg, const struct kernel_param *kp)
 {
@@ -54,7 +60,7 @@ static struct kernel_param_ops zero_memory_ops = {
        .set = zero_memory_set,
 };
 
-module_param_cb(zero_memory, &zero_memory_ops, &zero_memory, 0644);
+module_param_cb(zero_memory, &zero_memory_ops, &zero_memory, ZERO_MEMORY_PERMS);
 
 u32 nvmap_max_handle_count;
 
index f6060e8..27cb329 100644 (file)
 #define __GFP_NVMAP     (GFP_KERNEL | __GFP_HIGHMEM)
 #endif
 
-#ifdef CONFIG_NVMAP_FORCE_ZEROED_USER_PAGES
-#define NVMAP_ZEROED_PAGES     __GFP_ZERO
-#else
-#define NVMAP_ZEROED_PAGES     0
-#endif
-
-#define GFP_NVMAP              (__GFP_NVMAP | __GFP_NOWARN | NVMAP_ZEROED_PAGES)
-
-extern bool zero_memory;
+#define GFP_NVMAP       (__GFP_NVMAP | __GFP_NOWARN)
 
 #ifdef CONFIG_64BIT
 #define NVMAP_LAZY_VFREE