summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/kmem.h19
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h23
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/posix/kmem.h10
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/timers.h5
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/utils.h6
5 files changed, 31 insertions, 32 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/kmem.h b/drivers/gpu/nvgpu/include/nvgpu/kmem.h
index 91574ce0..852f6f8a 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/kmem.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/kmem.h
@@ -24,13 +24,7 @@
24#define __NVGPU_KMEM_H__ 24#define __NVGPU_KMEM_H__
25 25
26#include <nvgpu/types.h> 26#include <nvgpu/types.h>
27 27#include <nvgpu/utils.h>
28/*
29 * Incase this isn't defined already.
30 */
31#ifndef _THIS_IP_
32#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
33#endif
34 28
35struct gk20a; 29struct gk20a;
36 30
@@ -125,7 +119,7 @@ void nvgpu_kmem_cache_free(struct nvgpu_kmem_cache *cache, void *ptr);
125 * 119 *
126 * This function may sleep so cannot be used in IRQs. 120 * This function may sleep so cannot be used in IRQs.
127 */ 121 */
128#define nvgpu_kmalloc(g, size) __nvgpu_kmalloc(g, size, _THIS_IP_) 122#define nvgpu_kmalloc(g, size) __nvgpu_kmalloc(g, size, _NVGPU_GET_IP_)
129 123
130/** 124/**
131 * nvgpu_kzalloc - Allocate from the kernel's allocator. 125 * nvgpu_kzalloc - Allocate from the kernel's allocator.
@@ -136,7 +130,7 @@ void nvgpu_kmem_cache_free(struct nvgpu_kmem_cache *cache, void *ptr);
136 * Identical to nvgpu_kalloc() except the memory will be zeroed before being 130 * Identical to nvgpu_kalloc() except the memory will be zeroed before being
137 * returned. 131 * returned.
138 */ 132 */
139#define nvgpu_kzalloc(g, size) __nvgpu_kzalloc(g, size, _THIS_IP_) 133#define nvgpu_kzalloc(g, size) __nvgpu_kzalloc(g, size, _NVGPU_GET_IP_)
140 134
141/** 135/**
142 * nvgpu_kcalloc - Allocate from the kernel's allocator. 136 * nvgpu_kcalloc - Allocate from the kernel's allocator.
@@ -148,7 +142,8 @@ void nvgpu_kmem_cache_free(struct nvgpu_kmem_cache *cache, void *ptr);
148 * Identical to nvgpu_kalloc() except the size of the memory chunk returned is 142 * Identical to nvgpu_kalloc() except the size of the memory chunk returned is
149 * @n * @size. 143 * @n * @size.
150 */ 144 */
151#define nvgpu_kcalloc(g, n, size) __nvgpu_kcalloc(g, n, size, _THIS_IP_) 145#define nvgpu_kcalloc(g, n, size) \
146 __nvgpu_kcalloc(g, n, size, _NVGPU_GET_IP_)
152 147
153/** 148/**
154 * nvgpu_vmalloc - Allocate memory and return a map to it. 149 * nvgpu_vmalloc - Allocate memory and return a map to it.
@@ -164,7 +159,7 @@ void nvgpu_kmem_cache_free(struct nvgpu_kmem_cache *cache, void *ptr);
164 * 159 *
165 * This function may sleep. 160 * This function may sleep.
166 */ 161 */
167#define nvgpu_vmalloc(g, size) __nvgpu_vmalloc(g, size, _THIS_IP_) 162#define nvgpu_vmalloc(g, size) __nvgpu_vmalloc(g, size, _NVGPU_GET_IP_)
168 163
169/** 164/**
170 * nvgpu_vzalloc - Allocate memory and return a map to it. 165 * nvgpu_vzalloc - Allocate memory and return a map to it.
@@ -174,7 +169,7 @@ void nvgpu_kmem_cache_free(struct nvgpu_kmem_cache *cache, void *ptr);
174 * 169 *
175 * Identical to nvgpu_vmalloc() except this will return zero'ed memory. 170 * Identical to nvgpu_vmalloc() except this will return zero'ed memory.
176 */ 171 */
177#define nvgpu_vzalloc(g, size) __nvgpu_vzalloc(g, size, _THIS_IP_) 172#define nvgpu_vzalloc(g, size) __nvgpu_vzalloc(g, size, _NVGPU_GET_IP_)
178 173
179/** 174/**
180 * nvgpu_kfree - Frees an alloc from nvgpu_kmalloc, nvgpu_kzalloc, 175 * nvgpu_kfree - Frees an alloc from nvgpu_kmalloc, nvgpu_kzalloc,
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h b/drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h
index 611854f2..660aac9f 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/linux/kmem.h
@@ -21,14 +21,11 @@ struct gk20a;
21struct device; 21struct device;
22 22
23#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE 23#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
24void *__nvgpu_track_vmalloc(struct gk20a *g, unsigned long size, 24void *__nvgpu_track_vmalloc(struct gk20a *g, unsigned long size, void *ip);
25 unsigned long ip); 25void *__nvgpu_track_vzalloc(struct gk20a *g, unsigned long size, void *ip);
26void *__nvgpu_track_vzalloc(struct gk20a *g, unsigned long size, 26void *__nvgpu_track_kmalloc(struct gk20a *g, size_t size, void *ip);
27 unsigned long ip); 27void *__nvgpu_track_kzalloc(struct gk20a *g, size_t size, void *ip);
28void *__nvgpu_track_kmalloc(struct gk20a *g, size_t size, unsigned long ip); 28void *__nvgpu_track_kcalloc(struct gk20a *g, size_t n, size_t size, void *ip);
29void *__nvgpu_track_kzalloc(struct gk20a *g, size_t size, unsigned long ip);
30void *__nvgpu_track_kcalloc(struct gk20a *g, size_t n, size_t size,
31 unsigned long ip);
32void __nvgpu_track_vfree(struct gk20a *g, void *addr); 29void __nvgpu_track_vfree(struct gk20a *g, void *addr);
33void __nvgpu_track_kfree(struct gk20a *g, void *addr); 30void __nvgpu_track_kfree(struct gk20a *g, void *addr);
34#endif 31#endif
@@ -39,11 +36,11 @@ void __nvgpu_track_kfree(struct gk20a *g, void *addr);
39 * These are the Linux implementations of the various kmem functions defined by 36 * These are the Linux implementations of the various kmem functions defined by
40 * nvgpu. This should not be included directly - instead include <nvgpu/kmem.h>. 37 * nvgpu. This should not be included directly - instead include <nvgpu/kmem.h>.
41 */ 38 */
42void *__nvgpu_kmalloc(struct gk20a *g, size_t size, unsigned long ip); 39void *__nvgpu_kmalloc(struct gk20a *g, size_t size, void *ip);
43void *__nvgpu_kzalloc(struct gk20a *g, size_t size, unsigned long ip); 40void *__nvgpu_kzalloc(struct gk20a *g, size_t size, void *ip);
44void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, unsigned long ip); 41void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, void *ip);
45void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, unsigned long ip); 42void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, void *ip);
46void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, unsigned long ip); 43void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, void *ip);
47void __nvgpu_kfree(struct gk20a *g, void *addr); 44void __nvgpu_kfree(struct gk20a *g, void *addr);
48void __nvgpu_vfree(struct gk20a *g, void *addr); 45void __nvgpu_vfree(struct gk20a *g, void *addr);
49 46
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/kmem.h b/drivers/gpu/nvgpu/include/nvgpu/posix/kmem.h
index 483ac3b3..efcdd3d5 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/posix/kmem.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/posix/kmem.h
@@ -25,11 +25,11 @@
25 25
26#include <nvgpu/types.h> 26#include <nvgpu/types.h>
27 27
28void *__nvgpu_kmalloc(struct gk20a *g, size_t size, unsigned long ip); 28void *__nvgpu_kmalloc(struct gk20a *g, size_t size, void *ip);
29void *__nvgpu_kzalloc(struct gk20a *g, size_t size, unsigned long ip); 29void *__nvgpu_kzalloc(struct gk20a *g, size_t size, void *ip);
30void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, unsigned long ip); 30void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, void *ip);
31void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, unsigned long ip); 31void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, void *ip);
32void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, unsigned long ip); 32void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, void *ip);
33void __nvgpu_kfree(struct gk20a *g, void *addr); 33void __nvgpu_kfree(struct gk20a *g, void *addr);
34void __nvgpu_vfree(struct gk20a *g, void *addr); 34void __nvgpu_vfree(struct gk20a *g, void *addr);
35 35
diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h
index 83dd8d78..20becfdd 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/timers.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h
@@ -24,6 +24,7 @@
24#define __NVGPU_TIMERS_H__ 24#define __NVGPU_TIMERS_H__
25 25
26#include <nvgpu/types.h> 26#include <nvgpu/types.h>
27#include <nvgpu/utils.h>
27 28
28struct gk20a; 29struct gk20a;
29 30
@@ -85,10 +86,10 @@ int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout,
85int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout); 86int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout);
86 87
87#define nvgpu_timeout_expired(__timeout) \ 88#define nvgpu_timeout_expired(__timeout) \
88 __nvgpu_timeout_expired_msg(__timeout, (void *)_THIS_IP_, "") 89 __nvgpu_timeout_expired_msg(__timeout, _NVGPU_GET_IP_, "")
89 90
90#define nvgpu_timeout_expired_msg(__timeout, fmt, args...) \ 91#define nvgpu_timeout_expired_msg(__timeout, fmt, args...) \
91 __nvgpu_timeout_expired_msg(__timeout, (void *)_THIS_IP_, \ 92 __nvgpu_timeout_expired_msg(__timeout, _NVGPU_GET_IP_, \
92 fmt, ##args) 93 fmt, ##args)
93 94
94/* 95/*
diff --git a/drivers/gpu/nvgpu/include/nvgpu/utils.h b/drivers/gpu/nvgpu/include/nvgpu/utils.h
index 22102fa3..6184608a 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/utils.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/utils.h
@@ -49,4 +49,10 @@ static inline u32 get_field(u32 reg, u32 mask)
49{ 49{
50 return (reg & mask); 50 return (reg & mask);
51} 51}
52
53/*
54 * MISRA Rule 11.6 compliant IP address generator.
55 */
56#define _NVGPU_GET_IP_ ({ __label__ __here; __here: &&__here; })
57
52#endif /* NVGPU_UTILS_H */ 58#endif /* NVGPU_UTILS_H */