Lines Matching full:up
90 struct usb_process *up = arg;
100 sched_prio(td, up->up_prio);
103 USB_MTX_LOCK(up->up_mtx);
105 up->up_curtd = td;
108 if (up->up_gone)
138 * first one is sleeping, we end up enabling transmission
154 pm = TAILQ_FIRST(&up->up_qhead);
162 if (pm == TAILQ_FIRST(&up->up_qhead)) {
164 TAILQ_REMOVE(&up->up_qhead, pm, pm_qentry);
172 if (up->up_dsleep) {
173 up->up_dsleep = 0;
174 cv_broadcast(&up->up_drain);
176 up->up_msleep = 1;
177 cv_wait(&up->up_cv, up->up_mtx);
180 up->up_ptr = NULL;
181 cv_signal(&up->up_cv);
182 USB_MTX_UNLOCK(up->up_mtx);
196 * has returned. The structure pointed to by "up" is assumed to be
204 usb_proc_create(struct usb_process *up, struct mtx *p_mtx,
207 up->up_mtx = p_mtx;
208 up->up_prio = prio;
210 TAILQ_INIT(&up->up_qhead);
212 cv_init(&up->up_cv, "-");
213 cv_init(&up->up_drain, "usbdrain");
215 if (USB_THREAD_CREATE(&usb_process, up,
216 &up->up_ptr, "%s", pmesg)) {
218 up->up_ptr = NULL;
225 usb_proc_free(up);
232 * NOTE: If the structure pointed to by "up" is all zero, this
239 usb_proc_free(struct usb_process *up)
242 if (up->up_mtx == NULL)
245 usb_proc_drain(up);
247 cv_destroy(&up->up_cv);
248 cv_destroy(&up->up_drain);
251 up->up_mtx = NULL;
266 usb_proc_msignal(struct usb_process *up, void *_pm0, void *_pm1)
275 if (up->up_gone != 0 ||
279 USB_MTX_ASSERT(up->up_mtx, MA_OWNED);
297 if (pm0->pm_num == up->up_msg_num) {
298 up->up_msg_num++;
303 if (pm1->pm_num == up->up_msg_num) {
304 up->up_msg_num++;
321 TAILQ_REMOVE(&up->up_qhead, pm2, pm_qentry);
326 DPRINTF(" t=%u, num=%u\n", t, up->up_msg_num);
330 pm2->pm_num = up->up_msg_num;
331 TAILQ_INSERT_TAIL(&up->up_qhead, pm2, pm_qentry);
335 if (up->up_msleep) {
336 up->up_msleep = 0; /* save "cv_signal()" calls */
337 cv_signal(&up->up_cv);
350 usb_proc_is_gone(struct usb_process *up)
352 if (up->up_gone)
359 if (up->up_mtx != NULL)
360 USB_MTX_ASSERT(up->up_mtx, MA_OWNED);
365 usb_proc_mwait_impl(struct usb_process *up, void *_pm0, void *_pm1,
373 if (up->up_gone)
376 USB_MTX_ASSERT(up->up_mtx, MA_OWNED);
379 if (up->up_curtd == curthread) {
382 TAILQ_REMOVE(&up->up_qhead, pm0, pm_qentry);
386 TAILQ_REMOVE(&up->up_qhead, pm1, pm_qentry);
393 if (up->up_gone)
395 up->up_dsleep = 1;
397 error = cv_wait_sig(&up->up_drain, up->up_mtx);
407 cv_wait(&up->up_drain, up->up_mtx);
421 * having "up->up_mtx" locked.
424 usb_proc_mwait(struct usb_process *up, void *_pm0, void *_pm1)
427 (void)usb_proc_mwait_impl(up, _pm0, _pm1, false);
435 * having "up->up_mtx" locked. This version of usb_proc_mwait is
439 usb_proc_mwait_sig(struct usb_process *up, void *_pm0, void *_pm1)
442 return (usb_proc_mwait_impl(up, _pm0, _pm1, true));
451 * NOTE: If the structure pointed to by "up" is all zero,
455 usb_proc_drain(struct usb_process *up)
458 if (up->up_mtx == NULL)
461 if (up->up_mtx != &Giant)
462 USB_MTX_ASSERT(up->up_mtx, MA_NOTOWNED);
464 USB_MTX_LOCK(up->up_mtx);
468 up->up_gone = 1;
470 while (up->up_ptr) {
473 if (up->up_msleep || up->up_csleep) {
474 up->up_msleep = 0;
475 up->up_csleep = 0;
476 cv_signal(&up->up_cv);
481 USB_THREAD_SUSPEND(up->up_ptr);
487 cv_wait(&up->up_cv, up->up_mtx);
491 if (up->up_dsleep) {
492 up->up_dsleep = 0;
493 cv_broadcast(&up->up_drain);
497 USB_MTX_UNLOCK(up->up_mtx);
506 * having "up->up_mtx" locked.
509 usb_proc_rewakeup(struct usb_process *up)
512 if (up->up_mtx == NULL)
515 if (up->up_gone)
518 USB_MTX_ASSERT(up->up_mtx, MA_OWNED);
520 if (up->up_msleep == 0) {
522 cv_signal(&up->up_cv);
533 usb_proc_is_called_from(struct usb_process *up)
535 return (up->up_curtd == curthread);