Module Name:    src
Committed By:   mrg
Date:           Thu Dec  8 09:09:30 UTC 2011

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

Log Message:
partial sync with main branch


To generate a diff of this commit:
cvs rdiff -u -r1.218.6.2.2.3 -r1.218.6.2.2.4 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.218.6.2.2.3 src/sys/dev/usb/ohci.c:1.218.6.2.2.4
--- src/sys/dev/usb/ohci.c:1.218.6.2.2.3	Thu Dec  8 08:52:25 2011
+++ src/sys/dev/usb/ohci.c	Thu Dec  8 09:09:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.218.6.2.2.3 2011/12/08 08:52:25 mrg Exp $	*/
+/*	$NetBSD: ohci.c,v 1.218.6.2.2.4 2011/12/08 09:09:30 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.2.2.3 2011/12/08 08:52:25 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.2.2.4 2011/12/08 09:09:30 mrg Exp $");
 
 #include "opt_usb.h"
 
@@ -120,7 +120,8 @@ Static usbd_status	ohci_device_request(u
 Static void		ohci_add_ed(ohci_softc_t *, ohci_soft_ed_t *,
 			    ohci_soft_ed_t *);
 
-Static void		ohci_rem_ed(ohci_soft_ed_t *, ohci_soft_ed_t *);
+Static void		ohci_rem_ed(ohci_softc_t *, ohci_soft_ed_t *,
+				    ohci_soft_ed_t *);
 Static void		ohci_hash_add_td(ohci_softc_t *, ohci_soft_td_t *);
 Static void		ohci_hash_rem_td(ohci_softc_t *, ohci_soft_td_t *);
 Static ohci_soft_td_t  *ohci_hash_find_td(ohci_softc_t *, ohci_physaddr_t);
@@ -271,68 +272,68 @@ struct ohci_pipe {
 #define OHCI_INTR_ENDPT 1
 
 Static const struct usbd_bus_methods ohci_bus_methods = {
-	ohci_open,
-	ohci_softintr,
-	ohci_poll,
-	ohci_allocm,
-	ohci_freem,
-	ohci_allocx,
-	ohci_freex,
-	ohci_get_locks,
+	.open_pipe =	ohci_open,
+	.soft_intr =	ohci_softintr,
+	.do_poll =	ohci_poll,
+	.allocm =	ohci_allocm,
+	.freem =	ohci_freem,
+	.allocx =	ohci_allocx,
+	.freex =	ohci_freex,
+	.get_locks =	ohci_get_locks,
 };
 
 Static const struct usbd_pipe_methods ohci_root_ctrl_methods = {
-	ohci_root_ctrl_transfer,
-	ohci_root_ctrl_start,
-	ohci_root_ctrl_abort,
-	ohci_root_ctrl_close,
-	ohci_noop,
-	ohci_root_ctrl_done,
+	.transfer =	ohci_root_ctrl_transfer,
+	.start =	ohci_root_ctrl_start,
+	.abort =	ohci_root_ctrl_abort,
+	.close =	ohci_root_ctrl_close,
+	.cleartoggle =	ohci_noop,
+	.done =		ohci_root_ctrl_done,
 };
 
 Static const struct usbd_pipe_methods ohci_root_intr_methods = {
-	ohci_root_intr_transfer,
-	ohci_root_intr_start,
-	ohci_root_intr_abort,
-	ohci_root_intr_close,
-	ohci_noop,
-	ohci_root_intr_done,
+	.transfer =	ohci_root_intr_transfer,
+	.start =	ohci_root_intr_start,
+	.abort =	ohci_root_intr_abort,
+	.close =	ohci_root_intr_close,
+	.cleartoggle =	ohci_noop,
+	.done =		ohci_root_intr_done,
 };
 
 Static const struct usbd_pipe_methods ohci_device_ctrl_methods = {
-	ohci_device_ctrl_transfer,
-	ohci_device_ctrl_start,
-	ohci_device_ctrl_abort,
-	ohci_device_ctrl_close,
-	ohci_noop,
-	ohci_device_ctrl_done,
+	.transfer =	ohci_device_ctrl_transfer,
+	.start =	ohci_device_ctrl_start,
+	.abort =	ohci_device_ctrl_abort,
+	.close =	ohci_device_ctrl_close,
+	.cleartoggle =	ohci_noop,
+	.done =		ohci_device_ctrl_done,
 };
 
 Static const struct usbd_pipe_methods ohci_device_intr_methods = {
-	ohci_device_intr_transfer,
-	ohci_device_intr_start,
-	ohci_device_intr_abort,
-	ohci_device_intr_close,
-	ohci_device_clear_toggle,
-	ohci_device_intr_done,
+	.transfer =	ohci_device_intr_transfer,
+	.start =	ohci_device_intr_start,
+	.abort =	ohci_device_intr_abort,
+	.close =	ohci_device_intr_close,
+	.cleartoggle =	ohci_device_clear_toggle,
+	.done =		ohci_device_intr_done,
 };
 
 Static const struct usbd_pipe_methods ohci_device_bulk_methods = {
-	ohci_device_bulk_transfer,
-	ohci_device_bulk_start,
-	ohci_device_bulk_abort,
-	ohci_device_bulk_close,
-	ohci_device_clear_toggle,
-	ohci_device_bulk_done,
+	.transfer =	ohci_device_bulk_transfer,
+	.start =	ohci_device_bulk_start,
+	.abort =	ohci_device_bulk_abort,
+	.close =	ohci_device_bulk_close,
+	.cleartoggle =	ohci_device_clear_toggle,
+	.done =		ohci_device_bulk_done,
 };
 
 Static const struct usbd_pipe_methods ohci_device_isoc_methods = {
-	ohci_device_isoc_transfer,
-	ohci_device_isoc_start,
-	ohci_device_isoc_abort,
-	ohci_device_isoc_close,
-	ohci_noop,
-	ohci_device_isoc_done,
+	.transfer =	ohci_device_isoc_transfer,
+	.start =	ohci_device_isoc_start,
+	.abort =	ohci_device_isoc_abort,
+	.close =	ohci_device_isoc_close,
+	.cleartoggle =	ohci_noop,
+	.done =		ohci_device_isoc_done,
 };
 
 int
@@ -1497,7 +1498,9 @@ void
 ohci_device_ctrl_done(usbd_xfer_handle xfer)
 {
 	struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
+#ifdef DIAGNOSTIC
 	ohci_softc_t *sc = xfer->pipe->device->bus->hci_private;
+#endif
 	int len = UGETW(xfer->request.wLength);
 	int isread = (xfer->request.bmRequestType & UT_READ);
 
@@ -1573,7 +1576,9 @@ ohci_device_intr_done(usbd_xfer_handle x
 void
 ohci_device_bulk_done(usbd_xfer_handle xfer)
 {
+#ifdef DIAGNOSTIC
 	ohci_softc_t *sc = xfer->pipe->device->bus->hci_private;
+#endif
 	int isread =
 	    (UE_GET_DIR(xfer->pipe->endpoint->edesc->bEndpointAddress) == UE_DIR_IN);
 
@@ -1865,12 +1870,13 @@ ohci_device_request(usbd_xfer_handle xfe
 /*
  * Add an ED to the schedule.  Called at splusb().
  */
