Module Name:    src
Committed By:   mrg
Date:           Thu Dec  8 22:38:47 UTC 2011

Modified Files:
        src/sys/dev/usb [jmcneill-usbmp]: ohci.c usbdi.c usbdivar.h

Log Message:
make ohci mostly work again.


To generate a diff of this commit:
cvs rdiff -u -r1.218.6.6 -r1.218.6.7 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.134.2.3 -r1.134.2.4 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.93.8.2 -r1.93.8.3 src/sys/dev/usb/usbdivar.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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.218.6.6 src/sys/dev/usb/ohci.c:1.218.6.7
--- src/sys/dev/usb/ohci.c:1.218.6.6	Thu Dec  8 02:51:07 2011
+++ src/sys/dev/usb/ohci.c	Thu Dec  8 22:38:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.218.6.6 2011/12/08 02:51:07 mrg Exp $	*/
+/*	$NetBSD: ohci.c,v 1.218.6.7 2011/12/08 22:38:47 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $	*/
 
 /*
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.6 2011/12/08 02:51:07 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.7 2011/12/08 22:38:47 mrg Exp $");
 
 #include "opt_usb.h"
 
@@ -2163,7 +2163,9 @@ ohci_open(usbd_pipe_handle pipe)
 			goto bad0;
 		opipe->sed = sed;
 		if (xfertype == UE_ISOCHRONOUS) {
+			mutex_enter(&sc->sc_lock);
 			sitd = ohci_alloc_sitd(sc);
+			mutex_exit(&sc->sc_lock);
 			if (sitd == NULL)
 				goto bad1;
 			opipe->tail.itd = sitd;
@@ -2174,7 +2176,9 @@ ohci_open(usbd_pipe_handle pipe)
 			else
 				fmt |= OHCI_ED_DIR_OUT;
 		} else {
+			mutex_enter(&sc->sc_lock);
 			std = ohci_alloc_std(sc);
+			mutex_exit(&sc->sc_lock);
 			if (std == NULL)
 				goto bad1;
 			opipe->tail.td = std;
@@ -2961,8 +2965,8 @@ ohci_device_ctrl_close(usbd_pipe_handle 
 	DPRINTF(("ohci_device_ctrl_close: pipe=%p\n", pipe));
 	mutex_enter(&sc->sc_lock);
 	ohci_close_pipe(pipe, sc->sc_ctrl_head);
-	mutex_exit(&sc->sc_lock);
 	ohci_free_std(sc, opipe->tail.td);
+	mutex_exit(&sc->sc_lock);
 }
 
 /************************/
@@ -3125,8 +3129,8 @@ ohci_device_bulk_close(usbd_pipe_handle 
 	DPRINTF(("ohci_device_bulk_close: pipe=%p\n", pipe));
 	mutex_enter(&sc->sc_lock);
 	ohci_close_pipe(pipe, sc->sc_bulk_head);
-	mutex_exit(&sc->sc_lock);
 	ohci_free_std(sc, opipe->tail.td);
+	mutex_exit(&sc->sc_lock);
 }
 
 /************************/
@@ -3175,7 +3179,9 @@ ohci_device_intr_start(usbd_xfer_handle 
 	isread = UE_GET_DIR(endpt) == UE_DIR_IN;
 
 	data = opipe->tail.td;
+	mutex_enter(&sc->sc_lock);
 	tail = ohci_alloc_std(sc);
+	mutex_exit(&sc->sc_lock);
 	if (tail == NULL)
 		return (USBD_NOMEM);
 	tail->xfer = NULL;
@@ -3429,7 +3435,9 @@ ohci_device_isoc_enter(usbd_xfer_handle 
 		    OHCI_PAGE(buf + noffs) > bp0 + OHCI_PAGE_SIZE) { /* too many page crossings */
 
 			/* Allocate next ITD */
+			mutex_enter(&sc->sc_lock);
 			nsitd = ohci_alloc_sitd(sc);
+			mutex_exit(&sc->sc_lock);
 			if (nsitd == NULL) {
 				/* XXX what now? */
 				printf("%s: isoc TD alloc failed\n",
@@ -3460,7 +3468,9 @@ ohci_device_isoc_enter(usbd_xfer_handle 
 		sitd->itd.itd_offset[ncur] = HTOO16(OHCI_ITD_MK_OFFS(offs));
 		offs = noffs;
 	}
+	mutex_enter(&sc->sc_lock);
 	nsitd = ohci_alloc_sitd(sc);
+	mutex_exit(&sc->sc_lock);
 	if (nsitd == NULL) {
 		/* XXX what now? */
 		printf("%s: isoc TD alloc failed\n",
@@ -3644,6 +3654,6 @@ ohci_device_isoc_close(usbd_pipe_handle 
 #ifdef DIAGNOSTIC
 	opipe->tail.itd->isdone = 1;
 #endif
-	mutex_exit(&sc->sc_lock);
 	ohci_free_sitd(sc, opipe->tail.itd);
+	mutex_exit(&sc->sc_lock);
 }

Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.134.2.3 src/sys/dev/usb/usbdi.c:1.134.2.4
--- src/sys/dev/usb/usbdi.c:1.134.2.3	Thu Dec  8 03:10:09 2011
+++ src/sys/dev/usb/usbdi.c	Thu Dec  8 22:38:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.134.2.3 2011/12/08 03:10:09 mrg Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.134.2.4 2011/12/08 22:38:47 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.3 2011/12/08 03:10:09 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.4 2011/12/08 22:38:47 mrg Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_usb.h"
@@ -229,6 +229,7 @@ usbd_open_pipe_intr(usbd_interface_handl
 usbd_status
 usbd_close_pipe(usbd_pipe_handle pipe)
 {
+
 #ifdef DIAGNOSTIC
 	if (pipe == NULL) {
 		printf("usbd_close_pipe: pipe==NULL\n");
@@ -762,7 +763,6 @@ usb_transfer_complete(usbd_xfer_handle x
 	    xfer->status == USBD_TIMEOUT;
 	int repeat, polling;
 
-
 	DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
 		     "actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
 
@@ -854,11 +854,10 @@ usb_transfer_complete(usbd_xfer_handle x
 	}
 
 	if (sync && !polling) {
-		if (pipe->device->bus->lock) {
+		if (pipe->device->bus->lock)
 			cv_broadcast(&xfer->cv);
-		} else {
+		else
 			wakeup(xfer);
-		}
 	}
 
 	if (!repeat) {

Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.93.8.2 src/sys/dev/usb/usbdivar.h:1.93.8.3
--- src/sys/dev/usb/usbdivar.h:1.93.8.2	Thu Dec  8 02:51:08 2011
+++ src/sys/dev/usb/usbdivar.h	Thu Dec  8 22:38:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdivar.h,v 1.93.8.2 2011/12/08 02:51:08 mrg Exp $	*/
+/*	$NetBSD: usbdivar.h,v 1.93.8.3 2011/12/08 22:38:47 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $	*/
 
 /*
@@ -144,7 +144,7 @@ struct usbd_bus {
 	/* Filled by usb driver */
 	kmutex_t		*intr_lock;
 	kmutex_t		*lock;
-	struct usbd_device	*root_hub;
+	struct usbd_device      *root_hub;
 	usbd_device_handle	devices[USB_MAX_DEVICES];
 	char			needs_explore;/* a hub a signalled a change */
 	char			use_polling;

Reply via email to