diff options
Diffstat (limited to 'include/linux/fence.h')
-rw-r--r-- | include/linux/fence.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/include/linux/fence.h b/include/linux/fence.h index 39efee130d2b..bb522011383b 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h | |||
@@ -280,6 +280,22 @@ fence_is_signaled(struct fence *fence) | |||
280 | } | 280 | } |
281 | 281 | ||
282 | /** | 282 | /** |
283 | * fence_is_later - return if f1 is chronologically later than f2 | ||
284 | * @f1: [in] the first fence from the same context | ||
285 | * @f2: [in] the second fence from the same context | ||
286 | * | ||
287 | * Returns true if f1 is chronologically later than f2. Both fences must be | ||
288 | * from the same context, since a seqno is not re-used across contexts. | ||
289 | */ | ||
290 | static inline bool fence_is_later(struct fence *f1, struct fence *f2) | ||
291 | { | ||
292 | if (WARN_ON(f1->context != f2->context)) | ||
293 | return false; | ||
294 | |||
295 | return f1->seqno - f2->seqno < INT_MAX; | ||
296 | } | ||
297 | |||
298 | /** | ||
283 | * fence_later - return the chronologically later fence | 299 | * fence_later - return the chronologically later fence |
284 | * @f1: [in] the first fence from the same context | 300 | * @f1: [in] the first fence from the same context |
285 | * @f2: [in] the second fence from the same context | 301 | * @f2: [in] the second fence from the same context |
@@ -298,14 +314,15 @@ static inline struct fence *fence_later(struct fence *f1, struct fence *f2) | |||
298 | * set if enable_signaling wasn't called, and enabling that here is | 314 | * set if enable_signaling wasn't called, and enabling that here is |
299 | * overkill. | 315 | * overkill. |
300 | */ | 316 | */ |
301 | if (f2->seqno - f1->seqno <= INT_MAX) | 317 | if (fence_is_later(f1, f2)) |
302 | return fence_is_signaled(f2) ? NULL : f2; | ||
303 | else | ||
304 | return fence_is_signaled(f1) ? NULL : f1; | 318 | return fence_is_signaled(f1) ? NULL : f1; |
319 | else | ||
320 | return fence_is_signaled(f2) ? NULL : f2; | ||
305 | } | 321 | } |
306 | 322 | ||
307 | signed long fence_wait_timeout(struct fence *, bool intr, signed long timeout); | 323 | signed long fence_wait_timeout(struct fence *, bool intr, signed long timeout); |
308 | 324 | signed long fence_wait_any_timeout(struct fence **fences, uint32_t count, | |
325 | bool intr, signed long timeout); | ||
309 | 326 | ||
310 | /** | 327 | /** |
311 | * fence_wait - sleep until the fence gets signaled | 328 | * fence_wait - sleep until the fence gets signaled |