-void
+Static void
 ohci_add_ed(ohci_softc_t *sc, ohci_soft_ed_t *sed, ohci_soft_ed_t *head)
 {
 	DPRINTFN(8,("ohci_add_ed: sed=%p head=%p\n", sed, head));
 
-	SPLUSBCHECK;
+	KASSERT(mutex_owned(&sc->sc_lock));
+
 	usb_syncmem(&head->dma, head->offs + offsetof(ohci_ed_t, ed_nexted),
 	    sizeof(head->ed.ed_nexted),
 	    BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
@@ -1889,12 +1895,12 @@ ohci_add_ed(ohci_softc_t *sc, ohci_soft_
 /*
  * Remove an ED from the schedule.  Called at splusb().
  */
-void
-ohci_rem_ed(ohci_soft_ed_t *sed, ohci_soft_ed_t *head)
+Static void
+ohci_rem_ed(ohci_softc_t *sc, ohci_soft_ed_t *sed, ohci_soft_ed_t *head)
 {
 	ohci_soft_ed_t *p;
 
-	SPLUSBCHECK;
+	//KASSERT(mutex_owned(&sc->sc_lock));
 
 	/* XXX */
 	for (p = head; p != NULL && p->next != sed; p = p->next)
@@ -1928,7 +1934,7 @@ ohci_hash_add_td(ohci_softc_t *sc, ohci_
 {
 	int h = HASH(std->physaddr);
 
-	SPLUSBCHECK;
+	//KASSERT(mutex_owned(&sc->sc_lock));
 
 	LIST_INSERT_HEAD(&sc->sc_hash_tds[h], std, hnext);
 }
@@ -1937,7 +1943,8 @@ ohci_hash_add_td(ohci_softc_t *sc, ohci_
 void
 ohci_hash_rem_td(ohci_softc_t *sc, ohci_soft_td_t *std)
 {
-	SPLUSBCHECK;
+
+	//KASSERT(mutex_owned(&sc->sc_lock));
 
 	LIST_REMOVE(std, hnext);
 }
@@ -1962,7 +1969,7 @@ ohci_hash_add_itd(ohci_softc_t *sc, ohci
 {
 	int h = HASH(sitd->physaddr);
 
-	SPLUSBCHECK;
+	//KASSERT(mutex_owned(&sc->sc_lock));
 
 	DPRINTFN(10,("ohci_hash_add_itd: sitd=%p physaddr=0x%08lx\n",
 		    sitd, (u_long)sitd->physaddr));
@@ -1974,7 +1981,7 @@ ohci_hash_add_itd(ohci_softc_t *sc, ohci
 void
 ohci_hash_rem_itd(ohci_softc_t *sc, ohci_soft_itd_t *sitd)
 {
-	SPLUSBCHECK;
+	//KASSERT(mutex_owned(&sc->sc_lock));
 
 	DPRINTFN(10,("ohci_hash_rem_itd: sitd=%p physaddr=0x%08lx\n",
 		    sitd, (u_long)sitd->physaddr));
@@ -2225,7 +2232,6 @@ ohci_open(usbd_pipe_handle pipe)
 	if (sed != NULL)
 		ohci_free_sed(sc, sed);
  bad0:
-	mutex_exit(&sc->sc_lock);
 	return err;
 
 }
@@ -2241,7 +2247,7 @@ ohci_close_pipe(usbd_pipe_handle pipe, o
 	ohci_softc_t *sc = pipe->device->bus->hci_private;
 	ohci_soft_ed_t *sed = opipe->sed;
 
-//	KASSERT(mutex_owned(&sc->sc_lock));
+	KASSERT(mutex_owned(&sc->sc_lock));
 
 #ifdef DIAGNOSTIC
 	sed->ed.ed_flags |= HTOO32(OHCI_ED_SKIP);
@@ -2268,7 +2274,7 @@ ohci_close_pipe(usbd_pipe_handle pipe, o
 			printf("ohci_close_pipe: pipe still not empty\n");
 	}
 #endif
-	ohci_rem_ed(sed, head);
+	ohci_rem_ed(sc, sed, head);
 	/* Make sure the host controller is not touching this ED */
 	usb_delay_ms(&sc->sc_bus, 1);
 	pipe->endpoint->datatoggle =
@@ -3359,15 +3365,15 @@ ohci_device_setintr(ohci_softc_t *sc, st
 usbd_status
 ohci_device_isoc_transfer(usbd_xfer_handle xfer)
 {
-	//ohci_softc_t *sc = xfer->pipe->device->bus->hci_private;
+	ohci_softc_t *sc = xfer->pipe->device->bus->hci_private;
 	usbd_status err;
 
 	DPRINTFN(5,("ohci_device_isoc_transfer: xfer=%p\n", xfer));
 
 	/* Put it on our queue, */
-	//mutex_enter(&sc->sc_lock);
+	mutex_enter(&sc->sc_lock);
 	err = usb_insert_transfer(xfer);
-	//mutex_exit(&sc->sc_lock);
+	mutex_exit(&sc->sc_lock);
 
 	/* bail out on error, */
 	if (err && err != USBD_IN_PROGRESS)
@@ -3492,7 +3498,7 @@ ohci_device_isoc_enter(usbd_xfer_handle 
 	}
 #endif
 
-	//mutex_enter(&sc->sc_lock);
+	mutex_enter(&sc->sc_lock);
 	usb_syncmem(&sed->dma, sed->offs, sizeof(sed->ed),
 	    BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 	sed->ed.ed_tailp = HTOO32(nsitd->physaddr);
@@ -3501,7 +3507,7 @@ ohci_device_isoc_enter(usbd_xfer_handle 
 	usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags),
 	    sizeof(sed->ed.ed_flags),
 	    BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-	//mutex_exit(&sc->sc_lock);
+	mutex_exit(&sc->sc_lock);
 
 #ifdef OHCI_DEBUG
 	if (ohcidebug > 5) {
@@ -3549,7 +3555,7 @@ ohci_device_isoc_abort(usbd_xfer_handle 
 	ohci_soft_ed_t *sed;
 	ohci_soft_itd_t *sitd;
 
-	DPRINTFN(1,("ohci_device_isoc_abort: xfer=%p\n", xfer));
+	DPRINTFN(1,("ohci_device_isoc_abort: xfer=%p lock=%p\n", xfer, &sc->sc_lock));
 
 	mutex_enter(&sc->sc_lock);
 
@@ -3599,7 +3605,7 @@ ohci_device_isoc_abort(usbd_xfer_handle 
 	usb_syncmem(&sed->dma, sed->offs, sizeof(sed->ed),
 	    BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 
- done: ;
+ done:
 	mutex_exit(&sc->sc_lock);
 }
 

Reply via email to