diff options
author | Masao Uebayashi <uebayasi@cvs.openbsd.org> | 2015-02-10 13:49:49 +0000 |
---|---|---|
committer | Masao Uebayashi <uebayasi@cvs.openbsd.org> | 2015-02-10 13:49:49 +0000 |
commit | 56c289a5f89455e422c6555cf2d51bb827aa450c (patch) | |
tree | 8d1583740614b13f0458ea4d4f828dcbc0caed28 /sys/dev/usb | |
parent | 97fbea5ee3718ca0e58e9fb85d637f9a43d3f90e (diff) |
s/mutex/mtx/
s/pool_cache/pool/
s/callout/timeout/
s/kmem/malloc/
s/workqueue/taskq/
s/softint/softintr/
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/dwc2/dwc2.c | 174 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2.h | 28 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2_core.h | 6 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2_coreintr.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2_hcd.c | 48 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2_hcd.h | 8 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2_hcdddma.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2_hcdintr.c | 4 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2_hcdqueue.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2var.h | 14 |
10 files changed, 153 insertions, 153 deletions
diff --git a/sys/dev/usb/dwc2/dwc2.c b/sys/dev/usb/dwc2/dwc2.c index c6f0c2d02f6..e47993b9f00 100644 --- a/sys/dev/usb/dwc2/dwc2.c +++ b/sys/dev/usb/dwc2/dwc2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2.c,v 1.7 2015/02/10 13:36:13 uebayasi Exp $ */ +/* $OpenBSD: dwc2.c,v 1.8 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2.c,v 1.32 2014/09/02 23:26:20 macallan Exp $ */ /*- @@ -100,7 +100,7 @@ static void dwc2_freem(struct usbd_bus *, struct usb_dma *); static struct usbd_xfer * dwc2_allocx(struct usbd_bus *); static void dwc2_freex(struct usbd_bus *, struct usbd_xfer *); -static void dwc2_get_lock(struct usbd_bus *, kmutex_t **); +static void dwc2_get_lock(struct usbd_bus *, struct mutex **); static usbd_status dwc2_root_ctrl_transfer(struct usbd_xfer *); static usbd_status dwc2_root_ctrl_start(struct usbd_xfer *); @@ -270,7 +270,7 @@ dwc2_allocx(struct usbd_bus *bus) DPRINTFN(10, "\n"); DWC2_EVCNT_INCR(sc->sc_ev_xferpoolget); - dxfer = pool_cache_get(sc->sc_xferpool, PR_NOWAIT); + dxfer = pool_get(sc->sc_xferpool, PR_NOWAIT); if (dxfer != NULL) { memset(dxfer, 0, sizeof(*dxfer)); @@ -300,11 +300,11 @@ dwc2_freex(struct usbd_bus *bus, struct usbd_xfer *xfer) #endif DWC2_EVCNT_INCR(sc->sc_ev_xferpoolput); dwc2_hcd_urb_free(sc->sc_hsotg, dxfer->urb, DWC2_MAXISOCPACKETS); - pool_cache_put(sc->sc_xferpool, xfer); + pool_put(sc->sc_xferpool, xfer); } static void -dwc2_get_lock(struct usbd_bus *bus, kmutex_t **lock) +dwc2_get_lock(struct usbd_bus *bus, struct mutex **lock) { struct dwc2_softc *sc = DWC2_BUS2SC(bus); @@ -319,12 +319,12 @@ dwc2_rhc(void *addr) u_char *p; DPRINTF("\n"); - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); xfer = sc->sc_intrxfer; if (xfer == NULL) { /* Just ignore the change. */ - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); return; } @@ -337,7 +337,7 @@ dwc2_rhc(void *addr) xfer->status = USBD_NORMAL_COMPLETION; usb_transfer_complete(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); } static void @@ -348,12 +348,12 @@ dwc2_softintr(void *v) struct dwc2_hsotg *hsotg = sc->sc_hsotg; struct dwc2_xfer *dxfer; - KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock)); + KASSERT(sc->sc_bus.use_polling || mtx_owned(&sc->sc_lock)); - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); while ((dxfer = TAILQ_FIRST(&sc->sc_complete)) != NULL) { - KASSERTMSG(!callout_pending(&dxfer->xfer.timeout_handle), + KASSERTMSG(!timeout_pending(&dxfer->xfer.timeout_handle), "xfer %p pipe %p\n", dxfer, dxfer->xfer.pipe); /* @@ -368,11 +368,11 @@ dwc2_softintr(void *v) TAILQ_REMOVE(&sc->sc_complete, dxfer, xnext); - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); usb_transfer_complete(&dxfer->xfer); - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); } - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); } static void @@ -392,9 +392,9 @@ dwc2_waitintr(struct dwc2_softc *sc, struct usbd_xfer *xfer) DPRINTFN(15, "0x%08x\n", intrs); if (intrs) { - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); dwc2_interrupt(sc); - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); if (xfer->status != USBD_IN_PROGRESS) return; } @@ -403,10 +403,10 @@ dwc2_waitintr(struct dwc2_softc *sc, struct usbd_xfer *xfer) /* Timeout */ DPRINTF("timeout\n"); - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); xfer->status = USBD_TIMEOUT; usb_transfer_complete(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); } static void @@ -420,9 +420,9 @@ dwc2_timeout(void *addr) DPRINTF("dxfer=%p\n", dxfer); if (sc->sc_dying) { - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); dwc2_abort_xfer(&dxfer->xfer, USBD_TIMEOUT); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); return; } @@ -441,9 +441,9 @@ dwc2_timeout_task(void *addr) DPRINTF("xfer=%p\n", xfer); - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); dwc2_abort_xfer(xfer, USBD_TIMEOUT); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); } usbd_status @@ -514,9 +514,9 @@ dwc2_poll(struct usbd_bus *bus) struct dwc2_softc *sc = DWC2_BUS2SC(bus); struct dwc2_hsotg *hsotg = sc->sc_hsotg; - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); dwc2_interrupt(sc); - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); } /* @@ -530,7 +530,7 @@ dwc2_close_pipe(struct usbd_pipe * pipe) struct dwc2_softc *sc = pipe->device->bus->hci_private; #endif - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(mtx_owned(&sc->sc_lock)); } /* @@ -548,12 +548,12 @@ dwc2_abort_xfer(struct usbd_xfer *xfer, usbd_status status) DPRINTF("xfer=%p\n", xfer); - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(mtx_owned(&sc->sc_lock)); KASSERT(!cpu_intr_p() && !cpu_softintr_p()); if (sc->sc_dying) { xfer->status = status; - callout_stop(&xfer->timeout_handle); + timeout_stop(&xfer->timeout_handle); usb_transfer_complete(xfer); return; } @@ -573,11 +573,11 @@ dwc2_abort_xfer(struct usbd_xfer *xfer, usbd_status status) /* * Step 1: Make the stack ignore it and stop the callout. */ - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); xfer->hcflags |= UXFER_ABORTING; xfer->status = status; /* make software ignore it */ - callout_stop(&xfer->timeout_handle); + timeout_stop(&xfer->timeout_handle); /* XXXNH suboptimal */ TAILQ_FOREACH_SAFE(d, &sc->sc_complete, xnext, tmp) { @@ -591,7 +591,7 @@ dwc2_abort_xfer(struct usbd_xfer *xfer, usbd_status status) DPRINTF("dwc2_hcd_urb_dequeue failed\n"); } - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); /* * Step 2: Execute callback. @@ -696,9 +696,9 @@ dwc2_root_ctrl_transfer(struct usbd_xfer *xfer) struct dwc2_softc *sc = DWC2_XFER2SC(xfer); usbd_status err; - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); err = usb_insert_transfer(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); if (err) return err; @@ -844,10 +844,10 @@ dwc2_root_ctrl_start(struct usbd_xfer *xfer) err = USBD_NORMAL_COMPLETION; fail: - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); xfer->status = err; usb_transfer_complete(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); return USBD_IN_PROGRESS; } @@ -885,9 +885,9 @@ dwc2_root_intr_transfer(struct usbd_xfer *xfer) DPRINTF("\n"); /* Insert last in queue. */ - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); err = usb_insert_transfer(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); if (err) return err; @@ -905,10 +905,10 @@ dwc2_root_intr_start(struct usbd_xfer *xfer) if (sc->sc_dying) return USBD_IOERROR; - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); KASSERT(sc->sc_intrxfer == NULL); sc->sc_intrxfer = xfer; - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); return USBD_IN_PROGRESS; } @@ -921,7 +921,7 @@ dwc2_root_intr_abort(struct usbd_xfer *xfer) DPRINTF("xfer=%p\n", xfer); - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(mtx_owned(&sc->sc_lock)); KASSERT(xfer->pipe->intrxfer == xfer); sc->sc_intrxfer = NULL; @@ -937,7 +937,7 @@ dwc2_root_intr_close(struct usbd_pipe * pipe) DPRINTF("\n"); - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(mtx_owned(&sc->sc_lock)); sc->sc_intrxfer = NULL; } @@ -960,9 +960,9 @@ dwc2_device_ctrl_transfer(struct usbd_xfer *xfer) DPRINTF("\n"); /* Insert last in queue. */ - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); err = usb_insert_transfer(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); if (err) return err; @@ -978,10 +978,10 @@ dwc2_device_ctrl_start(struct usbd_xfer *xfer) DPRINTF("\n"); - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); xfer->status = USBD_IN_PROGRESS; err = dwc2_device_start(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); if (err) return err; @@ -998,7 +998,7 @@ dwc2_device_ctrl_abort(struct usbd_xfer *xfer) #ifdef DIAGNOSTIC struct dwc2_softc *sc = DWC2_XFER2SC(xfer); #endif - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(mtx_owned(&sc->sc_lock)); DPRINTF("xfer=%p\n", xfer); dwc2_abort_xfer(xfer, USBD_CANCELLED); @@ -1030,9 +1030,9 @@ dwc2_device_bulk_transfer(struct usbd_xfer *xfer) DPRINTF("xfer=%p\n", xfer); /* Insert last in queue. */ - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); err = usb_insert_transfer(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); if (err) return err; @@ -1047,10 +1047,10 @@ dwc2_device_bulk_start(struct usbd_xfer *xfer) usbd_status err; DPRINTF("xfer=%p\n", xfer); - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); xfer->status = USBD_IN_PROGRESS; err = dwc2_device_start(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); return err; } @@ -1061,7 +1061,7 @@ dwc2_device_bulk_abort(struct usbd_xfer *xfer) #ifdef DIAGNOSTIC struct dwc2_softc *sc = DWC2_XFER2SC(xfer); #endif - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(mtx_owned(&sc->sc_lock)); DPRINTF("xfer=%p\n", xfer); dwc2_abort_xfer(xfer, USBD_CANCELLED); @@ -1094,9 +1094,9 @@ dwc2_device_intr_transfer(struct usbd_xfer *xfer) DPRINTF("xfer=%p\n", xfer); /* Insert last in queue. */ - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); err = usb_insert_transfer(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); if (err) return err; @@ -1112,10 +1112,10 @@ dwc2_device_intr_start(struct usbd_xfer *xfer) struct dwc2_softc *sc = dev->bus->hci_private; usbd_status err; - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); xfer->status = USBD_IN_PROGRESS; err = dwc2_device_start(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); if (err) return err; @@ -1134,7 +1134,7 @@ dwc2_device_intr_abort(struct usbd_xfer *xfer) struct dwc2_softc *sc = DWC2_XFER2SC(xfer); #endif - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(mtx_owned(&sc->sc_lock)); KASSERT(xfer->pipe->intrxfer == xfer); DPRINTF("xfer=%p\n", xfer); @@ -1174,9 +1174,9 @@ dwc2_device_isoc_transfer(struct usbd_xfer *xfer) DPRINTF("xfer=%p\n", xfer); /* Insert last in queue. */ - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); err = usb_insert_transfer(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); if (err) return err; @@ -1192,10 +1192,10 @@ dwc2_device_isoc_start(struct usbd_xfer *xfer) struct dwc2_softc *sc = dev->bus->hci_private; usbd_status err; - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); xfer->status = USBD_IN_PROGRESS; err = dwc2_device_start(xfer); - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); if (sc->sc_bus.use_polling) dwc2_waitintr(sc, xfer); @@ -1209,7 +1209,7 @@ dwc2_device_isoc_abort(struct usbd_xfer *xfer) #ifdef DIAGNOSTIC struct dwc2_softc *sc = DWC2_XFER2SC(xfer); #endif - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(mtx_owned(&sc->sc_lock)); DPRINTF("xfer=%p\n", xfer); dwc2_abort_xfer(xfer, USBD_CANCELLED); @@ -1259,10 +1259,10 @@ dwc2_device_start(struct usbd_xfer *xfer) if (xfertype == UE_ISOCHRONOUS || xfertype == UE_INTERRUPT) { - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); if (!dwc2_hcd_is_bandwidth_allocated(hsotg, xfer)) alloc_bandwidth = 1; - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); } /* @@ -1370,7 +1370,7 @@ dwc2_device_start(struct usbd_xfer *xfer) } /* XXXNH bring down from callers?? */ -// mutex_enter(&sc->sc_lock); +// mtx_enter(&sc->sc_lock); xfer->actlen = 0; @@ -1389,10 +1389,10 @@ dwc2_device_start(struct usbd_xfer *xfer) } /* might need to check cpu_intr_p */ - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); if (xfer->timeout && !sc->sc_bus.use_polling) { - callout_reset(&xfer->timeout_handle, mstohz(xfer->timeout), + timeout_reset(&xfer->timeout_handle, mstohz(xfer->timeout), dwc2_timeout, xfer); } @@ -1408,9 +1408,9 @@ dwc2_device_start(struct usbd_xfer *xfer) } fail: - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); -// mutex_exit(&sc->sc_lock); +// mtx_leave(&sc->sc_lock); switch (retval) { case 0: @@ -1430,7 +1430,7 @@ fail: } void -dwc2_worker(struct work *wk, void *priv) +dwc2_worker(struct task *wk, void *priv) { struct dwc2_softc *sc = priv; struct dwc2_hsotg *hsotg = sc->sc_hsotg; @@ -1444,7 +1444,7 @@ Debugger(); dwc_free(NULL, dpipe->urb); #endif - mutex_enter(&sc->sc_lock); + mtx_enter(&sc->sc_lock); if (wk == &hsotg->wf_otg) { dwc2_conn_id_status_change(wk); } else if (wk == &hsotg->start_work.work) { @@ -1463,7 +1463,7 @@ Debugger(); cv_broadcast(&xfer->hccv); #endif } - mutex_exit(&sc->sc_lock); + mtx_leave(&sc->sc_lock); } int dwc2_intr(void *p) @@ -1476,7 +1476,7 @@ int dwc2_intr(void *p) return 0; hsotg = sc->sc_hsotg; - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); if (sc->sc_dying || !device_has_power(sc->sc_dev)) goto done; @@ -1491,7 +1491,7 @@ int dwc2_intr(void *p) } done: - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); return ret; } @@ -1583,24 +1583,24 @@ dwc2_init(struct dwc2_softc *sc) sc->sc_bus.pipe_size = sizeof(struct dwc2_pipe); sc->sc_hcdenabled = false; - mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB); + mtx_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB); TAILQ_INIT(&sc->sc_complete); - sc->sc_rhc_si = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE, + sc->sc_rhc_si = softintr_establish(SOFTINT_NET | SOFTINT_MPSAFE, dwc2_rhc, sc); usb_setup_reserve(sc->sc_dev, &sc->sc_dma_reserve, sc->sc_bus.dmatag, USB_MEM_RESERVE); - sc->sc_xferpool = pool_cache_init(sizeof(struct dwc2_xfer), 0, 0, 0, + sc->sc_xferpool = pool_init(sizeof(struct dwc2_xfer), 0, 0, 0, "dwc2xfer", NULL, IPL_USB, NULL, NULL, NULL); - sc->sc_qhpool = pool_cache_init(sizeof(struct dwc2_qh), 0, 0, 0, + sc->sc_qhpool = pool_init(sizeof(struct dwc2_qh), 0, 0, 0, "dwc2qh", NULL, IPL_USB, NULL, NULL, NULL); - sc->sc_qtdpool = pool_cache_init(sizeof(struct dwc2_qtd), 0, 0, 0, + sc->sc_qtdpool = pool_init(sizeof(struct dwc2_qtd), 0, 0, 0, "dwc2qtd", NULL, IPL_USB, NULL, NULL, NULL); - sc->sc_hsotg = kmem_zalloc(sizeof(struct dwc2_hsotg), KM_SLEEP); + sc->sc_hsotg = malloc(sizeof(struct dwc2_hsotg), KM_SLEEP); if (sc->sc_hsotg == NULL) { err = ENOMEM; goto fail1; @@ -1619,9 +1619,9 @@ dwc2_init(struct dwc2_softc *sc) return 0; fail2: - kmem_free(sc->sc_hsotg, sizeof(struct dwc2_hsotg)); + free(sc->sc_hsotg, sizeof(struct dwc2_hsotg)); fail1: - softint_disestablish(sc->sc_rhc_si); + softintr_disestablish(sc->sc_rhc_si); return err; } @@ -1652,7 +1652,7 @@ dw_callout(void *arg) { struct delayed_work *dw = arg; - workqueue_enqueue(dw->dw_wq, &dw->work, NULL); + taskq_enqueue(dw->dw_wq, &dw->work, NULL); } void dwc2_host_hub_info(struct dwc2_hsotg *hsotg, void *context, int *hub_addr, @@ -1774,15 +1774,15 @@ void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, } qtd->urb = NULL; - callout_stop(&xfer->timeout_handle); + timeout_stop(&xfer->timeout_handle); - KASSERT(mutex_owned(&hsotg->lock)); + KASSERT(mtx_owned(&hsotg->lock)); TAILQ_INSERT_TAIL(&sc->sc_complete, dxfer, xnext); - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); usb_schedsoftintr(&sc->sc_bus); - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); } @@ -1791,7 +1791,7 @@ _dwc2_hcd_start(struct dwc2_hsotg *hsotg) { dev_dbg(hsotg->dev, "DWC OTG HCD START\n"); - mutex_spin_enter(&hsotg->lock); + mtx_enter(&hsotg->lock); hsotg->op_state = OTG_STATE_A_HOST; @@ -1800,7 +1800,7 @@ _dwc2_hcd_start(struct dwc2_hsotg *hsotg) /*XXXNH*/ delay(50); - mutex_spin_exit(&hsotg->lock); + mtx_leave(&hsotg->lock); return 0; } diff --git a/sys/dev/usb/dwc2/dwc2.h b/sys/dev/usb/dwc2/dwc2.h index 32e58b523e0..405045f6300 100644 --- a/sys/dev/usb/dwc2/dwc2.h +++ b/sys/dev/usb/dwc2/dwc2.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2.h,v 1.3 2015/02/10 13:19:07 uebayasi Exp $ */ +/* $OpenBSD: dwc2.h,v 1.4 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2.h,v 1.4 2014/12/23 16:20:06 macallan Exp $ */ /*- @@ -121,16 +121,16 @@ enum usb_otg_state { #define usleep_range(l, u) do { DELAY(u); } while (0) -#define spinlock_t kmutex_t -#define spin_lock_init(lock) mutex_init(lock, MUTEX_DEFAULT, IPL_SCHED) -#define spin_lock(l) do { mutex_spin_enter(l); } while (0) -#define spin_unlock(l) do { mutex_spin_exit(l); } while (0) +#define spinlock_t struct mutex +#define spin_lock_init(lock) mtx_init(lock, MUTEX_DEFAULT, IPL_SCHED) +#define spin_lock(l) do { mtx_enter(l); } while (0) +#define spin_unlock(l) do { mtx_leave(l); } while (0) #define spin_lock_irqsave(l, f) \ - do { mutex_spin_enter(l); (void)(f); } while (0) + do { mtx_enter(l); (void)(f); } while (0) #define spin_unlock_irqrestore(l, f) \ - do { mutex_spin_exit(l); (void)(f); } while (0) + do { mtx_leave(l); (void)(f); } while (0) #define IRQ_RETVAL(r) (r) @@ -206,25 +206,25 @@ udelay(unsigned long usecs) #define NS_TO_US(ns) ((ns + 500L) / 1000L) void dw_callout(void *); -void dwc2_worker(struct work *, void *); +void dwc2_worker(struct task *, void *); struct delayed_work { - struct work work; + struct task work; struct callout dw_timer; - struct workqueue *dw_wq; + struct taskq *dw_wq; }; static inline void -INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct work *)) +INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct task *)) { - callout_init(&dw->dw_timer, CALLOUT_MPSAFE); + timeout_init(&dw->dw_timer, CALLOUT_MPSAFE); } static inline void -queue_delayed_work(struct workqueue *wq, struct delayed_work *dw, int j) +queue_delayed_work(struct taskq *wq, struct delayed_work *dw, int j) { - callout_reset(&dw->dw_timer, j, dw_callout, dw); + timeout_reset(&dw->dw_timer, j, dw_callout, dw); } #endif diff --git a/sys/dev/usb/dwc2/dwc2_core.h b/sys/dev/usb/dwc2/dwc2_core.h index 0316b17b0ec..fabfd376ca2 100644 --- a/sys/dev/usb/dwc2/dwc2_core.h +++ b/sys/dev/usb/dwc2/dwc2_core.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2_core.h,v 1.4 2015/02/10 13:30:27 uebayasi Exp $ */ +/* $OpenBSD: dwc2_core.h,v 1.5 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2_core.h,v 1.5 2014/04/03 06:34:58 skrll Exp $ */ /* @@ -416,8 +416,8 @@ struct dwc2_hsotg { unsigned int queuing_high_bandwidth:1; unsigned int srp_success:1; - struct workqueue *wq_otg; - struct work wf_otg; + struct taskq *wq_otg; + struct task wf_otg; struct callout wkp_timer; enum dwc2_lx_state lx_state; diff --git a/sys/dev/usb/dwc2/dwc2_coreintr.c b/sys/dev/usb/dwc2/dwc2_coreintr.c index 4ce9aad234a..c0a592b3ba8 100644 --- a/sys/dev/usb/dwc2/dwc2_coreintr.c +++ b/sys/dev/usb/dwc2/dwc2_coreintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2_coreintr.c,v 1.3 2015/02/10 13:19:07 uebayasi Exp $ */ +/* $OpenBSD: dwc2_coreintr.c,v 1.4 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2_coreintr.c,v 1.8 2014/04/04 05:40:57 skrll Exp $ */ /* @@ -305,7 +305,7 @@ static void dwc2_handle_conn_id_status_change_intr(struct dwc2_hsotg *hsotg) * scheduling. */ spin_unlock(&hsotg->lock); - workqueue_enqueue(hsotg->wq_otg, &hsotg->wf_otg, NULL); + taskq_enqueue(hsotg->wq_otg, &hsotg->wf_otg, NULL); spin_lock(&hsotg->lock); /* Clear interrupt */ @@ -361,7 +361,7 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg) /* Restart the Phy Clock */ pcgcctl &= ~PCGCTL_STOPPCLK; DWC2_WRITE_4(hsotg, PCGCTL, pcgcctl); - callout_reset(&hsotg->wkp_timer, mstohz(71), + timeout_reset(&hsotg->wkp_timer, mstohz(71), dwc2_wakeup_detected, hsotg); } else { /* Change to L0 state */ @@ -489,7 +489,7 @@ irqreturn_t dwc2_handle_common_intr(void *dev) goto out; } - KASSERT(mutex_owned(&hsotg->lock)); + KASSERT(mtx_owned(&hsotg->lock)); gintsts = dwc2_read_common_intr(hsotg); if (gintsts & ~GINTSTS_PRTINT) diff --git a/sys/dev/usb/dwc2/dwc2_hcd.c b/sys/dev/usb/dwc2/dwc2_hcd.c index 67b49cc7108..73c115e441d 100644 --- a/sys/dev/usb/dwc2/dwc2_hcd.c +++ b/sys/dev/usb/dwc2/dwc2_hcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2_hcd.c,v 1.4 2015/02/10 13:30:27 uebayasi Exp $ */ +/* $OpenBSD: dwc2_hcd.c,v 1.5 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2_hcd.c,v 1.15 2014/11/24 10:14:14 skrll Exp $ */ /* @@ -398,7 +398,7 @@ dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, struct dwc2_hcd_urb *urb, } } - qtd = pool_cache_get(sc->sc_qtdpool, PR_NOWAIT); + qtd = pool_get(sc->sc_qtdpool, PR_NOWAIT); if (!qtd) return -ENOMEM; @@ -411,7 +411,7 @@ dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, struct dwc2_hcd_urb *urb, dev_err(hsotg->dev, "DWC OTG HCD URB Enqueue failed adding QTD. Error status %d\n", retval); - pool_cache_put(sc->sc_qtdpool, qtd); + pool_put(sc->sc_qtdpool, qtd); return retval; } @@ -1312,7 +1312,7 @@ void dwc2_hcd_queue_transactions(struct dwc2_hsotg *hsotg, } void -dwc2_conn_id_status_change(struct work *work) +dwc2_conn_id_status_change(struct task *work) { struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, wf_otg); @@ -1779,7 +1779,7 @@ dwc2_hcd_urb_alloc(struct dwc2_hsotg *hsotg, int iso_desc_count, u32 size = sizeof(*urb) + iso_desc_count * sizeof(struct dwc2_hcd_iso_packet_desc); - urb = kmem_zalloc(size, mem_flags); + urb = malloc(size, mem_flags); if (urb) urb->packet_count = iso_desc_count; return urb; @@ -1793,7 +1793,7 @@ dwc2_hcd_urb_free(struct dwc2_hsotg *hsotg, struct dwc2_hcd_urb *urb, u32 size = sizeof(*urb) + iso_desc_count * sizeof(struct dwc2_hcd_iso_packet_desc); - kmem_free(urb, size); + free(urb, size); } void @@ -2034,7 +2034,7 @@ void dwc2_host_disconnect(struct dwc2_hsotg *hsotg) * Work queue function for starting the HCD when A-Cable is connected */ void -dwc2_hcd_start_func(struct work *work) +dwc2_hcd_start_func(struct task *work) { struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, start_work.work); @@ -2047,7 +2047,7 @@ dwc2_hcd_start_func(struct work *work) * Reset work queue function */ void -dwc2_hcd_reset_func(struct work *work) +dwc2_hcd_reset_func(struct task *work) { struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, reset_work.work); @@ -2103,7 +2103,7 @@ static void dwc2_hcd_free(struct dwc2_hsotg *hsotg) dev_dbg(hsotg->dev, "HCD Free channel #%i, chan=%p\n", i, chan); hsotg->hc_ptr_array[i] = NULL; - kmem_free(chan, sizeof(*chan)); + free(chan, sizeof(*chan)); } } @@ -2114,7 +2114,7 @@ static void dwc2_hcd_free(struct dwc2_hsotg *hsotg) hsotg->status_buf = NULL; } } else { - kmem_free(hsotg->status_buf,DWC2_HCD_STATUS_BUF_SIZE); + free(hsotg->status_buf,DWC2_HCD_STATUS_BUF_SIZE); hsotg->status_buf = NULL; } @@ -2132,12 +2132,12 @@ static void dwc2_hcd_free(struct dwc2_hsotg *hsotg) } if (hsotg->wq_otg) { - workqueue_destroy(hsotg->wq_otg); + taskq_destroy(hsotg->wq_otg); } - kmem_free(hsotg->core_params, sizeof(*hsotg->core_params)); + free(hsotg->core_params, sizeof(*hsotg->core_params)); hsotg->core_params = NULL; - callout_destroy(&hsotg->wkp_timer); + timeout_destroy(&hsotg->wkp_timer); } static void dwc2_hcd_release(struct dwc2_hsotg *hsotg) @@ -2189,11 +2189,11 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, dev_dbg(hsotg->dev, "hcfg=%08x\n", DWC2_READ_4(hsotg, HCFG)); #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS - hsotg->frame_num_array = kmem_zalloc(sizeof(*hsotg->frame_num_array) * + hsotg->frame_num_array = malloc(sizeof(*hsotg->frame_num_array) * FRAME_NUM_ARRAY_SIZE, KM_SLEEP); if (!hsotg->frame_num_array) goto error1; - hsotg->last_frame_num_array = kmem_zalloc( + hsotg->last_frame_num_array = malloc( sizeof(*hsotg->last_frame_num_array) * FRAME_NUM_ARRAY_SIZE, KM_SLEEP); if (!hsotg->last_frame_num_array) @@ -2201,7 +2201,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, hsotg->last_frame_num = HFNUM_MAX_FRNUM; #endif - hsotg->core_params = kmem_zalloc(sizeof(*hsotg->core_params), KM_SLEEP); + hsotg->core_params = malloc(sizeof(*hsotg->core_params), KM_SLEEP); if (!hsotg->core_params) goto error1; @@ -2225,7 +2225,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, /* Create new workqueue and init work */ retval = -ENOMEM; - err = workqueue_create(&hsotg->wq_otg, "dwc2", dwc2_worker, hsotg, + err = taskq_create(&hsotg->wq_otg, "dwc2", dwc2_worker, hsotg, PRI_BIO, IPL_USB, WQ_MPSAFE); retval = -err; @@ -2234,8 +2234,8 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, goto error2; } - callout_init(&hsotg->wkp_timer, CALLOUT_MPSAFE); - callout_setfunc(&hsotg->wkp_timer, dwc2_wakeup_detected, hsotg); + timeout_init(&hsotg->wkp_timer, CALLOUT_MPSAFE); + timeout_setfunc(&hsotg->wkp_timer, dwc2_wakeup_detected, hsotg); /* Initialize the non-periodic schedule */ INIT_LIST_HEAD(&hsotg->non_periodic_sched_inactive); @@ -2256,7 +2256,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, memset(&hsotg->hc_ptr_array[0], 0, sizeof(hsotg->hc_ptr_array)); for (i = 0; i < num_channels; i++) { - channel = kmem_zalloc(sizeof(*channel), KM_SLEEP); + channel = malloc(sizeof(*channel), KM_SLEEP); if (channel == NULL) goto error3; channel->hc_num = i; @@ -2288,7 +2288,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, hsotg->status_buf_dma = DMAADDR(&hsotg->status_buf_usbdma, 0); } } else - hsotg->status_buf = kmem_zalloc(DWC2_HCD_STATUS_BUF_SIZE, + hsotg->status_buf = malloc(DWC2_HCD_STATUS_BUF_SIZE, KM_SLEEP); if (!hsotg->status_buf) @@ -2314,12 +2314,12 @@ error3: dwc2_hcd_release(hsotg); error2: error1: - kmem_free(hsotg->core_params, sizeof(*hsotg->core_params)); + free(hsotg->core_params, sizeof(*hsotg->core_params)); #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS - kmem_free(hsotg->last_frame_num_array, + free(hsotg->last_frame_num_array, sizeof(*hsotg->last_frame_num_array) * FRAME_NUM_ARRAY_SIZE); - kmem_free(hsotg->frame_num_array, + free(hsotg->frame_num_array, sizeof(*hsotg->frame_num_array) * FRAME_NUM_ARRAY_SIZE); #endif diff --git a/sys/dev/usb/dwc2/dwc2_hcd.h b/sys/dev/usb/dwc2/dwc2_hcd.h index 511460ef5dd..c41fe0e75da 100644 --- a/sys/dev/usb/dwc2/dwc2_hcd.h +++ b/sys/dev/usb/dwc2/dwc2_hcd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2_hcd.h,v 1.5 2015/02/10 13:36:13 uebayasi Exp $ */ +/* $OpenBSD: dwc2_hcd.h,v 1.6 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2_hcd.h,v 1.9 2014/09/03 10:00:08 skrll Exp $ */ /* @@ -780,9 +780,9 @@ int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *, struct dwc2_hcd_urb *, void **, void dwc2_hcd_urb_set_pipeinfo(struct dwc2_hsotg *, struct dwc2_hcd_urb *, u8 ,u8, u8, u8, u16); -void dwc2_conn_id_status_change(struct work *); -void dwc2_hcd_start_func(struct work *); -void dwc2_hcd_reset_func(struct work *); +void dwc2_conn_id_status_change(struct task *); +void dwc2_hcd_start_func(struct task *); +void dwc2_hcd_reset_func(struct task *); struct dwc2_hcd_urb * dwc2_hcd_urb_alloc(struct dwc2_hsotg *, int, gfp_t); void dwc2_hcd_urb_free(struct dwc2_hsotg *, struct dwc2_hcd_urb *, int); diff --git a/sys/dev/usb/dwc2/dwc2_hcdddma.c b/sys/dev/usb/dwc2/dwc2_hcdddma.c index b34bc94374e..ccf8387f3e0 100644 --- a/sys/dev/usb/dwc2/dwc2_hcdddma.c +++ b/sys/dev/usb/dwc2/dwc2_hcdddma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2_hcdddma.c,v 1.4 2015/02/10 13:30:27 uebayasi Exp $ */ +/* $OpenBSD: dwc2_hcdddma.c,v 1.5 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2_hcdddma.c,v 1.6 2014/04/03 06:34:58 skrll Exp $ */ /* @@ -124,7 +124,7 @@ static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, memset(qh->desc_list, 0, sizeof(struct dwc2_hcd_dma_desc) * dwc2_max_desc_num(qh)); - qh->n_bytes = kmem_zalloc(sizeof(u32) * dwc2_max_desc_num(qh), KM_SLEEP); + qh->n_bytes = malloc(sizeof(u32) * dwc2_max_desc_num(qh), KM_SLEEP); if (!qh->n_bytes) { usb_freemem(&hsotg->hsotg_sc->sc_bus, &qh->desc_list_usbdma); qh->desc_list = NULL; @@ -141,7 +141,7 @@ static void dwc2_desc_list_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) qh->desc_list = NULL; } - kmem_free(qh->n_bytes, sizeof(u32) * dwc2_max_desc_num(qh)); + free(qh->n_bytes, sizeof(u32) * dwc2_max_desc_num(qh)); qh->n_bytes = NULL; } @@ -152,7 +152,7 @@ static int dwc2_frame_list_alloc(struct dwc2_hsotg *hsotg, gfp_t mem_flags) if (hsotg->frame_list) return 0; - /* XXXNH - pool_cache_t */ + /* XXXNH - struct pool */ hsotg->frame_list = NULL; err = usb_allocmem(&hsotg->hsotg_sc->sc_bus, 4 * FRLISTEN_64_SIZE, 0, &hsotg->frame_list_usbdma); diff --git a/sys/dev/usb/dwc2/dwc2_hcdintr.c b/sys/dev/usb/dwc2/dwc2_hcdintr.c index ceabee62eb8..48143262c41 100644 --- a/sys/dev/usb/dwc2/dwc2_hcdintr.c +++ b/sys/dev/usb/dwc2/dwc2_hcdintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2_hcdintr.c,v 1.3 2015/02/10 13:19:07 uebayasi Exp $ */ +/* $OpenBSD: dwc2_hcdintr.c,v 1.4 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2_hcdintr.c,v 1.11 2014/11/24 10:14:14 skrll Exp $ */ /* @@ -2092,7 +2092,7 @@ irqreturn_t dwc2_handle_hcd_intr(struct dwc2_hsotg *hsotg) return retval; } - KASSERT(mutex_owned(&hsotg->lock)); + KASSERT(mtx_owned(&hsotg->lock)); /* Check if HOST Mode */ if (dwc2_is_host_mode(hsotg)) { diff --git a/sys/dev/usb/dwc2/dwc2_hcdqueue.c b/sys/dev/usb/dwc2/dwc2_hcdqueue.c index 9fbca04b84a..e830f985107 100644 --- a/sys/dev/usb/dwc2/dwc2_hcdqueue.c +++ b/sys/dev/usb/dwc2/dwc2_hcdqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2_hcdqueue.c,v 1.3 2015/02/10 13:19:07 uebayasi Exp $ */ +/* $OpenBSD: dwc2_hcdqueue.c,v 1.4 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2_hcdqueue.c,v 1.11 2014/09/03 10:00:08 skrll Exp $ */ /* @@ -221,7 +221,7 @@ static struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, return NULL; /* Allocate memory */ - qh = pool_cache_get(sc->sc_qhpool, PR_NOWAIT); + qh = pool_get(sc->sc_qhpool, PR_NOWAIT); if (!qh) return NULL; @@ -259,7 +259,7 @@ void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) usb_freemem(&hsotg->hsotg_sc->sc_bus, &qh->dw_align_buf_usbdma); } - pool_cache_put(sc->sc_qhpool, qh); + pool_put(sc->sc_qhpool, qh); } /** @@ -851,7 +851,7 @@ void dwc2_hcd_qtd_unlink_and_free(struct dwc2_hsotg *hsotg, struct dwc2_softc *sc = hsotg->hsotg_sc; list_del_init(&qtd->qtd_list_entry); - pool_cache_put(sc->sc_qtdpool, qtd); + pool_put(sc->sc_qtdpool, qtd); } #define BITSTUFFTIME(bytecount) ((8 * 7 * (bytecount)) / 6) diff --git a/sys/dev/usb/dwc2/dwc2var.h b/sys/dev/usb/dwc2/dwc2var.h index db10d30a02b..665d23c34f4 100644 --- a/sys/dev/usb/dwc2/dwc2var.h +++ b/sys/dev/usb/dwc2/dwc2var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2var.h,v 1.4 2015/02/10 13:30:27 uebayasi Exp $ */ +/* $OpenBSD: dwc2var.h,v 1.5 2015/02/10 13:49:48 uebayasi Exp $ */ /* $NetBSD: dwc2var.h,v 1.3 2013/10/22 12:57:40 skrll Exp $ */ /*- @@ -86,7 +86,7 @@ typedef struct dwc2_softc { struct usbd_bus sc_bus; struct dwc2_hsotg *sc_hsotg; - kmutex_t sc_lock; + struct mutex sc_lock; bool sc_hcdenabled; void *sc_rhc_si; @@ -105,9 +105,9 @@ typedef struct dwc2_softc { uint8_t sc_addr; /* device address */ uint8_t sc_conf; /* device configuration */ - pool_cache_t sc_xferpool; - pool_cache_t sc_qhpool; - pool_cache_t sc_qtdpool; + struct pool sc_xferpool; + struct pool sc_qhpool; + struct pool sc_qtdpool; } dwc2_softc_t; @@ -120,7 +120,7 @@ int dwc2_activate(device_t, enum devact); bool dwc2_resume(device_t, const pmf_qual_t *); bool dwc2_suspend(device_t, const pmf_qual_t *); -void dwc2_worker(struct work *, void *); +void dwc2_worker(struct task *, void *); void dwc2_host_complete(struct dwc2_hsotg *, struct dwc2_qtd *, int); @@ -129,7 +129,7 @@ static inline void dwc2_root_intr(dwc2_softc_t *sc) { - softint_schedule(sc->sc_rhc_si); + softintr_schedule(sc->sc_rhc_si); } #endif /* _DWC_OTGVAR_H_ */ |