diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/posix')
25 files changed, 0 insertions, 2233 deletions
diff --git a/drivers/gpu/nvgpu/common/posix/bitmap.c b/drivers/gpu/nvgpu/common/posix/bitmap.c deleted file mode 100644 index f25f6e64..00000000 --- a/drivers/gpu/nvgpu/common/posix/bitmap.c +++ /dev/null | |||
@@ -1,216 +0,0 @@ | |||
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 | #include <stdio.h> | ||
24 | #include <stdlib.h> | ||
25 | |||
26 | #include <nvgpu/posix/bitops.h> | ||
27 | #include <nvgpu/posix/atomic.h> | ||
28 | |||
29 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
30 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) | ||
31 | |||
32 | unsigned long __nvgpu_posix_ffs(unsigned long word) | ||
33 | { | ||
34 | return (__builtin_ffsl(word) - 1) & | ||
35 | ((sizeof(unsigned long) * 8UL) - 1UL); | ||
36 | } | ||
37 | |||
38 | unsigned long __nvgpu_posix_fls(unsigned long word) | ||
39 | { | ||
40 | return ((sizeof(unsigned long) * 8UL) - 1UL) - __builtin_clzl(word); | ||
41 | } | ||
42 | |||
43 | static unsigned long __find_next_bit(const unsigned long *addr, | ||
44 | unsigned long n, | ||
45 | unsigned long start, | ||
46 | bool invert) | ||
47 | { | ||
48 | unsigned long idx; | ||
49 | unsigned long w; | ||
50 | unsigned long start_mask; | ||
51 | |||
52 | /* | ||
53 | * We make a mask we can XOR into the word so that we can invert the | ||
54 | * word without requiring a branch. I.e instead of doing: | ||
55 | * | ||
56 | * w = invert ? ~addr[idx] : addr[idx] | ||
57 | * | ||
58 | * We can do: | ||
59 | * | ||
60 | * w = addr[idx] ^= invert_mask | ||
61 | * | ||
62 | * This saves us a branch every iteration through the loop. Now we can | ||
63 | * always just look for 1s. | ||
64 | */ | ||
65 | unsigned long invert_mask = invert ? ~0UL : 0UL; | ||
66 | |||
67 | if (start >= n) | ||
68 | return n; | ||
69 | |||
70 | start_mask = ~0UL << (start & (BITS_PER_LONG - 1)); | ||
71 | |||
72 | idx = start / BITS_PER_LONG; | ||
73 | w = (addr[idx] ^ invert_mask) & start_mask; | ||
74 | |||
75 | start = round_up(start, BITS_PER_LONG); | ||
76 | |||
77 | /* | ||
78 | * Find the first non-zero word taking into account start and | ||
79 | * invert. | ||
80 | */ | ||
81 | while (!w) { | ||
82 | idx++; | ||
83 | start += BITS_PER_LONG; | ||
84 | |||
85 | w = addr[idx] ^ invert_mask; | ||
86 | } | ||
87 | |||
88 | return min(n, ffs(w) + idx * BITS_PER_LONG); | ||
89 | } | ||
90 | |||
91 | unsigned long find_first_bit(const unsigned long *addr, unsigned long size) | ||
92 | { | ||
93 | return __find_next_bit(addr, size, 0, false); | ||
94 | } | ||
95 | |||
96 | unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size) | ||
97 | { | ||
98 | return __find_next_bit(addr, size, 0, true); | ||
99 | } | ||
100 | |||
101 | unsigned long find_next_bit(const unsigned long *addr, unsigned long size, | ||
102 | unsigned long offset) | ||
103 | { | ||
104 | return __find_next_bit(addr, size, offset, false); | ||
105 | } | ||
106 | |||
107 | static unsigned long find_next_zero_bit(const unsigned long *addr, | ||
108 | unsigned long size, | ||
109 | unsigned long offset) | ||
110 | { | ||
111 | return __find_next_bit(addr, size, offset, true); | ||
112 | } | ||
113 | |||
114 | void bitmap_set(unsigned long *map, unsigned int start, int len) | ||
115 | { | ||
116 | unsigned int end = start + len; | ||
117 | |||
118 | /* | ||
119 | * Super slow naive implementation. But speed isn't what matters here. | ||
120 | */ | ||
121 | while (start < end) | ||
122 | set_bit(start++, map); | ||
123 | } | ||
124 | |||
125 | void bitmap_clear(unsigned long *map, unsigned int start, int len) | ||
126 | { | ||
127 | unsigned int end = start + len; | ||
128 | |||
129 | while (start < end) | ||
130 | clear_bit(start++, map); | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * This is essentially a find-first-fit allocator: this searches a bitmap for | ||
135 | * the first space that is large enough to satisfy the requested size of bits. | ||
136 | * That means that this is not a vary smart allocator. But it is fast relative | ||
137 | * to an allocator that goes looking for an optimal location. | ||
138 | */ | ||
139 | unsigned long bitmap_find_next_zero_area_off(unsigned long *map, | ||
140 | unsigned long size, | ||
141 | unsigned long start, | ||
142 | unsigned int nr, | ||
143 | unsigned long align_mask, | ||
144 | unsigned long align_offset) | ||
145 | { | ||
146 | unsigned long offs; | ||
147 | |||
148 | while (start + nr <= size) { | ||
149 | start = find_next_zero_bit(map, size, start); | ||
150 | |||
151 | start = ALIGN_MASK(start + align_offset, align_mask) - | ||
152 | align_offset; | ||
153 | |||
154 | /* | ||
155 | * Not enough space left to satisfy the requested area. | ||
156 | */ | ||
157 | if ((start + nr) > size) | ||
158 | return size; | ||
159 | |||
160 | offs = find_next_bit(map, size, start); | ||
161 | |||
162 | if ((offs - start) >= nr) | ||
163 | return start; | ||
164 | |||
165 | start = offs + 1; | ||
166 | } | ||
167 | |||
168 | return size; | ||
169 | } | ||
170 | |||
171 | unsigned long bitmap_find_next_zero_area(unsigned long *map, | ||
172 | unsigned long size, | ||
173 | unsigned long start, | ||
174 | unsigned int nr, | ||
175 | unsigned long align_mask) | ||
176 | { | ||
177 | return bitmap_find_next_zero_area_off(map, size, start, nr, | ||
178 | align_mask, 0); | ||
179 | } | ||
180 | |||
181 | bool test_bit(int nr, const volatile unsigned long *addr) | ||
182 | { | ||
183 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); | ||
184 | } | ||
185 | |||
186 | bool test_and_set_bit(int nr, volatile unsigned long *addr) | ||
187 | { | ||
188 | unsigned long mask = BIT_MASK(nr); | ||
189 | volatile unsigned long *p = addr + BIT_WORD(nr); | ||
190 | |||
191 | return !!(__sync_fetch_and_or(p, mask) & mask); | ||
192 | } | ||
193 | |||
194 | bool test_and_clear_bit(int nr, volatile unsigned long *addr) | ||
195 | { | ||
196 | unsigned long mask = BIT_MASK(nr); | ||
197 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); | ||
198 | |||
199 | return !!(__sync_fetch_and_and(p, ~mask) & mask); | ||
200 | } | ||
201 | |||
202 | void set_bit(int nr, volatile unsigned long *addr) | ||
203 | { | ||
204 | unsigned long mask = BIT_MASK(nr); | ||
205 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); | ||
206 | |||
207 | __atomic_or(p, mask); | ||
208 | } | ||
209 | |||
210 | void clear_bit(int nr, volatile unsigned long *addr) | ||
211 | { | ||
212 | unsigned long mask = BIT_MASK(nr); | ||
213 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); | ||
214 | |||
215 | __atomic_and(p, ~mask); | ||
216 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/bug.c b/drivers/gpu/nvgpu/common/posix/bug.c deleted file mode 100644 index 64f4a6f6..00000000 --- a/drivers/gpu/nvgpu/common/posix/bug.c +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
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 | #include <nvgpu/log.h> | ||
24 | |||
25 | #include <nvgpu/posix/bug.h> | ||
26 | |||
27 | __attribute__ ((noreturn)) | ||
28 | static void __hang(void) | ||
29 | { | ||
30 | nvgpu_err(NULL, "Hanging!"); | ||
31 | |||
32 | while (1) | ||
33 | ; | ||
34 | } | ||
35 | |||
36 | static void __dump_stack(unsigned int skip_frames) | ||
37 | { | ||
38 | return; | ||
39 | } | ||
40 | |||
41 | void dump_stack(void) | ||
42 | { | ||
43 | __dump_stack(0); | ||
44 | } | ||
45 | |||
46 | /* | ||
47 | * Ahhh! A bug! | ||
48 | */ | ||
49 | void __bug(const char *fmt, ...) | ||
50 | { | ||
51 | nvgpu_err(NULL, "BUG detected!"); | ||
52 | |||
53 | __hang(); | ||
54 | } | ||
55 | |||
56 | bool __warn(bool cond, const char *fmt, ...) | ||
57 | { | ||
58 | if (!cond) | ||
59 | goto done; | ||
60 | |||
61 | nvgpu_warn(NULL, "WARNING detected!"); | ||
62 | |||
63 | dump_stack(); | ||
64 | |||
65 | done: | ||
66 | return cond; | ||
67 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/channel.c b/drivers/gpu/nvgpu/common/posix/channel.c deleted file mode 100644 index 05697159..00000000 --- a/drivers/gpu/nvgpu/common/posix/channel.c +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
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 | #include "gk20a/channel_gk20a.h" | ||
24 | |||
25 | u32 nvgpu_get_gpfifo_entry_size(void) | ||
26 | { | ||
27 | /* | ||
28 | * There is no struct nvgpu_gpfifo for us to use yet. But when it's | ||
29 | * defined in userspace this is how big it will be. | ||
30 | */ | ||
31 | return 8; | ||
32 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/clk_arb.c b/drivers/gpu/nvgpu/common/posix/clk_arb.c deleted file mode 100644 index 2214b37b..00000000 --- a/drivers/gpu/nvgpu/common/posix/clk_arb.c +++ /dev/null | |||
@@ -1,149 +0,0 @@ | |||
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 | #include <nvgpu/list.h> | ||
24 | #include <nvgpu/clk_arb.h> | ||
25 | |||
26 | /** | ||
27 | * Stub imlementation of the clk_arb code. Yikes. Much of this probably could be | ||
28 | * commonized if one were to think through the implementation but that is | ||
29 | * probably weeks of work at a minimum. | ||
30 | * | ||
31 | * So for POSIX it will be stubbed. | ||
32 | */ | ||
33 | |||
34 | int nvgpu_clk_arb_init_arbiter(struct gk20a *g) | ||
35 | { | ||
36 | return -ENOSYS; | ||
37 | } | ||
38 | |||
39 | int nvgpu_clk_arb_get_arbiter_clk_range(struct gk20a *g, u32 api_domain, | ||
40 | u16 *min_mhz, u16 *max_mhz) | ||
41 | { | ||
42 | return -ENOSYS; | ||
43 | } | ||
44 | |||
45 | int nvgpu_clk_arb_get_arbiter_actual_mhz(struct gk20a *g, | ||
46 | u32 api_domain, u16 *actual_mhz) | ||
47 | { | ||
48 | return -ENOSYS; | ||
49 | } | ||
50 | |||
51 | int nvgpu_clk_arb_get_arbiter_effective_mhz(struct gk20a *g, | ||
52 | u32 api_domain, u16 *effective_mhz) | ||
53 | { | ||
54 | return -ENOSYS; | ||
55 | } | ||
56 | |||
57 | |||
58 | int nvgpu_clk_arb_get_arbiter_clk_f_points(struct gk20a *g, | ||
59 | u32 api_domain, | ||
60 | u32 *max_points, u16 *fpoints) | ||
61 | { | ||
62 | return -ENOSYS; | ||
63 | } | ||
64 | |||
65 | u32 nvgpu_clk_arb_get_arbiter_clk_domains(struct gk20a *g) | ||
66 | { | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | bool nvgpu_clk_arb_is_valid_domain(struct gk20a *g, u32 api_domain) | ||
71 | { | ||
72 | return false; | ||
73 | } | ||
74 | |||
75 | void nvgpu_clk_arb_cleanup_arbiter(struct gk20a *g) | ||
76 | { | ||
77 | } | ||
78 | |||
79 | int nvgpu_clk_arb_install_session_fd(struct gk20a *g, | ||
80 | struct nvgpu_clk_session *session) | ||
81 | { | ||
82 | return -ENOSYS; | ||
83 | } | ||
84 | |||
85 | |||
86 | int nvgpu_clk_arb_init_session(struct gk20a *g, | ||
87 | struct nvgpu_clk_session **_session) | ||
88 | { | ||
89 | return -ENOSYS; | ||
90 | } | ||
91 | |||
92 | void nvgpu_clk_arb_release_session(struct gk20a *g, | ||
93 | struct nvgpu_clk_session *session) | ||
94 | { | ||
95 | } | ||
96 | |||
97 | int nvgpu_clk_arb_commit_request_fd(struct gk20a *g, | ||
98 | struct nvgpu_clk_session *session, | ||
99 | int request_fd) | ||
100 | { | ||
101 | return -ENOSYS; | ||
102 | } | ||
103 | |||
104 | int nvgpu_clk_arb_set_session_target_mhz(struct nvgpu_clk_session *session, | ||
105 | int fd, u32 api_domain, u16 target_mhz) | ||
106 | { | ||
107 | return -ENOSYS; | ||
108 | } | ||
109 | |||
110 | int nvgpu_clk_arb_get_session_target_mhz(struct nvgpu_clk_session *session, | ||
111 | u32 api_domain, u16 *target_mhz) | ||
112 | { | ||
113 | return -ENOSYS; | ||
114 | } | ||
115 | |||
116 | int nvgpu_clk_arb_install_event_fd(struct gk20a *g, | ||
117 | struct nvgpu_clk_session *session, | ||
118 | int *event_fd, u32 alarm_mask) | ||
119 | { | ||
120 | return -ENOSYS; | ||
121 | } | ||
122 | |||
123 | int nvgpu_clk_arb_install_request_fd(struct gk20a *g, | ||
124 | struct nvgpu_clk_session *session, | ||
125 | int *event_fd) | ||
126 | { | ||
127 | return -ENOSYS; | ||
128 | } | ||
129 | |||
130 | void nvgpu_clk_arb_schedule_vf_table_update(struct gk20a *g) | ||
131 | { | ||
132 | } | ||
133 | |||
134 | int nvgpu_clk_arb_get_current_pstate(struct gk20a *g) | ||
135 | { | ||
136 | return -ENOSYS; | ||
137 | } | ||
138 | |||
139 | void nvgpu_clk_arb_pstate_change_lock(struct gk20a *g, bool lock) | ||
140 | { | ||
141 | } | ||
142 | |||
143 | void nvgpu_clk_arb_send_thermal_alarm(struct gk20a *g) | ||
144 | { | ||
145 | } | ||
146 | |||
147 | void nvgpu_clk_arb_schedule_alarm(struct gk20a *g, u32 alarm) | ||
148 | { | ||
149 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/cond.c b/drivers/gpu/nvgpu/common/posix/cond.c deleted file mode 100644 index ca8a2c4a..00000000 --- a/drivers/gpu/nvgpu/common/posix/cond.c +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
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 | #include <nvgpu/cond.h> | ||
24 | |||
25 | #include <nvgpu/posix/cond.h> | ||
26 | |||
27 | int nvgpu_cond_init(struct nvgpu_cond *cond) | ||
28 | { | ||
29 | return -ENOSYS; | ||
30 | } | ||
31 | |||
32 | int nvgpu_cond_signal(struct nvgpu_cond *cond) | ||
33 | { | ||
34 | return -ENOSYS; | ||
35 | } | ||
36 | |||
37 | int nvgpu_cond_signal_interruptible(struct nvgpu_cond *cond) | ||
38 | { | ||
39 | return -ENOSYS; | ||
40 | } | ||
41 | |||
42 | int nvgpu_cond_broadcast(struct nvgpu_cond *cond) | ||
43 | { | ||
44 | return -ENOSYS; | ||
45 | } | ||
46 | |||
47 | int nvgpu_cond_broadcast_interruptible(struct nvgpu_cond *cond) | ||
48 | { | ||
49 | return -ENOSYS; | ||
50 | } | ||
51 | |||
52 | void nvgpu_cond_destroy(struct nvgpu_cond *cond) | ||
53 | { | ||
54 | |||
55 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/dma.c b/drivers/gpu/nvgpu/common/posix/dma.c deleted file mode 100644 index 95bb1a75..00000000 --- a/drivers/gpu/nvgpu/common/posix/dma.c +++ /dev/null | |||
@@ -1,228 +0,0 @@ | |||
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 | #include <stdlib.h> | ||
24 | |||
25 | #include <nvgpu/mm.h> | ||
26 | #include <nvgpu/vm.h> | ||
27 | #include <nvgpu/bug.h> | ||
28 | #include <nvgpu/dma.h> | ||
29 | #include <nvgpu/gmmu.h> | ||
30 | #include <nvgpu/nvgpu_mem.h> | ||
31 | #include <nvgpu/enabled.h> | ||
32 | |||
33 | /* | ||
34 | * In userspace vidmem vs sysmem is just a difference in what is placed in the | ||
35 | * aperture field. | ||
36 | */ | ||
37 | static int __nvgpu_do_dma_alloc(struct gk20a *g, unsigned long flags, | ||
38 | size_t size, struct nvgpu_mem *mem, | ||
39 | enum nvgpu_aperture ap) | ||
40 | { | ||
41 | void *memory = malloc(mem->aligned_size); | ||
42 | |||
43 | if (memory == NULL) | ||
44 | return -ENOMEM; | ||
45 | |||
46 | mem->cpu_va = memory; | ||
47 | mem->aperture = ap; | ||
48 | mem->size = size; | ||
49 | mem->aligned_size = PAGE_ALIGN(size); | ||
50 | mem->gpu_va = 0ULL; | ||
51 | mem->skip_wmb = true; | ||
52 | mem->vidmem_alloc = NULL; | ||
53 | mem->allocator = NULL; | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | bool nvgpu_iommuable(struct gk20a *g) | ||
59 | { | ||
60 | return false; | ||
61 | } | ||
62 | |||
63 | int nvgpu_dma_alloc(struct gk20a *g, size_t size, struct nvgpu_mem *mem) | ||
64 | { | ||
65 | return nvgpu_dma_alloc_flags(g, 0, size, mem); | ||
66 | } | ||
67 | |||
68 | int nvgpu_dma_alloc_flags(struct gk20a *g, unsigned long flags, size_t size, | ||
69 | struct nvgpu_mem *mem) | ||
70 | { | ||
71 | if (!nvgpu_is_enabled(g, NVGPU_MM_UNIFIED_MEMORY)) { | ||
72 | /* | ||
73 | * First try vidmem. Obviously in userspace there's no such | ||
74 | * thing as vidmem per se but we will mark the aperture as | ||
75 | * vidmem. | ||
76 | */ | ||
77 | int err = nvgpu_dma_alloc_flags_vid(g, 0, size, mem); | ||
78 | |||
79 | if (!err) | ||
80 | return 0; | ||
81 | /* | ||
82 | * Fall back to sysmem (which may then also fail) in case | ||
83 | * vidmem is exhausted. | ||
84 | */ | ||
85 | } | ||
86 | |||
87 | return nvgpu_dma_alloc_flags_sys(g, flags, size, mem); | ||
88 | |||
89 | } | ||
90 | |||
91 | int nvgpu_dma_alloc_sys(struct gk20a *g, size_t size, struct nvgpu_mem *mem) | ||
92 | { | ||
93 | return nvgpu_dma_alloc_flags_sys(g, 0, size, mem); | ||
94 | } | ||
95 | |||
96 | int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, | ||
97 | size_t size, struct nvgpu_mem *mem) | ||
98 | { | ||
99 | return __nvgpu_do_dma_alloc(g, flags, size, mem, APERTURE_SYSMEM); | ||
100 | } | ||
101 | |||
102 | int nvgpu_dma_alloc_vid(struct gk20a *g, size_t size, struct nvgpu_mem *mem) | ||
103 | { | ||
104 | return nvgpu_dma_alloc_flags_vid(g, 0, size, mem); | ||
105 | } | ||
106 | |||
107 | int nvgpu_dma_alloc_flags_vid(struct gk20a *g, unsigned long flags, | ||
108 | size_t size, struct nvgpu_mem *mem) | ||
109 | { | ||
110 | return __nvgpu_do_dma_alloc(g, flags, size, mem, APERTURE_VIDMEM); | ||
111 | } | ||
112 | |||
113 | int nvgpu_dma_alloc_vid_at(struct gk20a *g, | ||
114 | size_t size, struct nvgpu_mem *mem, u64 at) | ||
115 | { | ||
116 | BUG(); | ||
117 | |||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | int nvgpu_dma_alloc_flags_vid_at(struct gk20a *g, unsigned long flags, | ||
122 | size_t size, struct nvgpu_mem *mem, u64 at) | ||
123 | { | ||
124 | BUG(); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | void nvgpu_dma_free(struct gk20a *g, struct nvgpu_mem *mem) | ||
130 | { | ||
131 | if (!(mem->mem_flags & NVGPU_MEM_FLAG_SHADOW_COPY)) | ||
132 | free(mem->cpu_va); | ||
133 | |||
134 | memset(mem, 0, sizeof(*mem)); | ||
135 | } | ||
136 | |||
137 | int nvgpu_dma_alloc_map(struct vm_gk20a *vm, size_t size, | ||
138 | struct nvgpu_mem *mem) | ||
139 | { | ||
140 | return nvgpu_dma_alloc_map_flags(vm, 0, size, mem); | ||
141 | } | ||
142 | |||
143 | int nvgpu_dma_alloc_map_flags(struct vm_gk20a *vm, unsigned long flags, | ||
144 | size_t size, struct nvgpu_mem *mem) | ||
145 | { | ||
146 | if (!nvgpu_is_enabled(gk20a_from_vm(vm), NVGPU_MM_UNIFIED_MEMORY)) { | ||
147 | int err = nvgpu_dma_alloc_map_flags_vid(vm, | ||
148 | flags | NVGPU_DMA_NO_KERNEL_MAPPING, | ||
149 | size, mem); | ||
150 | |||
151 | if (!err) | ||
152 | return 0; | ||
153 | /* | ||
154 | * Fall back to sysmem (which may then also fail) in case | ||
155 | * vidmem is exhausted. | ||
156 | */ | ||
157 | } | ||
158 | |||
159 | return nvgpu_dma_alloc_map_flags_sys(vm, flags, size, mem); | ||
160 | } | ||
161 | |||
162 | int nvgpu_dma_alloc_map_sys(struct vm_gk20a *vm, size_t size, | ||
163 | struct nvgpu_mem *mem) | ||
164 | { | ||
165 | return nvgpu_dma_alloc_map_flags_sys(vm, 0, size, mem); | ||
166 | } | ||
167 | |||
168 | int nvgpu_dma_alloc_map_flags_sys(struct vm_gk20a *vm, unsigned long flags, | ||
169 | size_t size, struct nvgpu_mem *mem) | ||
170 | { | ||
171 | int err = nvgpu_dma_alloc_flags_sys(vm->mm->g, flags, size, mem); | ||
172 | |||
173 | if (err) | ||
174 | return err; | ||
175 | |||
176 | mem->gpu_va = nvgpu_gmmu_map(vm, mem, size, 0, | ||
177 | gk20a_mem_flag_none, false, | ||
178 | mem->aperture); | ||
179 | if (!mem->gpu_va) { | ||
180 | err = -ENOMEM; | ||
181 | goto fail_free; | ||
182 | } | ||
183 | |||
184 | return 0; | ||
185 | |||
186 | fail_free: | ||
187 | nvgpu_dma_free(vm->mm->g, mem); | ||
188 | return err; | ||
189 | } | ||
190 | |||
191 | int nvgpu_dma_alloc_map_vid(struct vm_gk20a *vm, size_t size, | ||
192 | struct nvgpu_mem *mem) | ||
193 | { | ||
194 | return nvgpu_dma_alloc_map_flags_vid(vm, | ||
195 | NVGPU_DMA_NO_KERNEL_MAPPING, size, mem); | ||
196 | } | ||
197 | |||
198 | int nvgpu_dma_alloc_map_flags_vid(struct vm_gk20a *vm, unsigned long flags, | ||
199 | size_t size, struct nvgpu_mem *mem) | ||
200 | { | ||
201 | int err = nvgpu_dma_alloc_flags_vid(vm->mm->g, flags, size, mem); | ||
202 | |||
203 | if (err) | ||
204 | return err; | ||
205 | |||
206 | mem->gpu_va = nvgpu_gmmu_map(vm, mem, size, 0, | ||
207 | gk20a_mem_flag_none, false, | ||
208 | mem->aperture); | ||
209 | if (!mem->gpu_va) { | ||
210 | err = -ENOMEM; | ||
211 | goto fail_free; | ||
212 | } | ||
213 | |||
214 | return 0; | ||
215 | |||
216 | fail_free: | ||
217 | nvgpu_dma_free(vm->mm->g, mem); | ||
218 | return err; | ||
219 | } | ||
220 | |||
221 | void nvgpu_dma_unmap_free(struct vm_gk20a *vm, struct nvgpu_mem *mem) | ||
222 | { | ||
223 | if (mem->gpu_va) | ||
224 | nvgpu_gmmu_unmap(vm, mem, mem->gpu_va); | ||
225 | mem->gpu_va = 0; | ||
226 | |||
227 | nvgpu_dma_free(vm->mm->g, mem); | ||
228 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/error_notifier.c b/drivers/gpu/nvgpu/common/posix/error_notifier.c deleted file mode 100644 index 50b4f258..00000000 --- a/drivers/gpu/nvgpu/common/posix/error_notifier.c +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
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 | #include <nvgpu/error_notifier.h> | ||
24 | |||
25 | void nvgpu_set_error_notifier_locked(struct channel_gk20a *ch, u32 error) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | void nvgpu_set_error_notifier(struct channel_gk20a *ch, u32 error) | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void nvgpu_set_error_notifier_if_empty(struct channel_gk20a *ch, u32 error) | ||
34 | { | ||
35 | } | ||
36 | |||
37 | bool nvgpu_is_error_notifier_set(struct channel_gk20a *ch, u32 error_notifier) | ||
38 | { | ||
39 | return false; | ||
40 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/firmware.c b/drivers/gpu/nvgpu/common/posix/firmware.c deleted file mode 100644 index aedfef9f..00000000 --- a/drivers/gpu/nvgpu/common/posix/firmware.c +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
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 | #include <nvgpu/firmware.h> | ||
24 | |||
25 | struct nvgpu_firmware *nvgpu_request_firmware(struct gk20a *g, | ||
26 | const char *fw_name, | ||
27 | int flags) | ||
28 | { | ||
29 | return NULL; | ||
30 | } | ||
31 | |||
32 | void nvgpu_release_firmware(struct gk20a *g, struct nvgpu_firmware *fw) | ||
33 | { | ||
34 | /* Noop. */ | ||
35 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/fuse.c b/drivers/gpu/nvgpu/common/posix/fuse.c deleted file mode 100644 index 09ec36dc..00000000 --- a/drivers/gpu/nvgpu/common/posix/fuse.c +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
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 | #include <nvgpu/fuse.h> | ||
24 | |||
25 | int nvgpu_tegra_get_gpu_speedo_id(struct gk20a *g) | ||
26 | { | ||
27 | return 0; | ||
28 | } | ||
29 | |||
30 | void nvgpu_tegra_fuse_write_bypass(struct gk20a *g, u32 val) | ||
31 | { | ||
32 | } | ||
33 | |||
34 | void nvgpu_tegra_fuse_write_access_sw(struct gk20a *g, u32 val) | ||
35 | { | ||
36 | } | ||
37 | |||
38 | void nvgpu_tegra_fuse_write_opt_gpu_tpc0_disable(struct gk20a *g, u32 val) | ||
39 | { | ||
40 | } | ||
41 | |||
42 | void nvgpu_tegra_fuse_write_opt_gpu_tpc1_disable(struct gk20a *g, u32 val) | ||
43 | { | ||
44 | } | ||
45 | |||
46 | int nvgpu_tegra_fuse_read_gcplex_config_fuse(struct gk20a *g, u32 *val) | ||
47 | { | ||
48 | return -ENODEV; | ||
49 | } | ||
50 | |||
51 | int nvgpu_tegra_fuse_read_reserved_calib(struct gk20a *g, u32 *val) | ||
52 | { | ||
53 | return -ENODEV; | ||
54 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/io.c b/drivers/gpu/nvgpu/common/posix/io.c deleted file mode 100644 index 7bab8af6..00000000 --- a/drivers/gpu/nvgpu/common/posix/io.c +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
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 | #include <nvgpu/io.h> | ||
24 | #include <nvgpu/io_usermode.h> | ||
25 | #include <nvgpu/bug.h> | ||
26 | |||
27 | /* | ||
28 | * For now none of these make sense to execute in userspace. Eventually we | ||
29 | * may want to use these to verify certain register read/write sequences | ||
30 | * but for now, just hang. | ||
31 | */ | ||
32 | |||
33 | void nvgpu_writel(struct gk20a *g, u32 r, u32 v) | ||
34 | { | ||
35 | BUG(); | ||
36 | } | ||
37 | |||
38 | void nvgpu_writel_relaxed(struct gk20a *g, u32 r, u32 v) | ||
39 | { | ||
40 | BUG(); | ||
41 | } | ||
42 | |||
43 | u32 nvgpu_readl(struct gk20a *g, u32 r) | ||
44 | { | ||
45 | BUG(); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | u32 __nvgpu_readl(struct gk20a *g, u32 r) | ||
51 | { | ||
52 | BUG(); | ||
53 | |||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | void nvgpu_writel_loop(struct gk20a *g, u32 r, u32 v) | ||
58 | { | ||
59 | BUG(); | ||
60 | } | ||
61 | |||
62 | void nvgpu_bar1_writel(struct gk20a *g, u32 b, u32 v) | ||
63 | { | ||
64 | BUG(); | ||
65 | } | ||
66 | |||
67 | u32 nvgpu_bar1_readl(struct gk20a *g, u32 b) | ||
68 | { | ||
69 | BUG(); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | bool nvgpu_io_exists(struct gk20a *g) | ||
75 | { | ||
76 | return false; | ||
77 | } | ||
78 | |||
79 | bool nvgpu_io_valid_reg(struct gk20a *g, u32 r) | ||
80 | { | ||
81 | return false; | ||
82 | } | ||
83 | |||
84 | void nvgpu_usermode_writel(struct gk20a *g, u32 r, u32 v) | ||
85 | { | ||
86 | BUG(); | ||
87 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/kmem.c b/drivers/gpu/nvgpu/common/posix/kmem.c deleted file mode 100644 index 5fe0aeb2..00000000 --- a/drivers/gpu/nvgpu/common/posix/kmem.c +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
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 | #include <stdlib.h> | ||
24 | |||
25 | #include <nvgpu/bug.h> | ||
26 | #include <nvgpu/kmem.h> | ||
27 | #include <nvgpu/types.h> | ||
28 | |||
29 | #include <nvgpu/posix/kmem.h> | ||
30 | |||
31 | struct nvgpu_kmem_cache { | ||
32 | size_t alloc_size; | ||
33 | }; | ||
34 | |||
35 | /* | ||
36 | * kmem cache emulation: basically just do a regular malloc(). This is slower | ||
37 | * but should not affect a user of kmem cache in the slightest bit. | ||
38 | */ | ||
39 | struct nvgpu_kmem_cache *nvgpu_kmem_cache_create(struct gk20a *g, size_t size) | ||
40 | { | ||
41 | struct nvgpu_kmem_cache *cache = | ||
42 | malloc(sizeof(struct nvgpu_kmem_cache)); | ||
43 | |||
44 | if (cache != NULL) | ||
45 | return NULL; | ||
46 | |||
47 | cache->alloc_size = size; | ||
48 | |||
49 | return cache; | ||
50 | } | ||
51 | |||
52 | void nvgpu_kmem_cache_destroy(struct nvgpu_kmem_cache *cache) | ||
53 | { | ||
54 | free(cache); | ||
55 | } | ||
56 | |||
57 | void *nvgpu_kmem_cache_alloc(struct nvgpu_kmem_cache *cache) | ||
58 | { | ||
59 | return malloc(cache->alloc_size); | ||
60 | } | ||
61 | |||
62 | void nvgpu_kmem_cache_free(struct nvgpu_kmem_cache *cache, void *ptr) | ||
63 | { | ||
64 | free(ptr); | ||
65 | } | ||
66 | |||
67 | void *__nvgpu_kmalloc(struct gk20a *g, size_t size, void *ip) | ||
68 | { | ||
69 | return malloc(size); | ||
70 | } | ||
71 | |||
72 | void *__nvgpu_kzalloc(struct gk20a *g, size_t size, void *ip) | ||
73 | { | ||
74 | return calloc(1, size); | ||
75 | } | ||
76 | |||
77 | void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, void *ip) | ||
78 | { | ||
79 | /* | ||
80 | * calloc() implicitly zeros mem. So calloc a single member size bytes | ||
81 | * long. | ||
82 | */ | ||
83 | return calloc(n, size); | ||
84 | } | ||
85 | |||
86 | void __nvgpu_kfree(struct gk20a *g, void *addr) | ||
87 | { | ||
88 | free(addr); | ||
89 | } | ||
90 | |||
91 | /* | ||
92 | * The concept of vmalloc() does not exist in userspace. | ||
93 | */ | ||
94 | void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, void *ip) | ||
95 | { | ||
96 | return __nvgpu_kmalloc(g, size, ip); | ||
97 | } | ||
98 | |||
99 | void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, void *ip) | ||
100 | { | ||
101 | return __nvgpu_kzalloc(g, size, ip); | ||
102 | } | ||
103 | |||
104 | void __nvgpu_vfree(struct gk20a *g, void *addr) | ||
105 | { | ||
106 | __nvgpu_kfree(g, addr); | ||
107 | } | ||
108 | |||
109 | void *__nvgpu_big_alloc(struct gk20a *g, size_t size, bool clear) | ||
110 | { | ||
111 | /* | ||
112 | * Since in userspace vmalloc() == kmalloc() == malloc() we can just | ||
113 | * reuse k[zm]alloc() for this. | ||
114 | */ | ||
115 | return clear ? | ||
116 | __nvgpu_kzalloc(g, size, _NVGPU_GET_IP_) : | ||
117 | __nvgpu_kmalloc(g, size, _NVGPU_GET_IP_); | ||
118 | } | ||
119 | |||
120 | void nvgpu_big_free(struct gk20a *g, void *p) | ||
121 | { | ||
122 | __nvgpu_kfree(g, p); | ||
123 | } | ||
124 | |||
125 | int nvgpu_kmem_init(struct gk20a *g) | ||
126 | { | ||
127 | /* Nothing to init at the moment. */ | ||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | void nvgpu_kmem_fini(struct gk20a *g, int flags) | ||
132 | { | ||
133 | |||
134 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/lock.c b/drivers/gpu/nvgpu/common/posix/lock.c deleted file mode 100644 index bca0f04c..00000000 --- a/drivers/gpu/nvgpu/common/posix/lock.c +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
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 | #include <nvgpu/lock.h> | ||
24 | #include <nvgpu/posix/lock.h> | ||
25 | |||
26 | int nvgpu_mutex_init(struct nvgpu_mutex *mutex) | ||
27 | { | ||
28 | return pthread_mutex_init(&mutex->lock.mutex, NULL); | ||
29 | } | ||
30 | |||
31 | void nvgpu_mutex_acquire(struct nvgpu_mutex *mutex) | ||
32 | { | ||
33 | __nvgpu_posix_lock_acquire(&mutex->lock); | ||
34 | } | ||
35 | |||
36 | void nvgpu_mutex_release(struct nvgpu_mutex *mutex) | ||
37 | { | ||
38 | __nvgpu_posix_lock_release(&mutex->lock); | ||
39 | } | ||
40 | |||
41 | int nvgpu_mutex_tryacquire(struct nvgpu_mutex *mutex) | ||
42 | { | ||
43 | return __nvgpu_posix_lock_try_acquire(&mutex->lock); | ||
44 | } | ||
45 | |||
46 | void nvgpu_mutex_destroy(struct nvgpu_mutex *mutex) | ||
47 | { | ||
48 | pthread_mutex_destroy(&mutex->lock.mutex); | ||
49 | } | ||
50 | |||
51 | void nvgpu_spinlock_init(struct nvgpu_spinlock *spinlock) | ||
52 | { | ||
53 | pthread_mutex_init(&spinlock->lock.mutex, NULL); | ||
54 | } | ||
55 | |||
56 | void nvgpu_spinlock_acquire(struct nvgpu_spinlock *spinlock) | ||
57 | { | ||
58 | __nvgpu_posix_lock_acquire(&spinlock->lock); | ||
59 | } | ||
60 | |||
61 | void nvgpu_spinlock_release(struct nvgpu_spinlock *spinlock) | ||
62 | { | ||
63 | __nvgpu_posix_lock_release(&spinlock->lock); | ||
64 | } | ||
65 | |||
66 | void nvgpu_raw_spinlock_init(struct nvgpu_raw_spinlock *spinlock) | ||
67 | { | ||
68 | pthread_mutex_init(&spinlock->lock.mutex, NULL); | ||
69 | } | ||
70 | |||
71 | void nvgpu_raw_spinlock_acquire(struct nvgpu_raw_spinlock *spinlock) | ||
72 | { | ||
73 | __nvgpu_posix_lock_acquire(&spinlock->lock); | ||
74 | } | ||
75 | |||
76 | void nvgpu_raw_spinlock_release(struct nvgpu_raw_spinlock *spinlock) | ||
77 | { | ||
78 | __nvgpu_posix_lock_release(&spinlock->lock); | ||
79 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/log.c b/drivers/gpu/nvgpu/common/posix/log.c deleted file mode 100644 index 6bfb673c..00000000 --- a/drivers/gpu/nvgpu/common/posix/log.c +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
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 | #include <nvgpu/log.h> | ||
24 | #include <nvgpu/types.h> | ||
25 | |||
26 | #include "gk20a/gk20a.h" | ||
27 | |||
28 | /* | ||
29 | * Define a length for log buffers. This is the buffer that the 'fmt, ...' part | ||
30 | * of __nvgpu_do_log_print() prints into. | ||
31 | */ | ||
32 | #define LOG_BUFFER_LENGTH 160 | ||
33 | |||
34 | /* | ||
35 | * Keep this roughly the same as the kernel log format. | ||
36 | */ | ||
37 | #define LOG_FMT "nvgpu: %s %33s:%-4d [%-4s] %s\n" | ||
38 | |||
39 | u64 nvgpu_dbg_mask = NVGPU_DEFAULT_DBG_MASK; | ||
40 | |||
41 | static const char *log_types[] = { | ||
42 | "ERR", | ||
43 | "WRN", | ||
44 | "DBG", | ||
45 | "INFO", | ||
46 | }; | ||
47 | |||
48 | static inline const char *nvgpu_log_name(struct gk20a *g) | ||
49 | { | ||
50 | return "gpu.USS"; | ||
51 | } | ||
52 | |||
53 | static void __nvgpu_really_print_log(const char *gpu_name, | ||
54 | const char *func_name, int line, | ||
55 | enum nvgpu_log_type type, const char *log) | ||
56 | { | ||
57 | const char *name = gpu_name ? gpu_name : ""; | ||
58 | const char *log_type = log_types[type]; | ||
59 | |||
60 | printf(LOG_FMT, name, func_name, line, log_type, log); | ||
61 | } | ||
62 | |||
63 | __attribute__((format (printf, 5, 6))) | ||
64 | void __nvgpu_log_msg(struct gk20a *g, const char *func_name, int line, | ||
65 | enum nvgpu_log_type type, const char *fmt, ...) | ||
66 | { | ||
67 | char log[LOG_BUFFER_LENGTH]; | ||
68 | va_list args; | ||
69 | |||
70 | va_start(args, fmt); | ||
71 | vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args); | ||
72 | va_end(args); | ||
73 | |||
74 | __nvgpu_really_print_log(nvgpu_log_name(g), | ||
75 | func_name, line, type, log); | ||
76 | } | ||
77 | |||
78 | __attribute__((format (printf, 5, 6))) | ||
79 | void __nvgpu_log_dbg(struct gk20a *g, u64 log_mask, | ||
80 | const char *func_name, int line, | ||
81 | const char *fmt, ...) | ||
82 | { | ||
83 | char log[LOG_BUFFER_LENGTH]; | ||
84 | va_list args; | ||
85 | |||
86 | if ((log_mask & g->log_mask) == 0) | ||
87 | return; | ||
88 | |||
89 | va_start(args, fmt); | ||
90 | vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args); | ||
91 | va_end(args); | ||
92 | |||
93 | __nvgpu_really_print_log(nvgpu_log_name(g), | ||
94 | func_name, line, NVGPU_DEBUG, log); | ||
95 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/nvgpu.c b/drivers/gpu/nvgpu/common/posix/nvgpu.c deleted file mode 100644 index a275f2de..00000000 --- a/drivers/gpu/nvgpu/common/posix/nvgpu.c +++ /dev/null | |||
@@ -1,144 +0,0 @@ | |||
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 | #include <unistd.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <pthread.h> | ||
26 | |||
27 | #include <nvgpu/bug.h> | ||
28 | #include <nvgpu/types.h> | ||
29 | #include <nvgpu/atomic.h> | ||
30 | #include <nvgpu/nvgpu_common.h> | ||
31 | #include <nvgpu/os_sched.h> | ||
32 | |||
33 | #include <nvgpu/posix/probe.h> | ||
34 | |||
35 | #include "os_posix.h" | ||
36 | |||
37 | #include "gk20a/gk20a.h" | ||
38 | |||
39 | void nvgpu_wait_for_deferred_interrupts(struct gk20a *g) | ||
40 | { | ||
41 | /* | ||
42 | * No interrupts in userspace so nothing to wait for. | ||
43 | */ | ||
44 | } | ||
45 | |||
46 | int nvgpu_current_pid(struct gk20a *g) | ||
47 | { | ||
48 | /* | ||
49 | * In the kernel this gets us the PID of the calling process for IOCTLs. | ||
50 | * But since we are in userspace this doesn't quite mean the same thing. | ||
51 | * This simply returns the PID of the currently running process. | ||
52 | */ | ||
53 | return (int)getpid(); | ||
54 | } | ||
55 | |||
56 | int nvgpu_current_tid(struct gk20a *g) | ||
57 | { | ||
58 | /* | ||
59 | * In POSIX thread ID is not the same as a process ID. In Linux threads | ||
60 | * and processes are represented by the same thing, but userspace can't | ||
61 | * really rely on that. | ||
62 | * | ||
63 | * We can, however, get a pthread_t for a given thread. But this | ||
64 | * pthread_t need not have any relation to the underlying system's | ||
65 | * representation of "threads". | ||
66 | */ | ||
67 | return (int)pthread_self(); | ||
68 | } | ||
69 | |||
70 | void __nvgpu_print_current(struct gk20a *g, const char *func_name, int line, | ||
71 | void *ctx, enum nvgpu_log_type type) | ||
72 | { | ||
73 | __nvgpu_log_msg(g, func_name, line, type, | ||
74 | "Current process: (nvgpu userspace)"); | ||
75 | } | ||
76 | |||
77 | /* | ||
78 | * Somewhat meaningless in userspace... | ||
79 | */ | ||
80 | void nvgpu_kernel_restart(void *cmd) | ||
81 | { | ||
82 | BUG(); | ||
83 | } | ||
84 | |||
85 | /* | ||
86 | * We have no runtime PM stuff in userspace so these are really just noops. | ||
87 | */ | ||
88 | void gk20a_busy_noresume(struct gk20a *g) | ||
89 | { | ||
90 | } | ||
91 | |||
92 | void gk20a_idle_nosuspend(struct gk20a *g) | ||
93 | { | ||
94 | } | ||
95 | |||
96 | int gk20a_busy(struct gk20a *g) | ||
97 | { | ||
98 | nvgpu_atomic_inc(&g->usage_count); | ||
99 | |||
100 | return 0; | ||
101 | } | ||
102 | |||
103 | void gk20a_idle(struct gk20a *g) | ||
104 | { | ||
105 | nvgpu_atomic_dec(&g->usage_count); | ||
106 | } | ||
107 | |||
108 | /* | ||
109 | * This function aims to initialize enough stuff to make unit testing worth | ||
110 | * while. There are several interfaces and APIs that rely on the struct gk20a's | ||
111 | * state in order to function: logging, for example, but there are many other | ||
112 | * things, too. | ||
113 | * | ||
114 | * Initialize as much of that as possible here. This is meant to be equivalent | ||
115 | * to the kernel space driver's probe function. | ||
116 | */ | ||
117 | struct gk20a *nvgpu_posix_probe(void) | ||
118 | { | ||
119 | struct gk20a *g; | ||
120 | struct nvgpu_os_posix *p; | ||
121 | int err; | ||
122 | |||
123 | p = malloc(sizeof(*p)); | ||
124 | if (p == NULL) | ||
125 | return NULL; | ||
126 | |||
127 | g = &p->g; | ||
128 | |||
129 | err = nvgpu_kmem_init(g); | ||
130 | if (err != 0) | ||
131 | goto fail; | ||
132 | |||
133 | return g; | ||
134 | |||
135 | fail: | ||
136 | free(p); | ||
137 | |||
138 | return NULL; | ||
139 | } | ||
140 | |||
141 | void nvgpu_posix_cleanup(struct gk20a *g) | ||
142 | { | ||
143 | nvgpu_kmem_fini(g, 0); | ||
144 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/nvlink.c b/drivers/gpu/nvgpu/common/posix/nvlink.c deleted file mode 100644 index c830d6ed..00000000 --- a/drivers/gpu/nvgpu/common/posix/nvlink.c +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
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 | #include <nvgpu/nvlink.h> | ||
24 | |||
25 | int nvgpu_nvlink_train(struct gk20a *g, u32 link_id, bool from_off) | ||
26 | { | ||
27 | return -ENOSYS; | ||
28 | } | ||
29 | |||
30 | int nvgpu_nvlink_enumerate(struct gk20a *g) | ||
31 | { | ||
32 | return -ENOSYS; | ||
33 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/os_posix.h b/drivers/gpu/nvgpu/common/posix/os_posix.h deleted file mode 100644 index 955186ef..00000000 --- a/drivers/gpu/nvgpu/common/posix/os_posix.h +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
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_OS_POSIX_H__ | ||
24 | #define __NVGPU_OS_POSIX_H__ | ||
25 | |||
26 | #include "gk20a/gk20a.h" | ||
27 | |||
28 | struct nvgpu_os_posix { | ||
29 | struct gk20a g; | ||
30 | }; | ||
31 | |||
32 | #endif | ||
diff --git a/drivers/gpu/nvgpu/common/posix/posix-comptags.c b/drivers/gpu/nvgpu/common/posix/posix-comptags.c deleted file mode 100644 index a00246dd..00000000 --- a/drivers/gpu/nvgpu/common/posix/posix-comptags.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
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 | #include <nvgpu/bug.h> | ||
24 | #include <nvgpu/comptags.h> | ||
25 | |||
26 | #include <nvgpu/posix/vm.h> | ||
27 | |||
28 | void gk20a_get_comptags(struct nvgpu_os_buffer *buf, | ||
29 | struct gk20a_comptags *comptags) | ||
30 | { | ||
31 | } | ||
32 | |||
33 | int gk20a_alloc_or_get_comptags(struct gk20a *g, | ||
34 | struct nvgpu_os_buffer *buf, | ||
35 | struct gk20a_comptag_allocator *allocator, | ||
36 | struct gk20a_comptags *comptags) | ||
37 | { | ||
38 | return -ENODEV; | ||
39 | } | ||
40 | |||
41 | bool gk20a_comptags_start_clear(struct nvgpu_os_buffer *buf) | ||
42 | { | ||
43 | return false; | ||
44 | } | ||
45 | |||
46 | void gk20a_comptags_finish_clear(struct nvgpu_os_buffer *buf, | ||
47 | bool clear_successful) | ||
48 | { | ||
49 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/posix-nvgpu_mem.c b/drivers/gpu/nvgpu/common/posix/posix-nvgpu_mem.c deleted file mode 100644 index fa92a7c6..00000000 --- a/drivers/gpu/nvgpu/common/posix/posix-nvgpu_mem.c +++ /dev/null | |||
@@ -1,140 +0,0 @@ | |||
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 | #include <nvgpu/bug.h> | ||
24 | #include <nvgpu/dma.h> | ||
25 | #include <nvgpu/gmmu.h> | ||
26 | #include <nvgpu/kmem.h> | ||
27 | #include <nvgpu/nvgpu_mem.h> | ||
28 | |||
29 | /* | ||
30 | * These functions are somewhat meaningless. | ||
31 | */ | ||
32 | u64 nvgpu_mem_get_addr(struct gk20a *g, struct nvgpu_mem *mem) | ||
33 | { | ||
34 | return (u64)(uintptr_t)mem->cpu_va; | ||
35 | } | ||
36 | |||
37 | u64 nvgpu_mem_get_phys_addr(struct gk20a *g, struct nvgpu_mem *mem) | ||
38 | { | ||
39 | return (u64)(uintptr_t)mem->cpu_va; | ||
40 | } | ||
41 | |||
42 | static struct nvgpu_sgl *nvgpu_mem_sgl_next(struct nvgpu_sgl *sgl) | ||
43 | { | ||
44 | return NULL; | ||
45 | } | ||
46 | |||
47 | static u64 nvgpu_mem_sgl_phys(struct gk20a *g, struct nvgpu_sgl *sgl) | ||
48 | { | ||
49 | struct nvgpu_mem *mem = (struct nvgpu_mem *)sgl; | ||
50 | |||
51 | return (u64)(uintptr_t)mem->cpu_va; | ||
52 | } | ||
53 | |||
54 | static u64 nvgpu_mem_sgl_dma(struct nvgpu_sgl *sgl) | ||
55 | { | ||
56 | struct nvgpu_mem *mem = (struct nvgpu_mem *)sgl; | ||
57 | |||
58 | return (u64)(uintptr_t)mem->cpu_va; | ||
59 | } | ||
60 | |||
61 | static u64 nvgpu_mem_sgl_length(struct nvgpu_sgl *sgl) | ||
62 | { | ||
63 | struct nvgpu_mem *mem = (struct nvgpu_mem *)sgl; | ||
64 | |||
65 | return (u64)mem->aligned_size; | ||
66 | } | ||
67 | |||
68 | static u64 nvgpu_mem_sgl_gpu_addr(struct gk20a *g, struct nvgpu_sgl *sgl, | ||
69 | struct nvgpu_gmmu_attrs *attrs) | ||
70 | { | ||
71 | struct nvgpu_mem *mem = (struct nvgpu_mem *)sgl; | ||
72 | |||
73 | return mem->gpu_va; | ||
74 | } | ||
75 | |||
76 | static bool nvgpu_mem_sgt_iommuable(struct gk20a *g, struct nvgpu_sgt *sgt) | ||
77 | { | ||
78 | return nvgpu_iommuable(g); | ||
79 | } | ||
80 | |||
81 | static void nvgpu_mem_sgt_free(struct gk20a *g, struct nvgpu_sgt *sgt) | ||
82 | { | ||
83 | nvgpu_kfree(g, sgt); | ||
84 | } | ||
85 | |||
86 | static struct nvgpu_sgt_ops nvgpu_sgt_posix_ops = { | ||
87 | .sgl_next = nvgpu_mem_sgl_next, | ||
88 | .sgl_phys = nvgpu_mem_sgl_phys, | ||
89 | .sgl_dma = nvgpu_mem_sgl_dma, | ||
90 | .sgl_length = nvgpu_mem_sgl_length, | ||
91 | .sgl_gpu_addr = nvgpu_mem_sgl_gpu_addr, | ||
92 | .sgt_iommuable = nvgpu_mem_sgt_iommuable, | ||
93 | .sgt_free = nvgpu_mem_sgt_free, | ||
94 | }; | ||
95 | |||
96 | struct nvgpu_sgt *nvgpu_sgt_create_from_mem(struct gk20a *g, | ||
97 | struct nvgpu_mem *mem) | ||
98 | { | ||
99 | struct nvgpu_sgt *sgt = nvgpu_kzalloc(g, sizeof(*sgt)); | ||
100 | |||
101 | if (sgt == NULL) | ||
102 | return NULL; | ||
103 | |||
104 | /* | ||
105 | * The userspace implementation is simple: a single 'entry' (which we | ||
106 | * only need the mem struct to describe). Maybe this could be expanded | ||
107 | * to be more interesting some day. | ||
108 | */ | ||
109 | sgt->sgl = (struct nvgpu_sgl *)mem; | ||
110 | sgt->ops = &nvgpu_sgt_posix_ops; | ||
111 | |||
112 | return sgt; | ||
113 | } | ||
114 | |||
115 | int nvgpu_mem_create_from_mem(struct gk20a *g, | ||
116 | struct nvgpu_mem *dest, struct nvgpu_mem *src, | ||
117 | int start_page, int nr_pages) | ||
118 | { | ||
119 | u64 start = start_page * PAGE_SIZE; | ||
120 | u64 size = nr_pages * PAGE_SIZE; | ||
121 | |||
122 | if (src->aperture != APERTURE_SYSMEM) | ||
123 | return -EINVAL; | ||
124 | |||
125 | /* Some silly things a caller might do... */ | ||
126 | if (size > src->size) | ||
127 | return -EINVAL; | ||
128 | if ((start + size) > src->size) | ||
129 | return -EINVAL; | ||
130 | |||
131 | memset(dest, 0, sizeof(*dest)); | ||
132 | |||
133 | dest->cpu_va = ((char *)src->cpu_va) + start; | ||
134 | dest->mem_flags = src->mem_flags | NVGPU_MEM_FLAG_SHADOW_COPY; | ||
135 | dest->aperture = src->aperture; | ||
136 | dest->skip_wmb = src->skip_wmb; | ||
137 | dest->size = size; | ||
138 | |||
139 | return 0; | ||
140 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/posix-vm.c b/drivers/gpu/nvgpu/common/posix/posix-vm.c deleted file mode 100644 index 588b956d..00000000 --- a/drivers/gpu/nvgpu/common/posix/posix-vm.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
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 | #include <stdlib.h> | ||
24 | |||
25 | #include <nvgpu/vm.h> | ||
26 | #include <nvgpu/bug.h> | ||
27 | |||
28 | #include <nvgpu/posix/vm.h> | ||
29 | |||
30 | u64 nvgpu_os_buf_get_size(struct nvgpu_os_buffer *os_buf) | ||
31 | { | ||
32 | return os_buf->size; | ||
33 | } | ||
34 | |||
35 | struct nvgpu_mapped_buf *nvgpu_vm_find_mapping(struct vm_gk20a *vm, | ||
36 | struct nvgpu_os_buffer *os_buf, | ||
37 | u64 map_addr, | ||
38 | u32 flags, | ||
39 | int kind) | ||
40 | { | ||
41 | BUG(); | ||
42 | |||
43 | /* | ||
44 | * No map caching for now. | ||
45 | */ | ||
46 | return NULL; | ||
47 | } | ||
48 | |||
49 | void nvgpu_vm_unmap_system(struct nvgpu_mapped_buf *mapped_buffer) | ||
50 | { | ||
51 | free(mapped_buffer->os_priv.buf); | ||
52 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/rwsem.c b/drivers/gpu/nvgpu/common/posix/rwsem.c deleted file mode 100644 index 7a696b75..00000000 --- a/drivers/gpu/nvgpu/common/posix/rwsem.c +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
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 | #include <nvgpu/bug.h> | ||
24 | #include <nvgpu/rwsem.h> | ||
25 | #include <nvgpu/timers.h> | ||
26 | |||
27 | #include <nvgpu/posix/rwsem.h> | ||
28 | |||
29 | void nvgpu_rwsem_init(struct nvgpu_rwsem *rwsem) | ||
30 | { | ||
31 | memset(rwsem, 0, sizeof(*rwsem)); | ||
32 | |||
33 | nvgpu_spinlock_init(&rwsem->lock); | ||
34 | } | ||
35 | |||
36 | /* | ||
37 | * Acquire. | ||
38 | */ | ||
39 | void nvgpu_rwsem_down_read(struct nvgpu_rwsem *rwsem) | ||
40 | { | ||
41 | while (true) { | ||
42 | nvgpu_spinlock_acquire(&rwsem->lock); | ||
43 | |||
44 | /* | ||
45 | * If there's a writer try again. | ||
46 | */ | ||
47 | if (rwsem->writers < 0) { | ||
48 | nvgpu_spinlock_release(&rwsem->lock); | ||
49 | nvgpu_msleep(10); | ||
50 | continue; | ||
51 | } | ||
52 | |||
53 | /* | ||
54 | * Otherwise decrement the read counter and return. | ||
55 | */ | ||
56 | rwsem->readers -= 1; | ||
57 | nvgpu_spinlock_release(&rwsem->lock); | ||
58 | return; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /* | ||
63 | * Release. | ||
64 | */ | ||
65 | void nvgpu_rwsem_up_read(struct nvgpu_rwsem *rwsem) | ||
66 | { | ||
67 | nvgpu_spinlock_acquire(&rwsem->lock); | ||
68 | rwsem->readers += 1; | ||
69 | |||
70 | /* | ||
71 | * Can't be any writers if there was a reader. Also can't be | ||
72 | * a positive number of readers. The increments are always | ||
73 | * downward so if we have a positive number then there is a | ||
74 | * balancing bug. | ||
75 | */ | ||
76 | BUG_ON(rwsem->writers < 0); | ||
77 | BUG_ON(rwsem->readers > 0); | ||
78 | |||
79 | nvgpu_spinlock_release(&rwsem->lock); | ||
80 | } | ||
81 | |||
82 | void nvgpu_rwsem_down_write(struct nvgpu_rwsem *rwsem) | ||
83 | { | ||
84 | while (true) { | ||
85 | nvgpu_spinlock_acquire(&rwsem->lock); | ||
86 | |||
87 | /* | ||
88 | * If there's a reader or a writer try again. Note: in this very | ||
89 | * simple implementation it's possible for readers to | ||
90 | * indefinitely starve writers. | ||
91 | */ | ||
92 | if (rwsem->writers < 0 || rwsem->readers < 0) { | ||
93 | nvgpu_spinlock_release(&rwsem->lock); | ||
94 | nvgpu_msleep(10); | ||
95 | continue; | ||
96 | } | ||
97 | |||
98 | rwsem->writers -= 1; | ||
99 | nvgpu_spinlock_release(&rwsem->lock); | ||
100 | return; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | void nvgpu_rwsem_up_write(struct nvgpu_rwsem *rwsem) | ||
105 | { | ||
106 | nvgpu_spinlock_acquire(&rwsem->lock); | ||
107 | rwsem->writers += 1; | ||
108 | |||
109 | /* | ||
110 | * Writers can't be positive: that would be an unbalanced free. Readers | ||
111 | * must be zero - otherwise this writer should never have had access! | ||
112 | */ | ||
113 | BUG_ON(rwsem->writers > 0); | ||
114 | BUG_ON(rwsem->readers != 0); | ||
115 | |||
116 | nvgpu_spinlock_release(&rwsem->lock); | ||
117 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/soc.c b/drivers/gpu/nvgpu/common/posix/soc.c deleted file mode 100644 index 2346d61e..00000000 --- a/drivers/gpu/nvgpu/common/posix/soc.c +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
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 | #include <nvgpu/soc.h> | ||
24 | |||
25 | bool nvgpu_platform_is_silicon(struct gk20a *g) | ||
26 | { | ||
27 | return false; | ||
28 | } | ||
29 | |||
30 | bool nvgpu_platform_is_simulation(struct gk20a *g) | ||
31 | { | ||
32 | return false; | ||
33 | } | ||
34 | |||
35 | bool nvgpu_platform_is_fpga(struct gk20a *g) | ||
36 | { | ||
37 | return false; | ||
38 | } | ||
39 | |||
40 | bool nvgpu_is_hypervisor_mode(struct gk20a *g) | ||
41 | { | ||
42 | return false; | ||
43 | } | ||
44 | |||
45 | bool nvgpu_is_bpmp_running(struct gk20a *g) | ||
46 | { | ||
47 | return false; | ||
48 | } | ||
49 | |||
50 | bool nvgpu_is_soc_t194_a01(struct gk20a *g) | ||
51 | { | ||
52 | return false; | ||
53 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/stubs.c b/drivers/gpu/nvgpu/common/posix/stubs.c deleted file mode 100644 index 1e50930a..00000000 --- a/drivers/gpu/nvgpu/common/posix/stubs.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
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 | /** | ||
24 | * Here lie OS stubs that do not have an implementation yet nor has any plans | ||
25 | * for an implementation. | ||
26 | */ | ||
27 | |||
28 | #include <nvgpu/ecc.h> | ||
29 | #include <nvgpu/ltc.h> | ||
30 | |||
31 | #include "gk20a/dbg_gpu_gk20a.h" | ||
32 | |||
33 | void nvgpu_dbg_session_post_event(struct dbg_session_gk20a *dbg_s) | ||
34 | { | ||
35 | } | ||
36 | |||
37 | int nvgpu_ecc_sysfs_init(struct gk20a *g) | ||
38 | { | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | void nvgpu_ecc_sysfs_remove(struct gk20a *g) | ||
43 | { | ||
44 | } | ||
45 | |||
46 | int nvgpu_ltc_alloc_cbc(struct gk20a *g, size_t compbit_backing_size) | ||
47 | { | ||
48 | return 0; | ||
49 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/thread.c b/drivers/gpu/nvgpu/common/posix/thread.c deleted file mode 100644 index d9476523..00000000 --- a/drivers/gpu/nvgpu/common/posix/thread.c +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
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 | #include <nvgpu/bug.h> | ||
24 | #include <nvgpu/thread.h> | ||
25 | |||
26 | #include <nvgpu/posix/thread.h> | ||
27 | |||
28 | /** | ||
29 | * Use pthreads to mostly emulate the Linux kernel APIs. There are some things | ||
30 | * that are quite different - especially the stop/should_stop notions. In user | ||
31 | * space threads can send signals to one another but of course within the kernel | ||
32 | * that is not as simple. | ||
33 | * | ||
34 | * This could use some nice debugging some day as well. | ||
35 | */ | ||
36 | |||
37 | /* | ||
38 | * nvgpu thread functions return int. POSIX threads return void *. This little | ||
39 | * wrapper takes the int returning nvgpu thread and instead passes that int back | ||
40 | * through the void * pointer. | ||
41 | */ | ||
42 | static void *__nvgpu_posix_thread_wrapper(void *data) | ||
43 | { | ||
44 | struct nvgpu_posix_thread_data *nvgpu = data; | ||
45 | |||
46 | return ERR_PTR(nvgpu->fn(nvgpu->data)); | ||
47 | } | ||
48 | |||
49 | int nvgpu_thread_create(struct nvgpu_thread *thread, | ||
50 | void *data, | ||
51 | int (*threadfn)(void *data), const char *name) | ||
52 | { | ||
53 | int ret; | ||
54 | |||
55 | BUG_ON(thread->running); | ||
56 | |||
57 | memset(thread, 0, sizeof(*thread)); | ||
58 | |||
59 | /* | ||
60 | * By subtracting 1 the above memset ensures that we have a zero | ||
61 | * terminated string. | ||
62 | */ | ||
63 | strncpy(thread->tname, name, NVGPU_THREAD_POSIX_MAX_NAMELEN - 1); | ||
64 | |||
65 | thread->nvgpu.data = data; | ||
66 | thread->nvgpu.fn = threadfn; | ||
67 | |||
68 | ret = pthread_create(&thread->thread, NULL, | ||
69 | __nvgpu_posix_thread_wrapper, | ||
70 | &thread->nvgpu); | ||
71 | if (ret != 0) | ||
72 | return ret; | ||
73 | |||
74 | #ifdef _GNU_SOURCE | ||
75 | pthread_setname_np(thread->thread, thread->tname); | ||
76 | #endif | ||
77 | |||
78 | thread->running = true; | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | void nvgpu_thread_stop(struct nvgpu_thread *thread) | ||
84 | { | ||
85 | thread->should_stop = true; | ||
86 | } | ||
87 | |||
88 | bool nvgpu_thread_should_stop(struct nvgpu_thread *thread) | ||
89 | { | ||
90 | return thread->should_stop; | ||
91 | } | ||
92 | |||
93 | bool nvgpu_thread_is_running(struct nvgpu_thread *thread) | ||
94 | { | ||
95 | return thread->running; | ||
96 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/timers.c b/drivers/gpu/nvgpu/common/posix/timers.c deleted file mode 100644 index c84b0de5..00000000 --- a/drivers/gpu/nvgpu/common/posix/timers.c +++ /dev/null | |||
@@ -1,169 +0,0 @@ | |||
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 | #include <sys/time.h> | ||
24 | |||
25 | #include <nvgpu/bug.h> | ||
26 | #include <nvgpu/log.h> | ||
27 | #include <nvgpu/timers.h> | ||
28 | |||
29 | static s64 now(void) | ||
30 | { | ||
31 | return nvgpu_current_time_ms(); | ||
32 | } | ||
33 | |||
34 | /* | ||
35 | * Returns true if a > b; | ||
36 | */ | ||
37 | static bool time_after(s64 a, s64 b) | ||
38 | { | ||
39 | return a - b > 0; | ||
40 | } | ||
41 | |||
42 | int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout, | ||
43 | u32 duration, unsigned long flags) | ||
44 | { | ||
45 | if (flags & ~NVGPU_TIMER_FLAG_MASK) | ||
46 | return -EINVAL; | ||
47 | |||
48 | memset(timeout, 0, sizeof(*timeout)); | ||
49 | |||
50 | timeout->g = g; | ||
51 | timeout->flags = flags; | ||
52 | |||
53 | if (flags & NVGPU_TIMER_RETRY_TIMER) | ||
54 | timeout->retries.max = duration; | ||
55 | else | ||
56 | timeout->time = nvgpu_current_time_ms() + (s64)duration; | ||
57 | |||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | static int __nvgpu_timeout_expired_msg_cpu(struct nvgpu_timeout *timeout, | ||
62 | void *caller, | ||
63 | const char *fmt, va_list args) | ||
64 | { | ||
65 | struct gk20a *g = timeout->g; | ||
66 | |||
67 | if (time_after(now(), timeout->time)) { | ||
68 | if (!(timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT)) { | ||
69 | char buf[128]; | ||
70 | |||
71 | vsnprintf(buf, sizeof(buf), fmt, args); | ||
72 | |||
73 | nvgpu_err(g, "Timeout detected @ %p %s", caller, buf); | ||
74 | } | ||
75 | |||
76 | return -ETIMEDOUT; | ||
77 | } | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static int __nvgpu_timeout_expired_msg_retry(struct nvgpu_timeout *timeout, | ||
83 | void *caller, | ||
84 | const char *fmt, va_list args) | ||
85 | { | ||
86 | struct gk20a *g = timeout->g; | ||
87 | |||
88 | if (timeout->retries.attempted >= timeout->retries.max) { | ||
89 | if (!(timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT)) { | ||
90 | char buf[128]; | ||
91 | |||
92 | vsnprintf(buf, sizeof(buf), fmt, args); | ||
93 | |||
94 | nvgpu_err(g, "No more retries @ %p %s", caller, buf); | ||
95 | } | ||
96 | |||
97 | return -ETIMEDOUT; | ||
98 | } | ||
99 | |||
100 | timeout->retries.attempted++; | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | int __nvgpu_timeout_expired_msg(struct nvgpu_timeout *timeout, | ||
106 | void *caller, const char *fmt, ...) | ||
107 | { | ||
108 | int ret; | ||
109 | va_list args; | ||
110 | |||
111 | va_start(args, fmt); | ||
112 | if (timeout->flags & NVGPU_TIMER_RETRY_TIMER) | ||
113 | ret = __nvgpu_timeout_expired_msg_retry(timeout, caller, fmt, | ||
114 | args); | ||
115 | else | ||
116 | ret = __nvgpu_timeout_expired_msg_cpu(timeout, caller, fmt, | ||
117 | args); | ||
118 | va_end(args); | ||
119 | |||
120 | return ret; | ||
121 | } | ||
122 | |||
123 | int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout) | ||
124 | { | ||
125 | if (timeout->flags & NVGPU_TIMER_RETRY_TIMER) | ||
126 | return timeout->retries.attempted >= timeout->retries.max; | ||
127 | else | ||
128 | return time_after(now(), timeout->time); | ||
129 | } | ||
130 | |||
131 | void nvgpu_udelay(unsigned int usecs) | ||
132 | { | ||
133 | BUG(); | ||
134 | } | ||
135 | |||
136 | void nvgpu_usleep_range(unsigned int min_us, unsigned int max_us) | ||
137 | { | ||
138 | BUG(); | ||
139 | } | ||
140 | |||
141 | void nvgpu_msleep(unsigned int msecs) | ||
142 | { | ||
143 | BUG(); | ||
144 | } | ||
145 | |||
146 | static inline s64 __nvgpu_current_time_us(void) | ||
147 | { | ||
148 | struct timeval now; | ||
149 | s64 time_now; | ||
150 | int ret; | ||
151 | |||
152 | ret = gettimeofday(&now, NULL); | ||
153 | if (ret != 0) | ||
154 | BUG(); | ||
155 | |||
156 | time_now = ((s64)now.tv_sec * (s64)1000000) + (s64)now.tv_usec; | ||
157 | |||
158 | return time_now; | ||
159 | } | ||
160 | |||
161 | s64 nvgpu_current_time_ms(void) | ||
162 | { | ||
163 | return __nvgpu_current_time_us() / (s64)1000; | ||
164 | } | ||
165 | |||
166 | u64 nvgpu_hr_timestamp(void) | ||
167 | { | ||
168 | return __nvgpu_current_time_us(); | ||
169 | } | ||
diff --git a/drivers/gpu/nvgpu/common/posix/tsg.c b/drivers/gpu/nvgpu/common/posix/tsg.c deleted file mode 100644 index 8736123d..00000000 --- a/drivers/gpu/nvgpu/common/posix/tsg.c +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
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 | #include "gk20a/tsg_gk20a.h" | ||
24 | |||
25 | void gk20a_tsg_event_id_post_event(struct tsg_gk20a *tsg, | ||
26 | int __event_id) | ||
27 | { | ||
28 | } | ||