From 648f43fe1e474b7232204da7dd68140a197e41c3 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Thu, 27 Apr 2017 12:37:14 -0700 Subject: gpu: nvgpu: Remove linux includes from kmem.h Remove the Linux includes that are included from . 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 Reviewed-on: http://git-master/r/1472370 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/kmem.c | 96 +++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'drivers/gpu/nvgpu/common') 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 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -37,6 +38,101 @@ */ static atomic_t kmem_cache_id; +void *__nvgpu_big_alloc(struct gk20a *g, size_t size, bool clear) +{ + void *p; + + if (size > PAGE_SIZE) { + if (clear) + p = nvgpu_vzalloc(g, size); + else + p = nvgpu_vmalloc(g, size); + } else { + if (clear) + p = nvgpu_kzalloc(g, size); + else + p = nvgpu_kmalloc(g, size); + } + + return p; +} + +void nvgpu_big_free(struct gk20a *g, void *p) +{ + /* + * This will have to be fixed eventually. Allocs that use + * nvgpu_big_[mz]alloc() will need to remember the size of the alloc + * when freeing. + */ + if (virt_addr_valid(p)) + nvgpu_kfree(g, p); + else + nvgpu_vfree(g, p); +} + +void *__nvgpu_kmalloc(struct gk20a *g, size_t size, unsigned long ip) +{ +#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE + return __nvgpu_track_kmalloc(g, size, ip); +#else + return kmalloc(size, GFP_KERNEL); +#endif +} + +void *__nvgpu_kzalloc(struct gk20a *g, size_t size, unsigned long ip) +{ +#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE + return __nvgpu_track_kzalloc(g, size, ip); +#else + return kzalloc(size, GFP_KERNEL); +#endif +} + +void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, unsigned long ip) +{ +#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE + return __nvgpu_track_kcalloc(g, n, size, ip); +#else + return kcalloc(n, size, GFP_KERNEL); +#endif +} + +void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, unsigned long ip) +{ +#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE + return __nvgpu_track_vmalloc(g, size, ip); +#else + return vmalloc(size); +#endif +} + +void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, unsigned long ip) +{ +#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE + return __nvgpu_track_vzalloc(g, size, ip); +#else + return vzalloc(size); +#endif +} + +void __nvgpu_kfree(struct gk20a *g, void *addr) +{ +#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE + __nvgpu_track_kfree(g, addr); +#else + kfree(addr); +#endif +} + +void __nvgpu_vfree(struct gk20a *g, void *addr) +{ +#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE + __nvgpu_track_vfree(g, addr); +#else + vfree(addr); +#endif +} + #ifdef CONFIG_NVGPU_TRACK_MEM_USAGE static void lock_tracker(struct nvgpu_mem_alloc_tracker *tracker) -- cgit v1.2.2