summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common
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/common
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/common')
-rw-r--r--drivers/gpu/nvgpu/common/linux/kmem.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/kmem.c b/drivers/gpu/nvgpu/common/linux/kmem.c
index f38a5e78..0d185e56 100644
--- a/drivers/gpu/nvgpu/common/linux/kmem.c
+++ b/drivers/gpu/nvgpu/common/linux/kmem.c
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#include <linux/mm.h>
17#include <linux/mutex.h> 18#include <linux/mutex.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/debugfs.h> 20#include <linux/debugfs.h>
@@ -37,6 +38,101 @@
37 */ 38 */
38static atomic_t kmem_cache_id; 39static atomic_t kmem_cache_id;
39 40
41void *__nvgpu_big_alloc(struct gk20a *g, size_t size, bool clear)
42{
43 void *p;
44
45 if (size > PAGE_SIZE) {
46 if (clear)
47 p = nvgpu_vzalloc(g, size);
48 else
49 p = nvgpu_vmalloc(g, size);
50 } else {
51 if (clear)
52 p = nvgpu_kzalloc(g, size);
53 else
54 p = nvgpu_kmalloc(g, size);
55 }
56
57 return p;
58}
59
60void nvgpu_big_free(struct gk20a *g, void *p)
61{
62 /*
63 * This will have to be fixed eventually. Allocs that use
64 * nvgpu_big_[mz]alloc() will need to remember the size of the alloc
65 * when freeing.
66 */
67 if (virt_addr_valid(p))
68 nvgpu_kfree(g, p);
69 else
70 nvgpu_vfree(g, p);
71}
72
73void *__nvgpu_kmalloc(struct gk20a *g, size_t size, unsigned long ip)
74{
75#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
76 return __nvgpu_track_kmalloc(g, size, ip);
77#else
78 return kmalloc(size, GFP_KERNEL);
79#endif
80}
81
82void *__nvgpu_kzalloc(struct gk20a *g, size_t size, unsigned long ip)
83{
84#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
85 return __nvgpu_track_kzalloc(g, size, ip);
86#else
87 return kzalloc(size, GFP_KERNEL);
88#endif
89}
90
91void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, unsigned long ip)
92{
93#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
94 return __nvgpu_track_kcalloc(g, n, size, ip);
95#else
96 return kcalloc(n, size, GFP_KERNEL);
97#endif
98}
99
100void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, unsigned long ip)
101{
102#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
103 return __nvgpu_track_vmalloc(g, size, ip);
104#else
105 return vmalloc(size);
106#endif
107}
108
109void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, unsigned long ip)
110{
111#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
112 return __nvgpu_track_vzalloc(g, size, ip);
113#else
114 return vzalloc(size);
115#endif
116}
117
118void __nvgpu_kfree(struct gk20a *g, void *addr)
119{
120#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
121 __nvgpu_track_kfree(g, addr);
122#else
123 kfree(addr);
124#endif
125}
126
127void __nvgpu_vfree(struct gk20a *g, void *addr)
128{
129#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
130 __nvgpu_track_vfree(g, addr);
131#else
132 vfree(addr);
133#endif
134}
135
40#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE 136#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
41 137
42static void lock_tracker(struct nvgpu_mem_alloc_tracker *tracker) 138static void lock_tracker(struct nvgpu_mem_alloc_tracker *tracker)