aboutsummaryrefslogtreecommitdiffstats
path: root/include/os/posix/nvgpu.c
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2024-09-25 16:09:09 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2024-09-25 16:09:09 -0400
commitf347fde22f1297e4f022600d201780d5ead78114 (patch)
tree76be305d6187003a1e0486ff6e91efb1062ae118 /include/os/posix/nvgpu.c
parent8340d234d78a7d0f46c11a584de538148b78b7cb (diff)
Delete no-longer-needed nvgpu headersHEADmasterjbakita-wip
The dependency on these was removed in commit 8340d234.
Diffstat (limited to 'include/os/posix/nvgpu.c')
-rw-r--r--include/os/posix/nvgpu.c165
1 files changed, 0 insertions, 165 deletions
diff --git a/include/os/posix/nvgpu.c b/include/os/posix/nvgpu.c
deleted file mode 100644
index 5b68113..0000000
--- a/include/os/posix/nvgpu.c
+++ /dev/null
@@ -1,165 +0,0 @@
1/*
2 * Copyright (c) 2018-2021, 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/gk20a.h>
28#include <nvgpu/bug.h>
29#include <nvgpu/types.h>
30#include <nvgpu/atomic.h>
31#include <nvgpu/nvgpu_common.h>
32#include <nvgpu/os_sched.h>
33#include <nvgpu/gk20a.h>
34
35#include <nvgpu/posix/probe.h>
36
37#include "os_posix.h"
38
39int nvgpu_wait_for_stall_interrupts(struct gk20a *g, u32 timeout)
40{
41 /*
42 * No interrupts in userspace so nothing to wait for.
43 */
44 return 0;
45}
46
47int nvgpu_wait_for_nonstall_interrupts(struct gk20a *g, u32 timeout)
48{
49 /*
50 * No interrupts in userspace so nothing to wait for.
51 */
52 return 0;
53}
54
55void nvgpu_wait_for_deferred_interrupts(struct gk20a *g)
56{
57 /*
58 * No interrupts in userspace so nothing to wait for.
59 */
60}
61
62int nvgpu_current_pid(struct gk20a *g)
63{
64 /*
65 * In the kernel this gets us the PID of the calling process for IOCTLs.
66 * But since we are in userspace this doesn't quite mean the same thing.
67 * This simply returns the PID of the currently running process.
68 */
69 return (int)getpid();
70}
71
72int nvgpu_current_tid(struct gk20a *g)
73{
74 /*
75 * In POSIX thread ID is not the same as a process ID. In Linux threads
76 * and processes are represented by the same thing, but userspace can't
77 * really rely on that.
78 *
79 * We can, however, get a pthread_t for a given thread. But this
80 * pthread_t need not have any relation to the underlying system's
81 * representation of "threads".
82 */
83 return (int)pthread_self();
84}
85
86void __nvgpu_print_current(struct gk20a *g, const char *func_name, int line,
87 void *ctx, enum nvgpu_log_type type)
88{
89 __nvgpu_log_msg(g, func_name, line, type,
90 "Current process: (nvgpu userspace)");
91}
92
93/*
94 * Somewhat meaningless in userspace...
95 */
96void nvgpu_kernel_restart(void *cmd)
97{
98 BUG();
99}
100
101/*
102 * We have no runtime PM stuff in userspace so these are really just noops.
103 */
104void gk20a_busy_noresume(struct gk20a *g)
105{
106}
107
108void gk20a_idle_nosuspend(struct gk20a *g)
109{
110}
111
112bool gk20a_check_poweron(struct gk20a *g)
113{
114 return false;
115}
116
117int gk20a_busy(struct gk20a *g)
118{
119 nvgpu_atomic_inc(&g->usage_count);
120
121 return 0;
122}
123
124void gk20a_idle(struct gk20a *g)
125{
126 nvgpu_atomic_dec(&g->usage_count);
127}
128
129/*
130 * This function aims to initialize enough stuff to make unit testing worth
131 * while. There are several interfaces and APIs that rely on the struct gk20a's
132 * state in order to function: logging, for example, but there are many other
133 * things, too.
134 *
135 * Initialize as much of that as possible here. This is meant to be equivalent
136 * to the kernel space driver's probe function.
137 */
138struct gk20a *nvgpu_posix_probe(void)
139{
140 struct gk20a *g;
141 struct nvgpu_os_posix *p;
142 int err;
143
144 p = malloc(sizeof(*p));
145 if (p == NULL)
146 return NULL;
147
148 g = &p->g;
149
150 err = nvgpu_kmem_init(g);
151 if (err != 0)
152 goto fail;
153
154 return g;
155
156fail:
157 free(p);
158
159 return NULL;
160}
161
162void nvgpu_posix_cleanup(struct gk20a *g)
163{
164 nvgpu_kmem_fini(g, 0);
165}