Lines Matching refs: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);
369 * having "up->up_mtx" locked.
372 usb_proc_mwait(struct usb_process *up, void *_pm0, void *_pm1)
378 if (up->up_gone)
381 USB_MTX_ASSERT(up->up_mtx, MA_OWNED);
383 if (up->up_curtd == curthread) {
386 TAILQ_REMOVE(&up->up_qhead, pm0, pm_qentry);
390 TAILQ_REMOVE(&up->up_qhead, pm1, pm_qentry);
397 if (up->up_gone)
399 up->up_dsleep = 1;
400 cv_wait(&up->up_drain, up->up_mtx);
410 * NOTE: If the structure pointed to by "up" is all zero,
414 usb_proc_drain(struct usb_process *up)
417 if (up->up_mtx == NULL)
420 if (up->up_mtx != &Giant)
421 USB_MTX_ASSERT(up->up_mtx, MA_NOTOWNED);
423 USB_MTX_LOCK(up->up_mtx);
427 up->up_gone = 1;
429 while (up->up_ptr) {
432 if (up->up_msleep || up->up_csleep) {
433 up->up_msleep = 0;
434 up->up_csleep = 0;
435 cv_signal(&up->up_cv);
440 USB_THREAD_SUSPEND(up->up_ptr);
446 cv_wait(&up->up_cv, up->up_mtx);
450 if (up->up_dsleep) {
451 up->up_dsleep = 0;
452 cv_broadcast(&up->up_drain);
456 USB_MTX_UNLOCK(up->up_mtx);
465 * having "up->up_mtx" locked.
468 usb_proc_rewakeup(struct usb_process *up)
471 if (up->up_mtx == NULL)
474 if (up->up_gone)
477 USB_MTX_ASSERT(up->up_mtx, MA_OWNED);
479 if (up->up_msleep == 0) {
481 cv_signal(&up->up_cv);
492 usb_proc_is_called_from(struct usb_process *up)
494 return (up->up_curtd == curthread);