CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Sep 5 07:07:15 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp Log Message: Update To generate a diff of this commit: cvs rdiff -u -r1.8.4.13 -r1.8.4.14 src/sys/dev/usb/TODO.usbmp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.13 src/sys/dev/usb/TODO.usbmp:1.8.4.14 --- src/sys/dev/usb/TODO.usbmp:1.8.4.13 Tue Feb 14 06:45:21 2017 +++ src/sys/dev/usb/TODO.usbmp Tue Sep 5 07:07:15 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.13 2017/02/14 06:45:21 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.14 2017/09/05 07:07:15 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -23,7 +23,6 @@ usb_detach_{waitold,wakeup} to cv_{wait, if_aue.c if_axe.c if_axen.c - if_smsc.c if_udav.c if_url.c ubt.c @@ -73,7 +72,6 @@ splusb drivers: - if_otus.c - if_rum.c - if_run.c - - if_smsc.c - if_udav.c - if_upl.c - if_ural.c @@ -121,7 +119,6 @@ missing CALLOUT_MPSAFE drivers: - if_otus.c - if_rum.c - if_run.c - - if_smsc.c - if_udav.c - if_upgt.c - if_ural.c @@ -144,7 +141,6 @@ missing USB_TASKQ_MPSAFE tasks: - if_otus.c - if_rum.c - if_run.c - - if_smsc.c - if_udav.c - if_upgt.c - if_ural.c
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Sep 5 07:06:30 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_upl.c Log Message: Remove unnecessary splnet from upl_attach To generate a diff of this commit: cvs rdiff -u -r1.47.4.16 -r1.47.4.17 src/sys/dev/usb/if_upl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_upl.c diff -u src/sys/dev/usb/if_upl.c:1.47.4.16 src/sys/dev/usb/if_upl.c:1.47.4.17 --- src/sys/dev/usb/if_upl.c:1.47.4.16 Sun Feb 5 13:40:46 2017 +++ src/sys/dev/usb/if_upl.c Tue Sep 5 07:06:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_upl.c,v 1.47.4.16 2017/02/05 13:40:46 skrll Exp $ */ +/* $NetBSD: if_upl.c,v 1.47.4.17 2017/09/05 07:06:30 skrll Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.47.4.16 2017/02/05 13:40:46 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.47.4.17 2017/09/05 07:06:30 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -220,7 +220,6 @@ upl_attach(device_t parent, device_t sel struct upl_softc *sc = device_private(self); struct usb_attach_arg *uaa = aux; char *devinfop; - int s; struct usbd_device * dev = uaa->uaa_device; struct usbd_interface * iface; usbd_status err; @@ -285,8 +284,6 @@ upl_attach(device_t parent, device_t sel return; } - s = splnet(); - /* Initialize interface info.*/ ifp = &sc->sc_if; ifp->if_softc = sc; @@ -316,7 +313,6 @@ upl_attach(device_t parent, device_t sel RND_TYPE_NET, RND_FLAG_DEFAULT); sc->sc_attached = 1; - splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Sep 5 07:04:17 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_kue.c if_kuereg.h Log Message: WIP MPification To generate a diff of this commit: cvs rdiff -u -r1.81.4.14 -r1.81.4.15 src/sys/dev/usb/if_kue.c cvs rdiff -u -r1.18.24.3 -r1.18.24.4 src/sys/dev/usb/if_kuereg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_kue.c diff -u src/sys/dev/usb/if_kue.c:1.81.4.14 src/sys/dev/usb/if_kue.c:1.81.4.15 --- src/sys/dev/usb/if_kue.c:1.81.4.14 Mon Aug 28 17:52:27 2017 +++ src/sys/dev/usb/if_kue.c Tue Sep 5 07:04:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_kue.c,v 1.81.4.14 2017/08/28 17:52:27 skrll Exp $ */ +/* $NetBSD: if_kue.c,v 1.81.4.15 2017/09/05 07:04:17 skrll Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.81.4.14 2017/08/28 17:52:27 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.81.4.15 2017/09/05 07:04:17 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -166,15 +166,20 @@ CFATTACH_DECL_NEW(kue, sizeof(struct kue kue_detach, kue_activate); static int kue_tx_list_init(struct kue_softc *); +static void kue_tx_list_free(struct kue_softc *); static int kue_rx_list_init(struct kue_softc *); +static void kue_rx_list_free(struct kue_softc *); static int kue_send(struct kue_softc *, struct mbuf *, int); static int kue_open_pipes(struct kue_softc *); static void kue_rxeof(struct usbd_xfer *, void *, usbd_status); static void kue_txeof(struct usbd_xfer *, void *, usbd_status); static void kue_start(struct ifnet *); +static void kue_start_locked(struct ifnet *); static int kue_ioctl(struct ifnet *, u_long, void *); static void kue_init(void *); +static void kue_init_locked(void *); static void kue_stop(struct kue_softc *); +static void kue_stop_locked(struct kue_softc *); static void kue_watchdog(struct ifnet *); static void kue_setmulti(struct kue_softc *); @@ -398,7 +403,6 @@ kue_attach(device_t parent, device_t sel struct kue_softc *sc = device_private(self); struct usb_attach_arg *uaa = aux; char *devinfop; - int s; struct ifnet *ifp; struct usbd_device * dev = uaa->uaa_device; struct usbd_interface * iface; @@ -479,8 +483,6 @@ kue_attach(device_t parent, device_t sel sc->kue_mcfilters = kmem_alloc(KUE_MCFILTCNT(sc) * ETHER_ADDR_LEN, KM_SLEEP); - s = splnet(); - /* * A KLSI chip was detected. Inform the world. */ @@ -506,7 +508,6 @@ kue_attach(device_t parent, device_t sel RND_TYPE_NET, RND_FLAG_DEFAULT); sc->kue_attached = true; - splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->kue_udev, sc->kue_dev); @@ -599,6 +600,18 @@ kue_rx_list_init(struct kue_softc *sc) return 0; } +static void +kue_rx_list_free(struct kue_softc *sc) +{ + /* Free RX resources. */ + for (int i = 0; i < KUE_RX_LIST_CNT; i++) { + if (sc->kue_cdata.kue_rx_chain[i].kue_xfer != NULL) { + usbd_destroy_xfer(sc->kue_cdata.kue_rx_chain[i].kue_xfer); + sc->kue_cdata.kue_rx_chain[i].kue_xfer = NULL; + } + } +} + static int kue_tx_list_init(struct kue_softc *sc) { @@ -625,6 +638,18 @@ kue_tx_list_init(struct kue_softc *sc) return 0; } +static void +kue_tx_list_free(struct kue_softc *sc) +{ + /* Free TX resources. */ + for (int i = 0; i < KUE_TX_LIST_CNT; i++) { + if (sc->kue_cdata.kue_tx_chain[i].kue_xfer != NULL) { + usbd_destroy_xfer(sc->kue_cdata.kue_tx_chain[i].kue_xfer); + sc->kue_cdata.kue_tx_chain[i].kue_xfer = NULL; + } + } +} + /* * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. @@ -813,6 +838,17 @@ kue_send(struct kue_softc *sc, struct mb static void kue_start(struct ifnet *ifp) { + struct kue_softc *sc = ifp->if_softc; + KASSERT(ifp->if_extflags & IFEF_START_MPSAFE); + + mutex_enter(&sc->kue_txlock); + kue_start_locked(ifp); + mutex_exit(&sc->kue_txlock); +} + +static void +kue_start_locked(struct ifnet *ifp) +{ struct kue_softc *sc = ifp->if_softc; struct mbuf *m; @@ -853,9 +889,18 @@ kue_start(struct ifnet *ifp) static void kue_init(void *xsc) { + struct kue_softc *sc = xsc; + + mutex_enter(&sc->kue_lock); + kue_init_locked(xsc); + mutex_exit(&sc->kue_lock); +} + +static void +kue_init_locked(void *xsc) +{ struct kue_softc *sc = xsc; struct ifnet *ifp = GET_IFP(sc); - int s; uint8_t eaddr[ETHER_ADDR_LEN]; DPRINTFN(5,("%s: %s: enter\n", device_xname(sc->kue_dev),__func__)); @@ -863,8 +908,6 @@ kue_init(void *xsc) if (ifp->if_flags & IFF_RUNNING) return; - s = splnet(); - memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr)); /* Set MAC address */ kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SET_MAC, 0, eaddr, ETHER_ADDR_LEN); @@ -892,21 +935,18 @@ kue_init(void *xsc) if (sc->kue_ep[KUE_ENDPT_RX] == NULL) { if (kue_open_pipes(sc)) { - splx(s); retu
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Sep 5 07:01:12 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: ehci.c Log Message: #ifdef DIAGNOSTIC -> KASSERT and add another KASSERT To generate a diff of this commit: cvs rdiff -u -r1.234.2.109 -r1.234.2.110 src/sys/dev/usb/ehci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.234.2.109 src/sys/dev/usb/ehci.c:1.234.2.110 --- src/sys/dev/usb/ehci.c:1.234.2.109 Mon Aug 28 17:52:27 2017 +++ src/sys/dev/usb/ehci.c Tue Sep 5 07:01:12 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.234.2.109 2017/08/28 17:52:27 skrll Exp $ */ +/* $NetBSD: ehci.c,v 1.234.2.110 2017/09/05 07:01:12 skrll Exp $ */ /* * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.109 2017/08/28 17:52:27 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.110 2017/09/05 07:01:12 skrll Exp $"); #include "ohci.h" #include "uhci.h" @@ -3154,10 +3154,8 @@ ehci_abort_xfer(struct usbd_xfer *xfer, */ if (xfer->ux_hcflags & UXFER_ABORTING) { DPRINTF("already aborting", 0, 0, 0, 0); -#ifdef DIAGNOSTIC - if (status == USBD_TIMEOUT) - printf("ehci_abort_xfer: TIMEOUT while aborting\n"); -#endif + KASSERT(status != USBD_TIMEOUT); + /* Override the status which might be USBD_TIMEOUT. */ xfer->ux_status = status; DPRINTF("waiting for abort to finish", 0, 0, 0, 0); @@ -3313,10 +3311,7 @@ ehci_abort_isoc_xfer(struct usbd_xfer *x if (xfer->ux_hcflags & UXFER_ABORTING) { DPRINTF("already aborting", 0, 0, 0, 0); -#ifdef DIAGNOSTIC - if (status == USBD_TIMEOUT) - printf("ehci_abort_isoc_xfer: TIMEOUT while aborting\n"); -#endif + KASSERT(status != USBD_TIMEOUT); xfer->ux_status = status; DPRINTF("waiting for abort to finish", 0, 0, 0, 0); @@ -3445,6 +3440,7 @@ ehci_timeout_task(void *addr) DPRINTF("xfer=%p", xfer, 0, 0, 0); mutex_enter(&sc->sc_lock); + KASSERT(xfer->ux_status == USBD_TIMEOUT); ehci_abort_xfer(xfer, USBD_TIMEOUT); mutex_exit(&sc->sc_lock); }
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Sep 5 06:58:51 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: umass.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.149.2.22 -r1.149.2.23 src/sys/dev/usb/umass.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umass.c diff -u src/sys/dev/usb/umass.c:1.149.2.22 src/sys/dev/usb/umass.c:1.149.2.23 --- src/sys/dev/usb/umass.c:1.149.2.22 Tue Aug 29 06:49:07 2017 +++ src/sys/dev/usb/umass.c Tue Sep 5 06:58:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass.c,v 1.149.2.22 2017/08/29 06:49:07 skrll Exp $ */ +/* $NetBSD: umass.c,v 1.149.2.23 2017/09/05 06:58:51 skrll Exp $ */ /* * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -124,7 +124,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.22 2017/08/29 06:49:07 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.23 2017/09/05 06:58:51 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -271,12 +271,10 @@ const struct umass_wire_methods umass_cb #ifdef UMASS_DEBUG /* General debugging functions */ -Static void umass_bbb_dump_cbw(struct umass_softc *sc, -umass_bbb_cbw_t *cbw); -Static void umass_bbb_dump_csw(struct umass_softc *sc, -umass_bbb_csw_t *csw); +Static void umass_bbb_dump_cbw(struct umass_softc *sc, umass_bbb_cbw_t *cbw); +Static void umass_bbb_dump_csw(struct umass_softc *sc, umass_bbb_csw_t *csw); Static void umass_dump_buffer(struct umass_softc *sc, uint8_t *buffer, -int buflen, int printlen); +int buflen, int printlen); #endif
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Fri Sep 1 13:45:24 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_cue.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.68.4.15 -r1.68.4.16 src/sys/dev/usb/if_cue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_cue.c diff -u src/sys/dev/usb/if_cue.c:1.68.4.15 src/sys/dev/usb/if_cue.c:1.68.4.16 --- src/sys/dev/usb/if_cue.c:1.68.4.15 Sun Feb 5 13:40:46 2017 +++ src/sys/dev/usb/if_cue.c Fri Sep 1 13:45:24 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cue.c,v 1.68.4.15 2017/02/05 13:40:46 skrll Exp $ */ +/* $NetBSD: if_cue.c,v 1.68.4.16 2017/09/01 13:45:24 skrll Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul . All rights reserved. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.68.4.15 2017/02/05 13:40:46 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.68.4.16 2017/09/01 13:45:24 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1118,7 +1118,7 @@ cue_init_locked(struct ifnet *ifp) for (i = 0; i < CUE_RX_LIST_CNT; i++) { struct cue_chain *c = &sc->cue_cdata.cue_rx_chain[i]; usbd_setup_xfer(c->cue_xfer, c, c->cue_buf, CUE_BUFSZ, - USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, cue_rxeof); + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, cue_rxeof); usbd_transfer(c->cue_xfer); }
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Aug 30 10:08:22 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c if_smscvar.h Log Message: Track used TX trasnfers and check there's a free transfer in smsc_start_locked To generate a diff of this commit: cvs rdiff -u -r1.22.2.36 -r1.22.2.37 src/sys/dev/usb/if_smsc.c cvs rdiff -u -r1.3.4.7 -r1.3.4.8 src/sys/dev/usb/if_smscvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.36 src/sys/dev/usb/if_smsc.c:1.22.2.37 --- src/sys/dev/usb/if_smsc.c:1.22.2.36 Sat Apr 15 14:38:44 2017 +++ src/sys/dev/usb/if_smsc.c Wed Aug 30 10:08:22 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.36 2017/04/15 14:38:44 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.37 2017/08/30 10:08:22 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -694,6 +694,12 @@ smsc_start_locked(struct ifnet *ifp) return; } + /* Any free USB transfers? */ + if (sc->sc_cdata.tx_free == 0) { + smsc_dbg_printf(sc, "%s: all USB transfers in use\n", __func__); + return; + } + if ((ifp->if_flags & (IFF_OACTIVE|IFF_RUNNING)) != IFF_RUNNING) { smsc_dbg_printf(sc, "%s: not running\n", __func__); return; @@ -703,15 +709,21 @@ smsc_start_locked(struct ifnet *ifp) if (m_head == NULL) return; + sc->sc_cdata.tx_free--; + IFQ_DEQUEUE(&ifp->if_snd, m_head); - if (smsc_encap(sc, m_head, 0)) { + if (smsc_encap(sc, m_head, sc->sc_cdata.tx_next)) { m_free(m_head); + sc->sc_cdata.tx_free++; return; } + sc->sc_cdata.tx_next = (sc->sc_cdata.tx_next + 1) % SMSC_TX_LIST_CNT; + bpf_mtap(ifp, m_head); - ifp->if_flags |= IFF_OACTIVE; + if (sc->sc_cdata.tx_free == 0) + ifp->if_flags |= IFF_OACTIVE; /* * Set a timeout in case the chip goes out to lunch. @@ -1559,6 +1571,7 @@ smsc_txeof(struct usbd_xfer *xfer, void return; } + sc->sc_cdata.tx_free++; ifp->if_timer = 0; ifp->if_flags &= ~IFF_OACTIVE; @@ -1608,6 +1621,9 @@ smsc_tx_list_init(struct smsc_softc *sc) } } + cd->tx_free = SMSC_TX_LIST_CNT; + cd->tx_next = 0; + return 0; } @@ -1721,7 +1737,5 @@ smsc_encap(struct smsc_softc *sc, struct return EIO; } - sc->sc_cdata.tx_cnt++; - return 0; } Index: src/sys/dev/usb/if_smscvar.h diff -u src/sys/dev/usb/if_smscvar.h:1.3.4.7 src/sys/dev/usb/if_smscvar.h:1.3.4.8 --- src/sys/dev/usb/if_smscvar.h:1.3.4.7 Sat Apr 15 14:38:44 2017 +++ src/sys/dev/usb/if_smscvar.h Wed Aug 30 10:08:22 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smscvar.h,v 1.3.4.7 2017/04/15 14:38:44 skrll Exp $ */ +/* $NetBSD: if_smscvar.h,v 1.3.4.8 2017/08/30 10:08:22 skrll Exp $ */ /* $OpenBSD: if_smscreg.h,v 1.2 2012/09/27 12:38:11 jsg Exp $ */ /*- @@ -46,9 +46,8 @@ struct smsc_chain { struct smsc_cdata { struct smsc_chain tx_chain[SMSC_TX_LIST_CNT]; struct smsc_chain rx_chain[SMSC_RX_LIST_CNT]; - int tx_prod; - int tx_cons; - int tx_cnt; + int tx_free; + int tx_next; int rx_prod; };
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Aug 29 06:49:07 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: umass.c Log Message: Typo To generate a diff of this commit: cvs rdiff -u -r1.149.2.21 -r1.149.2.22 src/sys/dev/usb/umass.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umass.c diff -u src/sys/dev/usb/umass.c:1.149.2.21 src/sys/dev/usb/umass.c:1.149.2.22 --- src/sys/dev/usb/umass.c:1.149.2.21 Mon Aug 28 17:52:28 2017 +++ src/sys/dev/usb/umass.c Tue Aug 29 06:49:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass.c,v 1.149.2.21 2017/08/28 17:52:28 skrll Exp $ */ +/* $NetBSD: umass.c,v 1.149.2.22 2017/08/29 06:49:07 skrll Exp $ */ /* * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -124,7 +124,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.21 2017/08/28 17:52:28 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.22 2017/08/29 06:49:07 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -679,7 +679,7 @@ umass_attach(device_t parent, device_t s } /* - * Record buffer pinters for data transfer (it's huge), command and + * Record buffer pointers for data transfer (it's huge), command and * status data here */ switch (sc->sc_wire) {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 15 14:38:44 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c if_smscvar.h Log Message: WIP MPification To generate a diff of this commit: cvs rdiff -u -r1.22.2.35 -r1.22.2.36 src/sys/dev/usb/if_smsc.c cvs rdiff -u -r1.3.4.6 -r1.3.4.7 src/sys/dev/usb/if_smscvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.35 src/sys/dev/usb/if_smsc.c:1.22.2.36 --- src/sys/dev/usb/if_smsc.c:1.22.2.35 Mon Feb 6 10:20:01 2017 +++ src/sys/dev/usb/if_smsc.c Sat Apr 15 14:38:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.35 2017/02/06 10:20:01 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.36 2017/04/15 14:38:44 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -172,6 +172,7 @@ struct mbuf *smsc_newbuf(void); void smsc_tick(void *); void smsc_tick_task(void *); void smsc_miibus_statchg(struct ifnet *); +void smsc_miibus_statchg_locked(struct ifnet *); int smsc_miibus_readreg(device_t, int, int); void smsc_miibus_writereg(device_t, int, int, int); int smsc_ifmedia_upd(struct ifnet *); @@ -312,14 +313,37 @@ smsc_miibus_writereg(device_t dev, int p void smsc_miibus_statchg(struct ifnet *ifp) { + if (ifp == NULL) + return; + + struct smsc_softc * const sc = ifp->if_softc; + + mutex_enter(&sc->sc_lock); + if (sc->sc_dying) { + mutex_exit(&sc->sc_lock); + return; + } + smsc_miibus_statchg_locked(ifp); + + mutex_exit(&sc->sc_lock); +} + + +void +smsc_miibus_statchg_locked(struct ifnet *ifp) +{ struct smsc_softc * const sc = ifp->if_softc; struct mii_data * const mii = &sc->sc_mii; int err; uint32_t flow; uint32_t afc_cfg; - if ((ifp->if_flags & IFF_RUNNING) == 0) + KASSERT(mutex_owned(&sc->sc_lock)); + + if ((ifp->if_flags & IFF_RUNNING) == 0) { + smsc_dbg_printf(sc, "%s: not running\n", __func__); return; + } /* Use the MII status to determine link status */ sc->sc_flags &= ~SMSC_FLAG_LINK; @@ -405,15 +429,20 @@ smsc_ifmedia_sts(struct ifnet *ifp, stru struct smsc_softc * const sc = ifp->if_softc; struct mii_data * const mii = &sc->sc_mii; + /* SMSC_LOCK */ + mii_pollstat(mii); ifmr->ifm_active = mii->mii_media_active; ifmr->ifm_status = mii->mii_media_status; + + /* SMSC_UNLOCK */ } static inline uint32_t smsc_hash(uint8_t addr[ETHER_ADDR_LEN]) { + return (ether_crc32_be(addr, ETHER_ADDR_LEN) >> 26) & 0x3f; } @@ -426,6 +455,8 @@ smsc_setmulti(struct smsc_softc *sc) uint32_t hashtbl[2] = { 0, 0 }; uint32_t hash; + KASSERT(mutex_owned(&sc->sc_lock)); + if (sc->sc_dying) return; @@ -441,16 +472,19 @@ allmulti: sc->sc_mac_csr &= ~(SMSC_MAC_CSR_PRMS | SMSC_MAC_CSR_MCPAS); } + ETHER_LOCK(&sc->sc_ec); ETHER_FIRST_MULTI(step, &sc->sc_ec, enm); while (enm != NULL) { - if (memcmp(enm->enm_addrlo, enm->enm_addrhi, - ETHER_ADDR_LEN) != 0) + if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) { + ETHER_UNLOCK(&sc->sc_ec); goto allmulti; + } hash = smsc_hash(enm->enm_addrlo); hashtbl[hash >> 5] |= 1 << (hash & 0x1F); ETHER_NEXT_MULTI(step, enm); } + ETHER_UNLOCK(&sc->sc_ec); /* Debug */ if (sc->sc_mac_csr & SMSC_MAC_CSR_HPFILT) { @@ -528,6 +562,7 @@ done: void smsc_reset(struct smsc_softc *sc) { + KASSERT(mutex_owned(&sc->sc_lock)); if (sc->sc_dying) return; @@ -600,6 +635,10 @@ smsc_init_locked(struct ifnet *ifp) goto fail3; } + mutex_enter(&sc->sc_rxlock); + mutex_enter(&sc->sc_txlock); + sc->sc_stopping = false; + /* Start up the receive pipe. */ for (size_t i = 0; i < SMSC_RX_LIST_CNT; i++) { struct smsc_chain *c = &sc->sc_cdata.rx_chain[i]; @@ -608,7 +647,8 @@ smsc_init_locked(struct ifnet *ifp) usbd_transfer(c->sc_xfer); } - sc->sc_stopping = false; + mutex_exit(&sc->sc_txlock); + mutex_exit(&sc->sc_rxlock); /* Indicate we are up and running. */ ifp->if_flags |= IFF_RUNNING; @@ -650,20 +690,24 @@ smsc_start_locked(struct ifnet *ifp) /* Don't send anything if there is no link or controller is busy. */ if ((sc->sc_flags & SMSC_FLAG_LINK) == 0) { + smsc_dbg_printf(sc, "%s: no link\n", __func__); return; } - if ((ifp->if_flags & (IFF_OACTIVE|IFF_RUNNING)) != IFF_RUNNING) + if ((ifp->if_flags & (IFF_OACTIVE|IFF_RUNNING)) != IFF_RUNNING) { + smsc_dbg_printf(sc, "%s: not running\n", __func__); return; + } IFQ_POLL(&ifp->if_snd, m_head); if (m_head == NULL) return; + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (smsc_encap(sc, m_head, 0)) { + m_free(m_head); return; } - IFQ_DEQUEUE(&ifp->if_snd, m_head); bpf_mtap(ifp, m_head); @@ -683,10 +727,19 @@ smsc_tick(void *xsc) if (sc == NULL) return; - if (sc->sc_dying) + mutex_enter(&sc->sc_lock); + + if (sc->sc_dyi
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Feb 14 06:45:21 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp Log Message: Fix previous To generate a diff of this commit: cvs rdiff -u -r1.8.4.12 -r1.8.4.13 src/sys/dev/usb/TODO.usbmp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.12 src/sys/dev/usb/TODO.usbmp:1.8.4.13 --- src/sys/dev/usb/TODO.usbmp:1.8.4.12 Tue Feb 14 06:44:30 2017 +++ src/sys/dev/usb/TODO.usbmp Tue Feb 14 06:45:21 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.12 2017/02/14 06:44:30 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.13 2017/02/14 06:45:21 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -144,7 +144,7 @@ missing USB_TASKQ_MPSAFE tasks: - if_otus.c - if_rum.c - if_run.c - - if_udav.c + - if_smsc.c - if_udav.c - if_upgt.c - if_ural.c
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Feb 14 06:44:31 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp Log Message: More stuff to do... To generate a diff of this commit: cvs rdiff -u -r1.8.4.11 -r1.8.4.12 src/sys/dev/usb/TODO.usbmp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.11 src/sys/dev/usb/TODO.usbmp:1.8.4.12 --- src/sys/dev/usb/TODO.usbmp:1.8.4.11 Sat Jan 28 12:12:19 2017 +++ src/sys/dev/usb/TODO.usbmp Tue Feb 14 06:44:30 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.11 2017/01/28 12:12:19 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.12 2017/02/14 06:44:30 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -133,6 +133,29 @@ missing CALLOUT_MPSAFE drivers: - ulpt.c - uyurex.c +missing USB_TASKQ_MPSAFE tasks: + - if_athn_usb.c + - if_atu.c + - if_aue.c + - if_axe.c + - if_axen.c + - if_cue.c + - if_cue.c + - if_otus.c + - if_rum.c + - if_run.c + - if_udav.c + - if_udav.c + - if_upgt.c + - if_ural.c + - if_url.c + - if_urtw.c + - if_urtwn.c + - if_zyd.c + - uatp.c + - ukbd.c + - umcs.c + driver testing: STATUS - uhub working - uhid working
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Feb 6 10:20:01 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Remove useless checks To generate a diff of this commit: cvs rdiff -u -r1.22.2.34 -r1.22.2.35 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.34 src/sys/dev/usb/if_smsc.c:1.22.2.35 --- src/sys/dev/usb/if_smsc.c:1.22.2.34 Mon Feb 6 09:08:48 2017 +++ src/sys/dev/usb/if_smsc.c Mon Feb 6 10:20:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.34 2017/02/06 09:08:48 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.35 2017/02/06 10:20:01 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -318,8 +318,7 @@ smsc_miibus_statchg(struct ifnet *ifp) uint32_t flow; uint32_t afc_cfg; - if (mii == NULL || ifp == NULL || - (ifp->if_flags & IFF_RUNNING) == 0) + if ((ifp->if_flags & IFF_RUNNING) == 0) return; /* Use the MII status to determine link status */ @@ -1236,9 +1235,6 @@ smsc_tick_task(void *xsc) struct ifnet * const ifp = &sc->sc_ec.ec_if; struct mii_data * const mii = &sc->sc_mii; - if (mii == NULL) - return; - const int s = splnet(); mii_tick(mii);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Feb 6 09:08:48 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Sprinkle const and reduce scope of a couple of variables. To generate a diff of this commit: cvs rdiff -u -r1.22.2.33 -r1.22.2.34 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.33 src/sys/dev/usb/if_smsc.c:1.22.2.34 --- src/sys/dev/usb/if_smsc.c:1.22.2.33 Mon Feb 6 09:02:38 2017 +++ src/sys/dev/usb/if_smsc.c Mon Feb 6 09:08:48 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.33 2017/02/06 09:02:38 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.34 2017/02/06 09:08:48 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -1283,14 +1283,11 @@ smsc_unlock_mii(struct smsc_softc *sc) void smsc_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status) { - struct smsc_chain *c = (struct smsc_chain *)priv; - struct smsc_softc *sc = c->sc_sc; - struct ifnet *ifp = &sc->sc_ec.ec_if; + struct smsc_chain * const c = (struct smsc_chain *)priv; + struct smsc_softc * const sc = c->sc_sc; + struct ifnet * const ifp = &sc->sc_ec.ec_if; u_char *buf = c->sc_buf; uint32_t total_len; - uint32_t rxhdr; - uint16_t pktlen; - struct mbuf *m; mutex_enter(&sc->sc_rxlock); @@ -1322,6 +1319,7 @@ smsc_rxeof(struct usbd_xfer *xfer, void smsc_dbg_printf(sc, "xfer status total_len %d\n", total_len); while (total_len != 0) { + uint32_t rxhdr; if (total_len < sizeof(rxhdr)) { smsc_dbg_printf(sc, "total_len %d < sizeof(rxhdr) %zu\n", total_len, sizeof(rxhdr)); @@ -1345,7 +1343,7 @@ smsc_rxeof(struct usbd_xfer *xfer, void goto done; } - pktlen = (uint16_t)SMSC_RX_STAT_FRM_LENGTH(rxhdr); + uint16_t pktlen = (uint16_t)SMSC_RX_STAT_FRM_LENGTH(rxhdr); smsc_dbg_printf(sc, "rxeof total_len %d pktlen %d rxhdr " "0x%08x\n", total_len, pktlen, rxhdr); @@ -1372,7 +1370,7 @@ smsc_rxeof(struct usbd_xfer *xfer, void goto done; } - m = smsc_newbuf(); + struct mbuf *m = smsc_newbuf(); if (m == NULL) { smsc_dbg_printf(sc, "smc_newbuf returned NULL\n"); ifp->if_ierrors++;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Feb 6 09:02:38 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.22.2.32 -r1.22.2.33 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.32 src/sys/dev/usb/if_smsc.c:1.22.2.33 --- src/sys/dev/usb/if_smsc.c:1.22.2.32 Sun Feb 5 13:40:46 2017 +++ src/sys/dev/usb/if_smsc.c Mon Feb 6 09:02:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.32 2017/02/05 13:40:46 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.33 2017/02/06 09:02:38 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -422,10 +422,10 @@ void smsc_setmulti(struct smsc_softc *sc) { struct ifnet * const ifp = &sc->sc_ec.ec_if; - struct ether_multi *enm; - struct ether_multistep step; - uint32_t hashtbl[2] = { 0, 0 }; - uint32_t hash; + struct ether_multi *enm; + struct ether_multistep step; + uint32_t hashtbl[2] = { 0, 0 }; + uint32_t hash; if (sc->sc_dying) return; @@ -966,8 +966,8 @@ out: int smsc_ioctl(struct ifnet *ifp, u_long cmd, void *data) { - struct smsc_softc *sc = ifp->if_softc; - int s, error = 0; + struct smsc_softc *sc = ifp->if_softc; + int s, error = 0; if (sc->sc_dying) return EIO; @@ -1283,14 +1283,14 @@ smsc_unlock_mii(struct smsc_softc *sc) void smsc_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status) { - struct smsc_chain *c = (struct smsc_chain *)priv; - struct smsc_softc *sc = c->sc_sc; - struct ifnet *ifp = &sc->sc_ec.ec_if; - u_char *buf = c->sc_buf; - uint32_t total_len; - uint32_t rxhdr; - uint16_t pktlen; - struct mbuf *m; + struct smsc_chain *c = (struct smsc_chain *)priv; + struct smsc_softc *sc = c->sc_sc; + struct ifnet *ifp = &sc->sc_ec.ec_if; + u_char *buf = c->sc_buf; + uint32_t total_len; + uint32_t rxhdr; + uint16_t pktlen; + struct mbuf *m; mutex_enter(&sc->sc_rxlock); @@ -1595,7 +1595,7 @@ smsc_rx_list_free(struct smsc_softc *sc) struct mbuf * smsc_newbuf(void) { - struct mbuf *m; + struct mbuf *m; MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL)
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Feb 5 09:02:38 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: umass.c umass_scsipi.c Log Message: Fix build To generate a diff of this commit: cvs rdiff -u -r1.149.2.19 -r1.149.2.20 src/sys/dev/usb/umass.c cvs rdiff -u -r1.49.2.9 -r1.49.2.10 src/sys/dev/usb/umass_scsipi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umass.c diff -u src/sys/dev/usb/umass.c:1.149.2.19 src/sys/dev/usb/umass.c:1.149.2.20 --- src/sys/dev/usb/umass.c:1.149.2.19 Sun Jan 29 10:16:09 2017 +++ src/sys/dev/usb/umass.c Sun Feb 5 09:02:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass.c,v 1.149.2.19 2017/01/29 10:16:09 skrll Exp $ */ +/* $NetBSD: umass.c,v 1.149.2.20 2017/02/05 09:02:38 skrll Exp $ */ /* * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -124,7 +124,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.19 2017/01/29 10:16:09 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.20 2017/02/05 09:02:38 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -139,6 +139,7 @@ __KERNEL_RCSID(0, "$NetBSD: umass.c,v 1. #include #include #include +#include #include #include Index: src/sys/dev/usb/umass_scsipi.c diff -u src/sys/dev/usb/umass_scsipi.c:1.49.2.9 src/sys/dev/usb/umass_scsipi.c:1.49.2.10 --- src/sys/dev/usb/umass_scsipi.c:1.49.2.9 Sun Jan 29 10:16:09 2017 +++ src/sys/dev/usb/umass_scsipi.c Sun Feb 5 09:02:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass_scsipi.c,v 1.49.2.9 2017/01/29 10:16:09 skrll Exp $ */ +/* $NetBSD: umass_scsipi.c,v 1.49.2.10 2017/02/05 09:02:38 skrll Exp $ */ /* * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.49.2.9 2017/01/29 10:16:09 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.49.2.10 2017/02/05 09:02:38 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: umass_scsipi #include /* XXX */ #include #include +#include #include #include #include
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Fri Feb 3 08:39:30 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Wrap a long line To generate a diff of this commit: cvs rdiff -u -r1.22.2.30 -r1.22.2.31 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.30 src/sys/dev/usb/if_smsc.c:1.22.2.31 --- src/sys/dev/usb/if_smsc.c:1.22.2.30 Fri Feb 3 07:48:05 2017 +++ src/sys/dev/usb/if_smsc.c Fri Feb 3 08:39:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.30 2017/02/03 07:48:05 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.31 2017/02/03 08:39:30 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -1122,7 +1122,8 @@ smsc_attach(device_t parent, device_t se } } - aprint_normal_dev(self, "Ethernet address %s\n", ether_sprintf(sc->sc_enaddr)); + aprint_normal_dev(self, "Ethernet address %s\n", + ether_sprintf(sc->sc_enaddr)); IFQ_SET_READY(&ifp->if_snd);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Fri Feb 3 07:54:44 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_kue.c Log Message: Sync with HEAD To generate a diff of this commit: cvs rdiff -u -r1.81.4.11 -r1.81.4.12 src/sys/dev/usb/if_kue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_kue.c diff -u src/sys/dev/usb/if_kue.c:1.81.4.11 src/sys/dev/usb/if_kue.c:1.81.4.12 --- src/sys/dev/usb/if_kue.c:1.81.4.11 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_kue.c Fri Feb 3 07:54:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_kue.c,v 1.81.4.11 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_kue.c,v 1.81.4.12 2017/02/03 07:54:44 skrll Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.81.4.11 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.81.4.12 2017/02/03 07:54:44 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -500,7 +500,7 @@ kue_attach(device_t parent, device_t sel ifp->if_ioctl = kue_ioctl; ifp->if_start = kue_start; ifp->if_watchdog = kue_watchdog; - strncpy(ifp->if_xname, device_xname(sc->kue_dev), IFNAMSIZ); + strlcpy(ifp->if_xname, device_xname(sc->kue_dev), IFNAMSIZ); IFQ_SET_READY(&ifp->if_snd);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Fri Feb 3 07:48:05 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_axe.c if_smsc.c Log Message: Simplify. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.67.4.13 -r1.67.4.14 src/sys/dev/usb/if_axe.c cvs rdiff -u -r1.22.2.29 -r1.22.2.30 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_axe.c diff -u src/sys/dev/usb/if_axe.c:1.67.4.13 src/sys/dev/usb/if_axe.c:1.67.4.14 --- src/sys/dev/usb/if_axe.c:1.67.4.13 Mon Dec 12 13:15:39 2016 +++ src/sys/dev/usb/if_axe.c Fri Feb 3 07:48:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_axe.c,v 1.67.4.13 2016/12/12 13:15:39 skrll Exp $ */ +/* $NetBSD: if_axe.c,v 1.67.4.14 2017/02/03 07:48:05 skrll Exp $ */ /* $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */ /* @@ -87,7 +87,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.67.4.13 2016/12/12 13:15:39 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.67.4.14 2017/02/03 07:48:05 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1877,12 +1877,12 @@ axe_ioctl(struct ifnet *ifp, u_long cmd, if (error == ENETRESET) { error = 0; - if (cmd != SIOCADDMULTI && cmd != SIOCDELMULTI) - ; - else if (ifp->if_flags & IFF_RUNNING) { - mutex_enter(&sc->axe_lock); - axe_setmulti(sc); - mutex_exit(&sc->axe_lock); + if (cmd == SIOCADDMULTI || cmd == SIOCDELMULTI) { + if (ifp->if_flags & IFF_RUNNING) { +mutex_enter(&sc->axe_lock); +axe_setmulti(sc); +mutex_exit(&sc->axe_lock); + } } } Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.29 src/sys/dev/usb/if_smsc.c:1.22.2.30 --- src/sys/dev/usb/if_smsc.c:1.22.2.29 Thu Feb 2 07:40:51 2017 +++ src/sys/dev/usb/if_smsc.c Fri Feb 3 07:48:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.29 2017/02/02 07:40:51 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.30 2017/02/03 07:48:05 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -978,12 +978,12 @@ smsc_ioctl(struct ifnet *ifp, u_long cmd if (error == ENETRESET) { error = 0; - if (cmd != SIOCADDMULTI && cmd != SIOCDELMULTI) - ; - else if (ifp->if_flags & IFF_RUNNING) { - mutex_enter(&sc->sc_lock); - smsc_setmulti(sc); - mutex_exit(&sc->sc_lock); + if (cmd == SIOCADDMULTI || cmd == SIOCDELMULTI) { + if (ifp->if_flags & IFF_RUNNING) { +mutex_enter(&sc->sc_lock); +smsc_setmulti(sc); +mutex_exit(&sc->sc_lock); + } } } return error;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Feb 2 07:40:51 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Style / more const. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.22.2.28 -r1.22.2.29 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.28 src/sys/dev/usb/if_smsc.c:1.22.2.29 --- src/sys/dev/usb/if_smsc.c:1.22.2.28 Thu Feb 2 07:36:45 2017 +++ src/sys/dev/usb/if_smsc.c Thu Feb 2 07:40:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.28 2017/02/02 07:36:45 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.29 2017/02/02 07:40:51 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -679,7 +679,7 @@ smsc_start_locked(struct ifnet *ifp) void smsc_tick(void *xsc) { - struct smsc_softc *sc = xsc; + struct smsc_softc * const sc = xsc; if (sc == NULL) return; @@ -1225,22 +1225,20 @@ smsc_detach(device_t self, int flags) void smsc_tick_task(void *xsc) { - int s; - struct smsc_softc *sc = xsc; - struct ifnet *ifp; - struct mii_data *mii; + struct smsc_softc * const sc = xsc; if (sc == NULL) return; if (sc->sc_dying) return; - ifp = &sc->sc_ec.ec_if; - mii = &sc->sc_mii; + + struct ifnet * const ifp = &sc->sc_ec.ec_if; + struct mii_data * const mii = &sc->sc_mii; if (mii == NULL) return; - s = splnet(); + const int s = splnet(); mii_tick(mii); if ((sc->sc_flags & SMSC_FLAG_LINK) == 0)
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Feb 2 07:36:45 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.22.2.27 -r1.22.2.28 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.27 src/sys/dev/usb/if_smsc.c:1.22.2.28 --- src/sys/dev/usb/if_smsc.c:1.22.2.27 Thu Feb 2 07:35:36 2017 +++ src/sys/dev/usb/if_smsc.c Thu Feb 2 07:36:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.27 2017/02/02 07:35:36 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.28 2017/02/02 07:36:45 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -1626,7 +1626,7 @@ smsc_encap(struct smsc_softc *sc, struct * length of the packet and buffer. */ txhdr = SMSC_TX_CTRL_0_BUF_SIZE(m->m_pkthdr.len) | - SMSC_TX_CTRL_0_FIRST_SEG | SMSC_TX_CTRL_0_LAST_SEG; + SMSC_TX_CTRL_0_FIRST_SEG | SMSC_TX_CTRL_0_LAST_SEG; txhdr = htole32(txhdr); memcpy(c->sc_buf, &txhdr, sizeof(txhdr));
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Feb 2 07:35:36 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Use lower case To generate a diff of this commit: cvs rdiff -u -r1.22.2.26 -r1.22.2.27 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.26 src/sys/dev/usb/if_smsc.c:1.22.2.27 --- src/sys/dev/usb/if_smsc.c:1.22.2.26 Thu Feb 2 07:34:15 2017 +++ src/sys/dev/usb/if_smsc.c Thu Feb 2 07:35:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.26 2017/02/02 07:34:15 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.27 2017/02/02 07:35:36 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -280,7 +280,7 @@ smsc_miibus_readreg(device_t dev, int ph done: smsc_unlock_mii(sc); - return val & 0x; + return val & 0x; } void
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Feb 2 07:34:15 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Remove useless check To generate a diff of this commit: cvs rdiff -u -r1.22.2.25 -r1.22.2.26 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.25 src/sys/dev/usb/if_smsc.c:1.22.2.26 --- src/sys/dev/usb/if_smsc.c:1.22.2.25 Thu Feb 2 07:23:03 2017 +++ src/sys/dev/usb/if_smsc.c Thu Feb 2 07:34:15 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.25 2017/02/02 07:23:03 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.26 2017/02/02 07:34:15 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -474,9 +474,6 @@ smsc_sethwcsum(struct smsc_softc *sc) uint32_t val; int err; - if (!ifp) - return EIO; - err = smsc_read_reg(sc, SMSC_COE_CTRL, &val); if (err != 0) { smsc_warn_printf(sc, "failed to read SMSC_COE_CTRL (err=%d)\n",
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Feb 2 07:23:03 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Sprinkle some const To generate a diff of this commit: cvs rdiff -u -r1.22.2.24 -r1.22.2.25 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.24 src/sys/dev/usb/if_smsc.c:1.22.2.25 --- src/sys/dev/usb/if_smsc.c:1.22.2.24 Thu Feb 2 07:16:03 2017 +++ src/sys/dev/usb/if_smsc.c Thu Feb 2 07:23:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.24 2017/02/02 07:16:03 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.25 2017/02/02 07:23:03 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -259,7 +259,7 @@ smsc_wait_for_bits(struct smsc_softc *sc int smsc_miibus_readreg(device_t dev, int phy, int reg) { - struct smsc_softc *sc = device_private(dev); + struct smsc_softc * const sc = device_private(dev); uint32_t addr; uint32_t val = 0; @@ -286,7 +286,7 @@ done: void smsc_miibus_writereg(device_t dev, int phy, int reg, int val) { - struct smsc_softc *sc = device_private(dev); + struct smsc_softc * const sc = device_private(dev); uint32_t addr; if (sc->sc_phyno != phy) @@ -312,8 +312,8 @@ smsc_miibus_writereg(device_t dev, int p void smsc_miibus_statchg(struct ifnet *ifp) { - struct smsc_softc *sc = ifp->if_softc; - struct mii_data *mii = &sc->sc_mii; + struct smsc_softc * const sc = ifp->if_softc; + struct mii_data * const mii = &sc->sc_mii; int err; uint32_t flow; uint32_t afc_cfg; @@ -386,8 +386,8 @@ smsc_miibus_statchg(struct ifnet *ifp) int smsc_ifmedia_upd(struct ifnet *ifp) { - struct smsc_softc *sc = ifp->if_softc; - struct mii_data *mii = &sc->sc_mii; + struct smsc_softc * const sc = ifp->if_softc; + struct mii_data * const mii = &sc->sc_mii; int err; if (mii->mii_instance) { @@ -403,8 +403,8 @@ smsc_ifmedia_upd(struct ifnet *ifp) void smsc_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) { - struct smsc_softc *sc = ifp->if_softc; - struct mii_data *mii = &sc->sc_mii; + struct smsc_softc * const sc = ifp->if_softc; + struct mii_data * const mii = &sc->sc_mii; mii_pollstat(mii); @@ -421,7 +421,7 @@ smsc_hash(uint8_t addr[ETHER_ADDR_LEN]) void smsc_setmulti(struct smsc_softc *sc) { - struct ifnet *ifp = &sc->sc_ec.ec_if; + struct ifnet * const ifp = &sc->sc_ec.ec_if; struct ether_multi *enm; struct ether_multistep step; uint32_t hashtbl[2] = { 0, 0 }; @@ -470,7 +470,7 @@ allmulti: int smsc_sethwcsum(struct smsc_softc *sc) { - struct ifnet *ifp = &sc->sc_ec.ec_if; + struct ifnet * const ifp = &sc->sc_ec.ec_if; uint32_t val; int err; @@ -545,7 +545,7 @@ smsc_reset(struct smsc_softc *sc) int smsc_init(struct ifnet *ifp) { - struct smsc_softc *sc = ifp->if_softc; + struct smsc_softc * const sc = ifp->if_softc; mutex_enter(&sc->sc_lock); int ret = smsc_init_locked(ifp);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Feb 2 07:16:03 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Add a TAB To generate a diff of this commit: cvs rdiff -u -r1.22.2.23 -r1.22.2.24 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.23 src/sys/dev/usb/if_smsc.c:1.22.2.24 --- src/sys/dev/usb/if_smsc.c:1.22.2.23 Tue Jan 31 17:09:08 2017 +++ src/sys/dev/usb/if_smsc.c Thu Feb 2 07:16:03 2017 @@ -1,7 +1,7 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.23 2017/01/31 17:09:08 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.24 2017/02/02 07:16:03 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ -/* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ +/* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ /*- * Copyright (c) 2012 * Ben Gray .
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Feb 1 07:55:08 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_otus.c if_zyd.c Log Message: Be more careful about malloc returning NULL To generate a diff of this commit: cvs rdiff -u -r1.25.6.9 -r1.25.6.10 src/sys/dev/usb/if_otus.c cvs rdiff -u -r1.36.14.13 -r1.36.14.14 src/sys/dev/usb/if_zyd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_otus.c diff -u src/sys/dev/usb/if_otus.c:1.25.6.9 src/sys/dev/usb/if_otus.c:1.25.6.10 --- src/sys/dev/usb/if_otus.c:1.25.6.9 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_otus.c Wed Feb 1 07:55:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_otus.c,v 1.25.6.9 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_otus.c,v 1.25.6.10 2017/02/01 07:55:08 skrll Exp $ */ /* $OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $ */ /*- @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.25.6.9 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.25.6.10 2017/02/01 07:55:08 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1493,7 +1493,7 @@ otus_node_alloc(struct ieee80211_node_ta DPRINTFN(DBG_FN, DBG_NO_SC, "\n"); on = malloc(sizeof(*on), M_DEVBUF, M_NOWAIT | M_ZERO); - return &on->ni; + return on ? &on->ni : NULL; } Static int Index: src/sys/dev/usb/if_zyd.c diff -u src/sys/dev/usb/if_zyd.c:1.36.14.13 src/sys/dev/usb/if_zyd.c:1.36.14.14 --- src/sys/dev/usb/if_zyd.c:1.36.14.13 Sat Jan 28 12:12:19 2017 +++ src/sys/dev/usb/if_zyd.c Wed Feb 1 07:55:08 2017 @@ -1,5 +1,5 @@ /* $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */ -/* $NetBSD: if_zyd.c,v 1.36.14.13 2017/01/28 12:12:19 skrll Exp $ */ +/* $NetBSD: if_zyd.c,v 1.36.14.14 2017/02/01 07:55:08 skrll Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.36.14.13 2017/01/28 12:12:19 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.36.14.14 2017/02/01 07:55:08 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -672,8 +672,7 @@ zyd_node_alloc(struct ieee80211_node_tab struct zyd_node *zn; zn = malloc(sizeof(struct zyd_node), M_80211_NODE, M_NOWAIT | M_ZERO); - - return &zn->ni; + return zn ? &zn->ni : NULL; } Static int
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Jan 31 17:09:08 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Minor code re-org. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.22.2.22 -r1.22.2.23 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.22 src/sys/dev/usb/if_smsc.c:1.22.2.23 --- src/sys/dev/usb/if_smsc.c:1.22.2.22 Tue Jan 31 16:52:39 2017 +++ src/sys/dev/usb/if_smsc.c Tue Jan 31 17:09:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.22 2017/01/31 16:52:39 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.23 2017/01/31 17:09:08 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -1032,14 +1032,8 @@ smsc_attach(device_t parent, device_t se ", err=%s\n", usbd_errstr(err)); return; } - /* Setup the endpoints for the SMSC LAN95xx device(s) */ - usb_init_task(&sc->sc_tick_task, smsc_tick_task, sc, 0); - - mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); - mutex_init(&sc->sc_txlock, MUTEX_DEFAULT, IPL_SOFTUSB); - mutex_init(&sc->sc_rxlock, MUTEX_DEFAULT, IPL_SOFTUSB); - mutex_init(&sc->sc_mii_lock, MUTEX_DEFAULT, IPL_NONE); + /* Setup the endpoints for the SMSC LAN95xx device(s) */ err = usbd_device2interface_handle(dev, SMSC_IFACE_IDX, &sc->sc_iface); if (err) { aprint_error_dev(self, "getting interface handle failed\n"); @@ -1072,6 +1066,13 @@ smsc_attach(device_t parent, device_t se } } + usb_init_task(&sc->sc_tick_task, smsc_tick_task, sc, 0); + + mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&sc->sc_txlock, MUTEX_DEFAULT, IPL_SOFTUSB); + mutex_init(&sc->sc_rxlock, MUTEX_DEFAULT, IPL_SOFTUSB); + mutex_init(&sc->sc_mii_lock, MUTEX_DEFAULT, IPL_NONE); + ifp = &sc->sc_ec.ec_if; ifp->if_softc = sc; strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Jan 31 16:52:40 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Remove useless lines. To generate a diff of this commit: cvs rdiff -u -r1.22.2.21 -r1.22.2.22 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.21 src/sys/dev/usb/if_smsc.c:1.22.2.22 --- src/sys/dev/usb/if_smsc.c:1.22.2.21 Tue Jan 31 11:41:14 2017 +++ src/sys/dev/usb/if_smsc.c Tue Jan 31 16:52:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.21 2017/01/31 11:41:14 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.22 2017/01/31 16:52:39 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -367,7 +367,6 @@ smsc_miibus_statchg(struct ifnet *ifp) afc_cfg |= 0xf; else afc_cfg &= ~0xf; - } else { smsc_dbg_printf(sc, "half duplex operation\n"); sc->sc_mac_csr &= ~SMSC_MAC_CSR_FDPX; @@ -710,8 +709,6 @@ smsc_stop_locked(struct ifnet *ifp, int struct smsc_softc * const sc = ifp->if_softc; usbd_status err; -// smsc_reset(sc); - KASSERT(mutex_owned(&sc->sc_lock)); mutex_enter(&sc->sc_rxlock); mutex_enter(&sc->sc_txlock); @@ -973,7 +970,6 @@ int smsc_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct smsc_softc *sc = ifp->if_softc; -// struct ifreq /*const*/ *ifr = data; int s, error = 0; if (sc->sc_dying)
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Jan 31 11:41:14 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c if_smscvar.h Log Message: G/C sc_stop_task To generate a diff of this commit: cvs rdiff -u -r1.22.2.20 -r1.22.2.21 src/sys/dev/usb/if_smsc.c cvs rdiff -u -r1.3.4.5 -r1.3.4.6 src/sys/dev/usb/if_smscvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.20 src/sys/dev/usb/if_smsc.c:1.22.2.21 --- src/sys/dev/usb/if_smsc.c:1.22.2.20 Tue Jan 31 11:39:46 2017 +++ src/sys/dev/usb/if_smsc.c Tue Jan 31 11:41:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.20 2017/01/31 11:39:46 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.21 2017/01/31 11:41:14 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -1038,7 +1038,6 @@ smsc_attach(device_t parent, device_t se } /* Setup the endpoints for the SMSC LAN95xx device(s) */ usb_init_task(&sc->sc_tick_task, smsc_tick_task, sc, 0); - usb_init_task(&sc->sc_stop_task, (void (*)(void *))smsc_stop, sc, 0); mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); mutex_init(&sc->sc_txlock, MUTEX_DEFAULT, IPL_SOFTUSB); @@ -1185,7 +1184,6 @@ smsc_detach(device_t self, int flags) * in the same thread as detach. */ usb_rem_task(sc->sc_udev, &sc->sc_tick_task); - usb_rem_task(sc->sc_udev, &sc->sc_stop_task); s = splusb(); Index: src/sys/dev/usb/if_smscvar.h diff -u src/sys/dev/usb/if_smscvar.h:1.3.4.5 src/sys/dev/usb/if_smscvar.h:1.3.4.6 --- src/sys/dev/usb/if_smscvar.h:1.3.4.5 Wed Dec 28 08:53:56 2016 +++ src/sys/dev/usb/if_smscvar.h Tue Jan 31 11:41:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smscvar.h,v 1.3.4.5 2016/12/28 08:53:56 skrll Exp $ */ +/* $NetBSD: if_smscvar.h,v 1.3.4.6 2017/01/31 11:41:14 skrll Exp $ */ /* $OpenBSD: if_smscreg.h,v 1.2 2012/09/27 12:38:11 jsg Exp $ */ /*- @@ -78,7 +78,6 @@ struct smsc_softc { int sc_refcnt; struct usb_task sc_tick_task; - struct usb_task sc_stop_task; int sc_ed[SMSC_ENDPT_MAX]; struct usbd_pipe * sc_ep[SMSC_ENDPT_MAX];
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Jan 31 11:39:46 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: Style / indentation To generate a diff of this commit: cvs rdiff -u -r1.22.2.19 -r1.22.2.20 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.19 src/sys/dev/usb/if_smsc.c:1.22.2.20 --- src/sys/dev/usb/if_smsc.c:1.22.2.19 Tue Jan 31 08:30:38 2017 +++ src/sys/dev/usb/if_smsc.c Tue Jan 31 11:39:46 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.19 2017/01/31 08:30:38 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.20 2017/01/31 11:39:46 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -1116,16 +1116,17 @@ smsc_attach(device_t parent, device_t se KASSERT(prop_data_size(eaprop) == ETHER_ADDR_LEN); memcpy(sc->sc_enaddr, prop_data_data_nocopy(eaprop), ETHER_ADDR_LEN); - } else - /* Check if there is already a MAC address in the register */ - if ((smsc_read_reg(sc, SMSC_MAC_ADDRL, &mac_l) == 0) && - (smsc_read_reg(sc, SMSC_MAC_ADDRH, &mac_h) == 0)) { - sc->sc_enaddr[5] = (uint8_t)((mac_h >> 8) & 0xff); - sc->sc_enaddr[4] = (uint8_t)((mac_h) & 0xff); - sc->sc_enaddr[3] = (uint8_t)((mac_l >> 24) & 0xff); - sc->sc_enaddr[2] = (uint8_t)((mac_l >> 16) & 0xff); - sc->sc_enaddr[1] = (uint8_t)((mac_l >> 8) & 0xff); - sc->sc_enaddr[0] = (uint8_t)((mac_l) & 0xff); + } else { + /* Check if there is already a MAC address in the register */ + if ((smsc_read_reg(sc, SMSC_MAC_ADDRL, &mac_l) == 0) && + (smsc_read_reg(sc, SMSC_MAC_ADDRH, &mac_h) == 0)) { + sc->sc_enaddr[5] = (uint8_t)((mac_h >> 8) & 0xff); + sc->sc_enaddr[4] = (uint8_t)((mac_h) & 0xff); + sc->sc_enaddr[3] = (uint8_t)((mac_l >> 24) & 0xff); + sc->sc_enaddr[2] = (uint8_t)((mac_l >> 16) & 0xff); + sc->sc_enaddr[1] = (uint8_t)((mac_l >> 8) & 0xff); + sc->sc_enaddr[0] = (uint8_t)((mac_l) & 0xff); + } } aprint_normal_dev(self, "Ethernet address %s\n", ether_sprintf(sc->sc_enaddr));
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Jan 31 08:30:38 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: KNF To generate a diff of this commit: cvs rdiff -u -r1.22.2.18 -r1.22.2.19 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.18 src/sys/dev/usb/if_smsc.c:1.22.2.19 --- src/sys/dev/usb/if_smsc.c:1.22.2.18 Wed Dec 28 09:45:16 2016 +++ src/sys/dev/usb/if_smsc.c Tue Jan 31 08:30:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.18 2016/12/28 09:45:16 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.19 2017/01/31 08:30:38 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -67,17 +67,15 @@ #include #include -#include -#include +#include +#include #include #include -#include #include -#include - -#include - #include +#include +#include +#include #include #include
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Jan 31 07:25:34 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: ohci.c Log Message: Sync with HEAD To generate a diff of this commit: cvs rdiff -u -r1.254.2.84 -r1.254.2.85 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.254.2.84 src/sys/dev/usb/ohci.c:1.254.2.85 --- src/sys/dev/usb/ohci.c:1.254.2.84 Wed Dec 28 10:44:27 2016 +++ src/sys/dev/usb/ohci.c Tue Jan 31 07:25:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.254.2.84 2016/12/28 10:44:27 skrll Exp $ */ +/* $NetBSD: ohci.c,v 1.254.2.85 2017/01/31 07:25:34 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.84 2016/12/28 10:44:27 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.85 2017/01/31 07:25:34 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -626,22 +626,24 @@ ohci_reset_std_chain(ohci_softc_t *sc, s KASSERT(next != cur); curlen = 0; - ohci_physaddr_t sdataphys = DMAADDR(dma, curoffs); + const ohci_physaddr_t sdataphys = DMAADDR(dma, curoffs); ohci_physaddr_t edataphys = DMAADDR(dma, curoffs + len - 1); - ohci_physaddr_t sphyspg = OHCI_PAGE(sdataphys); + const ohci_physaddr_t sphyspg = OHCI_PAGE(sdataphys); ohci_physaddr_t ephyspg = OHCI_PAGE(edataphys); /* * The OHCI hardware can handle at most one page * crossing per TD */ curlen = len; - if (!(sphyspg == ephyspg || sphyspg + 1 == ephyspg)) { + if (sphyspg != ephyspg && + sphyspg + OHCI_PAGE_SIZE != ephyspg) { /* must use multiple TDs, fill as much as possible. */ curlen = 2 * OHCI_PAGE_SIZE - - (sdataphys & (OHCI_PAGE_SIZE - 1)); + OHCI_PAGE_OFFSET(sdataphys); /* the length must be a multiple of the max size */ curlen -= curlen % mps; + edataphys = DMAADDR(dma, curoffs + curlen - 1); } KASSERT(curlen != 0); DPRINTFN(4, "sdataphys=0x%08x edataphys=0x%08x "
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 29 15:58:14 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: auvitek_video.c if_run.c slurm.c uark.c uatp.c uberry.c ubsa.c udsir.c uhso.c ukyopon.c usbdi_util.c uslsa.c uyap.c Log Message: KNF To generate a diff of this commit: cvs rdiff -u -r1.6.32.5 -r1.6.32.6 src/sys/dev/usb/auvitek_video.c cvs rdiff -u -r1.10.6.12 -r1.10.6.13 src/sys/dev/usb/if_run.c cvs rdiff -u -r1.1.18.5 -r1.1.18.6 src/sys/dev/usb/slurm.c cvs rdiff -u -r1.6.14.8 -r1.6.14.9 src/sys/dev/usb/uark.c cvs rdiff -u -r1.10.4.8 -r1.10.4.9 src/sys/dev/usb/uatp.c cvs rdiff -u -r1.9.14.5 -r1.9.14.6 src/sys/dev/usb/uberry.c cvs rdiff -u -r1.30.16.9 -r1.30.16.10 src/sys/dev/usb/ubsa.c cvs rdiff -u -r1.1.14.10 -r1.1.14.11 src/sys/dev/usb/udsir.c cvs rdiff -u -r1.17.2.12 -r1.17.2.13 src/sys/dev/usb/uhso.c cvs rdiff -u -r1.16.16.8 -r1.16.16.9 src/sys/dev/usb/ukyopon.c cvs rdiff -u -r1.63.2.14 -r1.63.2.15 src/sys/dev/usb/usbdi_util.c cvs rdiff -u -r1.19.6.6 -r1.19.6.7 src/sys/dev/usb/uslsa.c cvs rdiff -u -r1.19.24.4 -r1.19.24.5 src/sys/dev/usb/uyap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/auvitek_video.c diff -u src/sys/dev/usb/auvitek_video.c:1.6.32.5 src/sys/dev/usb/auvitek_video.c:1.6.32.6 --- src/sys/dev/usb/auvitek_video.c:1.6.32.5 Mon Dec 28 09:26:33 2015 +++ src/sys/dev/usb/auvitek_video.c Sun Jan 29 15:58:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: auvitek_video.c,v 1.6.32.5 2015/12/28 09:26:33 skrll Exp $ */ +/* $NetBSD: auvitek_video.c,v 1.6.32.6 2017/01/29 15:58:14 skrll Exp $ */ /*- * Copyright (c) 2010 Jared D. McNeill @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.6.32.5 2015/12/28 09:26:33 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.6.32.6 2017/01/29 15:58:14 skrll Exp $"); #include #include @@ -134,7 +134,7 @@ auvitek_video_attach(struct auvitek_soft auvitek_video_rescan(sc, NULL, NULL); - return (sc->sc_videodev != NULL); + return sc->sc_videodev != NULL; } int Index: src/sys/dev/usb/if_run.c diff -u src/sys/dev/usb/if_run.c:1.10.6.12 src/sys/dev/usb/if_run.c:1.10.6.13 --- src/sys/dev/usb/if_run.c:1.10.6.12 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_run.c Sun Jan 29 15:58:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_run.c,v 1.10.6.12 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_run.c,v 1.10.6.13 2017/01/29 15:58:14 skrll Exp $ */ /* $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */ /*- @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.10.6.12 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.10.6.13 2017/01/29 15:58:14 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1110,7 +1110,7 @@ run_efuse_read(struct run_softc *sc, uin static int run_efuse_read_2(struct run_softc *sc, uint16_t addr, uint16_t *val) { - return (run_efuse_read(sc, addr, val, 2)); + return run_efuse_read(sc, addr, val, 2); } static int @@ -4100,7 +4100,7 @@ run_rt3593_rf_init(struct run_softc *sc) run_read(sc, RT3070_OPT_14, &tmp); run_write(sc, RT3070_OPT_14, tmp | 1); - return (0); + return 0; } static int @@ -4165,7 +4165,7 @@ run_rt5390_rf_init(struct run_softc *sc) run_read(sc, RT3070_OPT_14, &tmp); run_write(sc, RT3070_OPT_14, tmp | 1); - return (0); + return 0; } static int @@ -4486,7 +4486,7 @@ run_adjust_freq_offset(struct run_softc if (tmp != rf) run_mcu_cmd(sc, 0x74, (tmp << 8 ) | rf); - return (0); + return 0; } static int Index: src/sys/dev/usb/slurm.c diff -u src/sys/dev/usb/slurm.c:1.1.18.5 src/sys/dev/usb/slurm.c:1.1.18.6 --- src/sys/dev/usb/slurm.c:1.1.18.5 Sat Jul 9 20:25:16 2016 +++ src/sys/dev/usb/slurm.c Sun Jan 29 15:58:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: slurm.c,v 1.1.18.5 2016/07/09 20:25:16 skrll Exp $ */ +/* $NetBSD: slurm.c,v 1.1.18.6 2017/01/29 15:58:14 skrll Exp $ */ /* * Copyright (c) 2012 Jonathan A. Kollasch @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: slurm.c,v 1.1.18.5 2016/07/09 20:25:16 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: slurm.c,v 1.1.18.6 2017/01/29 15:58:14 skrll Exp $"); #include #include @@ -156,7 +156,7 @@ slurm_detach(device_t self, int flags) usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); - return (rv); + return rv; } static int Index: src/sys/dev/usb/uark.c diff -u src/sys/dev/usb/uark.c:1.6.14.8 src/sys/dev/usb/uark.c:1.6.14.9 --- src/sys/dev/usb/uark.c:1.6.14.8 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/uark.c Sun Jan 29 15:58:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: uark.c,v 1.6.14.8 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: uark.c,v 1.6.14.9 2017/01/29 15:58:14 skrll Exp $ */ /* $OpenBSD: uark.c,v 1.13 2009/10/13 19:33:17 pirofti Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uark.c,v 1.6.
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 29 11:27:52 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: uyurex.c Log Message: KNF To generate a diff of this commit: cvs rdiff -u -r1.9.14.10 -r1.9.14.11 src/sys/dev/usb/uyurex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uyurex.c diff -u src/sys/dev/usb/uyurex.c:1.9.14.10 src/sys/dev/usb/uyurex.c:1.9.14.11 --- src/sys/dev/usb/uyurex.c:1.9.14.10 Sun Jan 29 09:55:21 2017 +++ src/sys/dev/usb/uyurex.c Sun Jan 29 11:27:52 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: uyurex.c,v 1.9.14.10 2017/01/29 09:55:21 skrll Exp $ */ +/* $NetBSD: uyurex.c,v 1.9.14.11 2017/01/29 11:27:52 skrll Exp $ */ /* $OpenBSD: uyurex.c,v 1.3 2010/03/04 03:47:22 deraadt Exp $ */ /* @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uyurex.c,v 1.9.14.10 2017/01/29 09:55:21 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uyurex.c,v 1.9.14.11 2017/01/29 11:27:52 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -125,7 +125,7 @@ uyurex_match(device_t parent, cfdata_t m if (uyurex_lookup(uha->uiaa->uiaa_vendor, uha->uiaa->uiaa_product) == NULL) return UMATCH_NONE; - return (UMATCH_VENDOR_PRODUCT); + return UMATCH_VENDOR_PRODUCT; } void @@ -224,7 +224,7 @@ uyurex_detach(device_t self, int flags) usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_hdev.sc_dev); - return (rv); + return rv; } int @@ -237,7 +237,7 @@ uyurex_activate(device_t self, enum deva sc->sc_dying = 1; break; } - return (0); + return 0; } void
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 29 10:16:09 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: umass.c umass_isdata.c umass_scsipi.c Log Message: KNF To generate a diff of this commit: cvs rdiff -u -r1.149.2.18 -r1.149.2.19 src/sys/dev/usb/umass.c cvs rdiff -u -r1.30.2.7 -r1.30.2.8 src/sys/dev/usb/umass_isdata.c cvs rdiff -u -r1.49.2.8 -r1.49.2.9 src/sys/dev/usb/umass_scsipi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umass.c diff -u src/sys/dev/usb/umass.c:1.149.2.18 src/sys/dev/usb/umass.c:1.149.2.19 --- src/sys/dev/usb/umass.c:1.149.2.18 Sun Jan 29 10:10:30 2017 +++ src/sys/dev/usb/umass.c Sun Jan 29 10:16:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass.c,v 1.149.2.18 2017/01/29 10:10:30 skrll Exp $ */ +/* $NetBSD: umass.c,v 1.149.2.19 2017/01/29 10:16:09 skrll Exp $ */ /* * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -124,7 +124,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.18 2017/01/29 10:10:30 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.19 2017/01/29 10:16:09 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -135,12 +135,12 @@ __KERNEL_RCSID(0, "$NetBSD: umass.c,v 1. #include "wd.h" #include -#include -#include -#include #include +#include #include +#include #include +#include #include #include Index: src/sys/dev/usb/umass_isdata.c diff -u src/sys/dev/usb/umass_isdata.c:1.30.2.7 src/sys/dev/usb/umass_isdata.c:1.30.2.8 --- src/sys/dev/usb/umass_isdata.c:1.30.2.7 Sun Jan 29 10:10:30 2017 +++ src/sys/dev/usb/umass_isdata.c Sun Jan 29 10:16:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass_isdata.c,v 1.30.2.7 2017/01/29 10:10:30 skrll Exp $ */ +/* $NetBSD: umass_isdata.c,v 1.30.2.8 2017/01/29 10:16:09 skrll Exp $ */ /* * TODO: @@ -37,21 +37,21 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.30.2.7 2017/01/29 10:10:30 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.30.2.8 2017/01/29 10:16:09 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" #endif #include -#include -#include -#include #include +#include #include -#include #include +#include #include +#include +#include #include #include Index: src/sys/dev/usb/umass_scsipi.c diff -u src/sys/dev/usb/umass_scsipi.c:1.49.2.8 src/sys/dev/usb/umass_scsipi.c:1.49.2.9 --- src/sys/dev/usb/umass_scsipi.c:1.49.2.8 Sun Jan 29 10:13:51 2017 +++ src/sys/dev/usb/umass_scsipi.c Sun Jan 29 10:16:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass_scsipi.c,v 1.49.2.8 2017/01/29 10:13:51 skrll Exp $ */ +/* $NetBSD: umass_scsipi.c,v 1.49.2.9 2017/01/29 10:16:09 skrll Exp $ */ /* * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.49.2.8 2017/01/29 10:13:51 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.49.2.9 2017/01/29 10:16:09 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -41,15 +41,16 @@ __KERNEL_RCSID(0, "$NetBSD: umass_scsipi #include "scsibus.h" #include -#include -#include -#include #include #include +#include #include +#include /* XXX */ #include +#include #include #include +#include /* SCSI & ATAPI */ #include @@ -64,7 +65,6 @@ __KERNEL_RCSID(0, "$NetBSD: umass_scsipi #include #include -#include /* XXX */ #include /* XXX */ /* USB */
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 29 10:13:51 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: umass_scsipi.c Log Message: The scsipi layer still uses malloc(9) To generate a diff of this commit: cvs rdiff -u -r1.49.2.7 -r1.49.2.8 src/sys/dev/usb/umass_scsipi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umass_scsipi.c diff -u src/sys/dev/usb/umass_scsipi.c:1.49.2.7 src/sys/dev/usb/umass_scsipi.c:1.49.2.8 --- src/sys/dev/usb/umass_scsipi.c:1.49.2.7 Sun Jan 29 10:10:30 2017 +++ src/sys/dev/usb/umass_scsipi.c Sun Jan 29 10:13:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass_scsipi.c,v 1.49.2.7 2017/01/29 10:10:30 skrll Exp $ */ +/* $NetBSD: umass_scsipi.c,v 1.49.2.8 2017/01/29 10:13:51 skrll Exp $ */ /* * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.49.2.7 2017/01/29 10:10:30 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.49.2.8 2017/01/29 10:13:51 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: umass_scsipi #include #include #include +#include /* SCSI & ATAPI */ #include
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 29 10:10:30 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: umass.c umass_isdata.c umass_scsipi.c Log Message: Convert to kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.149.2.17 -r1.149.2.18 src/sys/dev/usb/umass.c cvs rdiff -u -r1.30.2.6 -r1.30.2.7 src/sys/dev/usb/umass_isdata.c cvs rdiff -u -r1.49.2.6 -r1.49.2.7 src/sys/dev/usb/umass_scsipi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umass.c diff -u src/sys/dev/usb/umass.c:1.149.2.17 src/sys/dev/usb/umass.c:1.149.2.18 --- src/sys/dev/usb/umass.c:1.149.2.17 Sun Jan 29 10:08:38 2017 +++ src/sys/dev/usb/umass.c Sun Jan 29 10:10:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass.c,v 1.149.2.17 2017/01/29 10:08:38 skrll Exp $ */ +/* $NetBSD: umass.c,v 1.149.2.18 2017/01/29 10:10:30 skrll Exp $ */ /* * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -124,7 +124,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.17 2017/01/29 10:08:38 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.18 2017/01/29 10:10:30 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -140,7 +140,6 @@ __KERNEL_RCSID(0, "$NetBSD: umass.c,v 1. #include #include #include -#include #include #include @@ -822,7 +821,7 @@ umass_detach(device_t self, int flags) if (scbus != NULL) { if (scbus->sc_child != NULL) rv = config_detach(scbus->sc_child, flags); - free(scbus, M_DEVBUF); + kmem_free(scbus, sizeof(*scbus)); sc->bus = NULL; } Index: src/sys/dev/usb/umass_isdata.c diff -u src/sys/dev/usb/umass_isdata.c:1.30.2.6 src/sys/dev/usb/umass_isdata.c:1.30.2.7 --- src/sys/dev/usb/umass_isdata.c:1.30.2.6 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/umass_isdata.c Sun Jan 29 10:10:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass_isdata.c,v 1.30.2.6 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: umass_isdata.c,v 1.30.2.7 2017/01/29 10:10:30 skrll Exp $ */ /* * TODO: @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.30.2.6 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.30.2.7 2017/01/29 10:10:30 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: umass_isdata #include #include #include -#include +#include #include #include @@ -188,7 +188,7 @@ umass_isdata_attach(struct umass_softc * struct uisdata_softc *scbus; struct isd200_config *cf; - scbus = malloc(sizeof(*scbus), M_DEVBUF, M_WAITOK | M_ZERO); + scbus = kmem_zalloc(sizeof(*scbus), KM_SLEEP); sc->bus = &scbus->base; cf = &scbus->sc_isd_config; @@ -201,7 +201,7 @@ umass_isdata_attach(struct umass_softc * err = usbd_do_request(sc->sc_udev, &req, cf); if (err) { sc->bus = NULL; - free(scbus, M_DEVBUF); + kmem_free(scbus, sizeof(*scbus)); return EIO; } DPRINTF(("umass_wd_attach info:\n EventNotification=0x%02x " Index: src/sys/dev/usb/umass_scsipi.c diff -u src/sys/dev/usb/umass_scsipi.c:1.49.2.6 src/sys/dev/usb/umass_scsipi.c:1.49.2.7 --- src/sys/dev/usb/umass_scsipi.c:1.49.2.6 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/umass_scsipi.c Sun Jan 29 10:10:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass_scsipi.c,v 1.49.2.6 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: umass_scsipi.c,v 1.49.2.7 2017/01/29 10:10:30 skrll Exp $ */ /* * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.49.2.6 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.49.2.7 2017/01/29 10:10:30 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -49,7 +49,6 @@ __KERNEL_RCSID(0, "$NetBSD: umass_scsipi #include #include #include -#include /* SCSI & ATAPI */ #include @@ -180,7 +179,7 @@ umass_scsipi_setup(struct umass_softc *s { struct umass_scsipi_softc *scbus; - scbus = malloc(sizeof(*scbus), M_DEVBUF, M_WAITOK | M_ZERO); + scbus = kmem_zalloc(sizeof(*scbus), KM_SLEEP); sc->bus = &scbus->base; /* Only use big commands for USB SCSI devices. */
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 29 10:08:38 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: umass.c Log Message: Fix a comment To generate a diff of this commit: cvs rdiff -u -r1.149.2.16 -r1.149.2.17 src/sys/dev/usb/umass.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umass.c diff -u src/sys/dev/usb/umass.c:1.149.2.16 src/sys/dev/usb/umass.c:1.149.2.17 --- src/sys/dev/usb/umass.c:1.149.2.16 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/umass.c Sun Jan 29 10:08:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umass.c,v 1.149.2.16 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: umass.c,v 1.149.2.17 2017/01/29 10:08:38 skrll Exp $ */ /* * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -108,8 +108,8 @@ * umass_*_reset. * * The reason for doing this is a) CAM performs a lot better this way and b) it - * avoids using tsleep from interrupt context (for example after a failed - * transfer). + * avoids sleeping in interrupt context which is prohibited (for example after a + * failed transfer). */ /* @@ -124,7 +124,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.16 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149.2.17 2017/01/29 10:08:38 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h"
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 29 09:55:21 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: uyurex.c Log Message: Another tsleep bites the dust To generate a diff of this commit: cvs rdiff -u -r1.9.14.9 -r1.9.14.10 src/sys/dev/usb/uyurex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uyurex.c diff -u src/sys/dev/usb/uyurex.c:1.9.14.9 src/sys/dev/usb/uyurex.c:1.9.14.10 --- src/sys/dev/usb/uyurex.c:1.9.14.9 Sat Jan 28 10:15:01 2017 +++ src/sys/dev/usb/uyurex.c Sun Jan 29 09:55:21 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: uyurex.c,v 1.9.14.9 2017/01/28 10:15:01 skrll Exp $ */ +/* $NetBSD: uyurex.c,v 1.9.14.10 2017/01/29 09:55:21 skrll Exp $ */ /* $OpenBSD: uyurex.c,v 1.3 2010/03/04 03:47:22 deraadt Exp $ */ /* @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uyurex.c,v 1.9.14.9 2017/01/28 10:15:01 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uyurex.c,v 1.9.14.10 2017/01/29 09:55:21 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -341,7 +341,7 @@ uyurex_set_mode(struct uyurex_softc *sc, } /* wait ack */ - tsleep(&sc->sc_sme, 0, "uyurex", (1000*hz+999)/1000 + 1); + kpause("uyurexsm", false, (1000*hz+999)/1000 + 1, NULL); } void
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Jan 28 12:12:20 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp if_zyd.c if_zydreg.h Log Message: Remove tsleep/wakeup from if_zyd To generate a diff of this commit: cvs rdiff -u -r1.8.4.10 -r1.8.4.11 src/sys/dev/usb/TODO.usbmp cvs rdiff -u -r1.36.14.12 -r1.36.14.13 src/sys/dev/usb/if_zyd.c cvs rdiff -u -r1.7.16.4 -r1.7.16.5 src/sys/dev/usb/if_zydreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.10 src/sys/dev/usb/TODO.usbmp:1.8.4.11 --- src/sys/dev/usb/TODO.usbmp:1.8.4.10 Sat Jan 28 12:04:17 2017 +++ src/sys/dev/usb/TODO.usbmp Sat Jan 28 12:12:19 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.10 2017/01/28 12:04:17 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.11 2017/01/28 12:12:19 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -97,7 +97,6 @@ splusb drivers: wakeup/tsleep drivers: - if_run.c - - if_zyd.c - ucycom.c - udsir.c - uirda.c Index: src/sys/dev/usb/if_zyd.c diff -u src/sys/dev/usb/if_zyd.c:1.36.14.12 src/sys/dev/usb/if_zyd.c:1.36.14.13 --- src/sys/dev/usb/if_zyd.c:1.36.14.12 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_zyd.c Sat Jan 28 12:12:19 2017 @@ -1,5 +1,5 @@ /* $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */ -/* $NetBSD: if_zyd.c,v 1.36.14.12 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_zyd.c,v 1.36.14.13 2017/01/28 12:12:19 skrll Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.36.14.12 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.36.14.13 2017/01/28 12:12:19 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -343,6 +343,8 @@ zyd_attach(device_t parent, device_t sel IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); + mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB); + cv_init(&sc->sc_cmdcv, "zydcmd"); SIMPLEQ_INIT(&sc->sc_rqh); /* defer configrations after file system is ready to load firmware */ @@ -466,12 +468,11 @@ zyd_detach(device_t self, int flags) struct zyd_softc *sc = device_private(self); struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &sc->sc_if; - int s; if (!sc->attached) return 0; - s = splusb(); + mutex_enter(&sc->sc_lock); zyd_stop(ifp, 1); usb_rem_task(sc->sc_udev, &sc->sc_task); @@ -487,7 +488,10 @@ zyd_detach(device_t self, int flags) ieee80211_ifdetach(ic); if_detach(ifp); - splx(s); + mutex_exit(&sc->sc_lock); + + mutex_destroy(&sc->sc_lock); + cv_destroy(&sc->sc_cmdcv); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); @@ -792,7 +796,6 @@ zyd_cmd(struct zyd_softc *sc, uint16_t c uint16_t xferflags; int error; usbd_status uerror; - int s = 0; error = usbd_create_xfer(sc->zyd_ep[ZYD_ENDPT_IOUT], sizeof(uint16_t) + ilen, USBD_FORCE_SHORT_XFER, 0, &xfer); @@ -806,19 +809,18 @@ zyd_cmd(struct zyd_softc *sc, uint16_t c if (!(flags & ZYD_CMD_FLAG_READ)) xferflags |= USBD_SYNCHRONOUS; else { - s = splusb(); rq.idata = idata; rq.odata = odata; rq.len = olen / sizeof(struct zyd_pair); + mutex_enter(&sc->sc_lock); SIMPLEQ_INSERT_TAIL(&sc->sc_rqh, &rq, rq); + mutex_exit(&sc->sc_lock); } usbd_setup_xfer(xfer, 0, &cmd, sizeof(uint16_t) + ilen, xferflags, ZYD_INTR_TIMEOUT, NULL); uerror = usbd_transfer(xfer); if (uerror != USBD_IN_PROGRESS && uerror != 0) { - if (flags & ZYD_CMD_FLAG_READ) - splx(s); printf("%s: could not send command (error=%s)\n", device_xname(sc->sc_dev), usbd_errstr(uerror)); (void)usbd_destroy_xfer(xfer); @@ -829,11 +831,12 @@ zyd_cmd(struct zyd_softc *sc, uint16_t c return 0; /* write: don't wait for reply */ } /* wait at most one second for command reply */ - error = tsleep(odata, PCATCH, "zydcmd", hz); + mutex_enter(&sc->sc_lock); + error = cv_timedwait_sig(&sc->sc_cmdcv, &sc->sc_lock, hz); if (error == EWOULDBLOCK) printf("%s: zyd_read sleep timeout\n", device_xname(sc->sc_dev)); SIMPLEQ_REMOVE(&sc->sc_rqh, &rq, rq, rq); - splx(s); + mutex_exit(&sc->sc_lock); (void)usbd_destroy_xfer(xfer); return error; @@ -1872,6 +1875,7 @@ zyd_intr(struct usbd_xfer *xfer, void * datalen -= sizeof(cmd->code); datalen -= 2; /* XXX: padding? */ + mutex_enter(&sc->sc_lock); SIMPLEQ_FOREACH(rqp, &sc->sc_rqh, rq) { int i; @@ -1888,10 +1892,11 @@ zyd_intr(struct usbd_xfer *xfer, void * /* copy answer into caller-supplied buffer */ memcpy(rqp->odata, cmd->data, sizeof(struct zyd_pair) * rqp->len); - wakeup(rqp->odata); /* wakeup caller */ - + cv_signal(&sc->sc_cmdcv); + mutex_exit(&sc->sc_lock); return; } + mutex_exit(&sc->sc_lock); return; /* unexpected IORD notif
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Jan 28 12:04:17 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp if_urtwn.c if_urtwnvar.h Log Message: Remove tsleep(9) and wakeup(9) from urtwn(4) To generate a diff of this commit: cvs rdiff -u -r1.8.4.9 -r1.8.4.10 src/sys/dev/usb/TODO.usbmp cvs rdiff -u -r1.34.4.15 -r1.34.4.16 src/sys/dev/usb/if_urtwn.c cvs rdiff -u -r1.8.4.4 -r1.8.4.5 src/sys/dev/usb/if_urtwnvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.9 src/sys/dev/usb/TODO.usbmp:1.8.4.10 --- src/sys/dev/usb/TODO.usbmp:1.8.4.9 Sat Jan 28 10:15:01 2017 +++ src/sys/dev/usb/TODO.usbmp Sat Jan 28 12:04:17 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.9 2017/01/28 10:15:01 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.10 2017/01/28 12:04:17 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -97,7 +97,6 @@ splusb drivers: wakeup/tsleep drivers: - if_run.c - - if_urtwn.c - if_zyd.c - ucycom.c - udsir.c Index: src/sys/dev/usb/if_urtwn.c diff -u src/sys/dev/usb/if_urtwn.c:1.34.4.15 src/sys/dev/usb/if_urtwn.c:1.34.4.16 --- src/sys/dev/usb/if_urtwn.c:1.34.4.15 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_urtwn.c Sat Jan 28 12:04:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urtwn.c,v 1.34.4.15 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_urtwn.c,v 1.34.4.16 2017/01/28 12:04:17 skrll Exp $ */ /* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */ /*- @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.34.4.15 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.34.4.16 2017/01/28 12:04:17 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -372,6 +372,7 @@ urtwn_attach(device_t parent, device_t s (void) usbd_do_request(sc->sc_udev, &req, 0); + cv_init(&sc->sc_task_cv, "urtwntsk"); mutex_init(&sc->sc_task_mtx, MUTEX_DEFAULT, IPL_NET); mutex_init(&sc->sc_tx_mtx, MUTEX_DEFAULT, IPL_NONE); mutex_init(&sc->sc_rx_mtx, MUTEX_DEFAULT, IPL_NONE); @@ -559,6 +560,7 @@ urtwn_detach(device_t self, int flags) callout_destroy(&sc->sc_scan_to); callout_destroy(&sc->sc_calib_to); + cv_destroy(&sc->sc_task_cv); mutex_destroy(&sc->sc_write_mtx); mutex_destroy(&sc->sc_fwcmd_mtx); mutex_destroy(&sc->sc_tx_mtx); @@ -823,8 +825,8 @@ urtwn_task(void *arg) ring->queued--; ring->next = (ring->next + 1) % URTWN_HOST_CMD_RING_COUNT; } + cv_broadcast(&sc->sc_task_cv); mutex_spin_exit(&sc->sc_task_mtx); - wakeup(&sc->cmdq); splx(s); } @@ -863,8 +865,10 @@ urtwn_wait_async(struct urtwn_softc *sc) DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); /* Wait for all queued asynchronous commands to complete. */ + mutex_spin_enter(&sc->sc_task_mtx); while (sc->cmdq.queued > 0) - tsleep(&sc->cmdq, 0, "endtask", 0); + cv_wait(&sc->sc_task_cv, &sc->sc_task_mtx); + mutex_spin_exit(&sc->sc_task_mtx); } static int Index: src/sys/dev/usb/if_urtwnvar.h diff -u src/sys/dev/usb/if_urtwnvar.h:1.8.4.4 src/sys/dev/usb/if_urtwnvar.h:1.8.4.5 --- src/sys/dev/usb/if_urtwnvar.h:1.8.4.4 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_urtwnvar.h Sat Jan 28 12:04:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urtwnvar.h,v 1.8.4.4 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_urtwnvar.h,v 1.8.4.5 2017/01/28 12:04:17 skrll Exp $ */ /* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $ */ /*- @@ -128,6 +128,7 @@ struct urtwn_softc { callout_t sc_scan_to; callout_t sc_calib_to; + kcondvar_t sc_task_cv; kmutex_t sc_task_mtx; kmutex_t sc_fwcmd_mtx; kmutex_t sc_tx_mtx;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Jan 28 10:15:01 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp uyurex.c Log Message: Remove tsleep from uyurex(4) To generate a diff of this commit: cvs rdiff -u -r1.8.4.8 -r1.8.4.9 src/sys/dev/usb/TODO.usbmp cvs rdiff -u -r1.9.14.8 -r1.9.14.9 src/sys/dev/usb/uyurex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.8 src/sys/dev/usb/TODO.usbmp:1.8.4.9 --- src/sys/dev/usb/TODO.usbmp:1.8.4.8 Sat Jan 28 10:10:15 2017 +++ src/sys/dev/usb/TODO.usbmp Sat Jan 28 10:15:01 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.8 2017/01/28 10:10:15 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.9 2017/01/28 10:15:01 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -104,7 +104,6 @@ wakeup/tsleep drivers: - uirda.c - umass_isdata.c - ustir.c - - uyurex.c missing D_MPSAFE drivers: - ucycom Index: src/sys/dev/usb/uyurex.c diff -u src/sys/dev/usb/uyurex.c:1.9.14.8 src/sys/dev/usb/uyurex.c:1.9.14.9 --- src/sys/dev/usb/uyurex.c:1.9.14.8 Mon Dec 5 10:55:20 2016 +++ src/sys/dev/usb/uyurex.c Sat Jan 28 10:15:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: uyurex.c,v 1.9.14.8 2016/12/05 10:55:20 skrll Exp $ */ +/* $NetBSD: uyurex.c,v 1.9.14.9 2017/01/28 10:15:01 skrll Exp $ */ /* $OpenBSD: uyurex.c,v 1.3 2010/03/04 03:47:22 deraadt Exp $ */ /* @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uyurex.c,v 1.9.14.8 2016/12/05 10:55:20 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uyurex.c,v 1.9.14.9 2017/01/28 10:15:01 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -359,7 +359,7 @@ uyurex_read_value_request(struct uyurex_ return; /* wait till sensor data are updated, 500ms will be enough */ - tsleep(&sc->sc_sme, 0, "uyurex", (500*hz+999)/1000 + 1); + kpause("uyurexrd", false, (500*hz+999)/1000 + 1, NULL); } void @@ -382,5 +382,5 @@ uyurex_write_value_request(struct uyurex return; /* wait till sensor data are updated, 250ms will be enough */ - tsleep(&sc->sc_sme, 0, "uyurex", (250*hz+999)/1000 + 1); + kpause("uyurexwr", false, (250*hz+999)/1000 + 1, NULL); }
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Jan 28 10:10:15 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp uthum.c Log Message: Remove tsleep from uthum(4) To generate a diff of this commit: cvs rdiff -u -r1.8.4.7 -r1.8.4.8 src/sys/dev/usb/TODO.usbmp cvs rdiff -u -r1.10.14.8 -r1.10.14.9 src/sys/dev/usb/uthum.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.7 src/sys/dev/usb/TODO.usbmp:1.8.4.8 --- src/sys/dev/usb/TODO.usbmp:1.8.4.7 Sat Jan 28 10:05:09 2017 +++ src/sys/dev/usb/TODO.usbmp Sat Jan 28 10:10:15 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.7 2017/01/28 10:05:09 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.8 2017/01/28 10:10:15 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -104,7 +104,6 @@ wakeup/tsleep drivers: - uirda.c - umass_isdata.c - ustir.c - - uthum.c - uyurex.c missing D_MPSAFE drivers: Index: src/sys/dev/usb/uthum.c diff -u src/sys/dev/usb/uthum.c:1.10.14.8 src/sys/dev/usb/uthum.c:1.10.14.9 --- src/sys/dev/usb/uthum.c:1.10.14.8 Mon Dec 5 10:55:20 2016 +++ src/sys/dev/usb/uthum.c Sat Jan 28 10:10:15 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: uthum.c,v 1.10.14.8 2016/12/05 10:55:20 skrll Exp $ */ +/* $NetBSD: uthum.c,v 1.10.14.9 2017/01/28 10:10:15 skrll Exp $ */ /* $OpenBSD: uthum.c,v 1.6 2010/01/03 18:43:02 deraadt Exp $ */ /* @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.10.14.8 2016/12/05 10:55:20 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.10.14.9 2017/01/28 10:10:15 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -294,7 +294,7 @@ uthum_read_data(struct uthum_softc *sc, /* wait if required */ if (need_delay > 1) - tsleep(&sc->sc_sme, 0, "uthum", (need_delay*hz+999)/1000 + 1); + kpause("uthum", false, (need_delay*hz+999)/1000 + 1, NULL); /* get answer */ if (uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT,
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Jan 28 10:05:09 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp ulpt.c Log Message: Remove tsleep from ulpt(4) To generate a diff of this commit: cvs rdiff -u -r1.8.4.6 -r1.8.4.7 src/sys/dev/usb/TODO.usbmp cvs rdiff -u -r1.95.4.11 -r1.95.4.12 src/sys/dev/usb/ulpt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.6 src/sys/dev/usb/TODO.usbmp:1.8.4.7 --- src/sys/dev/usb/TODO.usbmp:1.8.4.6 Sat Jan 28 09:43:28 2017 +++ src/sys/dev/usb/TODO.usbmp Sat Jan 28 10:05:09 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.6 2017/01/28 09:43:28 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.7 2017/01/28 10:05:09 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -103,7 +103,6 @@ wakeup/tsleep drivers: - udsir.c - uirda.c - umass_isdata.c - - ulpt.c - ustir.c - uthum.c - uyurex.c Index: src/sys/dev/usb/ulpt.c diff -u src/sys/dev/usb/ulpt.c:1.95.4.11 src/sys/dev/usb/ulpt.c:1.95.4.12 --- src/sys/dev/usb/ulpt.c:1.95.4.11 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/ulpt.c Sat Jan 28 10:05:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ulpt.c,v 1.95.4.11 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: ulpt.c,v 1.95.4.12 2017/01/28 10:05:09 skrll Exp $ */ /* * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ulpt.c,v 1.95.4.11 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulpt.c,v 1.95.4.12 2017/01/28 10:05:09 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -465,7 +465,7 @@ ulptopen(dev_t dev, int flag, int mode, } /* wait 1/4 second, give up if we get a signal */ - error = tsleep((void *)sc, LPTPRI | PCATCH, "ulptop", STEP); + error = kpause("ulptop", true, STEP, NULL); if (error != EWOULDBLOCK) { sc->sc_state = 0; goto done; @@ -704,7 +704,7 @@ ulpt_do_read(struct ulpt_softc *sc, stru } /* - * XXX Even with the short timeout, this will tsleep, + * XXX Even with the short timeout, this will sleep, * but it should be adequately prompt in practice. */ n = nreq; @@ -748,7 +748,7 @@ ulpt_do_read(struct ulpt_softc *sc, stru case USBD_INTERRUPTED: /* - * The tsleep in usbd_bulk_transfer was + * The sleep in usbd_bulk_transfer was * interrupted. Reflect it to the caller so * that reading can be interrupted. */
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Jan 28 09:43:28 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp uvscom.c Log Message: Remove tsleep from uvscom(4) To generate a diff of this commit: cvs rdiff -u -r1.8.4.5 -r1.8.4.6 src/sys/dev/usb/TODO.usbmp cvs rdiff -u -r1.28.16.9 -r1.28.16.10 src/sys/dev/usb/uvscom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.5 src/sys/dev/usb/TODO.usbmp:1.8.4.6 --- src/sys/dev/usb/TODO.usbmp:1.8.4.5 Wed Dec 14 22:09:21 2016 +++ src/sys/dev/usb/TODO.usbmp Sat Jan 28 09:43:28 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.5 2016/12/14 22:09:21 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.6 2017/01/28 09:43:28 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -106,7 +106,6 @@ wakeup/tsleep drivers: - ulpt.c - ustir.c - uthum.c - - uvscom.c - uyurex.c missing D_MPSAFE drivers: Index: src/sys/dev/usb/uvscom.c diff -u src/sys/dev/usb/uvscom.c:1.28.16.9 src/sys/dev/usb/uvscom.c:1.28.16.10 --- src/sys/dev/usb/uvscom.c:1.28.16.9 Mon Dec 5 10:55:20 2016 +++ src/sys/dev/usb/uvscom.c Sat Jan 28 09:43:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: uvscom.c,v 1.28.16.9 2016/12/05 10:55:20 skrll Exp $ */ +/* $NetBSD: uvscom.c,v 1.28.16.10 2017/01/28 09:43:28 skrll Exp $ */ /*- * Copyright (c) 2001-2002, Shunsuke Akiyama . * All rights reserved. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvscom.c,v 1.28.16.9 2016/12/05 10:55:20 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvscom.c,v 1.28.16.10 2017/01/28 09:43:28 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -759,7 +759,7 @@ uvscom_open(void *addr, int portno) /* unit is not ready */ for (i = UVSCOM_UNIT_WAIT; i > 0; --i) { - tsleep(&err, TTIPRI, "uvsop", hz); /* XXX */ + kpause("uvsopen", false, hz, NULL); if (ISSET(sc->sc_usr, UVSCOM_USTAT_MASK)) break; }
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Jan 26 12:40:16 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: if_url.c if_urndis.c if_urndisreg.h Log Message: consistent softc member name prefix To generate a diff of this commit: cvs rdiff -u -r1.48.4.11 -r1.48.4.12 src/sys/dev/usb/if_url.c cvs rdiff -u -r1.9.4.14 -r1.9.4.15 src/sys/dev/usb/if_urndis.c cvs rdiff -u -r1.1.32.4 -r1.1.32.5 src/sys/dev/usb/if_urndisreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_url.c diff -u src/sys/dev/usb/if_url.c:1.48.4.11 src/sys/dev/usb/if_url.c:1.48.4.12 --- src/sys/dev/usb/if_url.c:1.48.4.11 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_url.c Thu Jan 26 12:40:16 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_url.c,v 1.48.4.11 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_url.c,v 1.48.4.12 2017/01/26 12:40:16 skrll Exp $ */ /* * Copyright (c) 2001, 2002 @@ -44,7 +44,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.48.4.11 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.48.4.12 2017/01/26 12:40:16 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -192,7 +192,7 @@ url_attach(device_t parent, device_t sel struct ifnet *ifp; struct mii_data *mii; u_char eaddr[ETHER_ADDR_LEN]; - int i, s; + int i; sc->sc_dev = self; @@ -256,8 +256,6 @@ url_attach(device_t parent, device_t sel goto bad; } - s = splnet(); - /* reset the adapter */ url_reset(sc); @@ -266,7 +264,6 @@ url_attach(device_t parent, device_t sel ETHER_ADDR_LEN); if (err) { aprint_error_dev(self, "read MAC address failed\n"); - splx(s); goto bad; } @@ -321,7 +318,6 @@ url_attach(device_t parent, device_t sel callout_init(&sc->sc_stat_ch, 0); sc->sc_attached = 1; - splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, dev, sc->sc_dev); Index: src/sys/dev/usb/if_urndis.c diff -u src/sys/dev/usb/if_urndis.c:1.9.4.14 src/sys/dev/usb/if_urndis.c:1.9.4.15 --- src/sys/dev/usb/if_urndis.c:1.9.4.14 Thu Dec 29 08:04:08 2016 +++ src/sys/dev/usb/if_urndis.c Thu Jan 26 12:40:16 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urndis.c,v 1.9.4.14 2016/12/29 08:04:08 skrll Exp $ */ +/* $NetBSD: if_urndis.c,v 1.9.4.15 2017/01/26 12:40:16 skrll Exp $ */ /* $OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */ /* @@ -21,7 +21,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.9.4.14 2016/12/29 08:04:08 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.9.4.15 2017/01/26 12:40:16 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1046,9 +1046,9 @@ urndis_init(struct ifnet *ifp) { struct urndis_softc *sc = ifp->if_softc; - mutex_enter(&sc->urndis_lock); + mutex_enter(&sc->sc_lock); int ret = urndis_init_locked(ifp); - mutex_exit(&sc->urndis_lock); + mutex_exit(&sc->sc_lock); return ret; } @@ -1130,9 +1130,9 @@ urndis_stop(struct ifnet *ifp) { struct urndis_softc *sc = ifp->if_softc; - mutex_enter(&sc->urndis_lock); + mutex_enter(&sc->sc_lock); urndis_stop_locked(ifp); - mutex_exit(&sc->urndis_lock); + mutex_exit(&sc->sc_lock); } static void @@ -1188,9 +1188,9 @@ urndis_start(struct ifnet *ifp) struct urndis_softc *sc = ifp->if_softc; KASSERT(ifp->if_extflags & IFEF_START_MPSAFE); - mutex_enter(&sc->urndis_txlock); + mutex_enter(&sc->sc_txlock); urndis_start_locked(ifp); - mutex_exit(&sc->urndis_txlock); + mutex_exit(&sc->sc_txlock); } static void @@ -1476,9 +1476,9 @@ urndis_attach(device_t parent, device_t return; found: - mutex_init(&sc->urndis_lock, MUTEX_DEFAULT, IPL_NONE); - mutex_init(&sc->urndis_txlock, MUTEX_DEFAULT, IPL_SOFTUSB); - mutex_init(&sc->urndis_rxlock, MUTEX_DEFAULT, IPL_SOFTUSB); + mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&sc->sc_txlock, MUTEX_DEFAULT, IPL_SOFTUSB); + mutex_init(&sc->sc_rxlock, MUTEX_DEFAULT, IPL_SOFTUSB); ifp = GET_IFP(sc); ifp->if_softc = sc; @@ -1537,9 +1537,9 @@ found: return; fail: - mutex_destroy(&sc->urndis_lock); - mutex_destroy(&sc->urndis_txlock); - mutex_destroy(&sc->urndis_rxlock); + mutex_destroy(&sc->sc_lock); + mutex_destroy(&sc->sc_txlock); + mutex_destroy(&sc->sc_rxlock); } static int @@ -1568,9 +1568,9 @@ urndis_detach(device_t self, int flags) urndis_stop(ifp); - mutex_destroy(&sc->urndis_rxlock); - mutex_destroy(&sc->urndis_txlock); - mutex_destroy(&sc->urndis_lock); + mutex_destroy(&sc->sc_rxlock); + mutex_destroy(&sc->sc_txlock); + mutex_destroy(&sc->sc_lock); sc->sc_attached = 0; Index: src/sys/dev/usb/if_urndisreg.h diff -u src/sys/dev/usb/if_urndisreg.h:1.1.32.4 src/sys/dev/usb/if_urndisreg.h:1.1.32.5 --- src/sys/dev/usb/if_urndisreg.h:1.1.32.4 Wed Dec 28 08:55:20 2016 +++ src/sys/dev/usb/if_urndisreg.h Thu Jan 26 12:40:16 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urndisreg.h,v 1.1.32.4 2016/12/28 08:55:20 skrll Exp $ */ +/* $NetBSD: if_
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Jan 3 12:50:51 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: usb.c usb.h usb_subr.c usbdivar.h xhci.c Log Message: Improve handling of roothub device and free up a bus address for LS/FS/HS controllers. To generate a diff of this commit: cvs rdiff -u -r1.156.2.16 -r1.156.2.17 src/sys/dev/usb/usb.c cvs rdiff -u -r1.111.2.11 -r1.111.2.12 src/sys/dev/usb/usb.h cvs rdiff -u -r1.198.2.38 -r1.198.2.39 src/sys/dev/usb/usb_subr.c cvs rdiff -u -r1.109.2.27 -r1.109.2.28 src/sys/dev/usb/usbdivar.h cvs rdiff -u -r1.28.2.83 -r1.28.2.84 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb.c diff -u src/sys/dev/usb/usb.c:1.156.2.16 src/sys/dev/usb/usb.c:1.156.2.17 --- src/sys/dev/usb/usb.c:1.156.2.16 Sun Jan 1 14:56:25 2017 +++ src/sys/dev/usb/usb.c Tue Jan 3 12:50:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: usb.c,v 1.156.2.16 2017/01/01 14:56:25 skrll Exp $ */ +/* $NetBSD: usb.c,v 1.156.2.17 2017/01/03 12:50:50 skrll Exp $ */ /* * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.156.2.16 2017/01/01 14:56:25 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.156.2.17 2017/01/03 12:50:50 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -727,8 +727,12 @@ usbioctl(dev_t devt, u_long cmd, void *d error = EINVAL; goto fail; } - if (addr < 0 || addr >= USB_MAX_DEVICES || - sc->sc_bus->ub_devices[addr] == NULL) { + if (addr < 0 || addr >= USB_MAX_DEVICES) { + error = EINVAL; + goto fail; + } + size_t dindex = usb_addr2dindex(addr); + if (sc->sc_bus->ub_devices[dindex] == NULL) { error = EINVAL; goto fail; } @@ -750,7 +754,7 @@ usbioctl(dev_t devt, u_long cmd, void *d goto ret; } } - err = usbd_do_request_flags(sc->sc_bus->ub_devices[addr], + err = usbd_do_request_flags(sc->sc_bus->ub_devices[dindex], &ur->ucr_request, ptr, ur->ucr_flags, &ur->ucr_actlen, USBD_DEFAULT_TIMEOUT); if (err) { @@ -783,7 +787,8 @@ usbioctl(dev_t devt, u_long cmd, void *d error = EINVAL; goto fail; } - if ((dev = sc->sc_bus->ub_devices[addr]) == NULL) { + size_t dindex = usb_addr2dindex(addr); + if ((dev = sc->sc_bus->ub_devices[dindex]) == NULL) { error = ENXIO; goto fail; } @@ -802,7 +807,8 @@ usbioctl(dev_t devt, u_long cmd, void *d error = EINVAL; goto fail; } - if ((dev = sc->sc_bus->ub_devices[addr]) == NULL) { + size_t dindex = usb_addr2dindex(addr); + if ((dev = sc->sc_bus->ub_devices[dindex]) == NULL) { error = ENXIO; goto fail; } Index: src/sys/dev/usb/usb.h diff -u src/sys/dev/usb/usb.h:1.111.2.11 src/sys/dev/usb/usb.h:1.111.2.12 --- src/sys/dev/usb/usb.h:1.111.2.11 Mon Jan 2 16:55:50 2017 +++ src/sys/dev/usb/usb.h Tue Jan 3 12:50:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: usb.h,v 1.111.2.11 2017/01/02 16:55:50 skrll Exp $ */ +/* $NetBSD: usb.h,v 1.111.2.12 2017/01/03 12:50:50 skrll Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -53,9 +53,9 @@ #define USB_STACK_VERSION 2 -#define USB_MAX_DEVICES (128 + 1) /* 0, root, and 1->127 */ -#define USB_MIN_DEVICES 2 /* unused + root HUB */ -#define USB_START_ADDR 0 +#define USB_MAX_DEVICES 128 /* 0, 1-127 */ +#define USB_MIN_DEVICES 2 /* unused + root HUB */ +#define USB_START_ADDR 0 #define USB_CONTROL_ENDPOINT 0 #define USB_MAX_ENDPOINTS 16 Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.198.2.38 src/sys/dev/usb/usb_subr.c:1.198.2.39 --- src/sys/dev/usb/usb_subr.c:1.198.2.38 Thu Dec 29 08:40:27 2016 +++ src/sys/dev/usb/usb_subr.c Tue Jan 3 12:50:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.198.2.38 2016/12/29 08:40:27 skrll Exp $ */ +/* $NetBSD: usb_subr.c,v 1.198.2.39 2017/01/03 12:50:50 skrll Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.38 2016/12/29 08:40:27 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.39 2017/01/03 12:50:50 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -832,9 +832,11 @@ usbd_getnewaddr(struct usbd_bus *bus) { int addr; - for (addr = 1; addr < USB_MAX_DEVICES; addr++) - if (bus->ub_devices[addr] == NULL) + for (addr = 1; addr < USB_MAX_DEVICES; addr++) { + size_t dindex = usb_addr2dindex(addr); + if (bus->ub_devices[dindex] == NULL) return addr; + } return -1; } @@ -1336,7 +1338,7 @@ usbd_new_device(device_t parent, struct /* Allow device time to set new address */ usbd_delay_ms(dev, USB_SET_ADDRESS_SETTLE); dev->ud_addr = addr; /* new device address now */ - bus->ub_devices[addr] = dev; + bus->ub_devices[usb_addr2dindex(addr)] = dev; /* Re-establish th
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Jan 2 16:54:15 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: xhci.c Log Message: Use %s for __func__... oops To generate a diff of this commit: cvs rdiff -u -r1.28.2.81 -r1.28.2.82 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.28.2.81 src/sys/dev/usb/xhci.c:1.28.2.82 --- src/sys/dev/usb/xhci.c:1.28.2.81 Mon Jan 2 16:45:30 2017 +++ src/sys/dev/usb/xhci.c Mon Jan 2 16:54:15 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.28.2.81 2017/01/02 16:45:30 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.28.2.82 2017/01/02 16:54:15 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.81 2017/01/02 16:45:30 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.82 2017/01/02 16:54:15 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2996,7 +2996,7 @@ xhci_setup_route(struct usbd_pipe *pipe, goto found; } } - panic("%d: cannot find HS port", __func__); + panic("%s: cannot find HS port", __func__); found: DPRINTFN(4, "high speed port %d", p, 0, 0, 0); } else {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Jan 2 16:45:30 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: xhci.c Log Message: Use __func__ in panic message To generate a diff of this commit: cvs rdiff -u -r1.28.2.80 -r1.28.2.81 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.28.2.80 src/sys/dev/usb/xhci.c:1.28.2.81 --- src/sys/dev/usb/xhci.c:1.28.2.80 Mon Jan 2 16:34:40 2017 +++ src/sys/dev/usb/xhci.c Mon Jan 2 16:45:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.28.2.80 2017/01/02 16:34:40 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.28.2.81 2017/01/02 16:45:30 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.80 2017/01/02 16:34:40 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.81 2017/01/02 16:45:30 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2996,7 +2996,7 @@ xhci_setup_route(struct usbd_pipe *pipe, goto found; } } - panic("xhci_setup_route: cannot find HS port"); + panic("%d: cannot find HS port", __func__); found: DPRINTFN(4, "high speed port %d", p, 0, 0, 0); } else {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Jan 2 16:34:40 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: xhci.c Log Message: Actually print the bus root hub device in debug output To generate a diff of this commit: cvs rdiff -u -r1.28.2.79 -r1.28.2.80 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.28.2.79 src/sys/dev/usb/xhci.c:1.28.2.80 --- src/sys/dev/usb/xhci.c:1.28.2.79 Mon Jan 2 16:32:23 2017 +++ src/sys/dev/usb/xhci.c Mon Jan 2 16:34:40 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.28.2.79 2017/01/02 16:32:23 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.28.2.80 2017/01/02 16:34:40 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.79 2017/01/02 16:32:23 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.80 2017/01/02 16:34:40 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2299,7 +2299,7 @@ xhci_new_device(device_t parent, struct if (depth == 0 && port == 0) { usbd_attach_roothub(parent, dev); - DPRINTFN(1, "root_hub %p", bus->ub_roothub, 0, 0, 0); + DPRINTFN(1, "root hub %p", dev, 0, 0, 0); return USBD_NORMAL_COMPLETION; }
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Jan 2 16:39:37 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: xhcireg.h Log Message: Use lower case for hex constants. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.2.2.8 -r1.2.2.9 src/sys/dev/usb/xhcireg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhcireg.h diff -u src/sys/dev/usb/xhcireg.h:1.2.2.8 src/sys/dev/usb/xhcireg.h:1.2.2.9 --- src/sys/dev/usb/xhcireg.h:1.2.2.8 Wed Oct 5 20:55:59 2016 +++ src/sys/dev/usb/xhcireg.h Mon Jan 2 16:39:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: xhcireg.h,v 1.2.2.8 2016/10/05 20:55:59 skrll Exp $ */ +/* $NetBSD: xhcireg.h,v 1.2.2.9 2017/01/02 16:39:36 skrll Exp $ */ /*- * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. @@ -38,10 +38,10 @@ #define PCI_XHCI_FLADJ 0x61 /* RW frame length adjust */ -#define PCI_XHCI_INTEL_XUSB2PR 0xD0/* Intel USB2 Port Routing */ -#define PCI_XHCI_INTEL_USB2PRM 0xD4/* Intel USB2 Port Routing Mask */ -#define PCI_XHCI_INTEL_USB3_PSSEN 0xD8 /* Intel USB3 Port SuperSpeed Enable */ -#define PCI_XHCI_INTEL_USB3PRM 0xDC/* Intel USB3 Port Routing Mask */ +#define PCI_XHCI_INTEL_XUSB2PR 0xd0/* Intel USB2 Port Routing */ +#define PCI_XHCI_INTEL_USB2PRM 0xd4/* Intel USB2 Port Routing Mask */ +#define PCI_XHCI_INTEL_USB3_PSSEN 0xd8 /* Intel USB3 Port SuperSpeed Enable */ +#define PCI_XHCI_INTEL_USB3PRM 0xdc/* Intel USB3 Port Routing Mask */ /* XHCI capability registers */ #define XHCI_CAPLENGTH 0x00 /* RO capability */ @@ -66,7 +66,7 @@ (__SHIFTOUT((x), XHCI_HCS2_SPBUFHI) << 5) | \ (__SHIFTOUT((x), XHCI_HCS2_SPBUFLO)) -#define XHCI_HCSPARAMS3 0x0C /* RO structual parameters 3 */ +#define XHCI_HCSPARAMS3 0x0c /* RO structual parameters 3 */ #define XHCI_HCS3_U1_DEL(x) ((x) & 0xFF) #define XHCI_HCS3_U2_DEL(x) (((x) >> 16) & 0x) @@ -132,14 +132,14 @@ #define XHCI_CRCR_LO_CRR 0x0008 /* RW - command ring running */ #define XHCI_CRCR_LO_MASK 0x000F -#define XHCI_CRCR_HI 0x1C /* XHCI command ring control */ +#define XHCI_CRCR_HI 0x1c /* XHCI command ring control */ #define XHCI_DCBAAP 0x30 /* XHCI dev context BA pointer */ #define XHCI_DCBAAP_HI 0x34 /* XHCI dev context BA pointer */ #define XHCI_CONFIG 0x38 #define XHCI_CONFIG_SLOTS_MASK 0x00FF /* RW - number of device slots enabled */ /* XHCI port status registers */ -#define XHCI_PORTSC(n) (0x3F0 + (0x10 * (n))) /* XHCI port status */ +#define XHCI_PORTSC(n) (0x3f0 + (0x10 * (n))) /* XHCI port status */ #define XHCI_PS_CCS 0x0001 /* RO - current connect status */ #define XHCI_PS_PED 0x0002 /* RW - port enabled / disabled */ #define XHCI_PS_OCA 0x0008 /* RO - over current active */ @@ -170,7 +170,7 @@ #define XHCI_PS_WPR 0x8000U /* RW - warm port reset */ #define XHCI_PS_CLEAR 0x80FF01FFU /* command bits */ -#define XHCI_PORTPMSC(n) (0x3F4 + (0x10 * (n))) /* XHCI status and control */ +#define XHCI_PORTPMSC(n) (0x3f4 + (0x10 * (n))) /* XHCI status and control */ #define XHCI_PM3_U1TO_GET(x) (((x) >> 0) & 0xFF) /* RW - U1 timeout */ #define XHCI_PM3_U1TO_SET(x) (((x) & 0xFF) << 0) /* RW - U1 timeout */ #define XHCI_PM3_U2TO_GET(x) (((x) >> 8) & 0xFF) /* RW - U2 timeout */ @@ -184,10 +184,10 @@ #define XHCI_PM2_L1SLOT_SET(x) (((x) & 0xFF) << 8) /* RW - L1 device slot */ #define XHCI_PM2_HLE 0x0001 /* RW - hardware LPM enable */ -#define XHCI_PORTLI(n) (0x3F8 + (0x10 * (n))) /* XHCI port link info */ +#define XHCI_PORTLI(n) (0x3f8 + (0x10 * (n))) /* XHCI port link info */ #define XHCI_PLI3_ERR_GET(x) (((x) >> 0) & 0x) /* RO - port link errors */ -#define XHCI_PORTRSV(n) (0x3FC + (0x10 * (n))) /* XHCI port reserved */ +#define XHCI_PORTRSV(n) (0x3fc + (0x10 * (n))) /* XHCI port reserved */ /* XHCI runtime registers. Offset given by XHCI_CAPLENGTH + XHCI_RTSOFF registers */ #define XHCI_MFINDEX 0x /* RO - microframe index */
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Jan 2 16:32:23 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: xhci.c Log Message: Remove unnecessary brackets To generate a diff of this commit: cvs rdiff -u -r1.28.2.78 -r1.28.2.79 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.28.2.78 src/sys/dev/usb/xhci.c:1.28.2.79 --- src/sys/dev/usb/xhci.c:1.28.2.78 Thu Dec 29 09:52:00 2016 +++ src/sys/dev/usb/xhci.c Mon Jan 2 16:32:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.28.2.78 2016/12/29 09:52:00 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.28.2.79 2017/01/02 16:32:23 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.78 2016/12/29 09:52:00 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.79 2017/01/02 16:32:23 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2184,7 +2184,7 @@ xhci_new_device(device_t parent, struct dd = &dev->ud_ddesc; - if ((depth == 0) && (port == 0)) { + if (depth == 0 && port == 0) { KASSERT(bus->ub_devices[dev->ud_addr] == NULL); bus->ub_devices[dev->ud_addr] = dev; err = usbd_get_initial_ddesc(dev, dd); @@ -2297,7 +2297,7 @@ xhci_new_device(device_t parent, struct usbd_add_dev_event(USB_EVENT_DEVICE_ATTACH, dev); - if ((depth == 0) && (port == 0)) { + if (depth == 0 && port == 0) { usbd_attach_roothub(parent, dev); DPRINTFN(1, "root_hub %p", bus->ub_roothub, 0, 0, 0); return USBD_NORMAL_COMPLETION;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 1 14:56:25 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: usb.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.156.2.15 -r1.156.2.16 src/sys/dev/usb/usb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb.c diff -u src/sys/dev/usb/usb.c:1.156.2.15 src/sys/dev/usb/usb.c:1.156.2.16 --- src/sys/dev/usb/usb.c:1.156.2.15 Thu Dec 29 08:36:46 2016 +++ src/sys/dev/usb/usb.c Sun Jan 1 14:56:25 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: usb.c,v 1.156.2.15 2016/12/29 08:36:46 skrll Exp $ */ +/* $NetBSD: usb.c,v 1.156.2.16 2017/01/01 14:56:25 skrll Exp $ */ /* * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.156.2.15 2016/12/29 08:36:46 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.156.2.16 2017/01/01 14:56:25 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -343,7 +343,7 @@ usb_doattach(device_t self) usb_add_event(USB_EVENT_CTRLR_ATTACH, ue); err = usbd_new_device(self, sc->sc_bus, 0, speed, 0, - &sc->sc_port); + &sc->sc_port); if (!err) { dev = sc->sc_port.up_dev; if (dev->ud_hub == NULL) {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Jan 1 14:21:44 UTC 2017 Modified Files: src/sys/dev/usb [nick-nhusb]: usbroothub.c usbroothub.h Log Message: Some initial USB 3 roothub support To generate a diff of this commit: cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/sys/dev/usb/usbroothub.c cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/dev/usb/usbroothub.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbroothub.c diff -u src/sys/dev/usb/usbroothub.c:1.1.2.7 src/sys/dev/usb/usbroothub.c:1.1.2.8 --- src/sys/dev/usb/usbroothub.c:1.1.2.7 Mon Dec 28 22:35:19 2015 +++ src/sys/dev/usb/usbroothub.c Sun Jan 1 14:21:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: usbroothub.c,v 1.1.2.7 2015/12/28 22:35:19 skrll Exp $ */ +/* $NetBSD: usbroothub.c,v 1.1.2.8 2017/01/01 14:21:44 skrll Exp $ */ /*- * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc. @@ -169,6 +169,24 @@ static const struct usb_roothub_descript }, }; +/* USB 3.0 10.15.1 */ +static const usb_device_descriptor_t usbroothub_devd3 = { + .bLength = sizeof(usb_device_descriptor_t), + .bDescriptorType = UDESC_DEVICE, + .bcdUSB = {0x00, 0x03}, + .bDeviceClass = UDCLASS_HUB, + .bDeviceSubClass = UDSUBCLASS_HUB, + .bDeviceProtocol = UDPROTO_SSHUB, + .bMaxPacketSize = 9, + .idVendor = {0}, + .idProduct = {0}, + .bcdDevice = {0x00, 0x01}, + .iManufacturer = 1, + .iProduct = 2, + .iSerialNumber = 0, + .bNumConfigurations = 1 +}; + static const usb_device_descriptor_t usbroothub_devd2 = { .bLength = sizeof(usb_device_descriptor_t), .bDescriptorType = UDESC_DEVICE, @@ -229,6 +247,82 @@ static const struct usb_roothub_descript }, }; +static const struct usb3_roothub_descriptors usbroothub_confd3 = { + .urh_confd = { + .bLength = USB_CONFIG_DESCRIPTOR_SIZE, + .bDescriptorType = UDESC_CONFIG, + .wTotalLength = USETWD(sizeof(usbroothub_confd3)), + .bNumInterface = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = UC_SELF_POWERED, /* 10.13.1 */ + .bMaxPower = 0, + }, + .urh_ifcd = { + .bLength = USB_INTERFACE_DESCRIPTOR_SIZE, + .bDescriptorType = UDESC_INTERFACE, + .bInterfaceNumber = 0, + .bAlternateSetting = 0, + .bNumEndpoints = 1, + .bInterfaceClass = UICLASS_HUB, + .bInterfaceSubClass = UISUBCLASS_HUB, + .bInterfaceProtocol = 0, /* UIPROTO_SSHUB ??? */ + .iInterface = 0 + }, + .urh_endpd = { + .bLength = USB_ENDPOINT_DESCRIPTOR_SIZE, + .bDescriptorType = UDESC_ENDPOINT, + .bEndpointAddress = UE_DIR_IN | USBROOTHUB_INTR_ENDPT, + .bmAttributes = UE_INTERRUPT, + .wMaxPacketSize = USETWD(2), /* max packet */ + .bInterval = 8, + }, + .urh_endpssd = { + .bLength = USB_ENDPOINT_SS_COMP_DESCRIPTOR_SIZE, + .bDescriptorType = UDESC_ENDPOINT_SS_COMP, + .bMaxBurst = 0, + .bmAttributes = 0, + .wBytesPerInterval = USETWD(2) + }, +}; + +static const struct usb3_roothub_bos_descriptors usbroothub_bosd3 = { + .urh_bosd = { + .bLength = USB_BOS_DESCRIPTOR_SIZE, + .bDescriptorType = UDESC_BOS, + .wTotalLength = USETWD(sizeof(usbroothub_bosd3)), + .bNumDeviceCaps = 3, + }, + /* 9.6.2.1 USB 2.0 Extension */ + .urh_usb2extd = { + .bLength = USB_DEVCAP_USB2EXT_DESCRIPTOR_SIZE, + .bDescriptorType = 1, + .bDevCapabilityType = 2, + .bmAttributes[0] = 2, + }, + /* 9.6.2.2 Superspeed device capability */ + .urh_ssd = { + .bLength = USB_DEVCAP_SS_DESCRIPTOR_SIZE, + .bDescriptorType = UDESC_DEVICE_CAPABILITY, + .bDevCapabilityType = USB_DEVCAP_SUPER_SPEED, + .bmAttributes = 0, /* USB_DEVCAP_SS_LTM */ + .wSpeedsSupported = USETWD( + USB_DEVCAP_SS_SPEED_LS | USB_DEVCAP_SS_SPEED_FS | + USB_DEVCAP_SS_SPEED_HS | USB_DEVCAP_SS_SPEED_SS), + .bFunctionalitySupport = 8, /* SS is 3, i.e. 1 << 3? */ + .bU1DevExitLat = 255, /* Dummy... 0? */ + .wU2DevExitLat = USETWD(8), /* Also dummy... 0? */ + }, + /* 9.6.2.3 Container ID - see RFC 4122 */ + .urh_containerd = { + .bLength = USB_DEVCAP_CONTAINER_ID_DESCRIPTOR_SIZE, + .bDescriptorType = 1, + .bDevCapabilityType = 4, + .bReserved = 0, + // ContainerID will be zero + }, +}; + static const usb_hub_descriptor_t usbroothub_hubd = { .bDescLength = USB_HUB_DESCRIPTOR_SIZE, .bDescriptorType = UDESC_HUB, @@ -310,7 +404,10 @@ roothub_ctrl_start(struct usbd_xfer *xfe break; switch (value) { case C(0, UDESC_DEVICE): - if (bus->ub_revision == USBREV_2_0) { + if (bus->ub_revision >= USBREV_3_0) { +buflen = min(len, sizeof(usbroothub_devd3)); +memcpy(buf, &usbroothub_devd3, buflen); + } else if (bus->ub_revision == USBREV_2_0) { buflen = min(len, sizeof(usbroothub_devd2)); memcpy(buf, &usbroothub_devd2, buflen); } else { @@ -319,7 +416,10 @@ roothub_ctrl_start(struct usbd_xfer *xfe } break; case C(0, UDESC_CONFIG): - if (bus->ub_revision == USBREV_2_0) { + if (bus->ub_revision >= USBREV_3_0) { +buflen = min(len, sizeof(usbroothub_confd3)); +memcpy(buf, &usbroothub_confd3, bu
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Dec 29 09:52:00 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: xhci.c Log Message: Mark device transfers as USBD_IN_PROGRESS appropriately and improve abort handling To generate a diff of this commit: cvs rdiff -u -r1.28.2.77 -r1.28.2.78 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.28.2.77 src/sys/dev/usb/xhci.c:1.28.2.78 --- src/sys/dev/usb/xhci.c:1.28.2.77 Wed Oct 5 20:55:59 2016 +++ src/sys/dev/usb/xhci.c Thu Dec 29 09:52:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.28.2.77 2016/10/05 20:55:59 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.28.2.78 2016/12/29 09:52:00 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.77 2016/10/05 20:55:59 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.78 2016/12/29 09:52:00 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1560,12 +1560,13 @@ xhci_abort_xfer(struct usbd_xfer *xfer, xfer, xfer->ux_pipe, status, 0); KASSERT(mutex_owned(&sc->sc_lock)); + ASSERT_SLEEPABLE(); if (sc->sc_dying) { /* If we're dying, just do the software part. */ DPRINTFN(4, "xfer %p dying %u", xfer, xfer->ux_status, 0, 0); xfer->ux_status = status; - callout_stop(&xfer->ux_callout); + callout_halt(&xfer->ux_callout, &sc->sc_lock); usb_transfer_complete(xfer); return; } @@ -1592,10 +1593,16 @@ xhci_abort_xfer(struct usbd_xfer *xfer, xfer->ux_hcflags |= UXFER_ABORTING; /* - * Step 1: Stop xfer timeout timer. + * Step 1: When cancelling a transfer make sure the timeout handler + * didn't run or ran to the end and saw the USBD_CANCELLED status. + * Otherwise we must have got here via a timeout. */ - xfer->ux_status = status; - callout_stop(&xfer->ux_callout); + if (status == USBD_CANCELLED) { + xfer->ux_status = status; + callout_halt(&xfer->ux_callout, &sc->sc_lock); + } else { + KASSERT(xfer->ux_status == USBD_TIMEOUT); + } /* * Step 2: Stop execution of TD on the ring. @@ -1879,7 +1886,7 @@ xhci_event_transfer(struct xhci_softc * * UF_ENDPOINT_HALT). */ xfer->ux_status = err; - callout_stop(&xfer->ux_callout); + callout_halt(&xfer->ux_callout, &sc->sc_lock); xhci_clear_endpoint_stall_async(xfer); return; default: @@ -3629,17 +3636,18 @@ xhci_device_ctrl_start(struct usbd_xfer XHCI_TRB_3_IOC_BIT; xhci_trb_put(&xx->xx_trb[i++], parameter, status, control); + if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) { + callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout), + xhci_timeout, xfer); + } + xfer->ux_status = USBD_IN_PROGRESS; + mutex_enter(&tr->xr_lock); xhci_ring_put(sc, tr, xfer, xx->xx_trb, i); mutex_exit(&tr->xr_lock); xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci); - if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) { - callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout), - xhci_timeout, xfer); - } - return USBD_IN_PROGRESS; } @@ -3745,17 +3753,18 @@ xhci_device_bulk_start(struct usbd_xfer XHCI_TRB_3_IOC_BIT; xhci_trb_put(&xx->xx_trb[i++], parameter, status, control); + if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) { + callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout), + xhci_timeout, xfer); + } + xfer->ux_status = USBD_IN_PROGRESS; + mutex_enter(&tr->xr_lock); xhci_ring_put(sc, tr, xfer, xx->xx_trb, i); mutex_exit(&tr->xr_lock); xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci); - if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) { - callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout), - xhci_timeout, xfer); - } - return USBD_IN_PROGRESS; } @@ -3851,17 +3860,18 @@ xhci_device_intr_start(struct usbd_xfer XHCI_TRB_3_IOC_BIT; xhci_trb_put(&xx->xx_trb[i++], parameter, status, control); + if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) { + callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout), + xhci_timeout, xfer); + } + xfer->ux_status = USBD_IN_PROGRESS; + mutex_enter(&tr->xr_lock); xhci_ring_put(sc, tr, xfer, xx->xx_trb, i); mutex_exit(&tr->xr_lock); xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci); - if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) { - callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout), - xhci_timeout, xfer); - } - return USBD_IN_PROGRESS; } @@ -3914,31 +3924,42 @@ xhci_device_intr_close(struct usbd_pipe static void xhci_timeout(void *addr) { + XHCIHIST_FUNC(); XHCIHIST_CALLED(); struct xhci_xfer * const xx = addr; struct usbd_xfer * const xfer = &xx->xx_xfer; struct xhci_softc * const sc = XHCI_XFER2SC(xfer); + bool timeout = false; - XHCIHIST_FUNC(); XHCIHIST_CALLED(); - + mutex_enter(&sc->sc_lock); if (sc->sc_dying) { + mutex_exit(&sc->
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Dec 29 08:40:27 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: usb_subr.c Log Message: Take bus lock while removing a device from the bus list and announce detach once complete (not before) To generate a diff of this commit: cvs rdiff -u -r1.198.2.37 -r1.198.2.38 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.198.2.37 src/sys/dev/usb/usb_subr.c:1.198.2.38 --- src/sys/dev/usb/usb_subr.c:1.198.2.37 Thu Dec 29 08:38:19 2016 +++ src/sys/dev/usb/usb_subr.c Thu Dec 29 08:40:27 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.198.2.37 2016/12/29 08:38:19 skrll Exp $ */ +/* $NetBSD: usb_subr.c,v 1.198.2.38 2016/12/29 08:40:27 skrll Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.37 2016/12/29 08:38:19 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.38 2016/12/29 08:40:27 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -1736,9 +1736,14 @@ usb_disconnect_port(struct usbd_port *up KASSERT(!dev->ud_nifaces_claimed); } - usbd_add_dev_event(USB_EVENT_DEVICE_DETACH, dev); + mutex_enter(dev->ud_bus->ub_lock); dev->ud_bus->ub_devices[dev->ud_addr] = NULL; up->up_dev = NULL; + mutex_exit(dev->ud_bus->ub_lock); + + usbd_add_dev_event(USB_EVENT_DEVICE_DETACH, dev); + usb_free_device(dev); + return 0; }
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Dec 29 08:38:19 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: usb_subr.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.198.2.36 -r1.198.2.37 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.198.2.36 src/sys/dev/usb/usb_subr.c:1.198.2.37 --- src/sys/dev/usb/usb_subr.c:1.198.2.36 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/usb_subr.c Thu Dec 29 08:38:19 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.198.2.36 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: usb_subr.c,v 1.198.2.37 2016/12/29 08:38:19 skrll Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.36 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.37 2016/12/29 08:38:19 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -1160,8 +1160,8 @@ usbd_get_initial_ddesc(struct usbd_devic * and attach a driver. */ usbd_status -usbd_new_device(device_t parent, struct usbd_bus* bus, int depth, -int speed, int port, struct usbd_port *up) +usbd_new_device(device_t parent, struct usbd_bus *bus, int depth, int speed, +int port, struct usbd_port *up) { USBHIST_FUNC(); USBHIST_CALLED(usbdebug); struct usbd_device *dev, *adev; @@ -1248,7 +1248,7 @@ usbd_new_device(device_t parent, struct /* Establish the default pipe. */ err = usbd_setup_pipe_flags(dev, 0, &dev->ud_ep0, USBD_DEFAULT_INTERVAL, - &dev->ud_pipe0, USBD_MPSAFE); + &dev->ud_pipe0, USBD_MPSAFE); if (err) { usbd_remove_device(dev, up); return err;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Dec 29 08:36:46 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: usb.c Log Message: Whitespae To generate a diff of this commit: cvs rdiff -u -r1.156.2.14 -r1.156.2.15 src/sys/dev/usb/usb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb.c diff -u src/sys/dev/usb/usb.c:1.156.2.14 src/sys/dev/usb/usb.c:1.156.2.15 --- src/sys/dev/usb/usb.c:1.156.2.14 Fri Jun 10 08:15:22 2016 +++ src/sys/dev/usb/usb.c Thu Dec 29 08:36:46 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usb.c,v 1.156.2.14 2016/06/10 08:15:22 skrll Exp $ */ +/* $NetBSD: usb.c,v 1.156.2.15 2016/12/29 08:36:46 skrll Exp $ */ /* * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.156.2.14 2016/06/10 08:15:22 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.156.2.15 2016/12/29 08:36:46 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -132,7 +132,7 @@ struct usb_softc { #if 0 device_t sc_dev; /* base device */ #endif - struct usbd_bus *sc_bus; /* USB controller */ + struct usbd_bus *sc_bus; /* USB controller */ struct usbd_port sc_port; /* dummy port for root hub */ struct lwp *sc_event_thread;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Dec 29 08:04:08 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_urndis.c Log Message: Initialise later and tidyup better in the attach routine. To generate a diff of this commit: cvs rdiff -u -r1.9.4.13 -r1.9.4.14 src/sys/dev/usb/if_urndis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_urndis.c diff -u src/sys/dev/usb/if_urndis.c:1.9.4.13 src/sys/dev/usb/if_urndis.c:1.9.4.14 --- src/sys/dev/usb/if_urndis.c:1.9.4.13 Wed Dec 28 09:45:16 2016 +++ src/sys/dev/usb/if_urndis.c Thu Dec 29 08:04:08 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urndis.c,v 1.9.4.13 2016/12/28 09:45:16 skrll Exp $ */ +/* $NetBSD: if_urndis.c,v 1.9.4.14 2016/12/29 08:04:08 skrll Exp $ */ /* $OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */ /* @@ -21,7 +21,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.9.4.13 2016/12/28 09:45:16 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.9.4.14 2016/12/29 08:04:08 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1388,10 +1388,6 @@ urndis_attach(device_t parent, device_t sc->sc_ifaceno_ctl = if_ctl; if_data = -1; - mutex_init(&sc->urndis_lock, MUTEX_DEFAULT, IPL_NONE); - mutex_init(&sc->urndis_txlock, MUTEX_DEFAULT, IPL_SOFTUSB); - mutex_init(&sc->urndis_rxlock, MUTEX_DEFAULT, IPL_SOFTUSB); - usb_desc_iter_init(sc->sc_udev, &iter); while ((desc = (const void *)usb_desc_iter_next(&iter)) != NULL) { @@ -1480,6 +1476,9 @@ urndis_attach(device_t parent, device_t return; found: + mutex_init(&sc->urndis_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&sc->urndis_txlock, MUTEX_DEFAULT, IPL_SOFTUSB); + mutex_init(&sc->urndis_rxlock, MUTEX_DEFAULT, IPL_SOFTUSB); ifp = GET_IFP(sc); ifp->if_softc = sc; @@ -1503,7 +1502,7 @@ found: aprint_error("%s: unable to get hardware address\n", DEVNAME(sc)); urndis_stop(ifp); - return; + goto fail; } if (bufsz == ETHER_ADDR_LEN) { @@ -1515,7 +1514,7 @@ found: aprint_error("%s: invalid address\n", DEVNAME(sc)); kmem_free(buf, bufsz); urndis_stop(ifp); - return; + goto fail; } /* Initialize packet filter */ @@ -1526,7 +1525,7 @@ found: sizeof(filter)) != RNDIS_STATUS_SUCCESS) { aprint_error("%s: unable to set data filters\n", DEVNAME(sc)); urndis_stop(ifp); - return; + goto fail; } if_initialize(ifp); @@ -1535,6 +1534,12 @@ found: if_register(ifp); sc->sc_attached = 1; + return; + +fail: + mutex_destroy(&sc->urndis_lock); + mutex_destroy(&sc->urndis_txlock); + mutex_destroy(&sc->urndis_rxlock); } static int
CVS commit: [nick-nhusb] src/sys/dev
Module Name:src Committed By: skrll Date: Wed Dec 28 19:41:41 UTC 2016 Modified Files: src/sys/dev/ic [nick-nhusb]: athn.c src/sys/dev/usb [nick-nhusb]: if_athn_usb.c if_athn_usb.h Log Message: Various improvements - override the method before calling athn_attach -> if_attach -> interface announce - locking fixes for htc/wmi - some MPificaton To generate a diff of this commit: cvs rdiff -u -r1.10.4.2 -r1.10.4.3 src/sys/dev/ic/athn.c cvs rdiff -u -r1.6.8.17 -r1.6.8.18 src/sys/dev/usb/if_athn_usb.c cvs rdiff -u -r1.2.16.4 -r1.2.16.5 src/sys/dev/usb/if_athn_usb.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/athn.c diff -u src/sys/dev/ic/athn.c:1.10.4.2 src/sys/dev/ic/athn.c:1.10.4.3 --- src/sys/dev/ic/athn.c:1.10.4.2 Sun May 29 08:44:21 2016 +++ src/sys/dev/ic/athn.c Wed Dec 28 19:41:41 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: athn.c,v 1.10.4.2 2016/05/29 08:44:21 skrll Exp $ */ +/* $NetBSD: athn.c,v 1.10.4.3 2016/12/28 19:41:41 skrll Exp $ */ /* $OpenBSD: athn.c,v 1.83 2014/07/22 13:12:11 mpi Exp $ */ /*- @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.10.4.2 2016/05/29 08:44:21 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.10.4.3 2016/12/28 19:41:41 skrll Exp $"); #ifndef _MODULE #include "athn_usb.h" /* for NATHN_USB */ @@ -329,10 +329,14 @@ athn_attach(struct athn_softc *sc) ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_init = athn_init; - ifp->if_ioctl = athn_ioctl; - ifp->if_start = athn_start; - ifp->if_watchdog = athn_watchdog; + if (!ifp->if_init) + ifp->if_init = athn_init; + if (!ifp->if_ioctl) + ifp->if_ioctl = athn_ioctl; + if (!ifp->if_start) + ifp->if_start = athn_start; + if (!ifp->if_watchdog) + ifp->if_watchdog = athn_watchdog; IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); Index: src/sys/dev/usb/if_athn_usb.c diff -u src/sys/dev/usb/if_athn_usb.c:1.6.8.17 src/sys/dev/usb/if_athn_usb.c:1.6.8.18 --- src/sys/dev/usb/if_athn_usb.c:1.6.8.17 Wed Dec 28 19:36:03 2016 +++ src/sys/dev/usb/if_athn_usb.c Wed Dec 28 19:41:41 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_athn_usb.c,v 1.6.8.17 2016/12/28 19:36:03 skrll Exp $ */ +/* $NetBSD: if_athn_usb.c,v 1.6.8.18 2016/12/28 19:41:41 skrll Exp $ */ /* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */ /*- @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.17 2016/12/28 19:36:03 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.18 2016/12/28 19:41:41 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -144,7 +144,7 @@ Static void athn_usb_rxeof(struct usbd_x usbd_status); Static void athn_usb_start(struct ifnet *); //Static void athn_usb_start_locked(struct ifnet *); -Static void athn_usb_stop(struct ifnet *); +Static void athn_usb_stop(struct ifnet *, int disable); Static void athn_usb_stop_locked(struct ifnet *); Static void athn_usb_swba(struct athn_usb_softc *); Static int athn_usb_switch_chan(struct athn_softc *, @@ -157,7 +157,6 @@ Static void athn_usb_txeof(struct usbd_x Static void athn_usb_updateslot(struct ifnet *); Static void athn_usb_updateslot_cb(struct athn_usb_softc *, void *); Static void athn_usb_wait_async(struct athn_usb_softc *); -Static int athn_usb_wait_cmd(struct athn_usb_softc *); Static int athn_usb_wait_msg(struct athn_usb_softc *); Static void athn_usb_watchdog(struct ifnet *); Static int athn_usb_wmi_xcmd(struct athn_usb_softc *, uint16_t, void *, @@ -274,6 +273,9 @@ athn_usb_attach(device_t parent, device_ mutex_init(&usc->usc_lock, MUTEX_DEFAULT, IPL_NONE); + cv_init(&usc->usc_wmi_cv, "athnwmi"); + cv_init(&usc->usc_htc_cv, "athnhtc"); + cv_init(&usc->usc_cmd_cv, "athncmd"); mutex_init(&usc->usc_cmd_mtx, MUTEX_DEFAULT, IPL_SOFTUSB); cv_init(&usc->usc_msg_cv, "athnmsg"); @@ -337,6 +339,8 @@ athn_usb_attach(device_t parent, device_ cv_destroy(&usc->usc_cmd_cv); cv_destroy(&usc->usc_msg_cv); + cv_destroy(&usc->usc_wmi_cv); + cv_destroy(&usc->usc_htc_cv); mutex_destroy(&usc->usc_lock); mutex_destroy(&usc->usc_cmd_mtx); @@ -385,7 +389,7 @@ athn_usb_attachhook(device_t arg) struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &sc->sc_if; size_t i; - int s, error; + int error; if (usc->usc_dying) return; @@ -406,24 +410,24 @@ athn_usb_attachhook(device_t arg) return; /* We're now ready to attach the bus agnostic driver. */ - s = splnet(); ic->ic_ifp = ifp; ic->ic_updateslot = athn_usb_updateslot; sc->sc_max_aid = AR_USB_MAX_STA; /* Firmware is limited to 8 STA */ sc->sc_media_change = athn_usb_media_change; - error = athn_attach(sc); - if (error != 0) { - splx(s); - return; - } - usc->usc_athn_attached = 1; /* Override some operations for USB. */ ifp->if_init = athn_usb_init; + ifp->if_stop = a
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 28 19:36:03 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_athn_usb.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.6.8.16 -r1.6.8.17 src/sys/dev/usb/if_athn_usb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_athn_usb.c diff -u src/sys/dev/usb/if_athn_usb.c:1.6.8.16 src/sys/dev/usb/if_athn_usb.c:1.6.8.17 --- src/sys/dev/usb/if_athn_usb.c:1.6.8.16 Wed Dec 28 19:29:03 2016 +++ src/sys/dev/usb/if_athn_usb.c Wed Dec 28 19:36:03 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_athn_usb.c,v 1.6.8.16 2016/12/28 19:29:03 skrll Exp $ */ +/* $NetBSD: if_athn_usb.c,v 1.6.8.17 2016/12/28 19:36:03 skrll Exp $ */ /* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */ /*- @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.16 2016/12/28 19:29:03 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.17 2016/12/28 19:36:03 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1144,7 +1144,7 @@ athn_usb_htc_connect_svc(struct athn_usb Static int athn_usb_wait_msg(struct athn_usb_softc *usc) { - DPRINTFN(DBG_FN, usc, "\n"); + DPRINTFN(DBG_FN, usc, "\n"); KASSERT(mutex_owned(&usc->usc_msg_mtx));
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 28 19:29:03 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_athn_usb.c Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.6.8.15 -r1.6.8.16 src/sys/dev/usb/if_athn_usb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_athn_usb.c diff -u src/sys/dev/usb/if_athn_usb.c:1.6.8.15 src/sys/dev/usb/if_athn_usb.c:1.6.8.16 --- src/sys/dev/usb/if_athn_usb.c:1.6.8.15 Sat Dec 17 15:30:34 2016 +++ src/sys/dev/usb/if_athn_usb.c Wed Dec 28 19:29:03 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_athn_usb.c,v 1.6.8.15 2016/12/17 15:30:34 skrll Exp $ */ +/* $NetBSD: if_athn_usb.c,v 1.6.8.16 2016/12/28 19:29:03 skrll Exp $ */ /* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */ /*- @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.15 2016/12/17 15:30:34 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.16 2016/12/28 19:29:03 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -273,7 +273,7 @@ athn_usb_attach(device_t parent, device_ sc->sc_ops.write_barrier = athn_usb_write_barrier; mutex_init(&usc->usc_lock, MUTEX_DEFAULT, IPL_NONE); - + cv_init(&usc->usc_cmd_cv, "athncmd"); mutex_init(&usc->usc_cmd_mtx, MUTEX_DEFAULT, IPL_SOFTUSB); cv_init(&usc->usc_msg_cv, "athnmsg"); @@ -324,7 +324,7 @@ athn_usb_attach(device_t parent, device_ return; fail: - + /* Free Tx/Rx buffers. */ athn_usb_abort_pipes(usc); athn_usb_free_tx_list(usc); @@ -2697,7 +2697,7 @@ athn_usb_init(struct ifnet *ifp) return ret; } - + Static int athn_usb_init_locked(struct ifnet *ifp) {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 28 10:44:27 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ohci.c Log Message: Set device transfer status to USBD_IN_PROGRESS if start methods succeeds To generate a diff of this commit: cvs rdiff -u -r1.254.2.83 -r1.254.2.84 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.254.2.83 src/sys/dev/usb/ohci.c:1.254.2.84 --- src/sys/dev/usb/ohci.c:1.254.2.83 Tue Dec 27 08:33:08 2016 +++ src/sys/dev/usb/ohci.c Wed Dec 28 10:44:27 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.254.2.83 2016/12/27 08:33:08 skrll Exp $ */ +/* $NetBSD: ohci.c,v 1.254.2.84 2016/12/28 10:44:27 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.83 2016/12/27 08:33:08 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.84 2016/12/28 10:44:27 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2960,6 +2960,7 @@ ohci_device_ctrl_start(struct usbd_xfer DPRINTF("done", 0, 0, 0, 0); + xfer->ux_status = USBD_IN_PROGRESS; mutex_exit(&sc->sc_lock); return USBD_IN_PROGRESS; @@ -3171,6 +3172,8 @@ ohci_device_bulk_start(struct usbd_xfer callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout), ohci_timeout, xfer); } + + xfer->ux_status = USBD_IN_PROGRESS; mutex_exit(&sc->sc_lock); return USBD_IN_PROGRESS; @@ -3359,6 +3362,7 @@ ohci_device_intr_start(struct usbd_xfer usb_syncmem(&sed->dma, sed->offs, sizeof(sed->ed), BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); + xfer->ux_status = USBD_IN_PROGRESS; mutex_exit(&sc->sc_lock); return USBD_IN_PROGRESS;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 28 10:42:59 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ehci.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.234.2.107 -r1.234.2.108 src/sys/dev/usb/ehci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.234.2.107 src/sys/dev/usb/ehci.c:1.234.2.108 --- src/sys/dev/usb/ehci.c:1.234.2.107 Tue Dec 27 10:37:52 2016 +++ src/sys/dev/usb/ehci.c Wed Dec 28 10:42:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.234.2.107 2016/12/27 10:37:52 skrll Exp $ */ +/* $NetBSD: ehci.c,v 1.234.2.108 2016/12/28 10:42:59 skrll Exp $ */ /* * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.107 2016/12/27 10:37:52 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.108 2016/12/28 10:42:59 skrll Exp $"); #include "ohci.h" #include "uhci.h" @@ -4490,7 +4490,6 @@ ehci_device_fs_isoc_transfer(struct usbd ehci_add_intr_list(sc, exfer); xfer->ux_status = USBD_IN_PROGRESS; - mutex_exit(&sc->sc_lock); return USBD_IN_PROGRESS; @@ -4884,7 +4883,6 @@ ehci_device_isoc_transfer(struct usbd_xf ehci_add_intr_list(sc, exfer); xfer->ux_status = USBD_IN_PROGRESS; - mutex_exit(&sc->sc_lock); return USBD_IN_PROGRESS;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 28 10:25:06 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: uhci.c uhcivar.h Log Message: Improve transfer abort To generate a diff of this commit: cvs rdiff -u -r1.264.4.78 -r1.264.4.79 src/sys/dev/usb/uhci.c cvs rdiff -u -r1.52.14.18 -r1.52.14.19 src/sys/dev/usb/uhcivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uhci.c diff -u src/sys/dev/usb/uhci.c:1.264.4.78 src/sys/dev/usb/uhci.c:1.264.4.79 --- src/sys/dev/usb/uhci.c:1.264.4.78 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/uhci.c Wed Dec 28 10:25:06 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: uhci.c,v 1.264.4.78 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: uhci.c,v 1.264.4.79 2016/12/28 10:25:06 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.264.4.78 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.264.4.79 2016/12/28 10:25:06 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -574,8 +574,6 @@ uhci_init(uhci_softc_t *sc) callout_init(&sc->sc_poll_handle, CALLOUT_MPSAFE); - cv_init(&sc->sc_softwake_cv, "uhciab"); - /* Set up the bus struct. */ sc->sc_bus.ub_methods = &uhci_bus_methods; sc->sc_bus.ub_pipesize = sizeof(struct uhci_pipe); @@ -639,8 +637,6 @@ uhci_detach(struct uhci_softc *sc, int f callout_halt(&sc->sc_poll_handle, NULL); callout_destroy(&sc->sc_poll_handle); - cv_destroy(&sc->sc_softwake_cv); - mutex_destroy(&sc->sc_lock); mutex_destroy(&sc->sc_intr_lock); @@ -1422,11 +1418,6 @@ uhci_softintr(void *v) DPRINTF("ux %p", ux, 0, 0, 0); usb_transfer_complete(&ux->ux_xfer); } - - if (sc->sc_softwake) { - sc->sc_softwake = 0; - cv_broadcast(&sc->sc_softwake_cv); - } } /* Check for an interrupt. */ @@ -1482,8 +1473,6 @@ uhci_check_intr(uhci_softc_t *sc, struct if (!(status & UHCI_TD_ACTIVE)) { done: DPRINTFN(12, "ux=%p done", ux, 0, 0, 0); - - callout_stop(&xfer->ux_callout); uhci_idone(ux, cqp); return; } @@ -1554,18 +1543,30 @@ uhci_check_intr(uhci_softc_t *sc, struct void uhci_idone(struct uhci_xfer *ux, ux_completeq_t *cqp) { + UHCIHIST_FUNC(); UHCIHIST_CALLED(); struct usbd_xfer *xfer = &ux->ux_xfer; uhci_softc_t *sc __diagused = UHCI_XFER2SC(xfer); struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); uhci_soft_td_t *std; uint32_t status = 0, nstatus; + bool polling = sc->sc_bus.ub_usepolling; int actlen; KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); - UHCIHIST_FUNC(); UHCIHIST_CALLED(); DPRINTFN(12, "ux=%p", ux, 0, 0, 0); + /* + * Make sure the timeout handler didn't run or ran to the end + * and set the transfer status. + */ + callout_halt(&xfer->ux_callout, polling ? NULL : &sc->sc_lock); + if (xfer->ux_status == USBD_CANCELLED || + xfer->ux_status == USBD_TIMEOUT) { + DPRINTF("aborted xfer=%p", xfer, 0, 0, 0); + return; + } + #ifdef DIAGNOSTIC #ifdef UHCI_DEBUG if (ux->ux_isdone) { @@ -1699,26 +1700,32 @@ uhci_idone(struct uhci_xfer *ux, ux_comp void uhci_timeout(void *addr) { + UHCIHIST_FUNC(); UHCIHIST_CALLED(); struct usbd_xfer *xfer = addr; - struct uhci_xfer *uxfer = UHCI_XFER2UXFER(xfer); uhci_softc_t *sc = UHCI_XFER2SC(xfer); + bool timeout = false; - UHCIHIST_FUNC(); UHCIHIST_CALLED(); - - DPRINTF("uxfer %p", uxfer, 0, 0, 0); + DPRINTF("xfer %p", xfer, 0, 0, 0); + mutex_enter(&sc->sc_lock); if (sc->sc_dying) { - mutex_enter(&sc->sc_lock); - uhci_abort_xfer(xfer, USBD_TIMEOUT); mutex_exit(&sc->sc_lock); return; } + if (xfer->ux_status != USBD_CANCELLED) { + xfer->ux_status = USBD_TIMEOUT; + timeout = true; + } + mutex_exit(&sc->sc_lock); - /* Execute the abort in a process context. */ - usb_init_task(&xfer->ux_aborttask, uhci_timeout_task, xfer, - USB_TASKQ_MPSAFE); - usb_add_task(uxfer->ux_xfer.ux_pipe->up_dev, &xfer->ux_aborttask, - USB_TASKQ_HC); + if (timeout) { + struct usbd_device *dev = xfer->ux_pipe->up_dev; + + /* Execute the abort in a process context. */ + usb_init_task(&xfer->ux_aborttask, uhci_timeout_task, xfer, + USB_TASKQ_MPSAFE); + usb_add_task(dev, &xfer->ux_aborttask, USB_TASKQ_HC); + } } void @@ -1732,6 +1739,7 @@ uhci_timeout_task(void *addr) DPRINTF("xfer=%p", xfer, 0, 0, 0); mutex_enter(&sc->sc_lock); + KASSERT(xfer->ux_status == USBD_TIMEOUT); uhci_abort_xfer(xfer, USBD_TIMEOUT); mutex_exit(&sc->sc_lock); } @@ -2323,16 +2331,18 @@ uhci_device_bulk_abort(struct usbd_xfer } /* - * Abort a device request. - * If this routine is called at splusb() it guarantees that the request - * will be removed from the hardware scheduling and that the callback - * for it will be called with USBD_CANCELLED status. + * Cancel or timeout a device request. We have two cases to deal with + * + * 1) A driver want
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 28 09:45:16 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_aue.c if_axen.c if_cdce.c if_cue.c if_smsc.c if_udav.c if_urndis.c Log Message: Destroy all mutexes on detach To generate a diff of this commit: cvs rdiff -u -r1.132.4.15 -r1.132.4.16 src/sys/dev/usb/if_aue.c cvs rdiff -u -r1.3.6.13 -r1.3.6.14 src/sys/dev/usb/if_axen.c cvs rdiff -u -r1.38.14.10 -r1.38.14.11 src/sys/dev/usb/if_cdce.c cvs rdiff -u -r1.68.4.13 -r1.68.4.14 src/sys/dev/usb/if_cue.c cvs rdiff -u -r1.22.2.17 -r1.22.2.18 src/sys/dev/usb/if_smsc.c cvs rdiff -u -r1.43.4.12 -r1.43.4.13 src/sys/dev/usb/if_udav.c cvs rdiff -u -r1.9.4.12 -r1.9.4.13 src/sys/dev/usb/if_urndis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_aue.c diff -u src/sys/dev/usb/if_aue.c:1.132.4.15 src/sys/dev/usb/if_aue.c:1.132.4.16 --- src/sys/dev/usb/if_aue.c:1.132.4.15 Mon Dec 12 13:17:56 2016 +++ src/sys/dev/usb/if_aue.c Wed Dec 28 09:45:16 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aue.c,v 1.132.4.15 2016/12/12 13:17:56 skrll Exp $ */ +/* $NetBSD: if_aue.c,v 1.132.4.16 2016/12/28 09:45:16 skrll Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.132.4.15 2016/12/12 13:17:56 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.132.4.16 2016/12/28 09:45:16 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -933,6 +933,9 @@ aue_detach(device_t self, int flags) usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->aue_udev, sc->aue_dev); mutex_destroy(&sc->aue_mii_lock); + mutex_destroy(&sc->aue_lock); + mutex_destroy(&sc->aue_txlock); + mutex_destroy(&sc->aue_rxlock); #if 0 mutex_destroy(&sc->wkmtx); #endif Index: src/sys/dev/usb/if_axen.c diff -u src/sys/dev/usb/if_axen.c:1.3.6.13 src/sys/dev/usb/if_axen.c:1.3.6.14 --- src/sys/dev/usb/if_axen.c:1.3.6.13 Mon Dec 12 13:15:39 2016 +++ src/sys/dev/usb/if_axen.c Wed Dec 28 09:45:16 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_axen.c,v 1.3.6.13 2016/12/12 13:15:39 skrll Exp $ */ +/* $NetBSD: if_axen.c,v 1.3.6.14 2016/12/28 09:45:16 skrll Exp $ */ /* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */ /* @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.3.6.13 2016/12/12 13:15:39 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.3.6.14 2016/12/28 09:45:16 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -874,6 +874,10 @@ axen_detach(device_t self, int flags) rw_destroy(&sc->axen_mii_lock); + mutex_destroy(&sc->axen_txlock); + mutex_destroy(&sc->axen_rxlock); + mutex_destroy(&sc->axen_lock); + return 0; } Index: src/sys/dev/usb/if_cdce.c diff -u src/sys/dev/usb/if_cdce.c:1.38.14.10 src/sys/dev/usb/if_cdce.c:1.38.14.11 --- src/sys/dev/usb/if_cdce.c:1.38.14.10 Mon Dec 12 13:15:39 2016 +++ src/sys/dev/usb/if_cdce.c Wed Dec 28 09:45:16 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cdce.c,v 1.38.14.10 2016/12/12 13:15:39 skrll Exp $ */ +/* $NetBSD: if_cdce.c,v 1.38.14.11 2016/12/28 09:45:16 skrll Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.38.14.10 2016/12/12 13:15:39 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.38.14.11 2016/12/28 09:45:16 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -332,6 +332,10 @@ cdce_detach(device_t self, int flags) if_detach(ifp); + mutex_destroy(&sc->cdce_rxlock); + mutex_destroy(&sc->cdce_txlock); + mutex_destroy(&sc->cdce_lock); + sc->cdce_attached = 0; splx(s); Index: src/sys/dev/usb/if_cue.c diff -u src/sys/dev/usb/if_cue.c:1.68.4.13 src/sys/dev/usb/if_cue.c:1.68.4.14 --- src/sys/dev/usb/if_cue.c:1.68.4.13 Mon Dec 12 13:15:39 2016 +++ src/sys/dev/usb/if_cue.c Wed Dec 28 09:45:16 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cue.c,v 1.68.4.13 2016/12/12 13:15:39 skrll Exp $ */ +/* $NetBSD: if_cue.c,v 1.68.4.14 2016/12/28 09:45:16 skrll Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul . All rights reserved. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.68.4.13 2016/12/12 13:15:39 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.68.4.14 2016/12/28 09:45:16 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -613,6 +613,10 @@ cue_detach(device_t self, int flags) aprint_debug_dev(self, "detach has active endpoints\n"); #endif + mutex_destroy(&sc->cue_rxlock); + mutex_destroy(&sc->cue_txlock); + mutex_destroy(&sc->cue_lock); + sc->cue_attached = 0; splx(s); Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.17 src/sys/dev/usb/if_smsc.c:1.22.2.18 --- src/sys/dev/usb/if_smsc.c:1.22.2.17 Wed Dec 28 07:44:26 2016 +++ src/sys/dev/usb/if_smsc.c Wed Dec 28 09:45:16 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 28 08:55:20 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_urndisreg.h Log Message: Missed commit in MPification To generate a diff of this commit: cvs rdiff -u -r1.1.32.3 -r1.1.32.4 src/sys/dev/usb/if_urndisreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_urndisreg.h diff -u src/sys/dev/usb/if_urndisreg.h:1.1.32.3 src/sys/dev/usb/if_urndisreg.h:1.1.32.4 --- src/sys/dev/usb/if_urndisreg.h:1.1.32.3 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_urndisreg.h Wed Dec 28 08:55:20 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urndisreg.h,v 1.1.32.3 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_urndisreg.h,v 1.1.32.4 2016/12/28 08:55:20 skrll Exp $ */ /* $OpenBSD: if_urndisreg.h,v 1.14 2010/07/08 18:22:01 ckuethe Exp $ */ /* @@ -42,6 +42,10 @@ struct urndis_cdata { struct urndis_softc { device_t sc_dev; + kmutex_t urndis_lock; + kmutex_t urndis_txlock; + kmutex_t urndis_rxlock; + charsc_attached; intsc_dying; struct ethercom sc_ec; @@ -63,6 +67,8 @@ struct urndis_softc { struct usbd_pipe * sc_bulkout_pipe; struct urndis_cdata sc_data; + + struct if_percpuq * urndis_ipq; }; #define RNDIS_STATUS_BUFFER_OVERFLOW 0x8005L
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 28 08:53:56 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smscvar.h Log Message: Missed commit To generate a diff of this commit: cvs rdiff -u -r1.3.4.4 -r1.3.4.5 src/sys/dev/usb/if_smscvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smscvar.h diff -u src/sys/dev/usb/if_smscvar.h:1.3.4.4 src/sys/dev/usb/if_smscvar.h:1.3.4.5 --- src/sys/dev/usb/if_smscvar.h:1.3.4.4 Fri Jul 15 08:50:59 2016 +++ src/sys/dev/usb/if_smscvar.h Wed Dec 28 08:53:56 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smscvar.h,v 1.3.4.4 2016/07/15 08:50:59 skrll Exp $ */ +/* $NetBSD: if_smscvar.h,v 1.3.4.5 2016/12/28 08:53:56 skrll Exp $ */ /* $OpenBSD: if_smscreg.h,v 1.2 2012/09/27 12:38:11 jsg Exp $ */ /*- @@ -56,6 +56,7 @@ struct smsc_softc { device_t sc_dev; struct usbd_device * sc_udev; bool sc_dying; + bool sc_stopping; uint8_t sc_enaddr[ETHER_ADDR_LEN]; struct ethercom sc_ec;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 28 07:44:26 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_smsc.c Log Message: More MPification To generate a diff of this commit: cvs rdiff -u -r1.22.2.16 -r1.22.2.17 src/sys/dev/usb/if_smsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.22.2.16 src/sys/dev/usb/if_smsc.c:1.22.2.17 --- src/sys/dev/usb/if_smsc.c:1.22.2.16 Sun Oct 16 11:18:30 2016 +++ src/sys/dev/usb/if_smsc.c Wed Dec 28 07:44:26 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.22.2.16 2016/10/16 11:18:30 skrll Exp $ */ +/* $NetBSD: if_smsc.c,v 1.22.2.17 2016/12/28 07:44:26 skrll Exp $ */ /* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ @@ -557,7 +557,6 @@ smsc_init(struct ifnet *ifp) return ret; } - int smsc_init_locked(struct ifnet *ifp) { @@ -581,7 +580,7 @@ smsc_init_locked(struct ifnet *ifp) /* Open RX and TX pipes. */ err = usbd_open_pipe(sc->sc_iface, sc->sc_ed[SMSC_ENDPT_RX], - USBD_EXCLUSIVE_USE, &sc->sc_ep[SMSC_ENDPT_RX]); + USBD_EXCLUSIVE_USE | USBD_MPSAFE, &sc->sc_ep[SMSC_ENDPT_RX]); if (err) { printf("%s: open rx pipe failed: %s\n", device_xname(sc->sc_dev), usbd_errstr(err)); @@ -589,7 +588,7 @@ smsc_init_locked(struct ifnet *ifp) } err = usbd_open_pipe(sc->sc_iface, sc->sc_ed[SMSC_ENDPT_TX], - USBD_EXCLUSIVE_USE, &sc->sc_ep[SMSC_ENDPT_TX]); + USBD_EXCLUSIVE_USE | USBD_MPSAFE, &sc->sc_ep[SMSC_ENDPT_TX]); if (err) { printf("%s: open tx pipe failed: %s\n", device_xname(sc->sc_dev), usbd_errstr(err)); @@ -616,6 +615,8 @@ smsc_init_locked(struct ifnet *ifp) usbd_transfer(c->sc_xfer); } + sc->sc_stopping = false; + /* Indicate we are up and running. */ ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; @@ -641,7 +642,8 @@ smsc_start(struct ifnet *ifp) KASSERT(ifp->if_extflags & IFEF_START_MPSAFE); mutex_enter(&sc->sc_txlock); - smsc_start_locked(ifp); + if (!sc->sc_stopping) + smsc_start_locked(ifp); mutex_exit(&sc->sc_txlock); } @@ -651,6 +653,8 @@ smsc_start_locked(struct ifnet *ifp) struct smsc_softc * const sc = ifp->if_softc; struct mbuf *m_head = NULL; + KASSERT(mutex_owned(&sc->sc_txlock)); + /* Don't send anything if there is no link or controller is busy. */ if ((sc->sc_flags & SMSC_FLAG_LINK) == 0) { return; @@ -710,6 +714,13 @@ smsc_stop_locked(struct ifnet *ifp, int // smsc_reset(sc); + KASSERT(mutex_owned(&sc->sc_lock)); + mutex_enter(&sc->sc_rxlock); + mutex_enter(&sc->sc_txlock); + sc->sc_stopping = true; + mutex_exit(&sc->sc_txlock); + mutex_exit(&sc->sc_rxlock); + callout_stop(&sc->sc_stat_ch); /* Stop transfers. */ @@ -1012,6 +1023,7 @@ smsc_attach(device_t parent, device_t se sc->sc_dev = self; sc->sc_udev = dev; + sc->sc_stopping = false; aprint_naive("\n"); aprint_normal("\n"); @@ -1285,17 +1297,24 @@ smsc_rxeof(struct usbd_xfer *xfer, void uint32_t rxhdr; uint16_t pktlen; struct mbuf *m; - int s; - if (sc->sc_dying) + mutex_enter(&sc->sc_rxlock); + + if (sc->sc_dying) { + mutex_exit(&sc->sc_rxlock); return; + } - if (!(ifp->if_flags & IFF_RUNNING)) + if (!(ifp->if_flags & IFF_RUNNING)) { + mutex_exit(&sc->sc_rxlock); return; + } if (status != USBD_NORMAL_COMPLETION) { - if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) + if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) { + mutex_exit(&sc->sc_rxlock); return; + } if (usbd_ratecheck(&sc->sc_rx_notice)) { printf("%s: usb errors on rx: %s\n", device_xname(sc->sc_dev), usbd_errstr(status)); @@ -1434,14 +1453,18 @@ smsc_rxeof(struct usbd_xfer *xfer, void buf += pktlen; total_len -= pktlen; + mutex_exit(&sc->sc_rxlock); + /* push the packet up */ - s = splnet(); bpf_mtap(ifp, m); if_percpuq_enqueue(sc->sc_ipq, m); - splx(s); + + mutex_enter(&sc->sc_rxlock); } done: + mutex_exit(&sc->sc_rxlock); + /* Setup new transfer. */ usbd_setup_xfer(xfer, c, c->sc_buf, sc->sc_bufsz, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, smsc_rxeof); @@ -1457,17 +1480,24 @@ smsc_txeof(struct usbd_xfer *xfer, void struct smsc_softc *sc = c->sc_sc; struct ifnet *ifp = &sc->sc_ec.ec_if; - if (sc->sc_dying) + mutex_enter(&sc->sc_txlock); + + if (sc->sc_dying) { + mutex_exit(&sc->sc_txlock); return; + } - int s = splnet(); + if (sc->sc_stopping) { + mutex_exit(&sc->sc_txlock); + return; + } ifp->if_timer = 0; ifp->if_flags &= ~IFF_OACTIVE; if (status != USBD_NORMAL_COMPLETION) { if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) { - splx(s); + mutex_exit(&sc->sc_txlock); return; } ifp->if_oerrors++; @@ -1475,7 +1505,7 @@ smsc_txeof(struct usbd_xfer *xfer, void usbd_er
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 15:25:42 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Another merge botch To generate a diff of this commit: cvs rdiff -u -r1.108.2.35 -r1.108.2.36 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.35 src/sys/dev/usb/ucom.c:1.108.2.36 --- src/sys/dev/usb/ucom.c:1.108.2.35 Tue Dec 27 15:22:10 2016 +++ src/sys/dev/usb/ucom.c Tue Dec 27 15:25:41 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.35 2016/12/27 15:22:10 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.36 2016/12/27 15:25:41 skrll Exp $ */ /* * Copyright (c) 1998, 2000, 2016 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.35 2016/12/27 15:22:10 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.36 2016/12/27 15:25:41 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1639,6 +1639,7 @@ ucomreadcb(struct usbd_xfer *xfer, void return; } + mutex_exit(&sc->sc_lock); ub->ub_data = usbd_get_buffer(xfer); if (sc->sc_methods->ucom_read != NULL) { sc->sc_methods->ucom_read(sc->sc_parent, sc->sc_portno, @@ -1649,6 +1650,15 @@ ucomreadcb(struct usbd_xfer *xfer, void ub->ub_len = cc; + mutex_enter(&sc->sc_lock); + if (sc->sc_dying) { + if (--sc->sc_refcnt < 0) + cv_broadcast(&sc->sc_detachcv); + mutex_exit(&sc->sc_lock); + DPRINTF("... dying", 0, 0, 0, 0); + return; + } + SIMPLEQ_INSERT_TAIL(&sc->sc_ibuff_full, ub, ub_link); ucom_read_complete(sc);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 15:22:10 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Update copyright notice To generate a diff of this commit: cvs rdiff -u -r1.108.2.34 -r1.108.2.35 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.34 src/sys/dev/usb/ucom.c:1.108.2.35 --- src/sys/dev/usb/ucom.c:1.108.2.34 Tue Dec 27 15:21:46 2016 +++ src/sys/dev/usb/ucom.c Tue Dec 27 15:22:10 2016 @@ -1,12 +1,12 @@ -/* $NetBSD: ucom.c,v 1.108.2.34 2016/12/27 15:21:46 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.35 2016/12/27 15:22:10 skrll Exp $ */ /* - * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. + * Copyright (c) 1998, 2000, 2016 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Lennart Augustsson (lenn...@augustsson.net) at - * Carlstedt Research & Technology. + * Carlstedt Research & Technology, and Nick Hudson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.34 2016/12/27 15:21:46 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.35 2016/12/27 15:22:10 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h"
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 15:21:46 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Fix merge botch To generate a diff of this commit: cvs rdiff -u -r1.108.2.33 -r1.108.2.34 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.33 src/sys/dev/usb/ucom.c:1.108.2.34 --- src/sys/dev/usb/ucom.c:1.108.2.33 Tue Dec 27 14:58:07 2016 +++ src/sys/dev/usb/ucom.c Tue Dec 27 15:21:46 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.33 2016/12/27 14:58:07 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.34 2016/12/27 15:21:46 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.33 2016/12/27 14:58:07 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.34 2016/12/27 15:21:46 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1208,16 +1208,6 @@ ucomparam(struct tty *tp, struct termios sc->sc_refcnt++; mutex_exit(&sc->sc_lock); - mutex_enter(&sc->sc_lock); - if (sc->sc_dying) { - DPRINTF("... dying", 0, 0, 0, 0); - mutex_exit(&sc->sc_lock); - return EIO; - } - - sc->sc_refcnt++; - mutex_exit(&sc->sc_lock); - /* Check requested parameters. */ if (t->c_ispeed && t->c_ispeed != t->c_ospeed) { error = EINVAL;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 14:58:07 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Open pipes with USBD_MPSAFE - we don't need the KERNEL_LOCK to be held. To generate a diff of this commit: cvs rdiff -u -r1.108.2.32 -r1.108.2.33 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.32 src/sys/dev/usb/ucom.c:1.108.2.33 --- src/sys/dev/usb/ucom.c:1.108.2.32 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/ucom.c Tue Dec 27 14:58:07 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.32 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.33 2016/12/27 14:58:07 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.32 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.33 2016/12/27 14:58:07 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -323,7 +323,7 @@ ucom_attach(device_t parent, device_t se if (sc->sc_bulkin_no != -1) { /* Open the bulk pipes */ err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin_no, - USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe); + USBD_EXCLUSIVE_USE | USBD_MPSAFE, &sc->sc_bulkin_pipe); if (err) { DPRINTF("open bulk in error (addr %d), err=%d", sc->sc_bulkin_no, err, 0, 0); @@ -345,7 +345,7 @@ ucom_attach(device_t parent, device_t se if (sc->sc_bulkout_no != -1) { err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_no, - USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe); + USBD_EXCLUSIVE_USE | USBD_MPSAFE, &sc->sc_bulkout_pipe); if (err) { DPRINTF("open bulk out error (addr %d), err=%d", sc->sc_bulkout_no, err, 0, 0);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 14:43:59 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: usbdi.c Log Message: Fix a comment To generate a diff of this commit: cvs rdiff -u -r1.162.2.49 -r1.162.2.50 src/sys/dev/usb/usbdi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdi.c diff -u src/sys/dev/usb/usbdi.c:1.162.2.49 src/sys/dev/usb/usbdi.c:1.162.2.50 --- src/sys/dev/usb/usbdi.c:1.162.2.49 Sun Dec 11 17:31:09 2016 +++ src/sys/dev/usb/usbdi.c Tue Dec 27 14:43:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.162.2.49 2016/12/11 17:31:09 skrll Exp $ */ +/* $NetBSD: usbdi.c,v 1.162.2.50 2016/12/27 14:43:59 skrll Exp $ */ /* * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.49 2016/12/11 17:31:09 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.50 2016/12/27 14:43:59 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -860,7 +860,7 @@ usbd_get_interface(struct usbd_interface /*** Internal routines ***/ -/* Dequeue all pipe operations, called at splusb(). */ +/* Dequeue all pipe operations, called with bus lock held. */ Static usbd_status usbd_ar_pipe(struct usbd_pipe *pipe) {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 11:37:36 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_urndis.c Log Message: WIP MPification To generate a diff of this commit: cvs rdiff -u -r1.9.4.11 -r1.9.4.12 src/sys/dev/usb/if_urndis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_urndis.c diff -u src/sys/dev/usb/if_urndis.c:1.9.4.11 src/sys/dev/usb/if_urndis.c:1.9.4.12 --- src/sys/dev/usb/if_urndis.c:1.9.4.11 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_urndis.c Tue Dec 27 11:37:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urndis.c,v 1.9.4.11 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_urndis.c,v 1.9.4.12 2016/12/27 11:37:36 skrll Exp $ */ /* $OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */ /* @@ -21,7 +21,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.9.4.11 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.9.4.12 2016/12/27 11:37:36 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -75,13 +75,18 @@ static void urndis_watchdog(struct ifnet #endif static void urndis_start(struct ifnet *); +static void urndis_start_locked(struct ifnet *); static void urndis_rxeof(struct usbd_xfer *, void *, usbd_status); static void urndis_txeof(struct usbd_xfer *, void *, usbd_status); static int urndis_rx_list_init(struct urndis_softc *); +static void urndis_rx_list_free(struct urndis_softc *); static int urndis_tx_list_init(struct urndis_softc *); +static void urndis_tx_list_free(struct urndis_softc *); static int urndis_init(struct ifnet *); +static int urndis_init_locked(struct ifnet *); static void urndis_stop(struct ifnet *); +static void urndis_stop_locked(struct ifnet *); static usbd_status urndis_ctrl_msg(struct urndis_softc *, uint8_t, uint8_t, uint16_t, uint16_t, void *, size_t); @@ -879,7 +884,7 @@ urndis_decap(struct urndis_softc *sc, st bpf_mtap(ifp, m); - if_percpuq_enqueue(ifp->if_percpuq, m); + if_percpuq_enqueue(sc->urndis_ipq, m); } splx(s); @@ -941,6 +946,21 @@ urndis_rx_list_init(struct urndis_softc return 0; } +static void +urndis_rx_list_free(struct urndis_softc *sc) +{ + for (int i = 0; i < RNDIS_RX_LIST_CNT; i++) { + if (sc->sc_data.sc_rx_chain[i].sc_mbuf != NULL) { + m_freem(sc->sc_data.sc_rx_chain[i].sc_mbuf); + sc->sc_data.sc_rx_chain[i].sc_mbuf = NULL; + } + if (sc->sc_data.sc_rx_chain[i].sc_xfer != NULL) { + usbd_destroy_xfer(sc->sc_data.sc_rx_chain[i].sc_xfer); + sc->sc_data.sc_rx_chain[i].sc_xfer = NULL; + } + } +} + static int urndis_tx_list_init(struct urndis_softc *sc) { @@ -965,6 +985,21 @@ urndis_tx_list_init(struct urndis_softc return 0; } +static void +urndis_tx_list_free(struct urndis_softc *sc) +{ + for (int i = 0; i < RNDIS_TX_LIST_CNT; i++) { + if (sc->sc_data.sc_tx_chain[i].sc_mbuf != NULL) { + m_freem(sc->sc_data.sc_tx_chain[i].sc_mbuf); + sc->sc_data.sc_tx_chain[i].sc_mbuf = NULL; + } + if (sc->sc_data.sc_tx_chain[i].sc_xfer != NULL) { + usbd_destroy_xfer(sc->sc_data.sc_tx_chain[i].sc_xfer); + sc->sc_data.sc_tx_chain[i].sc_xfer = NULL; + } + } +} + static int urndis_ioctl(struct ifnet *ifp, unsigned long command, void *data) { @@ -979,24 +1014,7 @@ urndis_ioctl(struct ifnet *ifp, unsigned s = splnet(); - switch(command) { - case SIOCSIFFLAGS: - if ((error = ifioctl_common(ifp, command, data)) != 0) - break; - if (ifp->if_flags & IFF_UP) { - if (!(ifp->if_flags & IFF_RUNNING)) -urndis_init(ifp); - } else { - if (ifp->if_flags & IFF_RUNNING) -urndis_stop(ifp); - } - error = 0; - break; - - default: - error = ether_ioctl(ifp, command, data); - break; - } + error = ether_ioctl(ifp, command, data); if (error == ENETRESET) error = 0; @@ -1026,8 +1044,20 @@ urndis_watchdog(struct ifnet *ifp) static int urndis_init(struct ifnet *ifp) { + struct urndis_softc *sc = ifp->if_softc; + + mutex_enter(&sc->urndis_lock); + int ret = urndis_init_locked(ifp); + mutex_exit(&sc->urndis_lock); + + return ret; +} + +static int +urndis_init_locked(struct ifnet *ifp) +{ struct urndis_softc *sc; - int i, s; + int i; int err; usbd_status usberr; @@ -1040,15 +1070,12 @@ urndis_init(struct ifnet *ifp) if (err != RNDIS_STATUS_SUCCESS) return EIO; - s = splnet(); - usberr = usbd_open_pipe(sc->sc_iface_data, sc->sc_bulkin_no, USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe); if (usberr) { printf("%s: open rx pipe failed: %s\n", DEVNAME(sc), usbd_errstr(err)); - splx(s); - return EIO; + goto fail; } usberr = usbd_open_pipe(sc->sc_iface_data, sc->sc_bulkout_no, @@ -1056,24 +1083,21 @@ urndis_init(struct ifnet *ifp) if (usberr) { printf("%s: open tx pipe failed: %s\n", DEVNAME(sc), usbd_errstr(err)); - splx(s); - return EIO; + goto fail2; } err = urndis_tx_list_init(sc); if (err) {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 10:37:52 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ehci.c Log Message: Reduce scope of variables To generate a diff of this commit: cvs rdiff -u -r1.234.2.106 -r1.234.2.107 src/sys/dev/usb/ehci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.234.2.106 src/sys/dev/usb/ehci.c:1.234.2.107 --- src/sys/dev/usb/ehci.c:1.234.2.106 Tue Dec 27 10:16:49 2016 +++ src/sys/dev/usb/ehci.c Tue Dec 27 10:37:52 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.234.2.106 2016/12/27 10:16:49 skrll Exp $ */ +/* $NetBSD: ehci.c,v 1.234.2.107 2016/12/27 10:37:52 skrll Exp $ */ /* * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.106 2016/12/27 10:16:49 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.107 2016/12/27 10:37:52 skrll Exp $"); #include "ohci.h" #include "uhci.h" @@ -3392,18 +3392,17 @@ done: Static void ehci_timeout(void *addr) { + EHCIHIST_FUNC(); EHCIHIST_CALLED(); struct usbd_xfer *xfer = addr; - struct usbd_pipe *pipe = xfer->ux_pipe; - struct usbd_device *dev = pipe->up_dev; ehci_softc_t *sc = EHCI_XFER2SC(xfer); bool timeout = false; - EHCIHIST_FUNC(); EHCIHIST_CALLED(); - DPRINTF("xfer %p", xfer, 0, 0, 0); #ifdef EHCI_DEBUG - if (ehcidebug >= 2) + if (ehcidebug >= 2) { + struct usbd_pipe *pipe = xfer->ux_pipe; usbd_dump_pipe(pipe); + } #endif mutex_enter(&sc->sc_lock); @@ -3418,6 +3417,8 @@ ehci_timeout(void *addr) mutex_exit(&sc->sc_lock); if (timeout) { + struct usbd_device *dev = xfer->ux_pipe->up_dev; + /* Execute the abort in a process context. */ usb_init_task(&xfer->ux_aborttask, ehci_timeout_task, xfer, USB_TASKQ_MPSAFE);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 10:24:00 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ehcivar.h Log Message: Missed commit in the ehci abort improvement To generate a diff of this commit: cvs rdiff -u -r1.42.14.26 -r1.42.14.27 src/sys/dev/usb/ehcivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ehcivar.h diff -u src/sys/dev/usb/ehcivar.h:1.42.14.26 src/sys/dev/usb/ehcivar.h:1.42.14.27 --- src/sys/dev/usb/ehcivar.h:1.42.14.26 Sat Apr 30 10:34:14 2016 +++ src/sys/dev/usb/ehcivar.h Tue Dec 27 10:24:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ehcivar.h,v 1.42.14.26 2016/04/30 10:34:14 skrll Exp $ */ +/* $NetBSD: ehcivar.h,v 1.42.14.27 2016/12/27 10:24:00 skrll Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -164,6 +164,7 @@ typedef struct ehci_softc { device_t sc_dev; kmutex_t sc_lock; kmutex_t sc_intr_lock; + bool sc_dbanswered; kcondvar_t sc_doorbell; void *sc_doorbell_si; void *sc_pcd_si; @@ -210,8 +211,6 @@ typedef struct ehci_softc { uint8_t sc_istthreshold; /* ISOC Scheduling Threshold (uframes) */ struct usbd_xfer *sc_intrxfer; char sc_isreset[EHCI_MAX_PORTS]; - char sc_softwake; - kcondvar_t sc_softwake_cv; uint32_t sc_eintrs; ehci_soft_qh_t *sc_async_head;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 10:16:49 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ehci.c Log Message: Remove a printf To generate a diff of this commit: cvs rdiff -u -r1.234.2.105 -r1.234.2.106 src/sys/dev/usb/ehci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.234.2.105 src/sys/dev/usb/ehci.c:1.234.2.106 --- src/sys/dev/usb/ehci.c:1.234.2.105 Tue Dec 27 08:59:48 2016 +++ src/sys/dev/usb/ehci.c Tue Dec 27 10:16:49 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.234.2.105 2016/12/27 08:59:48 skrll Exp $ */ +/* $NetBSD: ehci.c,v 1.234.2.106 2016/12/27 10:16:49 skrll Exp $ */ /* * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.105 2016/12/27 08:59:48 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.106 2016/12/27 10:16:49 skrll Exp $"); #include "ohci.h" #include "uhci.h" @@ -3239,7 +3239,6 @@ ehci_abort_xfer(struct usbd_xfer *xfer, sqtd = sqtd->nextqtd; /* Zap curqtd register if hardware pointed inside the xfer. */ if (hit && sqtd != NULL) { -printf("%s: hit!\n", __func__); DPRINTF("cur=0x%08x", sqtd->physaddr, 0, 0, 0); sqh->qh.qh_curqtd = htole32(sqtd->physaddr); /* unlink qTDs */ usb_syncmem(&sqh->dma,
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 10:09:24 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: motg.c Log Message: Stray #endif To generate a diff of this commit: cvs rdiff -u -r1.12.2.31 -r1.12.2.32 src/sys/dev/usb/motg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/motg.c diff -u src/sys/dev/usb/motg.c:1.12.2.31 src/sys/dev/usb/motg.c:1.12.2.32 --- src/sys/dev/usb/motg.c:1.12.2.31 Tue Dec 27 08:49:29 2016 +++ src/sys/dev/usb/motg.c Tue Dec 27 10:09:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: motg.c,v 1.12.2.31 2016/12/27 08:49:29 skrll Exp $ */ +/* $NetBSD: motg.c,v 1.12.2.32 2016/12/27 10:09:24 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.31 2016/12/27 08:49:29 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.32 2016/12/27 10:09:24 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_motg.h" @@ -2090,7 +2090,6 @@ complete: KASSERTMSG(xfer && xfer->ux_status == USBD_IN_PROGRESS && ep->phase == DATA_OUT, "xfer %p status %d phase %d", xfer, xfer->ux_status, ep->phase); -#endif ep->phase = IDLE; ep->xfer = NULL; if (xfer && xfer->ux_status == USBD_IN_PROGRESS) {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 08:59:48 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ehci.c Log Message: Improve and simplify ehci_abort_xfer. The races should now be removed. To generate a diff of this commit: cvs rdiff -u -r1.234.2.104 -r1.234.2.105 src/sys/dev/usb/ehci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.234.2.104 src/sys/dev/usb/ehci.c:1.234.2.105 --- src/sys/dev/usb/ehci.c:1.234.2.104 Wed Oct 5 20:55:57 2016 +++ src/sys/dev/usb/ehci.c Tue Dec 27 08:59:48 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.234.2.104 2016/10/05 20:55:57 skrll Exp $ */ +/* $NetBSD: ehci.c,v 1.234.2.105 2016/12/27 08:59:48 skrll Exp $ */ /* * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.104 2016/10/05 20:55:57 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.105 2016/12/27 08:59:48 skrll Exp $"); #include "ohci.h" #include "uhci.h" @@ -412,8 +412,7 @@ ehci_init(ehci_softc_t *sc) mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB); mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_USB); - cv_init(&sc->sc_softwake_cv, "ehciab"); - cv_init(&sc->sc_doorbell, "ehcidi"); + cv_init(&sc->sc_doorbell, "ehcidb"); sc->sc_xferpool = pool_cache_init(sizeof(struct ehci_xfer), 0, 0, 0, "ehcixfer", NULL, IPL_USB, NULL, NULL, NULL); @@ -751,8 +750,10 @@ Static void ehci_doorbell(void *addr) { ehci_softc_t *sc = addr; + EHCIHIST_FUNC(); EHCIHIST_CALLED(); mutex_enter(&sc->sc_lock); + sc->sc_dbanswered = true; cv_broadcast(&sc->sc_doorbell); mutex_exit(&sc->sc_lock); } @@ -853,11 +854,6 @@ ehci_softintr(void *v) !TAILQ_EMPTY(&sc->sc_intrhead)) callout_reset(&sc->sc_tmo_intrlist, hz, ehci_intrlist_timeout, sc); - - if (sc->sc_softwake) { - sc->sc_softwake = 0; - cv_broadcast(&sc->sc_softwake_cv); - } } Static void @@ -939,7 +935,6 @@ ehci_check_qh_intr(ehci_softc_t *sc, str } done: DPRINTFN(10, "ex=%p done", ex, 0, 0, 0); - callout_stop(&ex->ex_xfer.ux_callout); ehci_idone(ex, cq); } @@ -985,7 +980,6 @@ ehci_check_itd_intr(ehci_softc_t *sc, st return; done: DPRINTF("ex %p done", ex, 0, 0, 0); - callout_stop(&ex->ex_xfer.ux_callout); ehci_idone(ex, cq); } @@ -1023,7 +1017,6 @@ ehci_check_sitd_intr(ehci_softc_t *sc, s return; DPRINTFN(10, "ex=%p done", ex, 0, 0, 0); - callout_stop(&(ex->ex_xfer.ux_callout)); ehci_idone(ex, cq); } @@ -1031,19 +1024,24 @@ ehci_check_sitd_intr(ehci_softc_t *sc, s Static void ehci_idone(struct ehci_xfer *ex, ex_completeq_t *cq) { + EHCIHIST_FUNC(); EHCIHIST_CALLED(); struct usbd_xfer *xfer = &ex->ex_xfer; struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); struct ehci_softc *sc = EHCI_XFER2SC(xfer); ehci_soft_qtd_t *sqtd, *fsqtd, *lsqtd; uint32_t status = 0, nstatus = 0; int actlen = 0; + bool polling = sc->sc_bus.ub_usepolling; - EHCIHIST_FUNC(); EHCIHIST_CALLED(); - - KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); + KASSERT(polling || mutex_owned(&sc->sc_lock)); DPRINTF("ex=%p", ex, 0, 0, 0); + /* + * Make sure the timeout handler didn't run or ran to the end + * and set the transfer status. + */ + callout_halt(&ex->ex_xfer.ux_callout, polling ? NULL : &sc->sc_lock); if (xfer->ux_status == USBD_CANCELLED || xfer->ux_status == USBD_TIMEOUT) { DPRINTF("aborted xfer=%p", xfer, 0, 0, 0); @@ -1332,7 +1330,6 @@ ehci_detach(struct ehci_softc *sc, int f kmem_free(sc->sc_softitds, sc->sc_flsize * sizeof(ehci_soft_itd_t *)); cv_destroy(&sc->sc_doorbell); - cv_destroy(&sc->sc_softwake_cv); #if 0 /* XXX destroyed in ehci_pci.c as it controls ehci_intr access */ @@ -2158,22 +2155,27 @@ ehci_sync_hc(ehci_softc_t *sc) DPRINTF("dying", 0, 0, 0, 0); return; } + /* ask for doorbell */ EOWRITE4(sc, EHCI_USBCMD, EOREAD4(sc, EHCI_USBCMD) | EHCI_CMD_IAAD); DPRINTF("cmd = 0x%08x sts = 0x%08x", EOREAD4(sc, EHCI_USBCMD), EOREAD4(sc, EHCI_USBSTS), 0, 0); - error = cv_timedwait(&sc->sc_doorbell, &sc->sc_lock, hz); /* bell wait */ + sc->sc_dbanswered = false; + /* bell wait */ + while (!sc->sc_dbanswered) { + error = cv_timedwait(&sc->sc_doorbell, &sc->sc_lock, hz); - DPRINTF("cmd = 0x%08x sts = 0x%08x ... done", - EOREAD4(sc, EHCI_USBCMD), EOREAD4(sc, EHCI_USBSTS), 0, 0); + DPRINTF("cmd = 0x%08x sts = 0x%08x ... done", + EOREAD4(sc, EHCI_USBCMD), EOREAD4(sc, EHCI_USBSTS), 0, 0); #ifdef DIAGNOSTIC - if (error == EWOULDBLOCK) { - printf("ehci_sync_hc: timed out\n"); - } else if (error) { - printf("ehci_sync_hc: cv_timedwait: error %d\n", error); - } + if (error == EWOULDBLOCK) { + printf("%s: timed out\n", __func__); + } else if (error) { + printf("%s: cv_timedwait: error %d\n", __func__, error); + } #endif + } } Static void
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 08:49:29 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: motg.c Log Message: #ifdef DIAGNOSTIC + panic -> KASSERTMSG To generate a diff of this commit: cvs rdiff -u -r1.12.2.30 -r1.12.2.31 src/sys/dev/usb/motg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/motg.c diff -u src/sys/dev/usb/motg.c:1.12.2.30 src/sys/dev/usb/motg.c:1.12.2.31 --- src/sys/dev/usb/motg.c:1.12.2.30 Sat Jul 9 20:25:15 2016 +++ src/sys/dev/usb/motg.c Tue Dec 27 08:49:29 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: motg.c,v 1.12.2.30 2016/07/09 20:25:15 skrll Exp $ */ +/* $NetBSD: motg.c,v 1.12.2.31 2016/12/27 08:49:29 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.30 2016/07/09 20:25:15 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.31 2016/12/27 08:49:29 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_motg.h" @@ -2087,9 +2087,9 @@ motg_device_intr_tx(struct motg_softc *s complete: DPRINTFN(MD_BULK, "xfer %p complete, status %d", xfer, (xfer != NULL) ? xfer->ux_status : 0, 0, 0); -#ifdef DIAGNOSTIC - if (xfer && xfer->ux_status == USBD_IN_PROGRESS && ep->phase != DATA_OUT) - panic("motg_device_intr_tx: bad phase %d", ep->phase); + KASSERTMSG(xfer && xfer->ux_status == USBD_IN_PROGRESS && + ep->phase == DATA_OUT, "xfer %p status %d phase %d", + xfer, xfer->ux_status, ep->phase); #endif ep->phase = IDLE; ep->xfer = NULL;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 08:33:08 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ohci.c Log Message: Actually set the transfer status on transfers in ohci_abort_xfer and the controller is dying To generate a diff of this commit: cvs rdiff -u -r1.254.2.82 -r1.254.2.83 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.254.2.82 src/sys/dev/usb/ohci.c:1.254.2.83 --- src/sys/dev/usb/ohci.c:1.254.2.82 Tue Dec 27 08:32:19 2016 +++ src/sys/dev/usb/ohci.c Tue Dec 27 08:33:08 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.254.2.82 2016/12/27 08:32:19 skrll Exp $ */ +/* $NetBSD: ohci.c,v 1.254.2.83 2016/12/27 08:33:08 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.82 2016/12/27 08:32:19 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.83 2016/12/27 08:33:08 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2269,7 +2269,7 @@ ohci_abort_xfer(struct usbd_xfer *xfer, if (sc->sc_dying) { /* If we're dying, just do the software part. */ - KASSERT(xfer->ux_status == status); + xfer->ux_status = status; callout_halt(&xfer->ux_callout, &sc->sc_lock); usb_transfer_complete(xfer); return;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Dec 27 08:32:19 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ohci.c Log Message: Don't supply the lock to callout_halt when polling as it won't be held To generate a diff of this commit: cvs rdiff -u -r1.254.2.81 -r1.254.2.82 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.254.2.81 src/sys/dev/usb/ohci.c:1.254.2.82 --- src/sys/dev/usb/ohci.c:1.254.2.81 Sat Dec 17 10:10:34 2016 +++ src/sys/dev/usb/ohci.c Tue Dec 27 08:32:19 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.254.2.81 2016/12/17 10:10:34 skrll Exp $ */ +/* $NetBSD: ohci.c,v 1.254.2.82 2016/12/27 08:32:19 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.81 2016/12/17 10:10:34 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.82 2016/12/27 08:32:19 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1402,8 +1402,9 @@ ohci_softintr(void *v) int len, cc; int i, j, actlen, iframes, uedir; ohci_physaddr_t done = 0; + bool polling = sc->sc_bus.ub_usepolling; - KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); + KASSERT(polling || mutex_owned(&sc->sc_lock)); OHCIHIST_FUNC(); OHCIHIST_CALLED(); @@ -1491,7 +1492,7 @@ ohci_softintr(void *v) * Make sure the timeout handler didn't run or ran to the end * and set the transfer status. */ - callout_halt(&xfer->ux_callout, &sc->sc_lock); + callout_halt(&xfer->ux_callout, polling ? NULL : &sc->sc_lock); if (xfer->ux_status == USBD_CANCELLED || xfer->ux_status == USBD_TIMEOUT) {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Dec 17 15:30:34 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_athn_usb.c Log Message: Call {mutex,cv}_destroy on all mutexes/condvars To generate a diff of this commit: cvs rdiff -u -r1.6.8.14 -r1.6.8.15 src/sys/dev/usb/if_athn_usb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_athn_usb.c diff -u src/sys/dev/usb/if_athn_usb.c:1.6.8.14 src/sys/dev/usb/if_athn_usb.c:1.6.8.15 --- src/sys/dev/usb/if_athn_usb.c:1.6.8.14 Sun Dec 11 15:10:43 2016 +++ src/sys/dev/usb/if_athn_usb.c Sat Dec 17 15:30:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_athn_usb.c,v 1.6.8.14 2016/12/11 15:10:43 skrll Exp $ */ +/* $NetBSD: if_athn_usb.c,v 1.6.8.15 2016/12/17 15:30:34 skrll Exp $ */ /* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */ /*- @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.14 2016/12/11 15:10:43 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.15 2016/12/17 15:30:34 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -499,8 +499,15 @@ athn_usb_detach(device_t self, int flags athn_usb_close_pipes(usc); mutex_destroy(&usc->usc_tx_mtx); - mutex_destroy(&usc->usc_task_mtx); cv_destroy(&usc->usc_task_cv); + mutex_destroy(&usc->usc_task_mtx); + + mutex_destroy(&usc->usc_cmd_mtx); + cv_destroy(&usc->usc_cmd_cv); + mutex_destroy(&usc->usc_msg_mtx); + cv_destroy(&usc->usc_msg_cv); + + mutex_destroy(&usc->usc_lock); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, usc->usc_udev, sc->sc_dev); return 0;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Dec 17 10:10:34 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ohci.c Log Message: Wrap a long line. To generate a diff of this commit: cvs rdiff -u -r1.254.2.80 -r1.254.2.81 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.254.2.80 src/sys/dev/usb/ohci.c:1.254.2.81 --- src/sys/dev/usb/ohci.c:1.254.2.80 Sat Dec 17 10:08:30 2016 +++ src/sys/dev/usb/ohci.c Sat Dec 17 10:10:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.254.2.80 2016/12/17 10:08:30 skrll Exp $ */ +/* $NetBSD: ohci.c,v 1.254.2.81 2016/12/17 10:10:34 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.80 2016/12/17 10:08:30 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.81 2016/12/17 10:10:34 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2369,7 +2369,10 @@ ohci_abort_xfer(struct usbd_xfer *xfer, DPRINTF("--- dump end ---", 0, 0, 0, 0); #endif -#define OHCI_CC_ACCESSED_P(x) (((x) & OHCI_CC_NOT_ACCESSED_MASK) != OHCI_CC_NOT_ACCESSED) +#define OHCI_CC_ACCESSED_P(x) \ +(((x) & OHCI_CC_NOT_ACCESSED_MASK) != OHCI_CC_NOT_ACCESSED) + + headp = O32TOH(sed->ed.ed_headp) & OHCI_HEADMASK; hit = 0; for (; p->xfer == xfer; p = n) {
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Dec 17 10:08:30 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ohci.c Log Message: Tweak a couple of comments To generate a diff of this commit: cvs rdiff -u -r1.254.2.79 -r1.254.2.80 src/sys/dev/usb/ohci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.254.2.79 src/sys/dev/usb/ohci.c:1.254.2.80 --- src/sys/dev/usb/ohci.c:1.254.2.79 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/ohci.c Sat Dec 17 10:08:30 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.254.2.79 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: ohci.c,v 1.254.2.80 2016/12/17 10:08:30 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.79 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.80 2016/12/17 10:08:30 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2229,7 +2229,7 @@ ohci_close_pipe(struct usbd_pipe *pipe, } /* - * Cancel or timeour a device request. We have two cases to deal with + * Cancel or timeout a device request. We have two cases to deal with * * 1) A driver wants to stop scheduled or inflight transfers * 2) A transfer has timed out @@ -2298,8 +2298,6 @@ ohci_abort_xfer(struct usbd_xfer *xfer, * Step 1: When cancelling a transfer make sure the timeout handler * didn't run or ran to the end and saw the USBD_CANCELLED status. * Otherwise we must have got here via a timeout. - * - * If we timed out then */ if (status == USBD_CANCELLED) { xfer->ux_status = status;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 14 22:14:28 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO Log Message: Remove one that won't happen To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.45.4.1 src/sys/dev/usb/TODO Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO diff -u src/sys/dev/usb/TODO:1.45 src/sys/dev/usb/TODO:1.45.4.1 --- src/sys/dev/usb/TODO:1.45 Wed Jun 25 21:23:03 2014 +++ src/sys/dev/usb/TODO Wed Dec 14 22:14:28 2016 @@ -59,8 +59,6 @@ Stylistic changes: use usb_ and usbd_ consistently rearrange the contents and names of some files (Nick) -Add threads to the Ethernet drivers. - Change what's done at watchdog timeout inb if_{a,c,k}ue.c; what we have now doesn't work because it's done in an interrupt context.
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Dec 14 22:09:21 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: TODO.usbmp Log Message: Some updates To generate a diff of this commit: cvs rdiff -u -r1.8.4.4 -r1.8.4.5 src/sys/dev/usb/TODO.usbmp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/TODO.usbmp diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.4 src/sys/dev/usb/TODO.usbmp:1.8.4.5 --- src/sys/dev/usb/TODO.usbmp:1.8.4.4 Mon Dec 5 10:55:17 2016 +++ src/sys/dev/usb/TODO.usbmp Wed Dec 14 22:09:21 2016 @@ -1,4 +1,4 @@ -$NetBSD: TODO.usbmp,v 1.8.4.4 2016/12/05 10:55:17 skrll Exp $ +$NetBSD: TODO.usbmp,v 1.8.4.5 2016/12/14 22:09:21 skrll Exp $ the majority of the USB MP device interface is documented in usbdivar.h. @@ -18,7 +18,7 @@ KERNEL_LOCK - uhub.c - usscanner.c -usb_detach_{waitold,wakeup} to usb_detach_{wait,broadcast} conversion: +usb_detach_{waitold,wakeup} to cv_{wait,broadcast} conversion: - drivers: if_aue.c if_axe.c @@ -26,15 +26,12 @@ usb_detach_{waitold,wakeup} to usb_detac if_smsc.c if_udav.c if_url.c - stuirda.c ubt.c - ucom.c ucycom.c udsir.c uhso.c uirda.c ulpt.c - umass.c - done, partially done -- need to check umass_scsipi.c change urio.c uscanner.c usscanner.c @@ -88,26 +85,31 @@ splusb drivers: - ubt.c - ucycom.c - udsir.c + - uhso.c + - ukbd.c + - ulpt.c + - urio.c + - uscanner.c + - usscanner.c + - ustir.c + - utoppy.c + - uvideo.c wakeup/tsleep drivers: - - if_otus.c - if_run.c - - if_upgt.c - if_urtwn.c - if_zyd.c - - ucom.c - ucycom.c - udsir.c - uirda.c - - ulpt.c - umass_isdata.c + - ulpt.c - ustir.c - uthum.c - uvscom.c - uyurex.c missing D_MPSAFE drivers: - - ucom - ucycom - ugen - partially ready - uhso @@ -148,7 +150,7 @@ driver testing: STATUS - uep - udl - ulpt attaches ok - - uhso working (must take kernel lock for scsipi) + - uhso working - umass working - uaudio working - umidi working @@ -177,7 +179,7 @@ driver testing: STATUS - uberry - uipad - urio - - uscanner ? (must take kernel lock for scsipi) + - uscanner ? - usscanner - utoppy - uyap @@ -185,9 +187,9 @@ driver testing: STATUS - ugen mostly done - pseye working - uvideo - - auvitek ? (must take kernel lock for scsipi) - - emdtv ? (must take kernel lock for scsipi) - - ubt working (must take kernel lock for scsipi) + - auvitek ? + - emdtv ? + - ubt working - aubtfwl - u3ginit ucom attachments: @@ -195,7 +197,7 @@ ucom attachments: - uark - ubsa - uchcom - - uftdi + - uftdi working - uipaq - umct - uplcom attaches ok
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Dec 12 13:17:56 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_aue.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.132.4.14 -r1.132.4.15 src/sys/dev/usb/if_aue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_aue.c diff -u src/sys/dev/usb/if_aue.c:1.132.4.14 src/sys/dev/usb/if_aue.c:1.132.4.15 --- src/sys/dev/usb/if_aue.c:1.132.4.14 Mon Dec 12 13:15:39 2016 +++ src/sys/dev/usb/if_aue.c Mon Dec 12 13:17:56 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aue.c,v 1.132.4.14 2016/12/12 13:15:39 skrll Exp $ */ +/* $NetBSD: if_aue.c,v 1.132.4.15 2016/12/12 13:17:56 skrll Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.132.4.14 2016/12/12 13:15:39 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.132.4.15 2016/12/12 13:17:56 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -811,8 +811,6 @@ aue_attach(device_t parent, device_t sel return; } - - /* Reset the adapter. */ aue_reset(sc);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Mon Dec 12 13:15:39 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_aue.c if_auereg.h if_axe.c if_axen.c if_axenreg.h if_axereg.h if_cdce.c if_cdcereg.h if_cue.c if_cuereg.h if_udav.c if_udavreg.h Log Message: WIP MPification To generate a diff of this commit: cvs rdiff -u -r1.132.4.13 -r1.132.4.14 src/sys/dev/usb/if_aue.c cvs rdiff -u -r1.25.24.3 -r1.25.24.4 src/sys/dev/usb/if_auereg.h cvs rdiff -u -r1.67.4.12 -r1.67.4.13 src/sys/dev/usb/if_axe.c cvs rdiff -u -r1.3.6.12 -r1.3.6.13 src/sys/dev/usb/if_axen.c cvs rdiff -u -r1.1.12.2 -r1.1.12.3 src/sys/dev/usb/if_axenreg.h cvs rdiff -u -r1.16.6.4 -r1.16.6.5 src/sys/dev/usb/if_axereg.h cvs rdiff -u -r1.38.14.9 -r1.38.14.10 src/sys/dev/usb/if_cdce.c cvs rdiff -u -r1.7.24.4 -r1.7.24.5 src/sys/dev/usb/if_cdcereg.h cvs rdiff -u -r1.68.4.12 -r1.68.4.13 src/sys/dev/usb/if_cue.c cvs rdiff -u -r1.18.24.4 -r1.18.24.5 src/sys/dev/usb/if_cuereg.h cvs rdiff -u -r1.43.4.11 -r1.43.4.12 src/sys/dev/usb/if_udav.c cvs rdiff -u -r1.9.16.4 -r1.9.16.5 src/sys/dev/usb/if_udavreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_aue.c diff -u src/sys/dev/usb/if_aue.c:1.132.4.13 src/sys/dev/usb/if_aue.c:1.132.4.14 --- src/sys/dev/usb/if_aue.c:1.132.4.13 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_aue.c Mon Dec 12 13:15:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aue.c,v 1.132.4.13 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_aue.c,v 1.132.4.14 2016/12/12 13:15:39 skrll Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -71,14 +71,13 @@ * TODO: * better error messages from rxstat * split out if_auevar.h - * add thread to avoid register reads from interrupt context * more error checks * investigate short rx problem * proper cleanup on errors */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.132.4.13 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.132.4.14 2016/12/12 13:15:39 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -217,11 +216,11 @@ extern struct cfdriver aue_cd; CFATTACH_DECL_NEW(aue, sizeof(struct aue_softc), aue_match, aue_attach, aue_detach, aue_activate); -Static void aue_multithread(void *); - Static void aue_reset_pegasus_II(struct aue_softc *); Static int aue_tx_list_init(struct aue_softc *); +Static void aue_tx_list_free(struct aue_softc *); Static int aue_rx_list_init(struct aue_softc *); +Static void aue_rx_list_free(struct aue_softc *); Static int aue_newbuf(struct aue_softc *, struct aue_chain *, struct mbuf *); Static int aue_send(struct aue_softc *, struct mbuf *, int); Static void aue_intr(struct usbd_xfer *, void *, usbd_status); @@ -230,11 +229,14 @@ Static void aue_txeof(struct usbd_xfer * Static void aue_tick(void *); Static void aue_tick_task(void *); Static void aue_start(struct ifnet *); +Static void aue_start_locked(struct ifnet *); Static int aue_ioctl(struct ifnet *, u_long, void *); -Static void aue_init(void *); -Static void aue_stop(struct aue_softc *); +Static int aue_ifflags_cb(struct ethercom *); +Static int aue_init(struct ifnet *); +Static int aue_init_locked(struct ifnet *); +Static void aue_stop(struct ifnet *, int); +Static void aue_stop_locked(struct ifnet *, int); Static void aue_watchdog(struct ifnet *); -Static int aue_openpipes(struct aue_softc *); Static int aue_ifmedia_upd(struct ifnet *); Static int aue_eeprom_getword(struct aue_softc *, int); @@ -723,7 +725,6 @@ aue_attach(device_t parent, device_t sel struct aue_softc *sc = device_private(self); struct usb_attach_arg *uaa = aux; char *devinfop; - int s; u_char eaddr[ETHER_ADDR_LEN]; struct ifnet *ifp; struct mii_data *mii; @@ -755,6 +756,9 @@ aue_attach(device_t parent, device_t sel usb_init_task(&sc->aue_tick_task, aue_tick_task, sc, 0); usb_init_task(&sc->aue_stop_task, (void (*)(void *))aue_stop, sc, 0); mutex_init(&sc->aue_mii_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&sc->aue_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&sc->aue_txlock, MUTEX_DEFAULT, IPL_SOFTUSB); + mutex_init(&sc->aue_rxlock, MUTEX_DEFAULT, IPL_SOFTUSB); err = usbd_device2interface_handle(dev, AUE_IFACE_IDX, &iface); if (err) { @@ -764,13 +768,8 @@ aue_attach(device_t parent, device_t sel sc->aue_closing = 0; mutex_init(&sc->aue_mcmtx, MUTEX_DRIVER, IPL_NET); - cv_init(&sc->aue_domc, "auemc"); cv_init(&sc->aue_closemc, "auemccl"); - err = kthread_create(PRI_NONE, 0, NULL, - aue_multithread, sc, &sc->aue_thread, - "%s-mc", device_xname(sc->aue_dev)); - if (err) { aprint_error_dev(self, "creating multicast configuration thread\n"); @@ -813,7 +812,6 @@ aue_attach(device_t parent, device_t sel } - s = splnet(); /* Reset the adapter. */ aue_reset(sc); @@ -833,6 +831,8 @@ aue_attach(device_t parent, device_t sel ifp->if_softc = sc;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Dec 11 17:31:09 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: usbdi.c Log Message: KASSERT -> KASSERTMSG To generate a diff of this commit: cvs rdiff -u -r1.162.2.48 -r1.162.2.49 src/sys/dev/usb/usbdi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdi.c diff -u src/sys/dev/usb/usbdi.c:1.162.2.48 src/sys/dev/usb/usbdi.c:1.162.2.49 --- src/sys/dev/usb/usbdi.c:1.162.2.48 Mon Dec 5 10:55:20 2016 +++ src/sys/dev/usb/usbdi.c Sun Dec 11 17:31:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.162.2.48 2016/12/05 10:55:20 skrll Exp $ */ +/* $NetBSD: usbdi.c,v 1.162.2.49 2016/12/11 17:31:09 skrll Exp $ */ /* * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.48 2016/12/05 10:55:20 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.49 2016/12/11 17:31:09 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1003,7 +1003,8 @@ usb_insert_transfer(struct usbd_xfer *xf xfer, pipe, pipe->up_running, xfer->ux_timeout); KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock)); - KASSERT(xfer->ux_state == XFER_BUSY); + KASSERTMSG(xfer->ux_state == XFER_BUSY, "xfer %p state is %x", xfer, + xfer->ux_state); #ifdef DIAGNOSTIC xfer->ux_state = XFER_ONQU;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Dec 11 15:10:43 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_athn_usb.c if_athn_usb.h Log Message: Sync with HEAD To generate a diff of this commit: cvs rdiff -u -r1.6.8.13 -r1.6.8.14 src/sys/dev/usb/if_athn_usb.c cvs rdiff -u -r1.2.16.3 -r1.2.16.4 src/sys/dev/usb/if_athn_usb.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_athn_usb.c diff -u src/sys/dev/usb/if_athn_usb.c:1.6.8.13 src/sys/dev/usb/if_athn_usb.c:1.6.8.14 --- src/sys/dev/usb/if_athn_usb.c:1.6.8.13 Mon Dec 5 10:55:18 2016 +++ src/sys/dev/usb/if_athn_usb.c Sun Dec 11 15:10:43 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_athn_usb.c,v 1.6.8.13 2016/12/05 10:55:18 skrll Exp $ */ +/* $NetBSD: if_athn_usb.c,v 1.6.8.14 2016/12/11 15:10:43 skrll Exp $ */ /* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */ /*- @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.13 2016/12/05 10:55:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.14 2016/12/11 15:10:43 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -94,6 +94,7 @@ CFATTACH_DECL_NEW(athn_usb, sizeof(struc Static int athn_usb_alloc_rx_list(struct athn_usb_softc *); Static int athn_usb_alloc_tx_cmd(struct athn_usb_softc *); +Static int athn_usb_alloc_tx_msg(struct athn_usb_softc *); Static int athn_usb_alloc_tx_list(struct athn_usb_softc *); Static void athn_usb_attachhook(device_t); Static void athn_usb_bcneof(struct usbd_xfer *, void *, @@ -108,6 +109,7 @@ Static void athn_usb_do_async(struct ath void (*)(struct athn_usb_softc *, void *), void *, int); Static void athn_usb_free_rx_list(struct athn_usb_softc *); Static void athn_usb_free_tx_cmd(struct athn_usb_softc *); +Static void athn_usb_free_tx_msg(struct athn_usb_softc *); Static void athn_usb_free_tx_list(struct athn_usb_softc *); Static int athn_usb_htc_connect_svc(struct athn_usb_softc *, uint16_t, uint8_t, uint8_t, uint8_t *); @@ -115,6 +117,7 @@ Static int athn_usb_htc_msg(struct athn_ int); Static int athn_usb_htc_setup(struct athn_usb_softc *); Static int athn_usb_init(struct ifnet *); +Static int athn_usb_init_locked(struct ifnet *); Static void athn_usb_intr(struct usbd_xfer *, void *, usbd_status); Static int athn_usb_ioctl(struct ifnet *, u_long, void *); @@ -140,7 +143,9 @@ Static void athn_usb_rx_wmi_ctrl(struct Static void athn_usb_rxeof(struct usbd_xfer *, void *, usbd_status); Static void athn_usb_start(struct ifnet *); +//Static void athn_usb_start_locked(struct ifnet *); Static void athn_usb_stop(struct ifnet *); +Static void athn_usb_stop_locked(struct ifnet *); Static void athn_usb_swba(struct athn_usb_softc *); Static int athn_usb_switch_chan(struct athn_softc *, struct ieee80211_channel *, struct ieee80211_channel *); @@ -152,9 +157,8 @@ Static void athn_usb_txeof(struct usbd_x Static void athn_usb_updateslot(struct ifnet *); Static void athn_usb_updateslot_cb(struct athn_usb_softc *, void *); Static void athn_usb_wait_async(struct athn_usb_softc *); -Static void athn_usb_wait_cmd(struct athn_usb_softc *); -Static void athn_usb_wait_msg(struct athn_usb_softc *); -Static void athn_usb_wait_wmi(struct athn_usb_softc *); +Static int athn_usb_wait_cmd(struct athn_usb_softc *); +Static int athn_usb_wait_msg(struct athn_usb_softc *); Static void athn_usb_watchdog(struct ifnet *); Static int athn_usb_wmi_xcmd(struct athn_usb_softc *, uint16_t, void *, int, void *); @@ -268,6 +272,13 @@ athn_usb_attach(device_t parent, device_ sc->sc_ops.write = athn_usb_write; sc->sc_ops.write_barrier = athn_usb_write_barrier; + mutex_init(&usc->usc_lock, MUTEX_DEFAULT, IPL_NONE); + + cv_init(&usc->usc_cmd_cv, "athncmd"); + mutex_init(&usc->usc_cmd_mtx, MUTEX_DEFAULT, IPL_SOFTUSB); + cv_init(&usc->usc_msg_cv, "athnmsg"); + mutex_init(&usc->usc_msg_mtx, MUTEX_DEFAULT, IPL_SOFTUSB); + cv_init(&usc->usc_task_cv, "athntsk"); mutex_init(&usc->usc_task_mtx, MUTEX_DEFAULT, IPL_NET); mutex_init(&usc->usc_tx_mtx, MUTEX_DEFAULT, IPL_NONE); @@ -295,6 +306,10 @@ athn_usb_attach(device_t parent, device_ if (athn_usb_alloc_tx_cmd(usc) != 0) goto fail; + /* Allocate xfer for firmware commands. */ + if (athn_usb_alloc_tx_msg(usc) != 0) + goto fail; + /* Allocate Tx/Rx buffers. */ error = athn_usb_alloc_rx_list(usc); if (error != 0) @@ -309,13 +324,23 @@ athn_usb_attach(device_t parent, device_ return; fail: + /* Free Tx/Rx buffers. */ athn_usb_abort_pipes(usc); athn_usb_free_tx_list(usc); athn_usb_free_rx_list(usc); athn_usb_free_tx_cmd(usc); + athn_usb_free_tx_msg(usc); athn_usb_close_pipes(usc); usb_rem_task(usc->usc_udev, &usc->usc_task); + + cv_destroy(&usc->usc_cmd_cv); + cv_destroy(&usc->usc_msg_cv); + + mutex_destroy(&usc->usc_lock); + + mutex_destroy(&usc->usc_cmd
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Nov 6 11:50:54 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Reduce the scope of the softc lock further and track device state via sc_state. All ucom methods apart from ucom_{read,write} are called without the softc lock held. ucom_close is called on last close only to match ucom_open being called on first open only. Fix ucom_detach where refcnt wasn't being decremented. More DEBUG. XXX still not sure where tty_lock needs to be held. To generate a diff of this commit: cvs rdiff -u -r1.108.2.30 -r1.108.2.31 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.30 src/sys/dev/usb/ucom.c:1.108.2.31 --- src/sys/dev/usb/ucom.c:1.108.2.30 Sun Nov 6 09:36:53 2016 +++ src/sys/dev/usb/ucom.c Sun Nov 6 11:50:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.30 2016/11/06 09:36:53 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.31 2016/11/06 11:50:54 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.30 2016/11/06 09:36:53 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.31 2016/11/06 11:50:54 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -78,7 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.1 #ifndef UCOM_DEBUG #define ucomdebug 0 #else -int ucomdebug = 0; +int ucomdebug = 10; SYSCTL_SETUP(sysctl_hw_ucom_setup, "sysctl hw.ucom setup") { @@ -181,8 +181,13 @@ struct ucom_softc { u_char sc_tx_stopped; int sc_swflags; - u_char sc_opening; /* lock during open */ - u_char sc_closing; /* lock during close */ + enum ucom_state { + UCOM_DEAD, + UCOM_ATTACHED, + UCOM_OPENING, + UCOM_CLOSING, + UCOM_OPEN + } sc_state; int sc_refcnt; bool sc_dying; /* disconnecting */ @@ -191,7 +196,7 @@ struct ucom_softc { krndsource_t sc_rndsource; /* random source */ kmutex_t sc_lock; - kcondvar_t sc_opencv; + kcondvar_t sc_statecv; kcondvar_t sc_detachcv; }; @@ -291,14 +296,13 @@ ucom_attach(device_t parent, device_t se sc->sc_mcr = 0; sc->sc_tx_stopped = 0; sc->sc_swflags = 0; - sc->sc_opening = 0; - sc->sc_closing = 0; sc->sc_refcnt = 0; sc->sc_dying = false; + sc->sc_state = UCOM_DEAD; sc->sc_si = softint_establish(SOFTINT_USB, ucom_softintr, sc); mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB); - cv_init(&sc->sc_opencv, "ucomopen"); + cv_init(&sc->sc_statecv, "ucomstate"); cv_init(&sc->sc_detachcv, "ucomdtch"); SIMPLEQ_INIT(&sc->sc_ibuff_empty); @@ -384,6 +388,9 @@ ucom_attach(device_t parent, device_t se if (!pmf_device_register(self, NULL, NULL)) aprint_error_dev(self, "couldn't establish power handler\n"); + + sc->sc_state = UCOM_ATTACHED; + return; fail_2: @@ -434,6 +441,18 @@ ucom_detach(device_t self, int flags) usbd_abort_pipe(sc->sc_bulkout_pipe); mutex_enter(&sc->sc_lock); + + /* wait for open/close to finish */ + while (sc->sc_state == UCOM_OPENING || sc->sc_state == UCOM_CLOSING) { + int error = cv_wait_sig(&sc->sc_statecv, &sc->sc_lock); + + if (error) { + mutex_exit(&sc->sc_lock); + return error; + } + } + + sc->sc_refcnt--; while (sc->sc_refcnt > 0) { /* Wake up anyone waiting */ if (tp != NULL) { @@ -494,7 +513,7 @@ ucom_detach(device_t self, int flags) rnd_detach_source(&sc->sc_rndsource); mutex_destroy(&sc->sc_lock); - cv_destroy(&sc->sc_opencv); + cv_destroy(&sc->sc_statecv); cv_destroy(&sc->sc_detachcv); return 0; @@ -544,7 +563,7 @@ ucomopen(dev_t dev, int flag, int mode, { const int unit = UCOMUNIT(dev); struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); - int error; + int error = 0; UCOMHIST_FUNC(); UCOMHIST_CALLED(); @@ -553,6 +572,7 @@ ucomopen(dev_t dev, int flag, int mode, mutex_enter(&sc->sc_lock); if (sc->sc_dying) { + DPRINTF("... dying", 0, 0, 0, 0); mutex_exit(&sc->sc_lock); return EIO; } @@ -575,29 +595,36 @@ ucomopen(dev_t dev, int flag, int mode, * Wait while the device is initialized by the * first opener or cleaned up by the last closer. */ - while (sc->sc_opening || sc->sc_closing) { - error = cv_wait_sig(&sc->sc_opencv, &sc->sc_lock); + while (sc->sc_state == UCOM_OPENING || sc->sc_state == UCOM_CLOSING) { + error = cv_wait_sig(&sc->sc_statecv, &sc->sc_lock); + + if (sc->sc_dying) + error = EIO; if (error) { mutex_exit(&sc->sc_lock); return error; } } + enum ucom_state state = sc->sc_state; - sc->sc_opening = 1; + KASSERTMSG(state == UCOM_OPEN || state == UCOM_ATTACHED, + "state is %d", state); + bool cleanup = false; + /* If this is the first open then perform the initialisation */ if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) { + KASSERT(state == UCO
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sun Nov 6 09:36:53 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Add #include "opt_usb.h" To generate a diff of this commit: cvs rdiff -u -r1.108.2.29 -r1.108.2.30 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.29 src/sys/dev/usb/ucom.c:1.108.2.30 --- src/sys/dev/usb/ucom.c:1.108.2.29 Wed Nov 2 08:41:00 2016 +++ src/sys/dev/usb/ucom.c Sun Nov 6 09:36:53 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.29 2016/11/02 08:41:00 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.30 2016/11/06 09:36:53 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.29 2016/11/02 08:41:00 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.30 2016/11/06 09:36:53 skrll Exp $"); + +#ifdef _KERNEL_OPT +#include "opt_usb.h" +#endif #include #include
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Fri Nov 4 16:22:38 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucomvar.h Log Message: Functional declaration nit. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.20.24.5 -r1.20.24.6 src/sys/dev/usb/ucomvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucomvar.h diff -u src/sys/dev/usb/ucomvar.h:1.20.24.5 src/sys/dev/usb/ucomvar.h:1.20.24.6 --- src/sys/dev/usb/ucomvar.h:1.20.24.5 Mon May 30 06:54:17 2016 +++ src/sys/dev/usb/ucomvar.h Fri Nov 4 16:22:38 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucomvar.h,v 1.20.24.5 2016/05/30 06:54:17 skrll Exp $ */ +/* $NetBSD: ucomvar.h,v 1.20.24.6 2016/11/04 16:22:38 skrll Exp $ */ /* * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -109,7 +109,7 @@ struct ucom_attach_args { }; int ucomprint(void *, const char *); -int ucomsubmatch(device_t t, cfdata_t, const int *, void *); +int ucomsubmatch(device_t, cfdata_t, const int *, void *); void ucom_status_change(struct ucom_softc *); void ucomreadcb(struct usbd_xfer *, void *, usbd_status);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Nov 2 08:41:01 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.108.2.28 -r1.108.2.29 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.28 src/sys/dev/usb/ucom.c:1.108.2.29 --- src/sys/dev/usb/ucom.c:1.108.2.28 Wed Nov 2 08:31:25 2016 +++ src/sys/dev/usb/ucom.c Wed Nov 2 08:41:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.28 2016/11/02 08:31:25 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.29 2016/11/02 08:41:00 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.28 2016/11/02 08:31:25 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.29 2016/11/02 08:41:00 skrll Exp $"); #include #include @@ -587,7 +587,7 @@ ucomopen(dev_t dev, int flag, int mode, if (sc->sc_methods->ucom_open != NULL) { error = sc->sc_methods->ucom_open(sc->sc_parent, - sc->sc_portno); + sc->sc_portno); if (error) { ucom_cleanup(sc); sc->sc_opening = 0; @@ -1153,7 +1153,7 @@ ucomparam(struct tty *tp, struct termios if (sc->sc_methods->ucom_param != NULL) { error = sc->sc_methods->ucom_param(sc->sc_parent, sc->sc_portno, - t); + t); if (error) return error; } @@ -1253,7 +1253,7 @@ ucomstart(struct tty *tp) if (sc->sc_methods->ucom_write != NULL) sc->sc_methods->ucom_write(sc->sc_parent, sc->sc_portno, - ub->ub_data, data, &cnt); + ub->ub_data, data, &cnt); else memcpy(ub->ub_data, data, cnt);
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Nov 2 08:31:25 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Reduce the scope of a variable and style. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.108.2.27 -r1.108.2.28 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.27 src/sys/dev/usb/ucom.c:1.108.2.28 --- src/sys/dev/usb/ucom.c:1.108.2.27 Wed Nov 2 08:28:10 2016 +++ src/sys/dev/usb/ucom.c Wed Nov 2 08:31:25 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.27 2016/11/02 08:28:10 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.28 2016/11/02 08:31:25 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.27 2016/11/02 08:28:10 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.28 2016/11/02 08:31:25 skrll Exp $"); #include #include @@ -540,7 +540,6 @@ ucomopen(dev_t dev, int flag, int mode, { const int unit = UCOMUNIT(dev); struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); - struct ucom_buffer *ub; int error; UCOMHIST_FUNC(); UCOMHIST_CALLED(); @@ -648,8 +647,8 @@ ucomopen(dev_t dev, int flag, int mode, /* * ucomsubmitread handles bulk vs other */ - for (ub = &sc->sc_ibuff[0]; ub != &sc->sc_ibuff[UCOM_IN_BUFFS]; - ub++) { + for (size_t i = 0; i < UCOM_IN_BUFFS; i++) { + struct ucom_buffer *ub = &sc->sc_ibuff[i]; error = ucomsubmitread(sc, ub); if (error) goto fail_2;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Wed Nov 2 08:28:10 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Make ucomsubmitread return int instead of usbd_status. To generate a diff of this commit: cvs rdiff -u -r1.108.2.26 -r1.108.2.27 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.26 src/sys/dev/usb/ucom.c:1.108.2.27 --- src/sys/dev/usb/ucom.c:1.108.2.26 Tue Nov 1 08:27:57 2016 +++ src/sys/dev/usb/ucom.c Wed Nov 2 08:28:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.26 2016/11/01 08:27:57 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.27 2016/11/02 08:28:10 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.26 2016/11/01 08:27:57 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.27 2016/11/02 08:28:10 skrll Exp $"); #include #include @@ -234,7 +234,7 @@ static void ucom_write_status(struct uco static void ucomwritecb(struct usbd_xfer *, void *, usbd_status); static void ucom_read_complete(struct ucom_softc *); -static usbd_status ucomsubmitread(struct ucom_softc *, struct ucom_buffer *); +static int ucomsubmitread(struct ucom_softc *, struct ucom_buffer *); static void ucom_softintr(void *); int ucom_match(device_t, cfdata_t, void *); @@ -650,10 +650,9 @@ ucomopen(dev_t dev, int flag, int mode, */ for (ub = &sc->sc_ibuff[0]; ub != &sc->sc_ibuff[UCOM_IN_BUFFS]; ub++) { - if (ucomsubmitread(sc, ub) != USBD_NORMAL_COMPLETION) { -error = EIO; + error = ucomsubmitread(sc, ub); + if (error) goto fail_2; - } } } sc->sc_opening = 0; @@ -1423,7 +1422,7 @@ ucom_read_complete(struct ucom_softc *sc sc->sc_rx_unblock = (ub != NULL); } -static usbd_status +static int ucomsubmitread(struct ucom_softc *sc, struct ucom_buffer *ub) { usbd_status err; @@ -1435,13 +1434,13 @@ ucomsubmitread(struct ucom_softc *sc, st if ((err = usbd_transfer(ub->ub_xfer)) != USBD_IN_PROGRESS) { /* XXX: Recover from this, please! */ printf("%s: err=%s\n", __func__, usbd_errstr(err)); - return err; + return EIO; } } SIMPLEQ_INSERT_TAIL(&sc->sc_ibuff_empty, ub, ub_link); - return USBD_NORMAL_COMPLETION; + return 0; } void
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Tue Nov 1 08:27:57 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Style... No functional change. To generate a diff of this commit: cvs rdiff -u -r1.108.2.25 -r1.108.2.26 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.25 src/sys/dev/usb/ucom.c:1.108.2.26 --- src/sys/dev/usb/ucom.c:1.108.2.25 Thu Oct 27 12:30:54 2016 +++ src/sys/dev/usb/ucom.c Tue Nov 1 08:27:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.25 2016/10/27 12:30:54 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.26 2016/11/01 08:27:57 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.25 2016/10/27 12:30:54 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.26 2016/11/01 08:27:57 skrll Exp $"); #include #include @@ -584,8 +584,6 @@ ucomopen(dev_t dev, int flag, int mode, sc->sc_opening = 1; if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) { - struct termios t; - tp->t_dev = dev; if (sc->sc_methods->ucom_open != NULL) { @@ -613,6 +611,8 @@ ucomopen(dev_t dev, int flag, int mode, * Initialize the termios status to the defaults. Add in the * sticky bits from TIOCSFLAGS. */ + struct termios t; + t.c_ispeed = 0; t.c_ospeed = TTYDEF_SPEED; t.c_cflag = TTYDEF_CFLAG;
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Oct 27 12:30:54 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c Log Message: Style and sprinkle const. To generate a diff of this commit: cvs rdiff -u -r1.108.2.24 -r1.108.2.25 src/sys/dev/usb/ucom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.24 src/sys/dev/usb/ucom.c:1.108.2.25 --- src/sys/dev/usb/ucom.c:1.108.2.24 Thu Oct 27 07:46:19 2016 +++ src/sys/dev/usb/ucom.c Thu Oct 27 12:30:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.24 2016/10/27 07:46:19 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.25 2016/10/27 12:30:54 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.24 2016/10/27 07:46:19 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.25 2016/10/27 12:30:54 skrll Exp $"); #include #include @@ -538,8 +538,8 @@ ucom_shutdown(struct ucom_softc *sc) int ucomopen(dev_t dev, int flag, int mode, struct lwp *l) { - int unit = UCOMUNIT(dev); - struct ucom_softc *sc = device_lookup_private(&ucom_cd, unit); + const int unit = UCOMUNIT(dev); + struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); struct ucom_buffer *ub; int error; @@ -701,7 +701,8 @@ bad: int ucomclose(dev_t dev, int flag, int mode, struct lwp *l) { - struct ucom_softc *sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev)); + const int unit = UCOMUNIT(dev); + struct ucom_softc *sc = device_lookup_private(&ucom_cd, unit); UCOMHIST_FUNC(); UCOMHIST_CALLED(); @@ -753,7 +754,8 @@ out: int ucomread(dev_t dev, struct uio *uio, int flag) { - struct ucom_softc *sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev)); + const int unit = UCOMUNIT(dev); + struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); int error; UCOMHIST_FUNC(); UCOMHIST_CALLED(); @@ -785,7 +787,8 @@ ucomread(dev_t dev, struct uio *uio, int int ucomwrite(dev_t dev, struct uio *uio, int flag) { - struct ucom_softc *sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev)); + const int unit = UCOMUNIT(dev); + struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); int error; if (sc == NULL) @@ -815,10 +818,9 @@ ucomwrite(dev_t dev, struct uio *uio, in int ucompoll(dev_t dev, int events, struct lwp *l) { - struct ucom_softc *sc; - int revents; + const int unit = UCOMUNIT(dev); + struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); - sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev)); if (sc == NULL) return POLLHUP; @@ -832,7 +834,7 @@ ucompoll(dev_t dev, int events, struct l sc->sc_refcnt++; mutex_exit(&sc->sc_lock); - revents = ((*tp->t_linesw->l_poll)(tp, events, l)); + int revents = ((*tp->t_linesw->l_poll)(tp, events, l)); mutex_enter(&sc->sc_lock); if (--sc->sc_refcnt < 0) @@ -845,7 +847,8 @@ ucompoll(dev_t dev, int events, struct l struct tty * ucomtty(dev_t dev) { - struct ucom_softc *sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev)); + const int unit = UCOMUNIT(dev); + struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); return sc != NULL ? sc->sc_tty : NULL; } @@ -853,7 +856,8 @@ ucomtty(dev_t dev) int ucomioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { - struct ucom_softc *sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev)); + const int unit = UCOMUNIT(dev); + struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); int error; if (sc == NULL) @@ -,8 +1115,8 @@ ucom_status_change(struct ucom_softc *sc static int ucomparam(struct tty *tp, struct termios *t) { - struct ucom_softc *sc = device_lookup_private(&ucom_cd, - UCOMUNIT(tp->t_dev)); + const int unit = UCOMUNIT(tp->t_dev); + struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); int error; UCOMHIST_FUNC(); UCOMHIST_CALLED(); @@ -1182,8 +1186,8 @@ XXX what if the hardware is not open static int ucomhwiflow(struct tty *tp, int block) { - struct ucom_softc *sc = device_lookup_private(&ucom_cd, - UCOMUNIT(tp->t_dev)); + const int unit = UCOMUNIT(tp->t_dev); + struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); int old; if (sc == NULL) @@ -1205,8 +1209,8 @@ ucomhwiflow(struct tty *tp, int block) static void ucomstart(struct tty *tp) { - struct ucom_softc *sc = device_lookup_private(&ucom_cd, - UCOMUNIT(tp->t_dev)); + const int unit = UCOMUNIT(tp->t_dev); + struct ucom_softc * const sc = device_lookup_private(&ucom_cd, unit); struct ucom_buffer *ub; u_char *data; int cnt; @@ -1270,8 +1274,8 @@ void ucomstop(struct tty *tp, int flag) { #if 0 - struct ucom_softc *sc = - device_lookup_private(&ucom_cd, UCOMUNIT(tp->t_dev)); + const int unit = UCOMUNIT(tp->t_dev); + struct ucom_softc * const sc = device
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Thu Oct 27 07:46:19 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ucom.c ugen.c uhid.c umass.c umidi.c usbdi_util.c usbdi_util.h Log Message: Retire usb_detach_{wait,broadcast} and simply use condvar(9) instead To generate a diff of this commit: cvs rdiff -u -r1.108.2.23 -r1.108.2.24 src/sys/dev/usb/ucom.c cvs rdiff -u -r1.126.2.15 -r1.126.2.16 src/sys/dev/usb/ugen.c cvs rdiff -u -r1.92.4.10 -r1.92.4.11 src/sys/dev/usb/uhid.c cvs rdiff -u -r1.149.2.14 -r1.149.2.15 src/sys/dev/usb/umass.c cvs rdiff -u -r1.65.14.12 -r1.65.14.13 src/sys/dev/usb/umidi.c cvs rdiff -u -r1.63.2.13 -r1.63.2.14 src/sys/dev/usb/usbdi_util.c cvs rdiff -u -r1.45.6.9 -r1.45.6.10 src/sys/dev/usb/usbdi_util.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ucom.c diff -u src/sys/dev/usb/ucom.c:1.108.2.23 src/sys/dev/usb/ucom.c:1.108.2.24 --- src/sys/dev/usb/ucom.c:1.108.2.23 Tue Oct 25 07:32:25 2016 +++ src/sys/dev/usb/ucom.c Thu Oct 27 07:46:19 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.108.2.23 2016/10/25 07:32:25 skrll Exp $ */ +/* $NetBSD: ucom.c,v 1.108.2.24 2016/10/27 07:46:19 skrll Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.23 2016/10/25 07:32:25 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.24 2016/10/27 07:46:19 skrll Exp $"); #include #include @@ -440,7 +440,10 @@ ucom_detach(device_t self, int flags) mutex_spin_exit(&tty_lock); } /* Wait for processes to go away. */ - usb_detach_wait(sc->sc_dev, &sc->sc_detachcv, &sc->sc_lock); + if (cv_timedwait(&sc->sc_detachcv, &sc->sc_lock, hz * 60)) { + printf("%s: %s didn't detach\n", __func__, + device_xname(sc->sc_dev)); + } } softint_disestablish(sc->sc_si); @@ -736,7 +739,7 @@ ucomclose(dev_t dev, int flag, int mode, sc->sc_methods->ucom_close(sc->sc_parent, sc->sc_portno); if (--sc->sc_refcnt < 0) - usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv); + cv_broadcast(&sc->sc_detachcv); out: sc->sc_closing = 0; @@ -773,7 +776,7 @@ ucomread(dev_t dev, struct uio *uio, int mutex_enter(&sc->sc_lock); if (--sc->sc_refcnt < 0) - usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv); + cv_broadcast(&sc->sc_detachcv); mutex_exit(&sc->sc_lock); return error; @@ -803,7 +806,7 @@ ucomwrite(dev_t dev, struct uio *uio, in mutex_enter(&sc->sc_lock); if (--sc->sc_refcnt < 0) - usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv); + cv_broadcast(&sc->sc_detachcv); mutex_exit(&sc->sc_lock); return error; @@ -833,7 +836,7 @@ ucompoll(dev_t dev, int events, struct l mutex_enter(&sc->sc_lock); if (--sc->sc_refcnt < 0) - usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv); + cv_broadcast(&sc->sc_detachcv); mutex_exit(&sc->sc_lock); return revents; @@ -869,7 +872,7 @@ ucomioctl(dev_t dev, u_long cmd, void *d mutex_enter(&sc->sc_lock); if (--sc->sc_refcnt < 0) - usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv); + cv_broadcast(&sc->sc_detachcv); mutex_exit(&sc->sc_lock); return error; Index: src/sys/dev/usb/ugen.c diff -u src/sys/dev/usb/ugen.c:1.126.2.15 src/sys/dev/usb/ugen.c:1.126.2.16 --- src/sys/dev/usb/ugen.c:1.126.2.15 Sat Jul 9 20:25:16 2016 +++ src/sys/dev/usb/ugen.c Thu Oct 27 07:46:19 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ugen.c,v 1.126.2.15 2016/07/09 20:25:16 skrll Exp $ */ +/* $NetBSD: ugen.c,v 1.126.2.16 2016/10/27 07:46:19 skrll Exp $ */ /* * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.126.2.15 2016/07/09 20:25:16 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.126.2.16 2016/10/27 07:46:19 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -812,7 +812,7 @@ ugenread(dev_t dev, struct uio *uio, int mutex_enter(&sc->sc_lock); if (--sc->sc_refcnt < 0) - usb_detach_broadcast(sc->sc_dev, &sc->sc_detach_cv); + cv_broadcast(&sc->sc_detach_cv); mutex_exit(&sc->sc_lock); return error; @@ -1006,7 +1006,7 @@ ugenwrite(dev_t dev, struct uio *uio, in mutex_enter(&sc->sc_lock); if (--sc->sc_refcnt < 0) - usb_detach_broadcast(sc->sc_dev, &sc->sc_detach_cv); + cv_broadcast(&sc->sc_detach_cv); mutex_exit(&sc->sc_lock); return error; @@ -1053,7 +1053,10 @@ ugen_detach(device_t self, int flags) for (i = 0; i < USB_MAX_ENDPOINTS; i++) cv_signal(&sc->sc_endpoints[i][IN].cv); /* Wait for processes to go away. */ - usb_detach_wait(sc->sc_dev, &sc->sc_detach_cv, &sc->sc_lock); + if (cv_timedwait(&sc->sc_detach_cv, &sc->sc_lock, hz * 60)) { + printf("%s: %s didn't detach\n", __func__, + device_xname(sc->sc_dev)); + } } mutex_exit(&sc->sc_lock); @@ -1836,7 +1839,7 @@ ugenioctl(dev_t dev, u_long cmd, void *a sc->sc_refcnt++; error = ug