summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-04-27 15:37:14 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-05-14 03:05:12 -0400
commit648f43fe1e474b7232204da7dd68140a197e41c3 (patch)
tree858e41670ea7b1d221016f0411b88d7a0e60a3bf /drivers/gpu/nvgpu/include
parenta4a1b8ef48ac1407028aa7cda2c95e7f4306577f (diff)
gpu: nvgpu: Remove linux includes from kmem.h
Remove the Linux includes that are included from <nvgpu/linux/kmem.h>. These includes leak into the core code and make it easy for Linux specific functions and APIs to be accidentally called. The only place that includes the Linux headers is now the Linux API implementation code. Change-Id: I2af8153a81408fe3b762c03c9504e41d0309aea9 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1472370 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/kmem.h43
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h81
2 files changed, 16 insertions, 108 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/kmem.h b/drivers/gpu/nvgpu/include/nvgpu/kmem.h
index cfbc0da5..5bda2f3a 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/kmem.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/kmem.h
@@ -17,6 +17,8 @@
17#ifndef __NVGPU_KMEM_H__ 17#ifndef __NVGPU_KMEM_H__
18#define __NVGPU_KMEM_H__ 18#define __NVGPU_KMEM_H__
19 19
20#include <nvgpu/types.h>
21
20/* 22/*
21 * Incase this isn't defined already. 23 * Incase this isn't defined already.
22 */ 24 */
@@ -29,12 +31,10 @@ struct gk20a;
29/* 31/*
30 * When there's other implementations make sure they are included instead of 32 * When there's other implementations make sure they are included instead of
31 * Linux when not compiling on Linux! 33 * Linux when not compiling on Linux!
32 *
33 * Also note this is above any usage of size_t. At the moment we don't have a
34 * cross OS way of defining the necessary types used by these APIs. Eventually
35 * we will need a <nvgpu/types.h> include to handle this.
36 */ 34 */
35#ifdef __KERNEL__
37#include <nvgpu/linux/kmem.h> 36#include <nvgpu/linux/kmem.h>
37#endif
38 38
39/** 39/**
40 * DOC: Kmem cache support 40 * DOC: Kmem cache support
@@ -224,24 +224,10 @@ void nvgpu_kmem_fini(struct gk20a *g, int flags);
224#define NVGPU_KMEM_FINI_WARN (1 << 2) 224#define NVGPU_KMEM_FINI_WARN (1 << 2)
225#define NVGPU_KMEM_FINI_BUG (1 << 3) 225#define NVGPU_KMEM_FINI_BUG (1 << 3)
226 226
227static inline void *__nvgpu_big_alloc(struct gk20a *g, size_t size, bool clear) 227/*
228{ 228 * Implemented by the OS interface.
229 void *p; 229 */
230 230void *__nvgpu_big_alloc(struct gk20a *g, size_t size, bool clear);
231 if (size > PAGE_SIZE) {
232 if (clear)
233 p = nvgpu_vzalloc(g, size);
234 else
235 p = nvgpu_vmalloc(g, size);
236 } else {
237 if (clear)
238 p = nvgpu_kzalloc(g, size);
239 else
240 p = nvgpu_kmalloc(g, size);
241 }
242
243 return p;
244}
245 231
246/** 232/**
247 * nvgpu_big_malloc - Pick virtual or physical alloc based on @size 233 * nvgpu_big_malloc - Pick virtual or physical alloc based on @size
@@ -289,17 +275,6 @@ static inline void *nvgpu_big_zalloc(struct gk20a *g, size_t size)
289 * @g - The GPU. 275 * @g - The GPU.
290 * @p - A pointer allocated by nvgpu_big_zalloc() or nvgpu_big_malloc(). 276 * @p - A pointer allocated by nvgpu_big_zalloc() or nvgpu_big_malloc().
291 */ 277 */
292static inline void nvgpu_big_free(struct gk20a *g, void *p) 278void nvgpu_big_free(struct gk20a *g, void *p);
293{
294 /*
295 * This will have to be fixed eventually. Allocs that use
296 * nvgpu_big_[mz]alloc() will need to remember the size of the alloc
297 * when freeing.
298 */
299 if (virt_addr_valid(p))
300 nvgpu_kfree(g, p);
301 else
302 nvgpu_vfree(g, p);
303}
304 279
305#endif /* __NVGPU_KMEM_H__ */ 280#endif /* __NVGPU_KMEM_H__ */
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h b/drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h
index dbafc0ce..dc198a04 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h
@@ -17,12 +17,6 @@
17#ifndef __NVGPU_KMEM_LINUX_H__ 17#ifndef __NVGPU_KMEM_LINUX_H__
18#define __NVGPU_KMEM_LINUX_H__ 18#define __NVGPU_KMEM_LINUX_H__
19 19
20#include <linux/mm.h>
21#include <linux/slab.h>
22#include <linux/vmalloc.h>
23
24#include <asm/page.h>
25
26struct gk20a; 20struct gk20a;
27struct device; 21struct device;
28 22
@@ -51,73 +45,12 @@ static inline void nvgpu_kmem_debugfs_init(struct device *dev)
51 * These are the Linux implementations of the various kmem functions defined by 45 * These are the Linux implementations of the various kmem functions defined by
52 * nvgpu. This should not be included directly - instead include <nvgpu/kmem.h>. 46 * nvgpu. This should not be included directly - instead include <nvgpu/kmem.h>.
53 */ 47 */
54 48void *__nvgpu_kmalloc(struct gk20a *g, size_t size, unsigned long ip);
55static inline void *__nvgpu_kmalloc(struct gk20a *g, size_t size, 49void *__nvgpu_kzalloc(struct gk20a *g, size_t size, unsigned long ip);
56 unsigned long ip) 50void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, unsigned long ip);
57{ 51void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, unsigned long ip);
58#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE 52void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, unsigned long ip);
59 return __nvgpu_track_vmalloc(g, size, ip); 53void __nvgpu_kfree(struct gk20a *g, void *addr);
60#else 54void __nvgpu_vfree(struct gk20a *g, void *addr);
61 return kmalloc(size, GFP_KERNEL);
62#endif
63}
64
65static inline void *__nvgpu_kzalloc(struct gk20a *g, size_t size,
66 unsigned long ip)
67{
68#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
69 return __nvgpu_track_kzalloc(g, size, ip);
70#else
71 return kzalloc(size, GFP_KERNEL);
72#endif
73}
74
75static inline void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size,
76 unsigned long ip)
77{
78#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
79 return __nvgpu_track_kcalloc(g, n, size, ip);
80#else
81 return kcalloc(n, size, GFP_KERNEL);
82#endif
83}
84
85static inline void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size,
86 unsigned long ip)
87{
88#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
89 return __nvgpu_track_vmalloc(g, size, ip);
90#else
91 return vmalloc(size);
92#endif
93}
94
95static inline void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size,
96 unsigned long ip)
97{
98#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
99 return __nvgpu_track_vzalloc(g, size, ip);
100#else
101 return vzalloc(size);
102#endif
103}
104
105static inline void __nvgpu_kfree(struct gk20a *g, void *addr)
106{
107#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
108 __nvgpu_track_kfree(g, addr);
109#else
110 kfree(addr);
111#endif
112}
113
114static inline void __nvgpu_vfree(struct gk20a *g, void *addr)
115{
116#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
117 __nvgpu_track_vfree(g, addr);
118#else
119 vfree(addr);
120#endif
121}
122 55
123#endif 56#endif