svn commit: r188273 - head/sys/dev/usb2/controller

Andrew Thompson thompsa at FreeBSD.org
Fri Feb 6 22:27:18 PST 2009


Author: thompsa
Date: Sat Feb  7 06:27:16 2009
New Revision: 188273
URL: http://svn.freebsd.org/changeset/base/188273

Log:
  Dont hold the lock over the controller init, we are still attaching.

Modified:
  head/sys/dev/usb2/controller/ehci2.c
  head/sys/dev/usb2/controller/ohci2.c
  head/sys/dev/usb2/controller/uhci2.c

Modified: head/sys/dev/usb2/controller/ehci2.c
==============================================================================
--- head/sys/dev/usb2/controller/ehci2.c	Sat Feb  7 05:41:24 2009	(r188272)
+++ head/sys/dev/usb2/controller/ehci2.c	Sat Feb  7 06:27:16 2009	(r188273)
@@ -223,8 +223,6 @@ ehci_init(ehci_softc_t *sc)
 	uint16_t bit;
 	usb2_error_t err = 0;
 
-	USB_BUS_LOCK(&sc->sc_bus);
-
 	DPRINTF("start\n");
 
 	usb2_callout_init_mtx(&sc->sc_tmo_pcd, &sc->sc_bus.bus_mtx, 0);
@@ -259,10 +257,12 @@ ehci_init(ehci_softc_t *sc)
 	/* Reset the controller */
 	DPRINTF("%s: resetting\n", device_get_nameunit(sc->sc_bus.bdev));
 
+	USB_BUS_LOCK(&sc->sc_bus);
 	err = ehci_hc_reset(sc);
+	USB_BUS_UNLOCK(&sc->sc_bus);
 	if (err) {
 		device_printf(sc->sc_bus.bdev, "reset timeout\n");
-		goto done;
+		return (error);
 	}
 	/*
 	 * use current frame-list-size selection 0: 1024*4 bytes 1:  512*4
@@ -270,8 +270,7 @@ ehci_init(ehci_softc_t *sc)
 	 */
 	if (EHCI_CMD_FLS(EOREAD4(sc, EHCI_USBCMD)) == 3) {
 		device_printf(sc->sc_bus.bdev, "invalid frame-list-size\n");
-		err = USB_ERR_IOERROR;
-		goto done;
+		return (USB_ERR_IOERROR);
 	}
 	/* set up the bus struct */
 	sc->sc_bus.methods = &ehci_bus_methods;
@@ -479,7 +478,7 @@ ehci_init(ehci_softc_t *sc)
 	EOWRITE4(sc, EHCI_CONFIGFLAG, EHCI_CONF_CF);
 
 	for (i = 0; i < 100; i++) {
-		usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+		usb2_pause_mtx(NULL, 1);
 		hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH;
 		if (!hcr) {
 			break;
@@ -487,11 +486,8 @@ ehci_init(ehci_softc_t *sc)
 	}
 	if (hcr) {
 		device_printf(sc->sc_bus.bdev, "run timeout\n");
-		err = USB_ERR_IOERROR;
-		goto done;
+		return (USB_ERR_IOERROR);
 	}
-done:
-	USB_BUS_UNLOCK(&sc->sc_bus);
 
 	if (!err) {
 		/* catch any lost interrupts */

Modified: head/sys/dev/usb2/controller/ohci2.c
==============================================================================
--- head/sys/dev/usb2/controller/ohci2.c	Sat Feb  7 05:41:24 2009	(r188272)
+++ head/sys/dev/usb2/controller/ohci2.c	Sat Feb  7 06:27:16 2009	(r188273)
@@ -168,7 +168,7 @@ ohci_controller_init(ohci_softc_t *sc)
 		DPRINTF("SMM active, request owner change\n");
 		OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_OCR);
 		for (i = 0; (i < 100) && (ctl & OHCI_IR); i++) {
-			usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+			usb2_pause_mtx(NULL, 1);
 			ctl = OREAD4(sc, OHCI_CONTROL);
 		}
 		if (ctl & OHCI_IR) {
@@ -181,8 +181,7 @@ ohci_controller_init(ohci_softc_t *sc)
 		DPRINTF("cold started\n");
 reset:
 		/* controller was cold started */
-		usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-		    USB_BUS_RESET_DELAY);
+		usb2_pause_mtx(NULL, USB_BUS_RESET_DELAY);
 	}
 
 	/*
@@ -192,8 +191,7 @@ reset:
 	DPRINTF("%s: resetting\n", device_get_nameunit(sc->sc_bus.bdev));
 	OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET);
 
-	usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-	    USB_BUS_RESET_DELAY);
+	usb2_pause_mtx(NULL, USB_BUS_RESET_DELAY);
 
 	/* we now own the host controller and the bus has been reset */
 	ival = OHCI_GET_IVAL(OREAD4(sc, OHCI_FM_INTERVAL));
