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/include/nvgpu/kmem.h | 43 ++++----------- drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h | 81 +++------------------------- 2 files changed, 16 insertions(+), 108 deletions(-) (limited to 'drivers/gpu/nvgpu/include') 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 @@ #ifndef __NVGPU_KMEM_H__ #define __NVGPU_KMEM_H__ +#include + /* * Incase this isn't defined already. */ @@ -29,12 +31,10 @@ struct gk20a; /* * When there's other implementations make sure they are included instead of * Linux when not compiling on Linux! - * - * Also note this is above any usage of size_t. At the moment we don't have a - * cross OS way of defining the necessary types used by these APIs. Eventually - * we will need a include to handle this. */ +#ifdef __KERNEL__ #include +#endif /** * DOC: Kmem cache support @@ -224,24 +224,10 @@ void nvgpu_kmem_fini(struct gk20a *g, int flags); #define NVGPU_KMEM_FINI_WARN (1 << 2) #define NVGPU_KMEM_FINI_BUG (1 << 3) -static inline 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; -} +/* + * Implemented by the OS interface. + */ +void *__nvgpu_big_alloc(struct gk20a *g, size_t size, bool clear); /** * 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) * @g - The GPU. * @p - A pointer allocated by nvgpu_big_zalloc() or nvgpu_big_malloc(). */ -static inline 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_big_free(struct gk20a *g, void *p); #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 @@ #ifndef __NVGPU_KMEM_LINUX_H__ #define __NVGPU_KMEM_LINUX_H__ -#include -#include -#include - -#include - struct gk20a; struct device; @@ -51,73 +45,12 @@ static inline void nvgpu_kmem_debugfs_init(struct device *dev) * These are the Linux implementations of the various kmem functions defined by * nvgpu. This should not be included directly - instead include . */ - -static inline void *__nvgpu_kmalloc(struct gk20a *g, size_t size, - unsigned long ip) -{ -#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE - return __nvgpu_track_vmalloc(g, size, ip); -#else - return kmalloc(size, GFP_KERNEL); -#endif -} - -static inline 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 -} - -static inline 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 -} - -static inline 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 -} - -static inline 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 -} - -static inline void __nvgpu_kfree(struct gk20a *g, void *addr) -{ -#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE - __nvgpu_track_kfree(g, addr); -#else - kfree(addr); -#endif -} - -static inline void __nvgpu_vfree(struct gk20a *g, void *addr) -{ -#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE - __nvgpu_track_vfree(g, addr); -#else - vfree(addr); -#endif -} +void *__nvgpu_kmalloc(struct gk20a *g, size_t size, unsigned long ip); +void *__nvgpu_kzalloc(struct gk20a *g, size_t size, unsigned long ip); +void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, unsigned long ip); +void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, unsigned long ip); +void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, unsigned long ip); +void __nvgpu_kfree(struct gk20a *g, void *addr); +void __nvgpu_vfree(struct gk20a *g, void *addr); #endif -- cgit v1.2.2