Merge tag 'x86-urgent-2022-08-06' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / drivers / gpu / drm / i915 / i915_tasklet.h
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5
6 #ifndef __I915_TASKLET_H__
7 #define __I915_TASKLET_H__
8
9 #include <linux/interrupt.h>
10
11 static inline void tasklet_lock(struct tasklet_struct *t)
12 {
13         while (!tasklet_trylock(t))
14                 cpu_relax();
15 }
16
17 static inline bool tasklet_is_locked(const struct tasklet_struct *t)
18 {
19         return test_bit(TASKLET_STATE_RUN, &t->state);
20 }
21
22 static inline void __tasklet_disable_sync_once(struct tasklet_struct *t)
23 {
24         if (!atomic_fetch_inc(&t->count))
25                 tasklet_unlock_spin_wait(t);
26 }
27
28 static inline bool __tasklet_is_enabled(const struct tasklet_struct *t)
29 {
30         return !atomic_read(&t->count);
31 }
32
33 static inline bool __tasklet_enable(struct tasklet_struct *t)
34 {
35         return atomic_dec_and_test(&t->count);
36 }
37
38 static inline bool __tasklet_is_scheduled(struct tasklet_struct *t)
39 {
40         return test_bit(TASKLET_STATE_SCHED, &t->state);
41 }
42
43 #endif /* __I915_TASKLET_H__ */