Lines Matching +full:lock +full:- +full:state

1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
15 return -ENOMEM; in rxe_alloc_wq()
29 * state will move out of busy if task returns a non zero value
30 * in do_task(). If state is already busy it is raised to armed
33 * Context: caller should hold task->lock.
34 * Returns: true if state transitioned from idle to busy else false.
38 WARN_ON(rxe_read(task->qp) <= 0); in __reserve_if_idle()
40 if (task->state == TASK_STATE_IDLE) { in __reserve_if_idle()
41 rxe_get(task->qp); in __reserve_if_idle()
42 task->state = TASK_STATE_BUSY; in __reserve_if_idle()
43 task->num_sched++; in __reserve_if_idle()
47 if (task->state == TASK_STATE_BUSY) in __reserve_if_idle()
48 task->state = TASK_STATE_ARMED; in __reserve_if_idle()
57 * Context: caller should hold task->lock.
62 if (work_pending(&task->work)) in __is_done()
65 if (task->state == TASK_STATE_IDLE || in __is_done()
66 task->state == TASK_STATE_DRAINED) { in __is_done()
79 spin_lock_irqsave(&task->lock, flags); in is_done()
81 spin_unlock_irqrestore(&task->lock, flags); in is_done()
88 * they return a non-zero value. It is called either
98 * has been consumed then it returns a non-zero value.
111 WARN_ON(rxe_read(task->qp) <= 0); in do_task()
113 spin_lock_irqsave(&task->lock, flags); in do_task()
114 if (task->state >= TASK_STATE_DRAINED) { in do_task()
115 rxe_put(task->qp); in do_task()
116 task->num_done++; in do_task()
117 spin_unlock_irqrestore(&task->lock, flags); in do_task()
120 spin_unlock_irqrestore(&task->lock, flags); in do_task()
127 ret = task->func(task->qp); in do_task()
128 } while (ret == 0 && iterations-- > 0); in do_task()
130 spin_lock_irqsave(&task->lock, flags); in do_task()
135 task->state = TASK_STATE_IDLE; in do_task()
140 switch (task->state) { in do_task()
142 task->state = TASK_STATE_IDLE; in do_task()
149 task->state = TASK_STATE_BUSY; in do_task()
154 task->state = TASK_STATE_DRAINED; in do_task()
159 rxe_dbg_qp(task->qp, "unexpected task state = %d\n", in do_task()
160 task->state); in do_task()
161 task->state = TASK_STATE_IDLE; in do_task()
166 task->num_done++; in do_task()
167 if (WARN_ON(task->num_done != task->num_sched)) in do_task()
169 task->qp, in do_task()
171 task->num_sched, task->num_done); in do_task()
173 spin_unlock_irqrestore(&task->lock, flags); in do_task()
176 task->ret = ret; in do_task()
181 rxe_put(task->qp); in do_task()
195 task->qp = qp; in rxe_init_task()
196 task->func = func; in rxe_init_task()
197 task->state = TASK_STATE_IDLE; in rxe_init_task()
198 spin_lock_init(&task->lock); in rxe_init_task()
199 INIT_WORK(&task->work, do_work); in rxe_init_task()
216 spin_lock_irqsave(&task->lock, flags); in rxe_cleanup_task()
217 if (!__is_done(task) && task->state < TASK_STATE_DRAINED) { in rxe_cleanup_task()
218 task->state = TASK_STATE_DRAINING; in rxe_cleanup_task()
220 task->state = TASK_STATE_INVALID; in rxe_cleanup_task()
221 spin_unlock_irqrestore(&task->lock, flags); in rxe_cleanup_task()
224 spin_unlock_irqrestore(&task->lock, flags); in rxe_cleanup_task()
232 spin_lock_irqsave(&task->lock, flags); in rxe_cleanup_task()
233 task->state = TASK_STATE_INVALID; in rxe_cleanup_task()
234 spin_unlock_irqrestore(&task->lock, flags); in rxe_cleanup_task()
238 * cannot call do_task holding the lock
245 WARN_ON(rxe_read(task->qp) <= 0); in rxe_run_task()
247 spin_lock_irqsave(&task->lock, flags); in rxe_run_task()
249 spin_unlock_irqrestore(&task->lock, flags); in rxe_run_task()
257 * the lock.
263 WARN_ON(rxe_read(task->qp) <= 0); in rxe_sched_task()
265 spin_lock_irqsave(&task->lock, flags); in rxe_sched_task()
267 queue_work(rxe_wq, &task->work); in rxe_sched_task()
268 spin_unlock_irqrestore(&task->lock, flags); in rxe_sched_task()
273 * to the drained state by do_task.
279 WARN_ON(rxe_read(task->qp) <= 0); in rxe_disable_task()
281 spin_lock_irqsave(&task->lock, flags); in rxe_disable_task()
282 if (!__is_done(task) && task->state < TASK_STATE_DRAINED) { in rxe_disable_task()
283 task->state = TASK_STATE_DRAINING; in rxe_disable_task()
285 task->state = TASK_STATE_DRAINED; in rxe_disable_task()
286 spin_unlock_irqrestore(&task->lock, flags); in rxe_disable_task()
289 spin_unlock_irqrestore(&task->lock, flags); in rxe_disable_task()
294 spin_lock_irqsave(&task->lock, flags); in rxe_disable_task()
295 task->state = TASK_STATE_DRAINED; in rxe_disable_task()
296 spin_unlock_irqrestore(&task->lock, flags); in rxe_disable_task()
303 WARN_ON(rxe_read(task->qp) <= 0); in rxe_enable_task()
305 spin_lock_irqsave(&task->lock, flags); in rxe_enable_task()
306 if (task->state == TASK_STATE_INVALID) { in rxe_enable_task()
307 spin_unlock_irqrestore(&task->lock, flags); in rxe_enable_task()
311 task->state = TASK_STATE_IDLE; in rxe_enable_task()
312 spin_unlock_irqrestore(&task->lock, flags); in rxe_enable_task()