Lines Matching defs:task

192 	/* explore task */
209 * until the USB task thread is running, which means that
256 * To avoid races with the usb task thread, mark the root hub
257 * as disconnecting and schedule an exploration task to detach
263 * handler when unplugging an HC card otherwise the task won't be
280 panic("unable to create usb abort task thread");
284 panic("unable to create usb task thread");
288 * Add a task to be performed by the task thread. This function can be
289 * called from any context and the task will be executed in a process
293 usb_add_task(struct usbd_device *dev, struct usb_task *task)
303 if (usbd_is_dying(dev) && (task->type != USB_TASK_TYPE_ABORT))
306 DPRINTFN(2,("%s: task=%p state=%d type=%d\n", __func__, task,
307 task->state, task->type));
310 if (!(task->state & USB_TASK_STATE_ONQ)) {
311 switch (task->type) {
313 TAILQ_INSERT_TAIL(&usb_abort_tasks, task, next);
316 TAILQ_INSERT_TAIL(&usb_explore_tasks, task, next);
319 TAILQ_INSERT_TAIL(&usb_generic_tasks, task, next);
322 task->state |= USB_TASK_STATE_ONQ;
323 task->dev = dev;
325 if (task->type == USB_TASK_TYPE_ABORT)
333 usb_rem_task(struct usbd_device *dev, struct usb_task *task)
337 if (!(task->state & USB_TASK_STATE_ONQ))
340 DPRINTFN(2,("%s: task=%p state=%d type=%d\n", __func__, task,
341 task->state, task->type));
345 switch (task->type) {
347 TAILQ_REMOVE(&usb_abort_tasks, task, next);
350 TAILQ_REMOVE(&usb_explore_tasks, task, next);
353 TAILQ_REMOVE(&usb_generic_tasks, task, next);
356 task->state &= ~USB_TASK_STATE_ONQ;
357 if (task->state == USB_TASK_STATE_NONE)
358 wakeup(task);
364 usb_wait_task(struct usbd_device *dev, struct usb_task *task)
368 DPRINTFN(2,("%s: task=%p state=%d type=%d\n", __func__, task,
369 task->state, task->type));
371 if (task->state == USB_TASK_STATE_NONE)
375 while (task->state != USB_TASK_STATE_NONE) {
376 DPRINTF(("%s: waiting for task to complete\n", __func__));
377 tsleep_nsec(task, PWAIT, "endtask", INFSLP);
383 usb_rem_wait_task(struct usbd_device *dev, struct usb_task *task)
385 usb_rem_task(dev, task);
386 usb_wait_task(dev, task);
392 struct usb_task *task;
399 if ((task = TAILQ_FIRST(&usb_explore_tasks)) != NULL)
400 TAILQ_REMOVE(&usb_explore_tasks, task, next);
401 else if ((task = TAILQ_FIRST(&usb_generic_tasks)) != NULL)
402 TAILQ_REMOVE(&usb_generic_tasks, task, next);
413 task->state |= USB_TASK_STATE_RUN;
414 task->state &= ~USB_TASK_STATE_ONQ;
415 /* Don't actually execute the task if dying. */
416 if (!usbd_is_dying(task->dev)) {
418 task->fun(task->arg);
421 task->state &= ~USB_TASK_STATE_RUN;
422 if (task->state == USB_TASK_STATE_NONE)
423 wakeup(task);
432 * Synchronous xfers sleep the task thread, so the aborts need to happen
438 struct usb_task *task;
445 if ((task = TAILQ_FIRST(&usb_abort_tasks)) != NULL)
446 TAILQ_REMOVE(&usb_abort_tasks, task, next);
458 task->state |= USB_TASK_STATE_RUN;
459 task->state &= ~USB_TASK_STATE_ONQ;
461 task->fun(task->arg);
463 task->state &= ~USB_TASK_STATE_RUN;
464 if (task->state == USB_TASK_STATE_NONE)
465 wakeup(task);
781 * function is only called from the task thread, with one exception:
805 * task, allowing the high speed explore task to run.