Lines Matching full:work
38 * Define all work struct states
68 * This function atomically updates the work state and returns the
93 linux_work_exec_unblock(struct work_struct *work) in linux_work_exec_unblock() argument
99 wq = work->work_queue; in linux_work_exec_unblock()
105 if (exec->target == work) { in linux_work_exec_unblock()
121 tq = dwork->work.work_queue->taskqueue; in linux_delayed_work_enqueue()
122 taskqueue_enqueue(tq, &dwork->work.work_task); in linux_delayed_work_enqueue()
126 * This function queues the given work structure on the given
127 * workqueue. It returns non-zero if the work was successfully
128 * [re-]queued. Else the work is already pending for completion.
132 struct work_struct *work) in linux_queue_work_on() argument
143 return (!work_pending(work)); in linux_queue_work_on()
145 switch (linux_update_state(&work->state, states)) { in linux_queue_work_on()
148 if (linux_work_exec_unblock(work) != 0) in linux_queue_work_on()
152 work->work_queue = wq; in linux_queue_work_on()
153 taskqueue_enqueue(wq->taskqueue, &work->work_task); in linux_queue_work_on()
169 linux_queue_work_on(WORK_CPU_UNBOUND, rwork->wq, &rwork->work); in rcu_work_func()
173 * This function queue a work after a grace period
174 * If the work was already pending it returns false,
181 if (!linux_work_pending(&rwork->work)) { in linux_queue_rcu_work()
190 * This function waits for the last execution of a work and then
191 * flush the work.
192 * It returns true if the work was pending and we waited, it returns
199 if (linux_work_pending(&rwork->work)) { in linux_flush_rcu_work()
201 linux_flush_work(&rwork->work); in linux_flush_rcu_work()
204 return (linux_flush_work(&rwork->work)); in linux_flush_rcu_work()
208 * This function queues the given work structure on the given
210 * work was successfully [re-]queued. Else the work is already pending
227 return (!work_pending(&dwork->work)); in linux_queue_delayed_work_on()
237 switch (linux_update_state(&dwork->work.state, states)) { in linux_queue_delayed_work_on()
240 if (delay == 0 && linux_work_exec_unblock(&dwork->work)) { in linux_queue_delayed_work_on()
247 dwork->work.work_queue = wq; in linux_queue_delayed_work_on()
275 [WORK_ST_TIMER] = WORK_ST_EXEC, /* delayed work w/o timeout */ in linux_work_fn()
280 struct work_struct *work; in linux_work_fn() local
288 work = context; in linux_work_fn()
289 wq = work->work_queue; in linux_work_fn()
292 exec.target = work; in linux_work_fn()
298 switch (linux_update_state(&work->state, states)) { in linux_work_fn()
304 /* set current work structure */ in linux_work_fn()
305 task->work = work; in linux_work_fn()
307 /* call work function */ in linux_work_fn()
308 work->func(work); in linux_work_fn()
310 /* set current work structure */ in linux_work_fn()
311 task->work = NULL; in linux_work_fn()
315 if (exec.target != work) { in linux_work_fn()
317 exec.target = work; in linux_work_fn()
337 * Make sure the timer belonging to the delayed work gets in linux_delayed_work_fn()
338 * drained before invoking the work function. Else the timer in linux_delayed_work_fn()
340 * situations, because the work function might free the work in linux_delayed_work_fn()
345 linux_work_fn(&dwork->work, pending); in linux_delayed_work_fn()
360 switch (linux_update_state(&dwork->work.state, states)) { in linux_delayed_work_timer_fn()
371 * This function cancels the given work structure in a
372 * non-blocking fashion. It returns non-zero if the work was
373 * successfully cancelled. Else the work may still be busy or already
377 linux_cancel_work(struct work_struct *work) in linux_cancel_work() argument
388 MPASS(atomic_read(&work->state) != WORK_ST_TIMER); in linux_cancel_work()
389 MPASS(atomic_read(&work->state) != WORK_ST_CANCEL); in linux_cancel_work()
391 switch (linux_update_state(&work->state, states)) { in linux_cancel_work()
393 tq = work->work_queue->taskqueue; in linux_cancel_work()
394 if (taskqueue_cancel(tq, &work->work_task, NULL) == 0) in linux_cancel_work()
403 * This function cancels the given work structure in a synchronous
404 * fashion. It returns non-zero if the work was successfully
405 * cancelled. Else the work was already cancelled.
408 linux_cancel_work_sync(struct work_struct *work) in linux_cancel_work_sync() argument
423 switch (linux_update_state(&work->state, states)) { in linux_cancel_work_sync()
428 tq = work->work_queue->taskqueue; in linux_cancel_work_sync()
429 if (taskqueue_cancel(tq, &work->work_task, NULL) != 0) in linux_cancel_work_sync()
430 taskqueue_drain(tq, &work->work_task); in linux_cancel_work_sync()
431 goto retry; /* work may have restarted itself */ in linux_cancel_work_sync()
433 tq = work->work_queue->taskqueue; in linux_cancel_work_sync()
434 if (taskqueue_cancel(tq, &work->work_task, NULL) != 0) in linux_cancel_work_sync()
435 taskqueue_drain(tq, &work->work_task); in linux_cancel_work_sync()
463 * This function cancels the given delayed work structure in a
464 * non-blocking fashion. It returns non-zero if the work was
465 * successfully cancelled. Else the work may still be busy or already
482 switch (linux_update_state(&dwork->work.state, states)) { in linux_cancel_delayed_work()
487 atomic_cmpxchg(&dwork->work.state, in linux_cancel_delayed_work()
494 tq = dwork->work.work_queue->taskqueue; in linux_cancel_delayed_work()
495 if (taskqueue_cancel(tq, &dwork->work.work_task, NULL) == 0) { in linux_cancel_delayed_work()
496 atomic_cmpxchg(&dwork->work.state, in linux_cancel_delayed_work()
509 * This function cancels the given work structure in a synchronous
510 * fashion. It returns true if the work was successfully
511 * cancelled. Else the work was already cancelled.
531 state = linux_update_state(&dwork->work.state, states); in linux_cancel_delayed_work_sync_int()
540 tq = dwork->work.work_queue->taskqueue; in linux_cancel_delayed_work_sync_int()
541 ret = taskqueue_cancel(tq, &dwork->work.work_task, NULL); in linux_cancel_delayed_work_sync_int()
545 taskqueue_drain(tq, &dwork->work.work_task); in linux_cancel_delayed_work_sync_int()
548 tq = dwork->work.work_queue->taskqueue; in linux_cancel_delayed_work_sync_int()
549 ret = taskqueue_cancel(tq, &dwork->work.work_task, NULL); in linux_cancel_delayed_work_sync_int()
552 taskqueue_drain(tq, &dwork->work.work_task); in linux_cancel_delayed_work_sync_int()
569 * This function waits until the given work structure is completed.
570 * It returns non-zero if the work was successfully
571 * waited for. Else the work was not waited for.
574 linux_flush_work(struct work_struct *work) in linux_flush_work() argument
582 switch (atomic_read(&work->state)) { in linux_flush_work()
586 tq = work->work_queue->taskqueue; in linux_flush_work()
587 retval = taskqueue_poll_is_busy(tq, &work->work_task); in linux_flush_work()
588 taskqueue_drain(tq, &work->work_task); in linux_flush_work()
594 * This function waits until the given delayed work structure is
595 * completed. It returns non-zero if the work was successfully waited
596 * for. Else the work was not waited for.
607 switch (atomic_read(&dwork->work.state)) { in linux_flush_delayed_work()
615 tq = dwork->work.work_queue->taskqueue; in linux_flush_delayed_work()
616 retval = taskqueue_poll_is_busy(tq, &dwork->work.work_task); in linux_flush_delayed_work()
617 taskqueue_drain(tq, &dwork->work.work_task); in linux_flush_delayed_work()
623 * This function returns true if the given work is pending, and not
627 linux_work_pending(struct work_struct *work) in linux_work_pending() argument
629 switch (atomic_read(&work->state)) { in linux_work_pending()
640 * This function returns true if the given work is busy.
643 linux_work_busy(struct work_struct *work) in linux_work_busy() argument
647 switch (atomic_read(&work->state)) { in linux_work_busy()
651 tq = work->work_queue->taskqueue; in linux_work_busy()
652 return (taskqueue_poll_is_busy(tq, &work->work_task)); in linux_work_busy()
694 dwork->work.func = func; in linux_init_delayed_work()
695 TASK_INIT(&dwork->work.work_task, 0, linux_delayed_work_fn, dwork); in linux_init_delayed_work()
704 return (current->work); in linux_current_work()