Lines Matching refs:up

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