Lines Matching full:up
56 struct usb_process *up = (struct usb_process*)para; in usb_process_thread() local
67 sched_prio(td, up->up_prio); in usb_process_thread()
70 USB_MTX_LOCK(up->up_mtx); in usb_process_thread()
72 up->up_curtd = td; in usb_process_thread()
74 if (up->up_gone) in usb_process_thread()
104 * first one is sleeping, we end up enabling transmission in usb_process_thread()
122 pm = TAILQ_FIRST(&up->up_qhead); in usb_process_thread()
132 if (pm == TAILQ_FIRST(&up->up_qhead)) { in usb_process_thread()
134 TAILQ_REMOVE(&up->up_qhead, pm, pm_qentry); in usb_process_thread()
143 if (up->up_dsleep) { in usb_process_thread()
144 up->up_dsleep = 0; in usb_process_thread()
145 (void)cv_broadcast(&up->up_drain); in usb_process_thread()
147 up->up_msleep = 1; in usb_process_thread()
148 (void)cv_wait(&up->up_cv, up->up_mtx); in usb_process_thread()
151 up->up_ptr = NULL; in usb_process_thread()
152 (void)cv_signal(&up->up_cv); in usb_process_thread()
153 USB_MTX_UNLOCK(up->up_mtx); in usb_process_thread()
198 * has returned. The structure pointed to by "up" is assumed to be
206 usb_proc_create(struct usb_process *up, struct mtx *p_mtx, in usb_proc_create() argument
211 up->up_mtx = p_mtx; in usb_proc_create()
212 up->up_prio = prio; in usb_proc_create()
214 TAILQ_INIT(&up->up_qhead); in usb_proc_create()
216 cv_init(&up->up_cv, "-"); in usb_proc_create()
217 cv_init(&up->up_drain, "usbdrain"); in usb_proc_create()
219 ret = usb_os_task_creat(&td, (TSK_ENTRY_FUNC)usb_process_thread, prio, pmesg, (UINTPTR)up); in usb_proc_create()
222 up->up_ptr = NULL; in usb_proc_create()
225 up->up_ptr = (struct thread *)(UINTPTR)td; in usb_proc_create()
229 usb_proc_free(up); in usb_proc_create()
236 * NOTE: If the structure pointed to by "up" is all zero, this
243 usb_proc_free(struct usb_process *up) in usb_proc_free() argument
246 if (up->up_mtx == NULL) in usb_proc_free()
249 usb_proc_drain(up); in usb_proc_free()
251 cv_destroy(&up->up_cv); in usb_proc_free()
252 cv_destroy(&up->up_drain); in usb_proc_free()
255 up->up_mtx = NULL; in usb_proc_free()
270 usb_proc_msignal(struct usb_process *up, void *_pm0, void *_pm1) in usb_proc_msignal() argument
280 if (up->up_gone) in usb_proc_msignal()
300 if (pm0->pm_num == up->up_msg_num) { in usb_proc_msignal()
301 up->up_msg_num++; in usb_proc_msignal()
306 if (pm1->pm_num == up->up_msg_num) { in usb_proc_msignal()
307 up->up_msg_num++; in usb_proc_msignal()
324 TAILQ_REMOVE(&up->up_qhead, pm2, pm_qentry); in usb_proc_msignal()
330 DPRINTF(" t=%u, num=%u\n", t, up->up_msg_num); in usb_proc_msignal()
334 pm2->pm_num = up->up_msg_num; in usb_proc_msignal()
335 TAILQ_INSERT_TAIL(&up->up_qhead, pm2, pm_qentry); in usb_proc_msignal()
340 up->up_msleep = 0; /* save "cv_signal()" calls */ in usb_proc_msignal()
341 (void)cv_signal(&up->up_cv); in usb_proc_msignal()
354 usb_proc_is_gone(struct usb_process *up) in usb_proc_is_gone() argument
356 if (up->up_gone) { in usb_proc_is_gone()
364 if (up->up_mtx != NULL) { in usb_proc_is_gone()
365 mtx_assert(up->up_mtx, MA_OWNED); in usb_proc_is_gone()
375 * having "up->up_mtx" locked.
378 usb_proc_mwait(struct usb_process *up, void *_pm0, void *_pm1) in usb_proc_mwait() argument
385 if (up->up_gone) in usb_proc_mwait()
388 mtx_assert(up->up_mtx, MA_OWNED); in usb_proc_mwait()
390 if (up->up_curtd == (struct thread *)(UINTPTR)curthread) { in usb_proc_mwait()
394 TAILQ_REMOVE(&up->up_qhead, pm0, pm_qentry); in usb_proc_mwait()
398 TAILQ_REMOVE(&up->up_qhead, pm1, pm_qentry); in usb_proc_mwait()
406 if (up->up_gone) in usb_proc_mwait()
408 up->up_dsleep = 1; in usb_proc_mwait()
409 (void)cv_wait(&up->up_drain, up->up_mtx); in usb_proc_mwait()
419 * NOTE: If the structure pointed to by "up" is all zero,
423 usb_proc_drain(struct usb_process *up) in usb_proc_drain() argument
426 if (up->up_mtx == NULL) { in usb_proc_drain()
431 if (up->up_mtx != &Giant) { in usb_proc_drain()
432 mtx_assert(up->up_mtx, MA_NOTOWNED); in usb_proc_drain()
435 USB_MTX_LOCK(up->up_mtx); in usb_proc_drain()
439 up->up_gone = 1; in usb_proc_drain()
441 while (up->up_ptr) { in usb_proc_drain()
445 if (up->up_msleep || up->up_csleep) { in usb_proc_drain()
446 up->up_msleep = 0; in usb_proc_drain()
447 up->up_csleep = 0; in usb_proc_drain()
448 (void)cv_signal(&up->up_cv); in usb_proc_drain()
450 (void)cv_wait(&up->up_cv, up->up_mtx); in usb_proc_drain()
454 if (up->up_dsleep) { in usb_proc_drain()
455 up->up_dsleep = 0; in usb_proc_drain()
456 (void)cv_broadcast(&up->up_drain); in usb_proc_drain()
460 USB_MTX_UNLOCK(up->up_mtx); in usb_proc_drain()
469 * having "up->up_mtx" locked.
472 usb_proc_rewakeup(struct usb_process *up) in usb_proc_rewakeup() argument
475 if (up->up_mtx == NULL) in usb_proc_rewakeup()
478 if (up->up_gone) in usb_proc_rewakeup()
481 mtx_assert(up->up_mtx, MA_OWNED); in usb_proc_rewakeup()
483 if (up->up_msleep == 0) { in usb_proc_rewakeup()
485 (void)cv_signal(&up->up_cv); in usb_proc_rewakeup()
496 usb_proc_is_called_from(struct usb_process *up) in usb_proc_is_called_from() argument
498 return (up->up_curtd == (struct thread *)(UINTPTR)curthread); in usb_proc_is_called_from()