summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIgor Nabirushkin <inabirushkin@nvidia.com>2021-11-16 02:52:51 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2021-11-30 13:09:24 -0500
commit6e0deb8f01a2102a4fb7384e79142e989eddab1f (patch)
treeb3a4dea87f0999b0f3635a7dcd02142fcf219833 /drivers
parentb4c216976e3d5a843114fd4495416ea01a9ef944 (diff)
misc: eventlib: fix building kernel with gcc 11
Eventlib: Add local implementation of __sync_fetch_and_or and __sync_fetch_and_and builtin functions. This fixes eventlib build errors with GCC 11. Bug 3375927 Change-Id: I1a8ed9dcc383242a5fa125df3cfb220c867adaf3 Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2629717 Reviewed-by: Bibek Basu <bbasu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/eventlib/eventlib_flt.h9
-rw-r--r--drivers/misc/eventlib/utility.h56
2 files changed, 60 insertions, 5 deletions
diff --git a/drivers/misc/eventlib/eventlib_flt.h b/drivers/misc/eventlib/eventlib_flt.h
index a2dd1f77c..80ce6b87b 100644
--- a/drivers/misc/eventlib/eventlib_flt.h
+++ b/drivers/misc/eventlib/eventlib_flt.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved.
3 * 3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a 4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"), 5 * copy of this software and associated documentation files (the "Software"),
@@ -24,6 +24,7 @@
24#define EVENTLIB_FLT_H 24#define EVENTLIB_FLT_H
25 25
26#include "eventlib.h" 26#include "eventlib.h"
27#include "utility.h"
27 28
28/* Readers' connects/updates/disconnects and writer's checks for updates, are 29/* Readers' connects/updates/disconnects and writer's checks for updates, are
29 * all fully asynchronous. 30 * all fully asynchronous.
@@ -157,17 +158,17 @@ struct eventlib_flt_ctx {
157 158
158static inline bool sync_test_and_set_bit(unsigned int n, uint32_t *p) 159static inline bool sync_test_and_set_bit(unsigned int n, uint32_t *p)
159{ 160{
160 return !!(__sync_fetch_and_or(p, (1u << n)) & (1u << n)); 161 return !!(tracebuf_sync_fetch_and_or_u32(p, (1u << n)) & (1u << n));
161} 162}
162 163
163static inline void sync_set_bit(unsigned int n, uint32_t *p) 164static inline void sync_set_bit(unsigned int n, uint32_t *p)
164{ 165{
165 __sync_fetch_and_or(p, (1u << n)); 166 tracebuf_sync_fetch_and_or_u32(p, (1u << n));
166} 167}
167 168
168static inline void sync_clear_bit(unsigned int n, uint32_t *p) 169static inline void sync_clear_bit(unsigned int n, uint32_t *p)
169{ 170{
170 __sync_fetch_and_and(p, ~(1u << n)); 171 tracebuf_sync_fetch_and_and_u32(p, ~(1u << n));
171} 172}
172 173
173/* Below functions are implemented by the filter subsystem interface. 174/* Below functions are implemented by the filter subsystem interface.
diff --git a/drivers/misc/eventlib/utility.h b/drivers/misc/eventlib/utility.h
index 83cd49075..a62898b1e 100644
--- a/drivers/misc/eventlib/utility.h
+++ b/drivers/misc/eventlib/utility.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved.
3 * 3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a 4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"), 5 * copy of this software and associated documentation files (the "Software"),
@@ -125,4 +125,58 @@ static inline uint64_t increment64(volatile uint64_t *addr)
125 return prev; 125 return prev;
126} 126}
127 127
128#if defined(__aarch64__) && defined(__GNUC__) && (__GNUC__ >= 11)
129
130static inline uint32_t
131tracebuf_sync_fetch_and_or_u32(uint32_t *ptr, uint32_t value)
132{
133 uint32_t result, tmp, flags = 0;
134
135 asm volatile(
136 "1: ldxr %w[result], [%[ptr]]\n"
137 " orr %w[tmp], %w[result], %w[value]\n"
138 " stlxr %w[flags], %w[tmp], [%[ptr]]\n"
139 " cbnz %w[flags], 1b\n"
140 " dmb ish"
141 : [result] "=&r"(result), [tmp] "=&r"(tmp)
142 : [value] "r"(value), [flags] "r"(flags), [ptr] "r"(ptr)
143 : "cc", "memory");
144
145 return result;
146}
147
148static inline uint32_t
149tracebuf_sync_fetch_and_and_u32(uint32_t *ptr, uint32_t value)
150{
151 uint32_t result, tmp, flags = 0;
152
153 asm volatile(
154 "1: ldxr %w[result], [%[ptr]]\n"
155 " and %w[tmp], %w[result], %w[value]\n"
156 " stlxr %w[flags], %w[tmp], [%[ptr]]\n"
157 " cbnz %w[flags], 1b\n"
158 " dmb ish"
159 : [result] "=&r"(result), [tmp] "=&r"(tmp)
160 : [value] "r"(value), [flags] "r"(flags), [ptr] "r"(ptr)
161 : "cc", "memory");
162
163 return result;
164}
165
166#else
167
168static inline uint32_t
169tracebuf_sync_fetch_and_or_u32(uint32_t *ptr, uint32_t value)
170{
171 return __sync_fetch_and_or(ptr, value);
172}
173
174static inline uint32_t
175tracebuf_sync_fetch_and_and_u32(uint32_t *ptr, uint32_t value)
176{
177 return __sync_fetch_and_and(ptr, value);
178}
179
180#endif
181
128#endif 182#endif