diff options
author | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
---|---|---|
committer | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
commit | 01e6fac4d61fdd7fff5433942ec93fc2ea1e4df1 (patch) | |
tree | 4ef34501728a087be24f4ba0af90f91486bf780b /include/nvgpu/linux/lock.h | |
parent | 306a03d18b305e4e573be3b2931978fa10679eb9 (diff) |
Include nvgpu headers
These are needed to build on NVIDIA's Jetson boards for the time
being. Only a couple structs are required, so it should be fairly
easy to remove this dependency at some point in the future.
Diffstat (limited to 'include/nvgpu/linux/lock.h')
-rw-r--r-- | include/nvgpu/linux/lock.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/include/nvgpu/linux/lock.h b/include/nvgpu/linux/lock.h new file mode 100644 index 0000000..fbf26e9 --- /dev/null +++ b/include/nvgpu/linux/lock.h | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #ifndef NVGPU_LOCK_LINUX_H | ||
18 | #define NVGPU_LOCK_LINUX_H | ||
19 | |||
20 | #include <linux/mutex.h> | ||
21 | #include <linux/spinlock.h> | ||
22 | |||
23 | struct nvgpu_mutex { | ||
24 | struct mutex mutex; | ||
25 | }; | ||
26 | struct nvgpu_spinlock { | ||
27 | spinlock_t spinlock; | ||
28 | }; | ||
29 | struct nvgpu_raw_spinlock { | ||
30 | raw_spinlock_t spinlock; | ||
31 | }; | ||
32 | |||
33 | static inline int nvgpu_mutex_init(struct nvgpu_mutex *mutex) | ||
34 | { | ||
35 | mutex_init(&mutex->mutex); | ||
36 | return 0; | ||
37 | }; | ||
38 | static inline void nvgpu_mutex_acquire(struct nvgpu_mutex *mutex) | ||
39 | { | ||
40 | mutex_lock(&mutex->mutex); | ||
41 | }; | ||
42 | static inline void nvgpu_mutex_release(struct nvgpu_mutex *mutex) | ||
43 | { | ||
44 | mutex_unlock(&mutex->mutex); | ||
45 | }; | ||
46 | static inline int nvgpu_mutex_tryacquire(struct nvgpu_mutex *mutex) | ||
47 | { | ||
48 | return mutex_trylock(&mutex->mutex); | ||
49 | }; | ||
50 | static inline void nvgpu_mutex_destroy(struct nvgpu_mutex *mutex) | ||
51 | { | ||
52 | mutex_destroy(&mutex->mutex); | ||
53 | }; | ||
54 | |||
55 | static inline void nvgpu_spinlock_init(struct nvgpu_spinlock *spinlock) | ||
56 | { | ||
57 | spin_lock_init(&spinlock->spinlock); | ||
58 | }; | ||
59 | static inline void nvgpu_spinlock_acquire(struct nvgpu_spinlock *spinlock) | ||
60 | { | ||
61 | spin_lock(&spinlock->spinlock); | ||
62 | }; | ||
63 | static inline void nvgpu_spinlock_release(struct nvgpu_spinlock *spinlock) | ||
64 | { | ||
65 | spin_unlock(&spinlock->spinlock); | ||
66 | }; | ||
67 | |||
68 | static inline void nvgpu_raw_spinlock_init(struct nvgpu_raw_spinlock *spinlock) | ||
69 | { | ||
70 | raw_spin_lock_init(&spinlock->spinlock); | ||
71 | }; | ||
72 | static inline void nvgpu_raw_spinlock_acquire(struct nvgpu_raw_spinlock *spinlock) | ||
73 | { | ||
74 | raw_spin_lock(&spinlock->spinlock); | ||
75 | }; | ||
76 | static inline void nvgpu_raw_spinlock_release(struct nvgpu_raw_spinlock *spinlock) | ||
77 | { | ||
78 | raw_spin_unlock(&spinlock->spinlock); | ||
79 | }; | ||
80 | |||
81 | #endif /* NVGPU_LOCK_LINUX_H */ | ||