From owner-svn-src-all@FreeBSD.ORG Mon Mar 2 02:44:12 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1136B106566C; Mon, 2 Mar 2009 02:44:12 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F2F2D8FC15; Mon, 2 Mar 2009 02:44:11 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n222iBxW062320; Mon, 2 Mar 2009 02:44:11 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n222iBk3062302; Mon, 2 Mar 2009 02:44:11 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200903020244.n222iBk3062302@svn.freebsd.org> From: Andrew Thompson Date: Mon, 2 Mar 2009 02:44:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189265 - head/sys/dev/usb/serial X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2009 02:44:12 -0000 Author: thompsa Date: Mon Mar 2 02:44:10 2009 New Revision: 189265 URL: http://svn.freebsd.org/changeset/base/189265 Log: Move the serial drivers from Giant to using their own mutexs. Tested with: u3g, ubser, uplcom Modified: head/sys/dev/usb/serial/u3g.c head/sys/dev/usb/serial/uark.c head/sys/dev/usb/serial/ubsa.c head/sys/dev/usb/serial/ubser.c head/sys/dev/usb/serial/uchcom.c head/sys/dev/usb/serial/ucycom.c head/sys/dev/usb/serial/ufoma.c head/sys/dev/usb/serial/uftdi.c head/sys/dev/usb/serial/ugensa.c head/sys/dev/usb/serial/uipaq.c head/sys/dev/usb/serial/ulpt.c head/sys/dev/usb/serial/umct.c head/sys/dev/usb/serial/umodem.c head/sys/dev/usb/serial/umoscom.c head/sys/dev/usb/serial/uplcom.c head/sys/dev/usb/serial/uslcom.c head/sys/dev/usb/serial/uvisor.c head/sys/dev/usb/serial/uvscom.c Modified: head/sys/dev/usb/serial/u3g.c ============================================================================== --- head/sys/dev/usb/serial/u3g.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/u3g.c Mon Mar 2 02:44:10 2009 (r189265) @@ -90,6 +90,7 @@ struct u3g_softc { struct usb2_xfer *sc_xfer[U3G_MAXPORTS][U3G_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint8_t sc_lsr; /* local status register */ uint8_t sc_msr; /* U3G status register */ @@ -455,6 +456,7 @@ u3g_attach(device_t dev) u3g_config_tmp[n] = u3g_config[n]; device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "u3g", NULL, MTX_DEF); sc->sc_udev = uaa->device; @@ -488,7 +490,7 @@ u3g_attach(device_t dev) /* try to allocate a set of BULK endpoints */ error = usb2_transfer_setup(uaa->device, &x, sc->sc_xfer[m], u3g_config_tmp, U3G_N_TRANSFER, - &sc->sc_ucom[m], &Giant); + &sc->sc_ucom[m], &sc->sc_mtx); if (error) { /* next interface */ x++; @@ -502,8 +504,10 @@ u3g_attach(device_t dev) uaa->info.bIfaceIndex); /* set stall by default */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[m][U3G_BULK_WR]); usb2_transfer_set_stall(sc->sc_xfer[m][U3G_BULK_RD]); + mtx_unlock(&sc->sc_mtx); m++; /* found one port */ i++; /* next endpoint index */ @@ -512,7 +516,7 @@ u3g_attach(device_t dev) sc->sc_numports = m; error = usb2_com_attach(&sc->sc_super_ucom, sc->sc_ucom, - sc->sc_numports, sc, &u3g_callback, &Giant); + sc->sc_numports, sc, &u3g_callback, &sc->sc_mtx); if (error) { DPRINTF("usb2_com_attach failed\n"); goto detach; @@ -542,6 +546,7 @@ u3g_detach(device_t dev) for (m = 0; m != U3G_MAXPORTS; m++) usb2_transfer_unsetup(sc->sc_xfer[m], U3G_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/uark.c ============================================================================== --- head/sys/dev/usb/serial/uark.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/uark.c Mon Mar 2 02:44:10 2009 (r189265) @@ -73,6 +73,7 @@ struct uark_softc { struct usb2_xfer *sc_xfer[UARK_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint8_t sc_msr; uint8_t sc_lsr; @@ -181,13 +182,14 @@ uark_attach(device_t dev) uint8_t iface_index; device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "uark", NULL, MTX_DEF); sc->sc_udev = uaa->device; iface_index = UARK_IFACE_INDEX; error = usb2_transfer_setup (uaa->device, &iface_index, sc->sc_xfer, - uark_xfer_config, UARK_N_TRANSFER, sc, &Giant); + uark_xfer_config, UARK_N_TRANSFER, sc, &sc->sc_mtx); if (error) { device_printf(dev, "allocating control USB " @@ -195,11 +197,13 @@ uark_attach(device_t dev) goto detach; } /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UARK_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UARK_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &uark_callback, &Giant); + &uark_callback, &sc->sc_mtx); if (error) { DPRINTF("usb2_com_attach failed\n"); goto detach; @@ -217,8 +221,8 @@ uark_detach(device_t dev) struct uark_softc *sc = device_get_softc(dev); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UARK_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/ubsa.c ============================================================================== --- head/sys/dev/usb/serial/ubsa.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/ubsa.c Mon Mar 2 02:44:10 2009 (r189265) @@ -153,6 +153,7 @@ struct ubsa_softc { struct usb2_xfer *sc_xfer[UBSA_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint8_t sc_iface_no; /* interface number */ uint8_t sc_iface_index; /* interface index */ @@ -289,24 +290,27 @@ ubsa_attach(device_t dev) DPRINTF("sc=%p\n", sc); device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "ubsa", NULL, MTX_DEF); sc->sc_udev = uaa->device; sc->sc_iface_no = uaa->info.bIfaceNum; sc->sc_iface_index = UBSA_IFACE_INDEX; error = usb2_transfer_setup(uaa->device, &sc->sc_iface_index, - sc->sc_xfer, ubsa_config, UBSA_N_TRANSFER, sc, &Giant); + sc->sc_xfer, ubsa_config, UBSA_N_TRANSFER, sc, &sc->sc_mtx); if (error) { DPRINTF("could not allocate all pipes\n"); goto detach; } /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UBSA_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UBSA_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &ubsa_callback, &Giant); + &ubsa_callback, &sc->sc_mtx); if (error) { DPRINTF("usb2_com_attach failed\n"); goto detach; @@ -326,8 +330,8 @@ ubsa_detach(device_t dev) DPRINTF("sc=%p\n", sc); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UBSA_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/ubser.c ============================================================================== --- head/sys/dev/usb/serial/ubser.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/ubser.c Mon Mar 2 02:44:10 2009 (r189265) @@ -122,6 +122,7 @@ struct ubser_softc { struct usb2_xfer *sc_xfer[UBSER_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint16_t sc_tx_size; @@ -227,6 +228,7 @@ ubser_attach(device_t dev) int error; device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "ubser", NULL, MTX_DEF); snprintf(sc->sc_name, sizeof(sc->sc_name), "%s", device_get_nameunit(dev)); @@ -258,7 +260,7 @@ ubser_attach(device_t dev) device_printf(dev, "found %i serials\n", sc->sc_numser); error = usb2_transfer_setup(uaa->device, &sc->sc_iface_index, - sc->sc_xfer, ubser_config, UBSER_N_TRANSFER, sc, &Giant); + sc->sc_xfer, ubser_config, UBSER_N_TRANSFER, sc, &sc->sc_mtx); if (error) { goto detach; } @@ -275,18 +277,16 @@ ubser_attach(device_t dev) } error = usb2_com_attach(&sc->sc_super_ucom, sc->sc_ucom, - sc->sc_numser, sc, &ubser_callback, &Giant); + sc->sc_numser, sc, &ubser_callback, &sc->sc_mtx); if (error) { goto detach; } - mtx_lock(&Giant); + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UBSER_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UBSER_BULK_DT_RD]); - usb2_transfer_start(sc->sc_xfer[UBSER_BULK_DT_RD]); - - mtx_unlock(&Giant); + mtx_unlock(&sc->sc_mtx); return (0); /* success */ @@ -303,8 +303,8 @@ ubser_detach(device_t dev) DPRINTF("\n"); usb2_com_detach(&sc->sc_super_ucom, sc->sc_ucom, sc->sc_numser); - usb2_transfer_unsetup(sc->sc_xfer, UBSER_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/uchcom.c ============================================================================== --- head/sys/dev/usb/serial/uchcom.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/uchcom.c Mon Mar 2 02:44:10 2009 (r189265) @@ -158,6 +158,7 @@ struct uchcom_softc { struct usb2_xfer *sc_xfer[UCHCOM_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint8_t sc_dtr; /* local copy */ uint8_t sc_rts; /* local copy */ @@ -303,6 +304,7 @@ uchcom_attach(device_t dev) DPRINTFN(11, "\n"); device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "uchcom", NULL, MTX_DEF); sc->sc_udev = uaa->device; @@ -318,7 +320,7 @@ uchcom_attach(device_t dev) iface_index = UCHCOM_IFACE_INDEX; error = usb2_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, uchcom_config_data, - UCHCOM_N_TRANSFER, sc, &Giant); + UCHCOM_N_TRANSFER, sc, &sc->sc_mtx); if (error) { DPRINTF("one or more missing USB endpoints, " @@ -338,11 +340,13 @@ uchcom_attach(device_t dev) sc->sc_rts = 1; /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UCHCOM_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UCHCOM_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &uchcom_callback, &Giant); + &uchcom_callback, &sc->sc_mtx); if (error) { goto detach; } @@ -361,8 +365,8 @@ uchcom_detach(device_t dev) DPRINTFN(11, "\n"); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UCHCOM_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/ucycom.c ============================================================================== --- head/sys/dev/usb/serial/ucycom.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/ucycom.c Mon Mar 2 02:44:10 2009 (r189265) @@ -71,6 +71,7 @@ struct ucycom_softc { struct usb2_device *sc_udev; struct usb2_xfer *sc_xfer[UCYCOM_N_TRANSFER]; + struct mtx sc_mtx; uint32_t sc_model; #define MODEL_CY7C63743 0x63743 @@ -204,6 +205,7 @@ ucycom_attach(device_t dev) sc->sc_udev = uaa->device; device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "ucycom", NULL, MTX_DEF); snprintf(sc->sc_name, sizeof(sc->sc_name), "%s", device_get_nameunit(dev)); @@ -250,14 +252,14 @@ ucycom_attach(device_t dev) iface_index = UCYCOM_IFACE_INDEX; error = usb2_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, ucycom_config, UCYCOM_N_TRANSFER, - sc, &Giant); + sc, &sc->sc_mtx); if (error) { device_printf(dev, "allocating USB " "transfers failed!\n"); goto detach; } error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &ucycom_callback, &Giant); + &ucycom_callback, &sc->sc_mtx); if (error) { goto detach; @@ -281,8 +283,8 @@ ucycom_detach(device_t dev) struct ucycom_softc *sc = device_get_softc(dev); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UCYCOM_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/ufoma.c ============================================================================== --- head/sys/dev/usb/serial/ufoma.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/ufoma.c Mon Mar 2 02:44:10 2009 (r189265) @@ -160,6 +160,7 @@ struct ufoma_softc { struct usb2_com_super_softc sc_super_ucom; struct usb2_com_softc sc_ucom; struct cv sc_cv; + struct mtx sc_mtx; struct usb2_xfer *sc_ctrl_xfer[UFOMA_CTRL_ENDPT_MAX]; struct usb2_xfer *sc_bulk_xfer[UFOMA_BULK_ENDPT_MAX]; @@ -365,6 +366,7 @@ ufoma_attach(device_t dev) sc->sc_dev = dev; sc->sc_unit = device_get_unit(dev); + mtx_init(&sc->sc_mtx, "ufoma", NULL, MTX_DEF); usb2_cv_init(&sc->sc_cv, "CWAIT"); device_set_usb2_desc(dev); @@ -383,7 +385,7 @@ ufoma_attach(device_t dev) error = usb2_transfer_setup(uaa->device, &sc->sc_ctrl_iface_index, sc->sc_ctrl_xfer, - ufoma_ctrl_config, UFOMA_CTRL_ENDPT_MAX, sc, &Giant); + ufoma_ctrl_config, UFOMA_CTRL_ENDPT_MAX, sc, &sc->sc_mtx); if (error) { device_printf(dev, "allocating control USB " @@ -424,11 +426,13 @@ ufoma_attach(device_t dev) sc->sc_modetoactivate = mad->bMode[0]; /* clear stall at first run, if any */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_WRITE]); usb2_transfer_set_stall(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_READ]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &ufoma_callback, &Giant); + &ufoma_callback, &sc->sc_mtx); if (error) { DPRINTF("usb2_com_attach failed\n"); goto detach; @@ -465,14 +469,13 @@ ufoma_detach(device_t dev) struct ufoma_softc *sc = device_get_softc(dev); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_ctrl_xfer, UFOMA_CTRL_ENDPT_MAX); - usb2_transfer_unsetup(sc->sc_bulk_xfer, UFOMA_BULK_ENDPT_MAX); if (sc->sc_modetable) { free(sc->sc_modetable, M_USBDEV); } + mtx_destroy(&sc->sc_mtx); usb2_cv_destroy(&sc->sc_cv); return (0); @@ -512,7 +515,7 @@ ufoma_cfg_link_state(struct ufoma_softc usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom, &req, sc->sc_modetable, 0, 1000); - error = usb2_cv_timedwait(&sc->sc_cv, &Giant, hz); + error = usb2_cv_timedwait(&sc->sc_cv, &sc->sc_mtx, hz); if (error) { DPRINTF("NO response\n"); @@ -534,7 +537,7 @@ ufoma_cfg_activate_state(struct ufoma_so usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom, &req, NULL, 0, 1000); - error = usb2_cv_timedwait(&sc->sc_cv, &Giant, + error = usb2_cv_timedwait(&sc->sc_cv, &sc->sc_mtx, (UFOMA_MAX_TIMEOUT * hz)); if (error) { DPRINTF("No response\n"); @@ -1035,7 +1038,7 @@ ufoma_modem_setup(device_t dev, struct u error = usb2_transfer_setup(uaa->device, &sc->sc_data_iface_index, sc->sc_bulk_xfer, - ufoma_bulk_config, UFOMA_BULK_ENDPT_MAX, sc, &Giant); + ufoma_bulk_config, UFOMA_BULK_ENDPT_MAX, sc, &sc->sc_mtx); if (error) { device_printf(dev, "allocating BULK USB " Modified: head/sys/dev/usb/serial/uftdi.c ============================================================================== --- head/sys/dev/usb/serial/uftdi.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/uftdi.c Mon Mar 2 02:44:10 2009 (r189265) @@ -96,6 +96,7 @@ struct uftdi_softc { struct usb2_device *sc_udev; struct usb2_xfer *sc_xfer[UFTDI_N_TRANSFER]; device_t sc_dev; + struct mtx sc_mtx; uint32_t sc_unit; enum uftdi_type sc_type; @@ -259,6 +260,7 @@ uftdi_attach(device_t dev) sc->sc_unit = device_get_unit(dev); device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "uftdi", NULL, MTX_DEF); snprintf(sc->sc_name, sizeof(sc->sc_name), "%s", device_get_nameunit(dev)); @@ -280,7 +282,7 @@ uftdi_attach(device_t dev) error = usb2_transfer_setup(uaa->device, &sc->sc_iface_index, sc->sc_xfer, uftdi_config, - UFTDI_N_TRANSFER, sc, &Giant); + UFTDI_N_TRANSFER, sc, &sc->sc_mtx); if (error) { device_printf(dev, "allocating USB " @@ -290,8 +292,10 @@ uftdi_attach(device_t dev) sc->sc_ucom.sc_portno = FTDI_PIT_SIOA + uaa->info.bIfaceNum; /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); /* set a valid "lcr" value */ @@ -301,7 +305,7 @@ uftdi_attach(device_t dev) FTDI_SIO_SET_DATA_BITS(8)); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &uftdi_callback, &Giant); + &uftdi_callback, &sc->sc_mtx); if (error) { goto detach; } @@ -318,8 +322,8 @@ uftdi_detach(device_t dev) struct uftdi_softc *sc = device_get_softc(dev); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UFTDI_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/ugensa.c ============================================================================== --- head/sys/dev/usb/serial/ugensa.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/ugensa.c Mon Mar 2 02:44:10 2009 (r189265) @@ -221,8 +221,10 @@ ugensa_attach(device_t dev) goto detach; } /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(ssc->sc_xfer[UGENSA_BULK_DT_WR]); usb2_transfer_set_stall(ssc->sc_xfer[UGENSA_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); /* initialize port number */ ssc->sc_usb2_com_ptr->sc_portno = sc->sc_niface; Modified: head/sys/dev/usb/serial/uipaq.c ============================================================================== --- head/sys/dev/usb/serial/uipaq.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/uipaq.c Mon Mar 2 02:44:10 2009 (r189265) @@ -86,6 +86,7 @@ struct uipaq_softc { struct usb2_xfer *sc_xfer[UIPAQ_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint16_t sc_line; @@ -1102,6 +1103,7 @@ uipaq_attach(device_t dev) sc->sc_udev = uaa->device; device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "uipaq", NULL, MTX_DEF); /* * Send magic bytes, cribbed from Linux ipaq driver that @@ -1125,17 +1127,19 @@ uipaq_attach(device_t dev) iface_index = UIPAQ_IFACE_INDEX; error = usb2_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, uipaq_config_data, - UIPAQ_N_TRANSFER, sc, &Giant); + UIPAQ_N_TRANSFER, sc, &sc->sc_mtx); if (error) { goto detach; } /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UIPAQ_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UIPAQ_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &uipaq_callback, &Giant); + &uipaq_callback, &sc->sc_mtx); if (error) { goto detach; } @@ -1152,8 +1156,8 @@ uipaq_detach(device_t dev) struct uipaq_softc *sc = device_get_softc(dev); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UIPAQ_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/ulpt.c ============================================================================== --- head/sys/dev/usb/serial/ulpt.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/ulpt.c Mon Mar 2 02:44:10 2009 (r189265) @@ -636,9 +636,7 @@ ulpt_detach(device_t dev) mtx_unlock(&sc->sc_mtx); usb2_transfer_unsetup(sc->sc_xfer, ULPT_N_TRANSFER); - usb2_callout_drain(&sc->sc_watchdog); - mtx_destroy(&sc->sc_mtx); return (0); Modified: head/sys/dev/usb/serial/umct.c ============================================================================== --- head/sys/dev/usb/serial/umct.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/umct.c Mon Mar 2 02:44:10 2009 (r189265) @@ -93,6 +93,7 @@ struct umct_softc { struct usb2_device *sc_udev; struct usb2_xfer *sc_xfer[UMCT_N_TRANSFER]; + struct mtx sc_mtx; uint32_t sc_unit; @@ -233,6 +234,7 @@ umct_attach(device_t dev) sc->sc_unit = device_get_unit(dev); device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "umct", NULL, MTX_DEF); snprintf(sc->sc_name, sizeof(sc->sc_name), "%s", device_get_nameunit(dev)); @@ -241,7 +243,7 @@ umct_attach(device_t dev) iface_index = UMCT_IFACE_INDEX; error = usb2_transfer_setup(uaa->device, &iface_index, - sc->sc_xfer, umct_config, UMCT_N_TRANSFER, sc, &Giant); + sc->sc_xfer, umct_config, UMCT_N_TRANSFER, sc, &sc->sc_mtx); if (error) { device_printf(dev, "allocating USB " @@ -274,7 +276,7 @@ umct_attach(device_t dev) } } error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &umct_callback, &Giant); + &umct_callback, &sc->sc_mtx); if (error) { goto detach; } @@ -291,8 +293,8 @@ umct_detach(device_t dev) struct umct_softc *sc = device_get_softc(dev); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UMCT_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/umodem.c ============================================================================== --- head/sys/dev/usb/serial/umodem.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/umodem.c Mon Mar 2 02:44:10 2009 (r189265) @@ -142,6 +142,7 @@ struct umodem_softc { struct usb2_xfer *sc_xfer[UMODEM_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint16_t sc_line; @@ -288,6 +289,7 @@ umodem_attach(device_t dev) int error; device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "umodem", NULL, MTX_DEF); sc->sc_ctrl_iface_no = uaa->info.bIfaceNum; sc->sc_iface_index[1] = uaa->info.bIfaceIndex; @@ -348,17 +350,19 @@ umodem_attach(device_t dev) error = usb2_transfer_setup(uaa->device, sc->sc_iface_index, sc->sc_xfer, umodem_config, UMODEM_N_TRANSFER, - sc, &Giant); + sc, &sc->sc_mtx); if (error) { goto detach; } /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UMODEM_BULK_WR]); usb2_transfer_set_stall(sc->sc_xfer[UMODEM_BULK_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &umodem_callback, &Giant); + &umodem_callback, &sc->sc_mtx); if (error) { goto detach; } @@ -781,8 +785,8 @@ umodem_detach(device_t dev) DPRINTF("sc=%p\n", sc); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UMODEM_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/umoscom.c ============================================================================== --- head/sys/dev/usb/serial/umoscom.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/umoscom.c Mon Mar 2 02:44:10 2009 (r189265) @@ -166,6 +166,7 @@ struct umoscom_softc { struct usb2_xfer *sc_xfer[UMOSCOM_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint8_t sc_mcr; uint8_t sc_lcr; @@ -300,20 +301,24 @@ umoscom_attach(device_t dev) device_set_desc(dev, "MOSCHIP USB Serial Port Adapter"); device_printf(dev, "\n"); + mtx_init(&sc->sc_mtx, "umoscom", NULL, MTX_DEF); + iface_index = UMOSCOM_IFACE_INDEX; error = usb2_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, umoscom_config_data, - UMOSCOM_N_TRANSFER, sc, &Giant); + UMOSCOM_N_TRANSFER, sc, &sc->sc_mtx); if (error) { goto detach; } /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UMOSCOM_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UMOSCOM_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &umoscom_callback, &Giant); + &umoscom_callback, &sc->sc_mtx); if (error) { goto detach; } @@ -330,13 +335,9 @@ umoscom_detach(device_t dev) { struct umoscom_softc *sc = device_get_softc(dev); - mtx_lock(&Giant); - - mtx_unlock(&Giant); - usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UMOSCOM_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/uplcom.c ============================================================================== --- head/sys/dev/usb/serial/uplcom.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/uplcom.c Mon Mar 2 02:44:10 2009 (r189265) @@ -145,6 +145,7 @@ struct uplcom_softc { struct usb2_xfer *sc_xfer[UPLCOM_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint16_t sc_line; @@ -326,6 +327,7 @@ uplcom_attach(device_t dev) DPRINTFN(11, "\n"); device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "uplcom", NULL, MTX_DEF); DPRINTF("sc = %p\n", sc); @@ -370,7 +372,7 @@ uplcom_attach(device_t dev) error = usb2_transfer_setup(uaa->device, sc->sc_iface_index, sc->sc_xfer, uplcom_config_data, - UPLCOM_N_TRANSFER, sc, &Giant); + UPLCOM_N_TRANSFER, sc, &sc->sc_mtx); if (error) { DPRINTF("one or more missing USB endpoints, " "error=%s\n", usb2_errstr(error)); @@ -383,11 +385,13 @@ uplcom_attach(device_t dev) goto detach; } /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &uplcom_callback, &Giant); + &uplcom_callback, &sc->sc_mtx); if (error) { goto detach; } @@ -416,8 +420,8 @@ uplcom_detach(device_t dev) DPRINTF("sc=%p\n", sc); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UPLCOM_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/uslcom.c ============================================================================== --- head/sys/dev/usb/serial/uslcom.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/uslcom.c Mon Mar 2 02:44:10 2009 (r189265) @@ -96,6 +96,7 @@ struct uslcom_softc { struct usb2_xfer *sc_xfer[USLCOM_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint8_t sc_msr; uint8_t sc_lsr; @@ -227,23 +228,26 @@ uslcom_attach(device_t dev) DPRINTFN(11, "\n"); device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "uslcom", NULL, MTX_DEF); sc->sc_udev = uaa->device; error = usb2_transfer_setup(uaa->device, &uaa->info.bIfaceIndex, sc->sc_xfer, uslcom_config, - USLCOM_N_TRANSFER, sc, &Giant); + USLCOM_N_TRANSFER, sc, &sc->sc_mtx); if (error) { DPRINTF("one or more missing USB endpoints, " "error=%s\n", usb2_errstr(error)); goto detach; } /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &uslcom_callback, &Giant); + &uslcom_callback, &sc->sc_mtx); if (error) { goto detach; } @@ -262,8 +266,8 @@ uslcom_detach(device_t dev) DPRINTF("sc=%p\n", sc); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, USLCOM_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/uvisor.c ============================================================================== --- head/sys/dev/usb/serial/uvisor.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/uvisor.c Mon Mar 2 02:44:10 2009 (r189265) @@ -160,6 +160,7 @@ struct uvisor_softc { struct usb2_xfer *sc_xfer[UVISOR_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint16_t sc_flag; #define UVISOR_FLAG_PALM4 0x0001 @@ -297,6 +298,8 @@ uvisor_attach(device_t dev) sizeof(uvisor_config_copy)); device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "uvisor", NULL, MTX_DEF); + sc->sc_udev = uaa->device; /* configure the device */ @@ -314,17 +317,19 @@ uvisor_attach(device_t dev) } error = usb2_transfer_setup(uaa->device, &sc->sc_iface_index, sc->sc_xfer, uvisor_config_copy, UVISOR_N_TRANSFER, - sc, &Giant); + sc, &sc->sc_mtx); if (error) { DPRINTF("could not allocate all pipes\n"); goto detach; } /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UVISOR_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UVISOR_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &uvisor_callback, &Giant); + &uvisor_callback, &sc->sc_mtx); if (error) { DPRINTF("usb2_com_attach failed\n"); goto detach; @@ -344,8 +349,8 @@ uvisor_detach(device_t dev) DPRINTF("sc=%p\n", sc); usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); - usb2_transfer_unsetup(sc->sc_xfer, UVISOR_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); } Modified: head/sys/dev/usb/serial/uvscom.c ============================================================================== --- head/sys/dev/usb/serial/uvscom.c Mon Mar 2 02:29:17 2009 (r189264) +++ head/sys/dev/usb/serial/uvscom.c Mon Mar 2 02:44:10 2009 (r189265) @@ -135,6 +135,7 @@ struct uvscom_softc { struct usb2_xfer *sc_xfer[UVSCOM_N_TRANSFER]; struct usb2_device *sc_udev; + struct mtx sc_mtx; uint16_t sc_line; /* line control register */ @@ -276,6 +277,7 @@ uvscom_attach(device_t dev) int error; device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, "uvscom", NULL, MTX_DEF); sc->sc_udev = uaa->device; @@ -285,7 +287,7 @@ uvscom_attach(device_t dev) sc->sc_iface_index = UVSCOM_IFACE_INDEX; error = usb2_transfer_setup(uaa->device, &sc->sc_iface_index, - sc->sc_xfer, uvscom_config, UVSCOM_N_TRANSFER, sc, &Giant); + sc->sc_xfer, uvscom_config, UVSCOM_N_TRANSFER, sc, &sc->sc_mtx); if (error) { DPRINTF("could not allocate all USB transfers!\n"); @@ -294,18 +296,20 @@ uvscom_attach(device_t dev) sc->sc_line = UVSCOM_LINE_INIT; /* clear stall at first run */ + mtx_lock(&sc->sc_mtx); usb2_transfer_set_stall(sc->sc_xfer[UVSCOM_BULK_DT_WR]); usb2_transfer_set_stall(sc->sc_xfer[UVSCOM_BULK_DT_RD]); + mtx_unlock(&sc->sc_mtx); error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, - &uvscom_callback, &Giant); + &uvscom_callback, &sc->sc_mtx); if (error) { goto detach; } /* start interrupt pipe */ - mtx_lock(&Giant); + mtx_lock(&sc->sc_mtx); usb2_transfer_start(sc->sc_xfer[UVSCOM_INTR_DT_RD]); - mtx_unlock(&Giant); + mtx_unlock(&sc->sc_mtx); return (0); @@ -323,12 +327,12 @@ uvscom_detach(device_t dev) /* stop interrupt pipe */ - if (sc->sc_xfer[UVSCOM_INTR_DT_RD]) { + if (sc->sc_xfer[UVSCOM_INTR_DT_RD]) usb2_transfer_stop(sc->sc_xfer[UVSCOM_INTR_DT_RD]); - } - usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); + usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1); usb2_transfer_unsetup(sc->sc_xfer, UVSCOM_N_TRANSFER); + mtx_destroy(&sc->sc_mtx); return (0); }