i915_tasklet.h 912 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright © 2022 Intel Corporation
  4. */
  5. #ifndef __I915_TASKLET_H__
  6. #define __I915_TASKLET_H__
  7. #include <linux/interrupt.h>
  8. static inline void tasklet_lock(struct tasklet_struct *t)
  9. {
  10. while (!tasklet_trylock(t))
  11. cpu_relax();
  12. }
  13. static inline bool tasklet_is_locked(const struct tasklet_struct *t)
  14. {
  15. return test_bit(TASKLET_STATE_RUN, &t->state);
  16. }
  17. static inline void __tasklet_disable_sync_once(struct tasklet_struct *t)
  18. {
  19. if (!atomic_fetch_inc(&t->count))
  20. tasklet_unlock_spin_wait(t);
  21. }
  22. static inline bool __tasklet_is_enabled(const struct tasklet_struct *t)
  23. {
  24. return !atomic_read(&t->count);
  25. }
  26. static inline bool __tasklet_enable(struct tasklet_struct *t)
  27. {
  28. return atomic_dec_and_test(&t->count);
  29. }
  30. static inline bool __tasklet_is_scheduled(struct tasklet_struct *t)
  31. {
  32. return test_bit(TASKLET_STATE_SCHED, &t->state);
  33. }
  34. #endif /* __I915_TASKLET_H__ */