@@ -255,8 +253,7 @@ reset:
 	desca = OREAD4(sc, OHCI_RH_DESCRIPTOR_A);
 	OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca | OHCI_NOCP);
 	OWRITE4(sc, OHCI_RH_STATUS, OHCI_LPSC);	/* Enable port power */
-	usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-	    OHCI_ENABLE_POWER_DELAY);
+	usb2_pause_mtx(NULL, OHCI_ENABLE_POWER_DELAY);
 	OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca);
 
 	/*
@@ -265,8 +262,7 @@ reset:
 	 */
 	sc->sc_noport = 0;
 	for (i = 0; (i < 10) && (sc->sc_noport == 0); i++) {
-		usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-		    OHCI_READ_DESC_DELAY);
+		usb2_pause_mtx(NULL, OHCI_READ_DESC_DELAY);
 		sc->sc_noport = OHCI_GET_NDP(OREAD4(sc, OHCI_RH_DESCRIPTOR_A));
 	}
 
@@ -304,8 +300,6 @@ ohci_init(ohci_softc_t *sc)
 	uint16_t x;
 	uint16_t y;
 
-	USB_BUS_LOCK(&sc->sc_bus);
-
 	DPRINTF("start\n");
 
 	sc->sc_eintrs = OHCI_NORMAL_INTRS;
@@ -402,10 +396,8 @@ ohci_init(ohci_softc_t *sc)
 	sc->sc_bus.usbrev = USB_REV_1_0;
 
 	if (ohci_controller_init(sc)) {
-		USB_BUS_UNLOCK(&sc->sc_bus);
 		return (USB_ERR_INVAL);
 	} else {
-		USB_BUS_UNLOCK(&sc->sc_bus);
 		/* catch any lost interrupts */
 		ohci_do_poll(&sc->sc_bus);
 		return (USB_ERR_NORMAL_COMPLETION);
@@ -473,8 +465,6 @@ ohci_resume(ohci_softc_t *sc)
 {
 	uint32_t ctl;
 
-	USB_BUS_LOCK(&sc->sc_bus);
-
 #if USB_DEBUG
 	DPRINTF("\n");
 	if (ohcidebug > 2) {
@@ -484,6 +474,7 @@ ohci_resume(ohci_softc_t *sc)
 	/* some broken BIOSes never initialize the Controller chip */
 	ohci_controller_init(sc);
 
+	USB_BUS_LOCK(&sc->sc_bus);
 	if (sc->sc_intre) {
 		OWRITE4(sc, OHCI_INTERRUPT_ENABLE,
 		    sc->sc_intre & (OHCI_ALL_INTRS | OHCI_MIE));

Modified: head/sys/dev/usb2/controller/uhci2.c
==============================================================================
--- head/sys/dev/usb2/controller/uhci2.c	Sat Feb  7 05:41:24 2009	(r188272)
+++ head/sys/dev/usb2/controller/uhci2.c	Sat Feb  7 06:27:16 2009	(r188273)
@@ -406,8 +406,6 @@ uhci_init(uhci_softc_t *sc)
 	uint16_t x;
 	uint16_t y;
 
-	USB_BUS_LOCK(&sc->sc_bus);
-
 	DPRINTF("start\n");
 
 #if USB_DEBUG
@@ -597,12 +595,12 @@ uhci_init(uhci_softc_t *sc)
 	/* set up the bus struct */
 	sc->sc_bus.methods = &uhci_bus_methods;
 
+	USB_BUS_LOCK(&sc->sc_bus);
 	/* reset the controller */
 	uhci_reset(sc);
 
 	/* start the controller */
 	uhci_start(sc);
-
 	USB_BUS_UNLOCK(&sc->sc_bus);
 
 	/* catch lost interrupts */


More information about the svn-src-head mailing list