diff options
Diffstat (limited to 'drivers/gpu/nvgpu/include')
35 files changed, 1148 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/atomic.h b/drivers/gpu/nvgpu/include/nvgpu/atomic.h index 0f319f71..12d1c86e 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/atomic.h +++ b/drivers/gpu/nvgpu/include/nvgpu/atomic.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <nvgpu/linux/atomic.h> | 26 | #include <nvgpu/linux/atomic.h> |
27 | #elif defined(__NVGPU_POSIX__) | ||
28 | #include <nvgpu/posix/atomic.h> | ||
27 | #else | 29 | #else |
28 | #include <nvgpu_rmos/include/atomic.h> | 30 | #include <nvgpu_rmos/include/atomic.h> |
29 | #endif | 31 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/barrier.h b/drivers/gpu/nvgpu/include/nvgpu/barrier.h index 03a14a99..49b10b86 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/barrier.h +++ b/drivers/gpu/nvgpu/include/nvgpu/barrier.h | |||
@@ -30,6 +30,8 @@ | |||
30 | 30 | ||
31 | #ifdef __KERNEL__ | 31 | #ifdef __KERNEL__ |
32 | #include <nvgpu/linux/barrier.h> | 32 | #include <nvgpu/linux/barrier.h> |
33 | #elif defined(__NVGPU_POSIX__) | ||
34 | #include <nvgpu/posix/barrier.h> | ||
33 | #else | 35 | #else |
34 | #include <nvgpu_rmos/include/barrier.h> | 36 | #include <nvgpu_rmos/include/barrier.h> |
35 | #endif | 37 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/bitops.h b/drivers/gpu/nvgpu/include/nvgpu/bitops.h index d3bac60e..26b6e19d 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/bitops.h +++ b/drivers/gpu/nvgpu/include/nvgpu/bitops.h | |||
@@ -25,6 +25,8 @@ | |||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <linux/bitops.h> | 26 | #include <linux/bitops.h> |
27 | #include <linux/bitmap.h> | 27 | #include <linux/bitmap.h> |
28 | #elif defined(__NVGPU_POSIX__) | ||
29 | #include <nvgpu/posix/bitops.h> | ||
28 | #else | 30 | #else |
29 | #include <nvgpu_rmos/include/bitops.h> | 31 | #include <nvgpu_rmos/include/bitops.h> |
30 | #endif | 32 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/bsearch.h b/drivers/gpu/nvgpu/include/nvgpu/bsearch.h index b02cc85c..872701e6 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/bsearch.h +++ b/drivers/gpu/nvgpu/include/nvgpu/bsearch.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <linux/bsearch.h> | 26 | #include <linux/bsearch.h> |
27 | #elif defined(__NVGPU_POSIX__) | ||
28 | #include <stdlib.h> | ||
27 | #endif | 29 | #endif |
28 | 30 | ||
29 | #endif | 31 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/bug.h b/drivers/gpu/nvgpu/include/nvgpu/bug.h index ea62c6d8..671439a1 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/bug.h +++ b/drivers/gpu/nvgpu/include/nvgpu/bug.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <linux/bug.h> | 26 | #include <linux/bug.h> |
27 | #elif defined(__NVGPU_POSIX__) | ||
28 | #include <nvgpu/posix/bug.h> | ||
27 | #else | 29 | #else |
28 | #include <nvgpu_rmos/include/bug.h> | 30 | #include <nvgpu_rmos/include/bug.h> |
29 | #endif | 31 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/circ_buf.h b/drivers/gpu/nvgpu/include/nvgpu/circ_buf.h index c6620663..4dd9e0d8 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/circ_buf.h +++ b/drivers/gpu/nvgpu/include/nvgpu/circ_buf.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <linux/circ_buf.h> | 26 | #include <linux/circ_buf.h> |
27 | #elif defined(__NVGPU_POSIX__) | ||
28 | #include <nvgpu/posix/circ_buf.h> | ||
27 | #endif | 29 | #endif |
28 | 30 | ||
29 | #endif | 31 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/cond.h b/drivers/gpu/nvgpu/include/nvgpu/cond.h index b6f2598e..340fb460 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/cond.h +++ b/drivers/gpu/nvgpu/include/nvgpu/cond.h | |||
@@ -25,6 +25,8 @@ | |||
25 | 25 | ||
26 | #ifdef __KERNEL__ | 26 | #ifdef __KERNEL__ |
27 | #include <nvgpu/linux/cond.h> | 27 | #include <nvgpu/linux/cond.h> |
28 | #elif defined(__NVGPU_POSIX__) | ||
29 | #include <nvgpu/posix/cond.h> | ||
28 | #else | 30 | #else |
29 | #include <nvgpu_rmos/include/cond.h> | 31 | #include <nvgpu_rmos/include/cond.h> |
30 | #endif | 32 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/kmem.h b/drivers/gpu/nvgpu/include/nvgpu/kmem.h index fef837cf..91574ce0 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/kmem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/kmem.h | |||
@@ -40,6 +40,8 @@ struct gk20a; | |||
40 | */ | 40 | */ |
41 | #ifdef __KERNEL__ | 41 | #ifdef __KERNEL__ |
42 | #include <nvgpu/linux/kmem.h> | 42 | #include <nvgpu/linux/kmem.h> |
43 | #elif defined(__NVGPU_POSIX__) | ||
44 | #include <nvgpu/posix/kmem.h> | ||
43 | #else | 45 | #else |
44 | #include <nvgpu_rmos/include/kmem.h> | 46 | #include <nvgpu_rmos/include/kmem.h> |
45 | #endif | 47 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/lock.h b/drivers/gpu/nvgpu/include/nvgpu/lock.h index bccded57..7e4b2ac3 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/lock.h +++ b/drivers/gpu/nvgpu/include/nvgpu/lock.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * Permission is hereby granted, free of charge, to any person obtaining a | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * copy of this software and associated documentation files (the "Software"), | 5 | * copy of this software and associated documentation files (the "Software"), |
@@ -25,6 +25,8 @@ | |||
25 | 25 | ||
26 | #ifdef __KERNEL__ | 26 | #ifdef __KERNEL__ |
27 | #include <nvgpu/linux/lock.h> | 27 | #include <nvgpu/linux/lock.h> |
28 | #elif defined(__NVGPU_POSIX__) | ||
29 | #include <nvgpu/posix/lock.h> | ||
28 | #else | 30 | #else |
29 | #include <nvgpu_rmos/include/lock.h> | 31 | #include <nvgpu_rmos/include/lock.h> |
30 | #endif | 32 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/log.h b/drivers/gpu/nvgpu/include/nvgpu/log.h index 897dcfc6..87ab17ee 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/log.h +++ b/drivers/gpu/nvgpu/include/nvgpu/log.h | |||
@@ -106,7 +106,7 @@ int nvgpu_log_mask_enabled(struct gk20a *g, u64 log_mask); | |||
106 | * Print a message if the log_mask matches the enabled debugging. | 106 | * Print a message if the log_mask matches the enabled debugging. |
107 | */ | 107 | */ |
108 | #define nvgpu_log(g, log_mask, fmt, arg...) \ | 108 | #define nvgpu_log(g, log_mask, fmt, arg...) \ |
109 | __nvgpu_log_dbg(g, log_mask, __func__, __LINE__, fmt, ##arg) | 109 | __nvgpu_log_dbg(g, (u32)log_mask, __func__, __LINE__, fmt, ##arg) |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * nvgpu_err - Print an error | 112 | * nvgpu_err - Print an error |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/log2.h b/drivers/gpu/nvgpu/include/nvgpu/log2.h index 827162f8..57b77217 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/log2.h +++ b/drivers/gpu/nvgpu/include/nvgpu/log2.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <linux/log2.h> | 26 | #include <linux/log2.h> |
27 | #elif defined(__NVGPU_POSIX__) | ||
28 | #include <nvgpu/posix/log2.h> | ||
27 | #endif | 29 | #endif |
28 | 30 | ||
29 | #endif /* __NVGPU_LOG2_H__ */ | 31 | #endif /* __NVGPU_LOG2_H__ */ |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h index c5e3e752..93fce81e 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | |||
@@ -29,6 +29,8 @@ | |||
29 | 29 | ||
30 | #ifdef __KERNEL__ | 30 | #ifdef __KERNEL__ |
31 | #include <nvgpu/linux/nvgpu_mem.h> | 31 | #include <nvgpu/linux/nvgpu_mem.h> |
32 | #elif defined(__NVGPU_POSIX__) | ||
33 | #include <nvgpu/posix/nvgpu_mem.h> | ||
32 | #else | 34 | #else |
33 | #include <nvgpu_rmos/include/nvgpu_mem.h> | 35 | #include <nvgpu_rmos/include/nvgpu_mem.h> |
34 | #endif | 36 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/atomic.h b/drivers/gpu/nvgpu/include/nvgpu/posix/atomic.h new file mode 100644 index 00000000..c9d92128 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/atomic.h | |||
@@ -0,0 +1,191 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_ATOMIC_H__ | ||
24 | #define __NVGPU_POSIX_ATOMIC_H__ | ||
25 | |||
26 | #include <nvgpu/types.h> | ||
27 | |||
28 | /* | ||
29 | * Note: this code uses the GCC builtins to implement atomics. | ||
30 | */ | ||
31 | |||
32 | #define __atomic_cmpxchg(p, v, c) __sync_val_compare_and_swap(p, v, c) | ||
33 | #define __atomic_and(p, v) __sync_fetch_and_and(p, v) | ||
34 | #define __atomic_or(p, v) __sync_fetch_and_or(p, v) | ||
35 | |||
36 | #define cmpxchg __atomic_cmpxchg | ||
37 | |||
38 | /* | ||
39 | * Place holders until real atomics can be implemented... Yay for GCC builtins! | ||
40 | * We can use those eventually to define all the Linux atomic ops. | ||
41 | * | ||
42 | * TODO: make these _actually_ atomic! | ||
43 | */ | ||
44 | typedef struct __nvgpu_posix_atomic { | ||
45 | int v; | ||
46 | } nvgpu_atomic_t; | ||
47 | |||
48 | typedef struct __nvgpu_posix_atomic64 { | ||
49 | long v; | ||
50 | } nvgpu_atomic64_t; | ||
51 | |||
52 | #define __nvgpu_atomic_init(i) { i } | ||
53 | #define __nvgpu_atomic64_init(i) { i } | ||
54 | |||
55 | static inline void __nvgpu_atomic_set(nvgpu_atomic_t *v, int i) | ||
56 | { | ||
57 | v->v = i; | ||
58 | } | ||
59 | |||
60 | static inline int __nvgpu_atomic_read(nvgpu_atomic_t *v) | ||
61 | { | ||
62 | return v->v; | ||
63 | } | ||
64 | |||
65 | static inline void __nvgpu_atomic_inc(nvgpu_atomic_t *v) | ||
66 | { | ||
67 | v->v++; | ||
68 | } | ||
69 | |||
70 | static inline int __nvgpu_atomic_inc_return(nvgpu_atomic_t *v) | ||
71 | { | ||
72 | v->v++; | ||
73 | return v->v; | ||
74 | } | ||
75 | |||
76 | static inline void __nvgpu_atomic_dec(nvgpu_atomic_t *v) | ||
77 | { | ||
78 | v->v--; | ||
79 | } | ||
80 | |||
81 | static inline int __nvgpu_atomic_dec_return(nvgpu_atomic_t *v) | ||
82 | { | ||
83 | v->v--; | ||
84 | return v->v; | ||
85 | } | ||
86 | |||
87 | static inline int __nvgpu_atomic_cmpxchg(nvgpu_atomic_t *v, int old, int new) | ||
88 | { | ||
89 | if (v->v == old) | ||
90 | v->v = new; | ||
91 | |||
92 | return v->v; | ||
93 | } | ||
94 | |||
95 | static inline int __nvgpu_atomic_xchg(nvgpu_atomic_t *v, int new) | ||
96 | { | ||
97 | v->v = new; | ||
98 | return new; | ||
99 | } | ||
100 | |||
101 | static inline bool __nvgpu_atomic_inc_and_test(nvgpu_atomic_t *v) | ||
102 | { | ||
103 | v->v++; | ||
104 | return v->v ? true : false; | ||
105 | } | ||
106 | |||
107 | static inline bool __nvgpu_atomic_dec_and_test(nvgpu_atomic_t *v) | ||
108 | { | ||
109 | v->v--; | ||
110 | return v->v ? true : false; | ||
111 | } | ||
112 | |||
113 | static inline bool __nvgpu_atomic_sub_and_test(int i, nvgpu_atomic_t *v) | ||
114 | { | ||
115 | v->v -= i; | ||
116 | return v->v ? true : false; | ||
117 | } | ||
118 | |||
119 | static inline int __nvgpu_atomic_add_return(int i, nvgpu_atomic_t *v) | ||
120 | { | ||
121 | v->v += i; | ||
122 | return v->v; | ||
123 | } | ||
124 | |||
125 | static inline int __nvgpu_atomic_add_unless(nvgpu_atomic_t *v, int a, int u) | ||
126 | { | ||
127 | if (v->v != u) | ||
128 | v->v += a; | ||
129 | |||
130 | return v->v; | ||
131 | } | ||
132 | |||
133 | static inline void __nvgpu_atomic64_set(nvgpu_atomic64_t *v, long i) | ||
134 | { | ||
135 | v->v = i; | ||
136 | } | ||
137 | |||
138 | static inline long __nvgpu_atomic64_read(nvgpu_atomic64_t *v) | ||
139 | { | ||
140 | return v->v; | ||
141 | } | ||
142 | |||
143 | static inline void __nvgpu_atomic64_add(long x, nvgpu_atomic64_t *v) | ||
144 | { | ||
145 | v->v += x; | ||
146 | } | ||
147 | |||
148 | static inline void __nvgpu_atomic64_inc(nvgpu_atomic64_t *v) | ||
149 | { | ||
150 | v->v++; | ||
151 | } | ||
152 | |||
153 | static inline long __nvgpu_atomic64_inc_return(nvgpu_atomic64_t *v) | ||
154 | { | ||
155 | v->v++; | ||
156 | return v->v; | ||
157 | } | ||
158 | |||
159 | static inline void __nvgpu_atomic64_dec(nvgpu_atomic64_t *v) | ||
160 | { | ||
161 | v->v--; | ||
162 | } | ||
163 | |||
164 | static inline long __nvgpu_atomic64_dec_return(nvgpu_atomic64_t *v) | ||
165 | { | ||
166 | v->v--; | ||
167 | return v->v; | ||
168 | } | ||
169 | |||
170 | static inline long __nvgpu_atomic64_cmpxchg(nvgpu_atomic64_t *v, | ||
171 | long old, long new) | ||
172 | { | ||
173 | |||
174 | if (v->v == old) | ||
175 | v->v = new; | ||
176 | |||
177 | return v->v; | ||
178 | } | ||
179 | |||
180 | static inline void __nvgpu_atomic64_sub(long x, nvgpu_atomic64_t *v) | ||
181 | { | ||
182 | v->v -= x; | ||
183 | } | ||
184 | |||
185 | static inline long __nvgpu_atomic64_sub_return(long x, nvgpu_atomic64_t *v) | ||
186 | { | ||
187 | v->v -= x; | ||
188 | return v->v; | ||
189 | } | ||
190 | |||
191 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/barrier.h b/drivers/gpu/nvgpu/include/nvgpu/posix/barrier.h new file mode 100644 index 00000000..edc7b129 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/barrier.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_BARRIER_H__ | ||
24 | #define __NVGPU_POSIX_BARRIER_H__ | ||
25 | |||
26 | #define ACCESS_ONCE(x) (*(volatile __typeof__(x) *)&x) | ||
27 | |||
28 | /* | ||
29 | * TODO: implement all these! | ||
30 | */ | ||
31 | #define __nvgpu_mb() | ||
32 | #define __nvgpu_rmb() | ||
33 | #define __nvgpu_wmb() | ||
34 | |||
35 | #define __nvgpu_smp_mb() | ||
36 | #define __nvgpu_smp_rmb() | ||
37 | #define __nvgpu_smp_wmb() | ||
38 | |||
39 | #define __nvgpu_read_barrier_depends() | ||
40 | #define __nvgpu_smp_read_barrier_depends() | ||
41 | |||
42 | #define __NV_ACCESS_ONCE(x) ACCESS_ONCE(x) | ||
43 | |||
44 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/bitops.h b/drivers/gpu/nvgpu/include/nvgpu/posix/bitops.h new file mode 100644 index 00000000..bfc6fef1 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/bitops.h | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_BITOPS_H__ | ||
24 | #define __NVGPU_POSIX_BITOPS_H__ | ||
25 | |||
26 | #include <nvgpu/types.h> | ||
27 | |||
28 | /* | ||
29 | * Assume an 8 bit byte, of course. | ||
30 | */ | ||
31 | #define BITS_PER_BYTE 8UL | ||
32 | #define BITS_PER_LONG (__SIZEOF_LONG__ * BITS_PER_BYTE) | ||
33 | #define BITS_TO_LONGS(bits) \ | ||
34 | (bits + (BITS_PER_LONG - 1) / BITS_PER_LONG) | ||
35 | |||
36 | #define BIT(i) (1UL << (i)) | ||
37 | |||
38 | #define GENMASK(h, l) \ | ||
39 | (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) | ||
40 | |||
41 | #define DECLARE_BITMAP(bmap, bits) \ | ||
42 | unsigned long bmap[BITS_TO_LONGS(bits)] | ||
43 | |||
44 | #define for_each_set_bit(bit, addr, size) \ | ||
45 | for ((bit) = find_first_bit((addr), (size)); \ | ||
46 | (bit) < (size); \ | ||
47 | (bit) = find_next_bit((addr), (size), (bit) + 1)) | ||
48 | |||
49 | #define ffs(word) __ffs(word) | ||
50 | #define ffz(word) __ffs(~(word)) | ||
51 | #define fls(word) __fls(word) | ||
52 | |||
53 | /* | ||
54 | * Clashes with symbols in libc it seems. | ||
55 | */ | ||
56 | #define __ffs(word) __nvgpu_posix_ffs(word) | ||
57 | #define __fls(word) __nvgpu_posix_fls(word) | ||
58 | |||
59 | unsigned long __nvgpu_posix_ffs(unsigned long word); | ||
60 | unsigned long __nvgpu_posix_fls(unsigned long word); | ||
61 | |||
62 | unsigned long find_first_bit(const unsigned long *addr, unsigned long size); | ||
63 | unsigned long find_next_bit(const unsigned long *addr, unsigned long size, | ||
64 | unsigned long offset); | ||
65 | unsigned long find_first_zero_bit(const unsigned long *addr, | ||
66 | unsigned long size); | ||
67 | |||
68 | bool test_bit(int nr, const volatile unsigned long *addr); | ||
69 | bool test_and_set_bit(int nr, volatile unsigned long *addr); | ||
70 | bool test_and_clear_bit(int nr, volatile unsigned long *addr); | ||
71 | |||
72 | /* | ||
73 | * These two are atomic. | ||
74 | */ | ||
75 | void set_bit(int nr, volatile unsigned long *addr); | ||
76 | void clear_bit(int nr, volatile unsigned long *addr); | ||
77 | |||
78 | void bitmap_set(unsigned long *map, unsigned int start, int len); | ||
79 | void bitmap_clear(unsigned long *map, unsigned int start, int len); | ||
80 | unsigned long bitmap_find_next_zero_area_off(unsigned long *map, | ||
81 | unsigned long size, | ||
82 | unsigned long start, | ||
83 | unsigned int nr, | ||
84 | unsigned long align_mask, | ||
85 | unsigned long align_offset); | ||
86 | unsigned long bitmap_find_next_zero_area(unsigned long *map, | ||
87 | unsigned long size, | ||
88 | unsigned long start, | ||
89 | unsigned int nr, | ||
90 | unsigned long align_mask); | ||
91 | |||
92 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/bug.h b/drivers/gpu/nvgpu/include/nvgpu/posix/bug.h new file mode 100644 index 00000000..04389a90 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/bug.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_BUG_H__ | ||
24 | #define __NVGPU_POSIX_BUG_H__ | ||
25 | |||
26 | #include <nvgpu/types.h> | ||
27 | |||
28 | /* | ||
29 | * TODO: make these actually useful! | ||
30 | */ | ||
31 | |||
32 | #define BUG() __bug("") | ||
33 | #define BUG_ON(cond) \ | ||
34 | do { \ | ||
35 | if (cond) \ | ||
36 | BUG(); \ | ||
37 | } while (0) | ||
38 | |||
39 | #define WARN(cond, msg, arg...) __warn(cond, msg, ##arg) | ||
40 | #define WARN_ON(cond) __warn(cond, "") | ||
41 | |||
42 | #define WARN_ONCE(cond, msg, arg...) \ | ||
43 | ({static int __warned__ = 0; \ | ||
44 | if (!__warned__) { \ | ||
45 | WARN(cond, msg, ##arg); \ | ||
46 | __warned__ = 1; \ | ||
47 | } \ | ||
48 | cond; }) | ||
49 | |||
50 | |||
51 | void dump_stack(void); | ||
52 | |||
53 | void __bug(const char *fmt, ...) __attribute__ ((noreturn)); | ||
54 | bool __warn(bool cond, const char *fmt, ...); | ||
55 | |||
56 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/circ_buf.h b/drivers/gpu/nvgpu/include/nvgpu/posix/circ_buf.h new file mode 100644 index 00000000..8d9b5ea0 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/circ_buf.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_CIRC_BUF_H__ | ||
24 | #define __NVGPU_POSIX_CIRC_BUF_H__ | ||
25 | |||
26 | #include <nvgpu/bug.h> | ||
27 | |||
28 | /* TODO: implement. */ | ||
29 | |||
30 | #define CIRC_CNT(head, tail, size) \ | ||
31 | ({(void)head; \ | ||
32 | (void)tail; \ | ||
33 | (void)size; \ | ||
34 | BUG(); \ | ||
35 | 1; }) | ||
36 | |||
37 | #define CIRC_SPACE(head, tail, size) \ | ||
38 | ({(void)head; \ | ||
39 | (void)tail; \ | ||
40 | (void)size; \ | ||
41 | BUG(); \ | ||
42 | 1; }) | ||
43 | |||
44 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/cond.h b/drivers/gpu/nvgpu/include/nvgpu/posix/cond.h new file mode 100644 index 00000000..3528388b --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/cond.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_COND_H__ | ||
24 | #define __NVGPU_POSIX_COND_H__ | ||
25 | |||
26 | #include <nvgpu/bug.h> | ||
27 | |||
28 | struct nvgpu_cond { | ||
29 | /* Place holder until this can be properly implemented. */ | ||
30 | }; | ||
31 | |||
32 | /** | ||
33 | * NVGPU_COND_WAIT - Wait for a condition to be true | ||
34 | * | ||
35 | * @c - The condition variable to sleep on | ||
36 | * @condition - The condition that needs to be true | ||
37 | * @timeout_ms - Timeout in milliseconds, or 0 for infinite wait | ||
38 | * | ||
39 | * Wait for a condition to become true. Returns -ETIMEOUT if | ||
40 | * the wait timed out with condition false. | ||
41 | */ | ||
42 | #define NVGPU_COND_WAIT(c, condition, timeout_ms) \ | ||
43 | ({BUG(); 1; }) | ||
44 | |||
45 | /** | ||
46 | * NVGPU_COND_WAIT_INTERRUPTIBLE - Wait for a condition to be true | ||
47 | * | ||
48 | * @c - The condition variable to sleep on | ||
49 | * @condition - The condition that needs to be true | ||
50 | * @timeout_ms - Timeout in milliseconds, or 0 for infinite wait | ||
51 | * | ||
52 | * Wait for a condition to become true. Returns -ETIMEOUT if | ||
53 | * the wait timed out with condition false or -ERESTARTSYS on | ||
54 | * signal. | ||
55 | */ | ||
56 | #define NVGPU_COND_WAIT_INTERRUPTIBLE(c, condition, timeout_ms) \ | ||
57 | ({BUG(); 1; }) | ||
58 | |||
59 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/kmem.h b/drivers/gpu/nvgpu/include/nvgpu/posix/kmem.h new file mode 100644 index 00000000..483ac3b3 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/kmem.h | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_KMEM_H__ | ||
24 | #define __NVGPU_POSIX_KMEM_H__ | ||
25 | |||
26 | #include <nvgpu/types.h> | ||
27 | |||
28 | void *__nvgpu_kmalloc(struct gk20a *g, size_t size, unsigned long ip); | ||
29 | void *__nvgpu_kzalloc(struct gk20a *g, size_t size, unsigned long ip); | ||
30 | void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, unsigned long ip); | ||
31 | void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, unsigned long ip); | ||
32 | void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, unsigned long ip); | ||
33 | void __nvgpu_kfree(struct gk20a *g, void *addr); | ||
34 | void __nvgpu_vfree(struct gk20a *g, void *addr); | ||
35 | |||
36 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/lock.h b/drivers/gpu/nvgpu/include/nvgpu/posix/lock.h new file mode 100644 index 00000000..82eddd02 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/lock.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_LOCK_H__ | ||
24 | #define __NVGPU_POSIX_LOCK_H__ | ||
25 | |||
26 | #include <stdlib.h> | ||
27 | |||
28 | #include <pthread.h> | ||
29 | |||
30 | /* | ||
31 | * All locks for posix nvgpu are just pthread locks. There's not a lot of reason | ||
32 | * to have real spinlocks in userspace since we aren't using real HW or running | ||
33 | * perf critical code where a sleep could be devestating. | ||
34 | * | ||
35 | * This could be revisited later, though. | ||
36 | */ | ||
37 | struct __nvgpu_posix_lock { | ||
38 | pthread_mutex_t mutex; | ||
39 | }; | ||
40 | |||
41 | static inline void __nvgpu_posix_lock_acquire(struct __nvgpu_posix_lock *lock) | ||
42 | { | ||
43 | pthread_mutex_lock(&lock->mutex); | ||
44 | } | ||
45 | |||
46 | static inline int __nvgpu_posix_lock_try_acquire( | ||
47 | struct __nvgpu_posix_lock *lock) | ||
48 | { | ||
49 | return pthread_mutex_trylock(&lock->mutex); | ||
50 | } | ||
51 | |||
52 | static inline void __nvgpu_posix_lock_release(struct __nvgpu_posix_lock *lock) | ||
53 | { | ||
54 | pthread_mutex_unlock(&lock->mutex); | ||
55 | } | ||
56 | |||
57 | struct nvgpu_mutex { | ||
58 | struct __nvgpu_posix_lock lock; | ||
59 | }; | ||
60 | |||
61 | struct nvgpu_spinlock { | ||
62 | struct __nvgpu_posix_lock lock; | ||
63 | }; | ||
64 | |||
65 | struct nvgpu_raw_spinlock { | ||
66 | struct __nvgpu_posix_lock lock; | ||
67 | }; | ||
68 | |||
69 | #endif /* NVGPU_LOCK_LINUX_H */ | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/log2.h b/drivers/gpu/nvgpu/include/nvgpu/posix/log2.h new file mode 100644 index 00000000..ca95c10a --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/log2.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_LOG2_H__ | ||
24 | #define __NVGPU_POSIX_LOG2_H__ | ||
25 | |||
26 | #define ilog2(x) (fls(x) - 1) | ||
27 | |||
28 | #define roundup_pow_of_two(x) (1UL << fls((x) - 1)) | ||
29 | #define rounddown_pow_of_two(x) (1UL << (fls(x) - 1)) | ||
30 | |||
31 | #define is_power_of_2(x) \ | ||
32 | ({ \ | ||
33 | typeof(x) __x__ = (x); \ | ||
34 | (__x__ != 0 && ((__x__ & (__x__ - 1)) == 0)); \ | ||
35 | }) | ||
36 | |||
37 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/posix/nvgpu_mem.h new file mode 100644 index 00000000..30cdf60f --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/nvgpu_mem.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_NVGPU_MEM_H__ | ||
24 | #define __NVGPU_POSIX_NVGPU_MEM_H__ | ||
25 | |||
26 | struct nvgpu_mem_priv { | ||
27 | /* | ||
28 | * Eventually this will require an implementation using nvmap. | ||
29 | */ | ||
30 | }; | ||
31 | |||
32 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/probe.h b/drivers/gpu/nvgpu/include/nvgpu/posix/probe.h new file mode 100644 index 00000000..a9763aa9 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/probe.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_PROBE_H__ | ||
24 | #define __NVGPU_POSIX_PROBE_H__ | ||
25 | |||
26 | struct gk20a; | ||
27 | |||
28 | struct gk20a *nvgpu_posix_probe(void); | ||
29 | void nvgpu_posix_cleanup(struct gk20a *g); | ||
30 | |||
31 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/rwsem.h b/drivers/gpu/nvgpu/include/nvgpu/posix/rwsem.h new file mode 100644 index 00000000..65aa931b --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/rwsem.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_RWSEM_H__ | ||
24 | #define __NVGPU_POSIX_RWSEM_H__ | ||
25 | |||
26 | #include <nvgpu/lock.h> | ||
27 | |||
28 | struct nvgpu_rwsem { | ||
29 | struct nvgpu_spinlock lock; | ||
30 | |||
31 | int readers; | ||
32 | int writers; | ||
33 | }; | ||
34 | |||
35 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/sizes.h b/drivers/gpu/nvgpu/include/nvgpu/posix/sizes.h new file mode 100644 index 00000000..3fda7574 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/sizes.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_SIZES_H__ | ||
24 | #define __NVGPU_POSIX_SIZES_H__ | ||
25 | |||
26 | #define SZ_1K (1UL << 10) | ||
27 | #define SZ_4K (SZ_1K << 2) | ||
28 | #define SZ_64K (SZ_1K << 6) | ||
29 | #define SZ_128K (SZ_1K << 7) | ||
30 | |||
31 | #define SZ_1M (1UL << 20) | ||
32 | #define SZ_16M (SZ_1M << 4) | ||
33 | #define SZ_256M (SZ_1M << 8) | ||
34 | |||
35 | #define SZ_1G (1UL << 30) | ||
36 | #define SZ_4G (SZ_1G << 2) | ||
37 | |||
38 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/sort.h b/drivers/gpu/nvgpu/include/nvgpu/posix/sort.h new file mode 100644 index 00000000..6a6920eb --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/sort.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_SORT_H__ | ||
24 | #define __NVGPU_POSIX_SORT_H__ | ||
25 | |||
26 | #include <nvgpu/bug.h> | ||
27 | |||
28 | static void sort(void *base, size_t num, size_t size, | ||
29 | int (*cmp)(const void *, const void *), | ||
30 | void (*swap)(void *, void *, int)) | ||
31 | { | ||
32 | __bug("sort() not implemented yet!"); | ||
33 | } | ||
34 | |||
35 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/thread.h b/drivers/gpu/nvgpu/include/nvgpu/posix/thread.h new file mode 100644 index 00000000..a312cc13 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/thread.h | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_THREAD_H__ | ||
24 | #define __NVGPU_POSIX_THREAD_H__ | ||
25 | |||
26 | #include <pthread.h> | ||
27 | |||
28 | #include <nvgpu/types.h> | ||
29 | |||
30 | /* | ||
31 | * Handles passing an nvgpu thread function into a posix thread. | ||
32 | */ | ||
33 | struct nvgpu_posix_thread_data { | ||
34 | int (*fn)(void *data); | ||
35 | void *data; | ||
36 | }; | ||
37 | |||
38 | /* | ||
39 | * For some reason POSIX only allows 16 bytes of name length. | ||
40 | */ | ||
41 | #define NVGPU_THREAD_POSIX_MAX_NAMELEN 16 | ||
42 | |||
43 | struct nvgpu_thread { | ||
44 | bool running; | ||
45 | bool should_stop; | ||
46 | pthread_t thread; | ||
47 | struct nvgpu_posix_thread_data nvgpu; | ||
48 | char tname[16]; | ||
49 | }; | ||
50 | |||
51 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/types.h b/drivers/gpu/nvgpu/include/nvgpu/posix/types.h new file mode 100644 index 00000000..3dfcec6c --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/types.h | |||
@@ -0,0 +1,219 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_TYPES_H__ | ||
24 | #define __NVGPU_POSIX_TYPES_H__ | ||
25 | |||
26 | #include <stdbool.h> | ||
27 | #include <stdint.h> | ||
28 | #include <stddef.h> | ||
29 | #include <errno.h> | ||
30 | #include <limits.h> | ||
31 | #include <string.h> | ||
32 | #include <strings.h> | ||
33 | #include <stdio.h> | ||
34 | #include <stdarg.h> | ||
35 | |||
36 | /* | ||
37 | * For endianness functions. | ||
38 | */ | ||
39 | #include <netinet/in.h> | ||
40 | |||
41 | typedef unsigned char __u8; | ||
42 | typedef unsigned short __u16; | ||
43 | typedef unsigned int __u32; | ||
44 | typedef unsigned long long __u64; | ||
45 | |||
46 | typedef __u8 u8; | ||
47 | typedef __u16 u16; | ||
48 | typedef __u32 u32; | ||
49 | typedef __u64 u64; | ||
50 | |||
51 | typedef char s8; | ||
52 | typedef short s16; | ||
53 | typedef int s32; | ||
54 | typedef long long s64; | ||
55 | |||
56 | #define min_t(type, a, b) \ | ||
57 | ({ \ | ||
58 | type __a = (a); \ | ||
59 | type __b = (b); \ | ||
60 | __a < __b ? __a : __b; \ | ||
61 | }) | ||
62 | |||
63 | #define min(a, b) \ | ||
64 | ({ \ | ||
65 | (a) < (b) ? a : b; \ | ||
66 | }) | ||
67 | #define min3(a, b, c) min(min(a, b), c) | ||
68 | |||
69 | #define max(a, b) \ | ||
70 | ({ \ | ||
71 | (a) > (b) ? a : b; \ | ||
72 | }) | ||
73 | |||
74 | #define PAGE_SIZE 4096 | ||
75 | |||
76 | #define ARRAY_SIZE(array) \ | ||
77 | (sizeof(array) / sizeof((array)[0])) | ||
78 | |||
79 | #define MAX_SCHEDULE_TIMEOUT LONG_MAX | ||
80 | |||
81 | #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) | ||
82 | |||
83 | /* | ||
84 | * Only used in clk_gm20b.c which we will never unit test. Don't use! | ||
85 | */ | ||
86 | #define DIV_ROUND_CLOSEST(x, divisor) ({BUG(); 0; }) | ||
87 | |||
88 | /* | ||
89 | * Joys of userspace: usually division just works since the compiler can link | ||
90 | * against external division functions implicitly. | ||
91 | */ | ||
92 | #define do_div(a, b) ((a) /= (b)) | ||
93 | #define div64_u64(a, b) ((a) / (b)) | ||
94 | |||
95 | #define __round_mask(x, y) ((__typeof__(x))((y) - 1)) | ||
96 | #define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1) | ||
97 | #define roundup(x, y) round_up(x, y) | ||
98 | #define round_down(x, y) ((x) & ~__round_mask(x, y)) | ||
99 | |||
100 | #define ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) | ||
101 | #define ALIGN(x, a) ALIGN_MASK(x, (typeof(x))(a) - 1) | ||
102 | #define PAGE_ALIGN(x) ALIGN(x, PAGE_SIZE) | ||
103 | |||
104 | /* | ||
105 | * Caps return at the size of the buffer not what would have been written if buf | ||
106 | * were arbitrarily sized. | ||
107 | */ | ||
108 | static inline int scnprintf(char *buf, size_t size, const char *format, ...) | ||
109 | { | ||
110 | size_t ret; | ||
111 | va_list args; | ||
112 | |||
113 | va_start(args, format); | ||
114 | ret = vsnprintf(buf, size, format, args); | ||
115 | va_end(args); | ||
116 | |||
117 | return ret <= size ? ret : size; | ||
118 | } | ||
119 | |||
120 | static inline u32 be32_to_cpu(u32 x) | ||
121 | { | ||
122 | /* | ||
123 | * Conveniently big-endian happens to be network byte order as well so | ||
124 | * we can use ntohl() for this. | ||
125 | */ | ||
126 | return ntohl(x); | ||
127 | } | ||
128 | |||
129 | /* | ||
130 | * Hamming weights. | ||
131 | */ | ||
132 | static inline unsigned long __hweight8(uint8_t x) | ||
133 | { | ||
134 | return (unsigned long)(!!(x & (1 << 0)) + | ||
135 | !!(x & (1 << 1)) + | ||
136 | !!(x & (1 << 2)) + | ||
137 | !!(x & (1 << 3)) + | ||
138 | !!(x & (1 << 4)) + | ||
139 | !!(x & (1 << 5)) + | ||
140 | !!(x & (1 << 6)) + | ||
141 | !!(x & (1 << 7))); | ||
142 | } | ||
143 | |||
144 | static inline unsigned long __hweight16(uint16_t x) | ||
145 | { | ||
146 | return __hweight8((uint8_t)x) + | ||
147 | __hweight8((uint8_t)((x & 0xff00) >> 8)); | ||
148 | } | ||
149 | |||
150 | static inline unsigned long __hweight32(uint32_t x) | ||
151 | { | ||
152 | return __hweight16((uint16_t)x) + | ||
153 | __hweight16((uint16_t)((x & 0xffff0000) >> 16)); | ||
154 | } | ||
155 | |||
156 | static inline unsigned long __hweight64(uint64_t x) | ||
157 | { | ||
158 | return __hweight32((uint32_t)x) + | ||
159 | __hweight32((uint32_t)((x & 0xffffffff00000000) >> 32)); | ||
160 | } | ||
161 | |||
162 | #define hweight32 __hweight32 | ||
163 | #define hweight_long __hweight64 | ||
164 | |||
165 | /* | ||
166 | * Better suited under a compiler.h type header file, but for now these can live | ||
167 | * here. | ||
168 | */ | ||
169 | #define __must_check | ||
170 | #define __maybe_unused __attribute__((unused)) | ||
171 | #define __iomem | ||
172 | #define unlikely | ||
173 | #define likely | ||
174 | |||
175 | #define __stringify(x) #x | ||
176 | |||
177 | /* | ||
178 | * Prevent compiler optimizations from mangling writes. But likely most uses of | ||
179 | * this in nvgpu are incorrect (i.e unnecessary). | ||
180 | */ | ||
181 | #define WRITE_ONCE(p, v) \ | ||
182 | ({ \ | ||
183 | volatile typeof(p) *__p__ = &(p); \ | ||
184 | *__p__ = v; \ | ||
185 | }) | ||
186 | |||
187 | #define container_of(ptr, type, member) ({ \ | ||
188 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | ||
189 | (type *)( (char *)__mptr - offsetof(type,member) );}) | ||
190 | |||
191 | #define __packed __attribute__((packed)) | ||
192 | |||
193 | #define IS_ENABLED(config) 0 | ||
194 | |||
195 | #define MAX_ERRNO 4095 | ||
196 | |||
197 | #define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) | ||
198 | |||
199 | static inline void *ERR_PTR(long error) | ||
200 | { | ||
201 | return (void *) error; | ||
202 | } | ||
203 | |||
204 | static inline long PTR_ERR(void *error) | ||
205 | { | ||
206 | return (long)(uintptr_t)error; | ||
207 | } | ||
208 | |||
209 | static inline bool IS_ERR(const void *ptr) | ||
210 | { | ||
211 | return IS_ERR_VALUE((unsigned long)ptr); | ||
212 | } | ||
213 | |||
214 | static inline bool IS_ERR_OR_NULL(const void *ptr) | ||
215 | { | ||
216 | return (ptr == NULL) || IS_ERR_VALUE((unsigned long)ptr); | ||
217 | } | ||
218 | |||
219 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/vm.h b/drivers/gpu/nvgpu/include/nvgpu/posix/vm.h new file mode 100644 index 00000000..ae997d3c --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/vm.h | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_VM_H__ | ||
24 | #define __NVGPU_POSIX_VM_H__ | ||
25 | |||
26 | #include <nvgpu/types.h> | ||
27 | |||
28 | struct nvgpu_os_buffer { | ||
29 | /* | ||
30 | * We just use malloc() buffers in userspace. | ||
31 | */ | ||
32 | void *buf; | ||
33 | size_t size; | ||
34 | }; | ||
35 | |||
36 | struct nvgpu_mapped_buf_priv { | ||
37 | void *buf; | ||
38 | size_t size; | ||
39 | }; | ||
40 | |||
41 | #endif | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/rwsem.h b/drivers/gpu/nvgpu/include/nvgpu/rwsem.h index 0366ceff..4facf138 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/rwsem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/rwsem.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <nvgpu/linux/rwsem.h> | 26 | #include <nvgpu/linux/rwsem.h> |
27 | #elif defined(__NVGPU_POSIX__) | ||
28 | #include <nvgpu/posix/rwsem.h> | ||
27 | #else | 29 | #else |
28 | #include <nvgpu_rmos/include/rwsem.h> | 30 | #include <nvgpu_rmos/include/rwsem.h> |
29 | #endif | 31 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/sizes.h b/drivers/gpu/nvgpu/include/nvgpu/sizes.h index bb6f9c3d..588e772d 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/sizes.h +++ b/drivers/gpu/nvgpu/include/nvgpu/sizes.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <linux/sizes.h> | 26 | #include <linux/sizes.h> |
27 | #elif defined(__NVGPU_POSIX__) | ||
28 | #include <nvgpu/posix/sizes.h> | ||
27 | #else | 29 | #else |
28 | #include <nvgpu_rmos/include/sizes.h> | 30 | #include <nvgpu_rmos/include/sizes.h> |
29 | #endif | 31 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/sort.h b/drivers/gpu/nvgpu/include/nvgpu/sort.h index 0bef3593..20d86680 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/sort.h +++ b/drivers/gpu/nvgpu/include/nvgpu/sort.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <linux/sort.h> | 26 | #include <linux/sort.h> |
27 | #elif defined(__NVGPU_POSIX__) | ||
28 | #include <nvgpu/posix/sort.h> | ||
27 | #else | 29 | #else |
28 | #include <nvgpu_rmos/include/sort.h> | 30 | #include <nvgpu_rmos/include/sort.h> |
29 | #endif | 31 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/thread.h b/drivers/gpu/nvgpu/include/nvgpu/thread.h index 79df9cda..316ca146 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/thread.h +++ b/drivers/gpu/nvgpu/include/nvgpu/thread.h | |||
@@ -25,10 +25,14 @@ | |||
25 | 25 | ||
26 | #ifdef __KERNEL__ | 26 | #ifdef __KERNEL__ |
27 | #include <nvgpu/linux/thread.h> | 27 | #include <nvgpu/linux/thread.h> |
28 | #elif defined(__NVGPU_POSIX__) | ||
29 | #include <nvgpu/posix/thread.h> | ||
28 | #else | 30 | #else |
29 | #include <nvgpu_rmos/include/thread.h> | 31 | #include <nvgpu_rmos/include/thread.h> |
30 | #endif | 32 | #endif |
31 | 33 | ||
34 | #include <nvgpu/types.h> | ||
35 | |||
32 | /** | 36 | /** |
33 | * nvgpu_thread_create - Create and run a new thread. | 37 | * nvgpu_thread_create - Create and run a new thread. |
34 | * | 38 | * |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/types.h b/drivers/gpu/nvgpu/include/nvgpu/types.h index 8425c25d..1e243e53 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/types.h +++ b/drivers/gpu/nvgpu/include/nvgpu/types.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
26 | #include <linux/types.h> | 26 | #include <linux/types.h> |
27 | #elif defined(__NVGPU_POSIX__) | ||
28 | #include <nvgpu/posix/types.h> | ||
27 | #else | 29 | #else |
28 | #include <nvgpu_rmos/include/types.h> | 30 | #include <nvgpu_rmos/include/types.h> |
29 | #endif | 31 | #endif |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm.h b/drivers/gpu/nvgpu/include/nvgpu/vm.h index a5a358ea..30a2d71d 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vm.h | |||
@@ -43,6 +43,8 @@ struct nvgpu_os_buffer; | |||
43 | 43 | ||
44 | #ifdef __KERNEL__ | 44 | #ifdef __KERNEL__ |
45 | #include <nvgpu/linux/vm.h> | 45 | #include <nvgpu/linux/vm.h> |
46 | #elif defined(__NVGPU_POSIX__) | ||
47 | #include <nvgpu/posix/vm.h> | ||
46 | #else | 48 | #else |
47 | /* QNX include goes here. */ | 49 | /* QNX include goes here. */ |
48 | #include <nvgpu_rmos/include/vm.h> | 50 | #include <nvgpu_rmos/include/vm.h> |