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