diff options
author | Debarshi Dutta <ddutta@nvidia.com> | 2017-08-03 06:04:44 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-08-17 17:26:47 -0400 |
commit | 98186ec2c2127c2af65a34f9e697e04f518a79ab (patch) | |
tree | 08ad87f3bf8c739e96b36f01728a8f7a30749a0e /drivers/gpu/nvgpu/include/nvgpu/atomic.h | |
parent | 49dc335cfe588179cbb42d8bab53bc76ba88b28f (diff) |
gpu: nvgpu: Add wrapper over atomic_t and atomic64_t
- added wrapper structs nvgpu_atomic_t and nvgpu_atomic64_t over
atomic_t and atomic64_t
- added nvgpu_atomic_* and nvgpu_atomic64_* APIs to access the above
wrappers.
JIRA NVGPU-121
Change-Id: I61667bb0a84c2fc475365abb79bffb42b8b4786a
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1533044
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/gpu/nvgpu/include/nvgpu/atomic.h')
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/atomic.h | 98 |
1 files changed, 94 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/atomic.h b/drivers/gpu/nvgpu/include/nvgpu/atomic.h index 700e29fe..c7a5fcd9 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/atomic.h +++ b/drivers/gpu/nvgpu/include/nvgpu/atomic.h | |||
@@ -9,12 +9,102 @@ | |||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
11 | * more details. | 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/>. | ||
12 | */ | 15 | */ |
13 | #ifndef __NVGPU_ATOMIC_H__ | 16 | #ifndef __NVGPU_ATOMIC_H__ |
14 | #define __NVGPU_ATOMIC_H__ | 17 | #define __NVGPU_ATOMIC_H__ |
15 | 18 | ||
16 | #ifdef __KERNEL__ | 19 | #include <nvgpu/linux/atomic.h> |
17 | #include <linux/atomic.h> | 20 | |
18 | #endif | 21 | #define NVGPU_ATOMIC_INIT(i) __nvgpu_atomic_init(i) |
22 | #define NVGPU_ATOMIC64_INIT(i) __nvgpu_atomic64_init(i) | ||
23 | |||
24 | static inline void nvgpu_atomic_set(nvgpu_atomic_t *v, int i) | ||
25 | { | ||
26 | __nvgpu_atomic_set(v, i); | ||
27 | } | ||
28 | static inline int nvgpu_atomic_read(nvgpu_atomic_t *v) | ||
29 | { | ||
30 | return __nvgpu_atomic_read(v); | ||
31 | } | ||
32 | static inline void nvgpu_atomic_inc(nvgpu_atomic_t *v) | ||
33 | { | ||
34 | __nvgpu_atomic_inc(v); | ||
35 | } | ||
36 | static inline int nvgpu_atomic_inc_return(nvgpu_atomic_t *v) | ||
37 | { | ||
38 | return __nvgpu_atomic_inc_return(v); | ||
39 | } | ||
40 | static inline void nvgpu_atomic_dec(nvgpu_atomic_t *v) | ||
41 | { | ||
42 | __nvgpu_atomic_dec(v); | ||
43 | } | ||
44 | static inline int nvgpu_atomic_dec_return(nvgpu_atomic_t *v) | ||
45 | { | ||
46 | return __nvgpu_atomic_dec_return(v); | ||
47 | } | ||
48 | static inline int nvgpu_atomic_cmpxchg(nvgpu_atomic_t *v, int old, int new) | ||
49 | { | ||
50 | return __nvgpu_atomic_cmpxchg(v, old, new); | ||
51 | } | ||
52 | static inline int nvgpu_atomic_xchg(nvgpu_atomic_t *v, int new) | ||
53 | { | ||
54 | return __nvgpu_atomic_xchg(v, new); | ||
55 | } | ||
56 | static inline bool nvgpu_atomic_inc_and_test(nvgpu_atomic_t *v) | ||
57 | { | ||
58 | return __nvgpu_atomic_inc_and_test(v); | ||
59 | } | ||
60 | static inline bool nvgpu_atomic_dec_and_test(nvgpu_atomic_t *v) | ||
61 | { | ||
62 | return __nvgpu_atomic_dec_and_test(v); | ||
63 | } | ||
64 | static inline int nvgpu_atomic_add_return(int i, nvgpu_atomic_t *v) | ||
65 | { | ||
66 | return __nvgpu_atomic_add_return(i, v); | ||
67 | } | ||
68 | static inline void nvgpu_atomic64_set(nvgpu_atomic64_t *v, long i) | ||
69 | { | ||
70 | return __nvgpu_atomic64_set(v, i); | ||
71 | } | ||
72 | static inline long nvgpu_atomic64_read(nvgpu_atomic64_t *v) | ||
73 | { | ||
74 | return __nvgpu_atomic64_read(v); | ||
75 | } | ||
76 | static inline void nvgpu_atomic64_add(long x, nvgpu_atomic64_t *v) | ||
77 | { | ||
78 | __nvgpu_atomic64_add(x, v); | ||
79 | } | ||
80 | static inline void nvgpu_atomic64_inc(nvgpu_atomic64_t *v) | ||
81 | { | ||
82 | __nvgpu_atomic64_inc(v); | ||
83 | } | ||
84 | static inline long nvgpu_atomic64_inc_return(nvgpu_atomic64_t *v) | ||
85 | { | ||
86 | return __nvgpu_atomic64_inc_return(v); | ||
87 | } | ||
88 | static inline void nvgpu_atomic64_dec(nvgpu_atomic64_t *v) | ||
89 | { | ||
90 | __nvgpu_atomic64_dec(v); | ||
91 | } | ||
92 | static inline void nvgpu_atomic64_dec_return(nvgpu_atomic64_t *v) | ||
93 | { | ||
94 | __nvgpu_atomic64_dec_return(v); | ||
95 | } | ||
96 | static inline long nvgpu_atomic64_cmpxchg(nvgpu_atomic64_t *v, long old, | ||
97 | long new) | ||
98 | { | ||
99 | return __nvgpu_atomic64_cmpxchg(v, old, new); | ||
100 | } | ||
101 | static inline void nvgpu_atomic64_sub(long x, nvgpu_atomic64_t *v) | ||
102 | { | ||
103 | __nvgpu_atomic64_sub(x, v); | ||
104 | } | ||
105 | static inline long nvgpu_atomic64_sub_return(long x, nvgpu_atomic64_t *v) | ||
106 | { | ||
107 | return __nvgpu_atomic64_sub_return(x, v); | ||
108 | } | ||
19 | 109 | ||
20 | #endif | 110 | #endif /* __NVGPU_ATOMIC_H__ */ |