diff --git a/drivers/gpu/nvgpu/common/linux/kmem.c b/drivers/gpu/nvgpu/common/linux/kmem.c
index f38a5e783..0d185e565 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)
diff --git a/drivers/gpu/nvgpu/include/nvgpu/kmem.h b/drivers/gpu/nvgpu/include/nvgpu/kmem.h
index cfbc0da54..5bda2f3ad 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 dbafc0ce0..dc198a04c 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