Lines Matching full:up
57 struct usb_process *up = (struct usb_process*)para; in usb_process_thread() local
68 sched_prio(td, up->up_prio); in usb_process_thread()
71 mtx_lock(up->up_mtx); in usb_process_thread()
73 up->up_curtd = td; in usb_process_thread()
75 if (up->up_gone) in usb_process_thread()
105 * first one is sleeping, we end up enabling transmission in usb_process_thread()
123 pm = TAILQ_FIRST(&up->up_qhead); in usb_process_thread()
133 if (pm == TAILQ_FIRST(&up->up_qhead)) { in usb_process_thread()
135 TAILQ_REMOVE(&up->up_qhead, pm, pm_qentry); in usb_process_thread()
144 if (up->up_dsleep) { in usb_process_thread()
145 up->up_dsleep = 0; in usb_process_thread()
146 (void)cv_broadcast(&up->up_drain); in usb_process_thread()
148 up->up_msleep = 1; in usb_process_thread()
149 (void)cv_wait(&up->up_cv, up->up_mtx); in usb_process_thread()
152 up->up_ptr = NULL; in usb_process_thread()
153 (void)cv_signal(&up->up_cv); in usb_process_thread()
154 mtx_unlock(up->up_mtx); in usb_process_thread()
199 * has returned. The structure pointed to by "up" is assumed to be
207 usb_proc_create(struct usb_process *up, struct mtx *p_mtx, in usb_proc_create() argument
212 up->up_mtx = p_mtx; in usb_proc_create()
213 up->up_prio = prio; in usb_proc_create()
215 TAILQ_INIT(&up->up_qhead); in usb_proc_create()
217 cv_init(&up->up_cv, "-"); in usb_proc_create()
218 cv_init(&up->up_drain, "usbdrain"); in usb_proc_create()
220 ret = usb_os_task_creat(&td, (TSK_ENTRY_FUNC)usb_process_thread, prio, pmesg, (UINTPTR)up); in usb_proc_create()
223 up->up_ptr = NULL; in usb_proc_create()
226 up->up_ptr = (struct thread *)(UINTPTR)td; in usb_proc_create()
230 usb_proc_free(up); in usb_proc_create()
237 * NOTE: If the structure pointed to by "up" is all zero, this
244 usb_proc_free(struct usb_process *up) in usb_proc_free() argument
247 if (up->up_mtx == NULL) in usb_proc_free()
250 usb_proc_drain(up); in usb_proc_free()
252 cv_destroy(&up->up_cv); in usb_proc_free()
253 cv_destroy(&up->up_drain); in usb_proc_free()
256 up->up_mtx = NULL; in usb_proc_free()
271 usb_proc_msignal(struct usb_process *up, void *_pm0, void *_pm1) in usb_proc_msignal() argument
281 if (up->up_gone) in usb_proc_msignal()
301 if (pm0->pm_num == up->up_msg_num) { in usb_proc_msignal()
302 up->up_msg_num++; in usb_proc_msignal()
307 if (pm1->pm_num == up->up_msg_num) { in usb_proc_msignal()
308 up->up_msg_num++; in usb_proc_msignal()
325 TAILQ_REMOVE(&up->up_qhead, pm2, pm_qentry); in usb_proc_msignal()
331 DPRINTF(" t=%u, num=%u\n", t, up->up_msg_num); in usb_proc_msignal()
335 pm2->pm_num = up->up_msg_num; in usb_proc_msignal()
336 TAILQ_INSERT_TAIL(&up->up_qhead, pm2, pm_qentry); in usb_proc_msignal()
341 up->up_msleep = 0; /* save "cv_signal()" calls */ in usb_proc_msignal()
342 (void)cv_signal(&up->up_cv); in usb_proc_msignal()
355 usb_proc_is_gone(struct usb_process *up) in usb_proc_is_gone() argument
357 if (up->up_gone) { in usb_proc_is_gone()
365 if (up->up_mtx != NULL) { in usb_proc_is_gone()
366 mtx_assert(up->up_mtx, MA_OWNED); in usb_proc_is_gone()
376 * having "up->up_mtx" locked.
379 usb_proc_mwait(struct usb_process *up, void *_pm0, void *_pm1) in usb_proc_mwait() argument
386 if (up->up_gone) in usb_proc_mwait()
389 mtx_assert(up->up_mtx, MA_OWNED); in usb_proc_mwait()
391 if (up->up_curtd == (struct thread *)(UINTPTR)curthread) { in usb_proc_mwait()
395 TAILQ_REMOVE(&up->up_qhead, pm0, pm_qentry); in usb_proc_mwait()
399 TAILQ_REMOVE(&up->up_qhead, pm1, pm_qentry); in usb_proc_mwait()
407 if (up->up_gone) in usb_proc_mwait()
409 up->up_dsleep = 1; in usb_proc_mwait()
410 (void)cv_wait(&up->up_drain, up->up_mtx); in usb_proc_mwait()
420 * NOTE: If the structure pointed to by "up" is all zero,
424 usb_proc_drain(struct usb_process *up) in usb_proc_drain() argument
427 if (up->up_mtx == NULL) { in usb_proc_drain()
432 if (up->up_mtx != &Giant) { in usb_proc_drain()
433 mtx_assert(up->up_mtx, MA_NOTOWNED); in usb_proc_drain()
436 mtx_lock(up->up_mtx); in usb_proc_drain()
440 up->up_gone = 1; in usb_proc_drain()
442 while (up->up_ptr) { in usb_proc_drain()
446 if (up->up_msleep || up->up_csleep) { in usb_proc_drain()
447 up->up_msleep = 0; in usb_proc_drain()
448 up->up_csleep = 0; in usb_proc_drain()
449 (void)cv_signal(&up->up_cv); in usb_proc_drain()
451 (void)cv_wait(&up->up_cv, up->up_mtx); in usb_proc_drain()
455 if (up->up_dsleep) { in usb_proc_drain()
456 up->up_dsleep = 0; in usb_proc_drain()
457 (void)cv_broadcast(&up->up_drain); in usb_proc_drain()
461 mtx_unlock(up->up_mtx); in usb_proc_drain()
470 * having "up->up_mtx" locked.
473 usb_proc_rewakeup(struct usb_process *up) in usb_proc_rewakeup() argument
476 if (up->up_mtx == NULL) in usb_proc_rewakeup()
479 if (up->up_gone) in usb_proc_rewakeup()
482 mtx_assert(up->up_mtx, MA_OWNED); in usb_proc_rewakeup()
484 if (up->up_msleep == 0) { in usb_proc_rewakeup()
486 (void)cv_signal(&up->up_cv); in usb_proc_rewakeup()
497 usb_proc_is_called_from(struct usb_process *up) in usb_proc_is_called_from() argument
499 return (up->up_curtd == (struct thread *)(UINTPTR)curthread); in usb_proc_is_called_from()