CVS commit: [mrg-ohci-jmcneill-usbmp] src/sys/dev/usb

2011-12-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec  8 08:52:25 UTC 2011

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

Log Message:
sync a couple more changes from the main branch, uaudio@ohci still works.


To generate a diff of this commit:
cvs rdiff -u -r1.181.6.2 -r1.181.6.2.2.1 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.218.6.2.2.2 -r1.218.6.2.2.3 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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.181.6.2 src/sys/dev/usb/ehci.c:1.181.6.2.2.1
--- src/sys/dev/usb/ehci.c:1.181.6.2	Sun Dec  4 19:22:56 2011
+++ src/sys/dev/usb/ehci.c	Thu Dec  8 08:52:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.181.6.2 2011/12/04 19:22:56 jmcneill Exp $ */
+/*	$NetBSD: ehci.c,v 1.181.6.2.2.1 2011/12/08 08:52:24 mrg Exp $ */
 
 /*
  * Copyright (c) 2004-2011 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ehci.c,v 1.181.6.2 2011/12/04 19:22:56 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: ehci.c,v 1.181.6.2.2.1 2011/12/08 08:52:24 mrg Exp $);
 
 #include ohci.h
 #include uhci.h
@@ -220,7 +220,8 @@ Static usbd_status	ehci_device_request(u
 Static usbd_status	ehci_device_setintr(ehci_softc_t *, ehci_soft_qh_t *,
 			int ival);
 
-Static void		ehci_add_qh(ehci_soft_qh_t *, ehci_soft_qh_t *);
+Static void		ehci_add_qh(ehci_softc_t *, ehci_soft_qh_t *,
+ehci_soft_qh_t *);
 Static void		ehci_rem_qh(ehci_softc_t *, ehci_soft_qh_t *,
 ehci_soft_qh_t *);
 Static void		ehci_set_qh_qtd(ehci_soft_qh_t *, ehci_soft_qtd_t *);
@@ -261,68 +262,68 @@ Static void		ehci_dump_exfer(struct ehci
 #define ehci_active_intr_list(ex) ((ex)-inext.tqe_prev != NULL)
 
 Static const struct usbd_bus_methods ehci_bus_methods = {
-	ehci_open,
-	ehci_softintr,
-	ehci_poll,
-	ehci_allocm,
-	ehci_freem,
-	ehci_allocx,
-	ehci_freex,
-	ehci_get_locks,
+	.open_pipe =	ehci_open,
+	.soft_intr =	ehci_softintr,
+	.do_poll =	ehci_poll,
+	.allocm =	ehci_allocm,
+	.freem =	ehci_freem,
+	.allocx =	ehci_allocx,
+	.freex =	ehci_freex,
+	.get_locks =	ehci_get_locks,
 };
 
 Static const struct usbd_pipe_methods ehci_root_ctrl_methods = {
-	ehci_root_ctrl_transfer,
-	ehci_root_ctrl_start,
-	ehci_root_ctrl_abort,
-	ehci_root_ctrl_close,
-	ehci_noop,
-	ehci_root_ctrl_done,
+	.transfer =	ehci_root_ctrl_transfer,
+	.start =	ehci_root_ctrl_start,
+	.abort =	ehci_root_ctrl_abort,
+	.close =	ehci_root_ctrl_close,
+	.cleartoggle =	ehci_noop,
+	.done =		ehci_root_ctrl_done,
 };
 
 Static const struct usbd_pipe_methods ehci_root_intr_methods = {
-	ehci_root_intr_transfer,
-	ehci_root_intr_start,
-	ehci_root_intr_abort,
-	ehci_root_intr_close,
-	ehci_noop,
-	ehci_root_intr_done,
+	.transfer =	ehci_root_intr_transfer,
+	.start =	ehci_root_intr_start,
+	.abort =	ehci_root_intr_abort,
+	.close =	ehci_root_intr_close,
+	.cleartoggle =	ehci_noop,
+	.done =		ehci_root_intr_done,
 };
 
 Static const struct usbd_pipe_methods ehci_device_ctrl_methods = {
-	ehci_device_ctrl_transfer,
-	ehci_device_ctrl_start,
-	ehci_device_ctrl_abort,
-	ehci_device_ctrl_close,
-	ehci_noop,
-	ehci_device_ctrl_done,
+	.transfer =	ehci_device_ctrl_transfer,
+	.start =	ehci_device_ctrl_start,
+	.abort =	ehci_device_ctrl_abort,
+	.close =	ehci_device_ctrl_close,
+	.cleartoggle =	ehci_noop,
+	.done =		ehci_device_ctrl_done,
 };
 
 Static const struct usbd_pipe_methods ehci_device_intr_methods = {
-	ehci_device_intr_transfer,
-	ehci_device_intr_start,
-	ehci_device_intr_abort,
-	ehci_device_intr_close,
-	ehci_device_clear_toggle,
-	ehci_device_intr_done,
+	.transfer =	ehci_device_intr_transfer,
+	.start =	ehci_device_intr_start,
+	.abort =	ehci_device_intr_abort,
+	.close =	ehci_device_intr_close,
+	.cleartoggle =	ehci_device_clear_toggle,
+	.done =		ehci_device_intr_done,
 };
 
 Static const struct usbd_pipe_methods ehci_device_bulk_methods = {
-	ehci_device_bulk_transfer,
-	ehci_device_bulk_start,
-	ehci_device_bulk_abort,
-	ehci_device_bulk_close,
-	ehci_device_clear_toggle,
-	ehci_device_bulk_done,
+	.transfer =	ehci_device_bulk_transfer,
+	.start =	ehci_device_bulk_start,
+	.abort =	ehci_device_bulk_abort,
+	.close =	ehci_device_bulk_close,
+	.cleartoggle =	ehci_device_clear_toggle,
+	.done =		ehci_device_bulk_done,
 };
 
 Static const struct usbd_pipe_methods ehci_device_isoc_methods = {
-	ehci_device_isoc_transfer,
-	ehci_device_isoc_start,
-	ehci_device_isoc_abort,
-	ehci_device_isoc_close,
-	ehci_noop,
-	ehci_device_isoc_done,
+	.transfer =	ehci_device_isoc_transfer,
+	.start =	ehci_device_isoc_start,
+	.abort =	ehci_device_isoc_abort,
+	.close =	ehci_device_isoc_close,
+	.cleartoggle =	ehci_noop,
+	.done =		ehci_device_isoc_done,
 };
 
 static const uint8_t revbits[EHCI_MAX_POLLRATE] = {
@@ -652,7 +653,9 @@ ehci_intr1(ehci_softc_t *sc)
 	sc-sc_bus.no_intrs++;
 	if (eintrs  EHCI_STS_IAA) {
 		DPRINTF((ehci_intr1: door 

CVS commit: [mrg-ohci-jmcneill-usbmp] src/sys/dev/usb

2011-12-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec  8 08:56:57 UTC 2011

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

Log Message:
sync with main branch


To generate a diff of this commit:
cvs rdiff -u -r1.240.6.1 -r1.240.6.1.2.1 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.48 -r1.48.14.1 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.240.6.1 src/sys/dev/usb/uhci.c:1.240.6.1.2.1
--- src/sys/dev/usb/uhci.c:1.240.6.1	Sun Dec  4 13:23:17 2011
+++ src/sys/dev/usb/uhci.c	Thu Dec  8 08:56:57 2011
@@ -1,13 +1,14 @@
-/*	$NetBSD: uhci.c,v 1.240.6.1 2011/12/04 13:23:17 jmcneill Exp $	*/
+/*	$NetBSD: uhci.c,v 1.240.6.1.2.1 2011/12/08 08:56:57 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $	*/
 
 /*
- * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2004, 2011 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, Jared D. McNeill (jmcne...@invisible.ca)
+ * and Matthew R. Green.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -42,14 +43,14 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uhci.c,v 1.240.6.1 2011/12/04 13:23:17 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: uhci.c,v 1.240.6.1.2.1 2011/12/08 08:56:57 mrg Exp $);
 
 #include opt_usb.h
 
 #include sys/param.h
 #include sys/systm.h
 #include sys/kernel.h
-#include sys/malloc.h
+#include sys/kmem.h
 #include sys/device.h
 #include sys/select.h
 #include sys/extent.h
@@ -171,6 +172,8 @@ Static void		uhci_freem(struct usbd_bus 
 
 Static usbd_xfer_handle	uhci_allocx(struct usbd_bus *);
 Static void		uhci_freex(struct usbd_bus *, usbd_xfer_handle);
+Static void		uhci_get_locks(struct usbd_bus *, kmutex_t **,
+   kmutex_t **);
 
 Static usbd_status	uhci_device_ctrl_transfer(usbd_xfer_handle);
 Static usbd_status	uhci_device_ctrl_start(usbd_xfer_handle);
@@ -281,68 +284,68 @@ UREAD4(uhci_softc_t *sc, bus_size_t r)
 #define UHCI_INTR_ENDPT 1
 
 const struct usbd_bus_methods uhci_bus_methods = {
-	uhci_open,
-	uhci_softintr,
-	uhci_poll,
-	uhci_allocm,
-	uhci_freem,
-	uhci_allocx,
-	uhci_freex,
-	NULL, /* uhci_get_locks */
+	.open_pipe =	uhci_open,
+	.soft_intr =	uhci_softintr,
+	.do_poll =	uhci_poll,
+	.allocm =	uhci_allocm,
+	.freem =	uhci_freem,
+	.allocx =	uhci_allocx,
+	.freex =	uhci_freex,
+	.get_locks =	uhci_get_locks,
 };
 
 const struct usbd_pipe_methods uhci_root_ctrl_methods = {
-	uhci_root_ctrl_transfer,
-	uhci_root_ctrl_start,
-	uhci_root_ctrl_abort,
-	uhci_root_ctrl_close,
-	uhci_noop,
-	uhci_root_ctrl_done,
+	.transfer =	uhci_root_ctrl_transfer,
+	.start =	uhci_root_ctrl_start,
+	.abort =	uhci_root_ctrl_abort,
+	.close =	uhci_root_ctrl_close,
+	.cleartoggle =	uhci_noop,
+	.done =		uhci_root_ctrl_done,
 };
 
 const struct usbd_pipe_methods uhci_root_intr_methods = {
-	uhci_root_intr_transfer,
-	uhci_root_intr_start,
-	uhci_root_intr_abort,
-	uhci_root_intr_close,
-	uhci_noop,
-	uhci_root_intr_done,
+	.transfer =	uhci_root_intr_transfer,
+	.start =	uhci_root_intr_start,
+	.abort =	uhci_root_intr_abort,
+	.close =	uhci_root_intr_close,
+	.cleartoggle =	uhci_noop,
+	.done =		uhci_root_intr_done,
 };
 
 const struct usbd_pipe_methods uhci_device_ctrl_methods = {
-	uhci_device_ctrl_transfer,
-	uhci_device_ctrl_start,
-	uhci_device_ctrl_abort,
-	uhci_device_ctrl_close,
-	uhci_noop,
-	uhci_device_ctrl_done,
+	.transfer =	uhci_device_ctrl_transfer,
+	.start =	uhci_device_ctrl_start,
+	.abort =	uhci_device_ctrl_abort,
+	.close =	uhci_device_ctrl_close,
+	.cleartoggle =	uhci_noop,
+	.done =		uhci_device_ctrl_done,
 };
 
 const struct usbd_pipe_methods uhci_device_intr_methods = {
-	uhci_device_intr_transfer,
-	uhci_device_intr_start,
-	uhci_device_intr_abort,
-	uhci_device_intr_close,
-	uhci_device_clear_toggle,
-	uhci_device_intr_done,
+	.transfer =	uhci_device_intr_transfer,
+	.start =	uhci_device_intr_start,
+	.abort =	uhci_device_intr_abort,
+	.close =	uhci_device_intr_close,
+	.cleartoggle =	uhci_device_clear_toggle,
+	.done =		uhci_device_intr_done,
 };
 
 const struct usbd_pipe_methods uhci_device_bulk_methods = {
-	uhci_device_bulk_transfer,
-	uhci_device_bulk_start,
-	uhci_device_bulk_abort,
-	uhci_device_bulk_close,
-	uhci_device_clear_toggle,
-	uhci_device_bulk_done,
+	.transfer =	uhci_device_bulk_transfer,
+	.start =	uhci_device_bulk_start,
+	.abort =	uhci_device_bulk_abort,
+	.close =	uhci_device_bulk_close,
+	.cleartoggle =	uhci_device_clear_toggle,
+	.done =		uhci_device_bulk_done,
 };
 
 const struct usbd_pipe_methods 

CVS commit: [mrg-ohci-jmcneill-usbmp] src/sys/dev/usb

2011-12-08 Thread matthew green
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 = 

CVS commit: [mrg-ohci-jmcneill-usbmp] src/sys/dev/usb

2011-12-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec  8 09:36:49 UTC 2011

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

Log Message:
at little closer to the main branch.


To generate a diff of this commit:
cvs rdiff -u -r1.218.6.2.2.4 -r1.218.6.2.2.5 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.180.6.1 -r1.180.6.1.2.1 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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.218.6.2.2.4 src/sys/dev/usb/ohci.c:1.218.6.2.2.5
--- src/sys/dev/usb/ohci.c:1.218.6.2.2.4	Thu Dec  8 09:09:30 2011
+++ src/sys/dev/usb/ohci.c	Thu Dec  8 09:36:49 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.218.6.2.2.4 2011/12/08 09:09:30 mrg Exp $	*/
+/*	$NetBSD: ohci.c,v 1.218.6.2.2.5 2011/12/08 09:36:49 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.4 2011/12/08 09:09:30 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: ohci.c,v 1.218.6.2.2.5 2011/12/08 09:36:49 mrg Exp $);
 
 #include opt_usb.h
 
@@ -1900,7 +1900,7 @@ ohci_rem_ed(ohci_softc_t *sc, ohci_soft_
 {
 	ohci_soft_ed_t *p;
 
-	//KASSERT(mutex_owned(sc-sc_lock));
+	KASSERT(mutex_owned(sc-sc_lock));
 
 	/* XXX */
 	for (p = head; p != NULL  p-next != sed; p = p-next)
@@ -1934,7 +1934,7 @@ ohci_hash_add_td(ohci_softc_t *sc, ohci_
 {
 	int h = HASH(std-physaddr);
 
-	//KASSERT(mutex_owned(sc-sc_lock));
+	KASSERT(mutex_owned(sc-sc_lock));
 
 	LIST_INSERT_HEAD(sc-sc_hash_tds[h], std, hnext);
 }
@@ -1944,7 +1944,7 @@ void
 ohci_hash_rem_td(ohci_softc_t *sc, ohci_soft_td_t *std)
 {
 
-	//KASSERT(mutex_owned(sc-sc_lock));
+	KASSERT(mutex_owned(sc-sc_lock));
 
 	LIST_REMOVE(std, hnext);
 }
@@ -1969,7 +1969,7 @@ ohci_hash_add_itd(ohci_softc_t *sc, ohci
 {
 	int h = HASH(sitd-physaddr);
 
-	//KASSERT(mutex_owned(sc-sc_lock));
+	KASSERT(1 || mutex_owned(sc-sc_lock));
 
 	DPRINTFN(10,(ohci_hash_add_itd: sitd=%p physaddr=0x%08lx\n,
 		sitd, (u_long)sitd-physaddr));
@@ -1981,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)
 {
-	//KASSERT(mutex_owned(sc-sc_lock));
+	KASSERT(1 || mutex_owned(sc-sc_lock));
 
 	DPRINTFN(10,(ohci_hash_rem_itd: sitd=%p physaddr=0x%08lx\n,
 		sitd, (u_long)sitd-physaddr));
@@ -2174,7 +2174,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;
@@ -2959,9 +2961,7 @@ ohci_device_ctrl_close(usbd_pipe_handle 
 	ohci_softc_t *sc = pipe-device-bus-hci_private;
 
 	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);
 }
 
@@ -3175,7 +3175,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;

Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.180.6.1 src/sys/dev/usb/usb_subr.c:1.180.6.1.2.1
--- src/sys/dev/usb/usb_subr.c:1.180.6.1	Sun Dec  4 13:23:17 2011
+++ src/sys/dev/usb/usb_subr.c	Thu Dec  8 09:36:49 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.180.6.1 2011/12/04 13:23:17 jmcneill Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.180.6.1.2.1 2011/12/08 09:36:49 mrg 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 sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: usb_subr.c,v 1.180.6.1 2011/12/04 13:23:17 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: usb_subr.c,v 1.180.6.1.2.1 2011/12/08 09:36:49 mrg Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_usbverbose.h
@@ -765,7 +765,11 @@ void
 usbd_kill_pipe(usbd_pipe_handle pipe)
 {
 	usbd_abort_pipe(pipe);
+	if (pipe-lock)	
+		mutex_enter(pipe-lock);
 	pipe-methods-close(pipe);
+	if (pipe-lock)	
+		mutex_exit(pipe-lock);
 	pipe-endpoint-refcnt--;
 	free(pipe, M_USB);
 }



CVS commit: [mrg-ohci-jmcneill-usbmp] src/sys/dev/usb

2011-12-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec  8 09:54:30 UTC 2011

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

Log Message:
mostly in sync with the branch here now.


To generate a diff of this commit:
cvs rdiff -u -r1.125.6.1 -r1.125.6.1.2.1 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.125.6.1 src/sys/dev/usb/usb.c:1.125.6.1.2.1
--- src/sys/dev/usb/usb.c:1.125.6.1	Sun Dec  4 13:23:17 2011
+++ src/sys/dev/usb/usb.c	Thu Dec  8 09:54:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.c,v 1.125.6.1 2011/12/04 13:23:17 jmcneill Exp $	*/
+/*	$NetBSD: usb.c,v 1.125.6.1.2.1 2011/12/08 09:54:30 mrg Exp $	*/
 
 /*
  * Copyright (c) 1998, 2002, 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: usb.c,v 1.125.6.1 2011/12/04 13:23:17 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: usb.c,v 1.125.6.1.2.1 2011/12/08 09:54:30 mrg Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_usb.h
@@ -83,6 +83,7 @@ int	usb_noexplore = 0;
 #else
 #define DPRINTF(x)
 #define DPRINTFN(n,x)
+#define	usb_noexplore 0
 #endif
 
 struct usb_softc {
@@ -372,17 +373,10 @@ usb_event_thread(void *arg)
 	config_pending_decr();
 
 	while (!sc-sc_dying) {
-#ifdef USB_DEBUG
 		if (usb_noexplore  2)
-#endif
-		usb_discover(sc);
-#ifdef USB_DEBUG
+			usb_discover(sc);
 		(void)tsleep(sc-sc_bus-needs_explore, PWAIT, usbevt,
 		usb_noexplore ? 0 : hz * 60);
-#else
-		(void)tsleep(sc-sc_bus-needs_explore, PWAIT, usbevt,
-		hz * 60);
-#endif
 		DPRINTFN(2,(usb_event_thread: woke up\n));
 	}
 	sc-sc_event_thread = NULL;
@@ -777,10 +771,8 @@ usb_discover(struct usb_softc *sc)
 {
 
 	DPRINTFN(2,(usb_discover\n));
-#ifdef USB_DEBUG
 	if (usb_noexplore  1)
 		return;
-#endif
 	/*
 	 * We need mutual exclusion while traversing the device tree,
 	 * but this is guaranteed since this function is only called
@@ -890,7 +882,9 @@ usb_add_event(int type, struct usb_event
 	wakeup(usb_events);
 	selnotify(usb_selevent, 0, 0);
 	if (usb_async_proc != NULL) {
+		kpreempt_disable();
 		softint_schedule(usb_async_sih);
+		kpreempt_enable();
 	}
 	splx(s);
 }
@@ -913,7 +907,9 @@ usb_schedsoftintr(usbd_bus_handle bus)
 	if (bus-use_polling) {
 		bus-methods-soft_intr(bus);
 	} else {
+		kpreempt_disable();
 		softint_schedule(bus-soft);
+		kpreempt_enable();
 	}
 }
 



CVS commit: [mrg-ohci-jmcneill-usbmp] src/sys/dev/usb

2011-12-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec  8 10:41:28 UTC 2011

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

Log Message:
merge a few more changes from the main branch.


To generate a diff of this commit:
cvs rdiff -u -r1.125.6.1.2.1 -r1.125.6.1.2.2 src/sys/dev/usb/usb.c
cvs rdiff -u -r1.180.6.1.2.2 -r1.180.6.1.2.3 src/sys/dev/usb/usb_subr.c
cvs rdiff -u -r1.93.8.1.2.1 -r1.93.8.1.2.2 src/sys/dev/usb/usbdivar.h
cvs rdiff -u -r1.15 -r1.15.14.1 src/sys/dev/usb/utoppy.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.125.6.1.2.1 src/sys/dev/usb/usb.c:1.125.6.1.2.2
--- src/sys/dev/usb/usb.c:1.125.6.1.2.1	Thu Dec  8 09:54:30 2011
+++ src/sys/dev/usb/usb.c	Thu Dec  8 10:41:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.c,v 1.125.6.1.2.1 2011/12/08 09:54:30 mrg Exp $	*/
+/*	$NetBSD: usb.c,v 1.125.6.1.2.2 2011/12/08 10:41:28 mrg Exp $	*/
 
 /*
  * Copyright (c) 1998, 2002, 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: usb.c,v 1.125.6.1.2.1 2011/12/08 09:54:30 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: usb.c,v 1.125.6.1.2.2 2011/12/08 10:41:28 mrg Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_usb.h
@@ -226,6 +226,13 @@ usb_doattach(device_t self)
 		panic(usb_doattach);
 	}
 
+	if (mpsafe) {
+		sc-sc_bus-methods-get_locks(sc-sc_bus,
+		sc-sc_bus-intr_lock, sc-sc_bus-lock);
+	} else {
+		sc-sc_bus-intr_lock = sc-sc_bus-lock = NULL;
+	}
+
 	ue = usb_alloc_event();
 	ue-u.ue_ctrlr.ue_bus = device_unit(self);
 	usb_add_event(USB_EVENT_CTRLR_ATTACH, ue);

Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.180.6.1.2.2 src/sys/dev/usb/usb_subr.c:1.180.6.1.2.3
--- src/sys/dev/usb/usb_subr.c:1.180.6.1.2.2	Thu Dec  8 10:22:40 2011
+++ src/sys/dev/usb/usb_subr.c	Thu Dec  8 10:41:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.180.6.1.2.2 2011/12/08 10:22:40 mrg Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.180.6.1.2.3 2011/12/08 10:41:28 mrg 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 sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: usb_subr.c,v 1.180.6.1.2.2 2011/12/08 10:22:40 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: usb_subr.c,v 1.180.6.1.2.3 2011/12/08 10:41:28 mrg Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_usbverbose.h
@@ -751,11 +751,13 @@ usbd_setup_pipe(usbd_device_handle dev, 
 		free(p, M_USB);
 		return (err);
 	}
+#if 1
 	if (dev-bus-methods-get_locks) {
 		dev-bus-methods-get_locks(dev-bus, p-intr_lock, p-lock);
 	} else {
 		p-intr_lock = p-lock = NULL;
 	}
+#endif
 	*pipe = p;
 	return (USBD_NORMAL_COMPLETION);
 }

Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.93.8.1.2.1 src/sys/dev/usb/usbdivar.h:1.93.8.1.2.2
--- src/sys/dev/usb/usbdivar.h:1.93.8.1.2.1	Thu Dec  8 10:22:40 2011
+++ src/sys/dev/usb/usbdivar.h	Thu Dec  8 10:41:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdivar.h,v 1.93.8.1.2.1 2011/12/08 10:22:40 mrg Exp $	*/
+/*	$NetBSD: usbdivar.h,v 1.93.8.1.2.2 2011/12/08 10:41:28 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $	*/
 
 /*
@@ -142,7 +142,9 @@ struct usbd_bus {
 	const struct usbd_bus_methods *methods;
 	u_int32_t		pipe_size; /* size of a pipe struct */
 	/* Filled by usb driver */
-	struct usbd_device *root_hub;
+	kmutex_t		*intr_lock;
+	kmutex_t		*lock;
+	struct usbd_device  *root_hub;
 	usbd_device_handle	devices[USB_MAX_DEVICES];
 	char			needs_explore;/* a hub a signalled a change */
 	char			use_polling;
@@ -304,3 +306,18 @@ void		usb_schedsoftintr(struct usbd_bus 
 
 #define usbd_lock(m)	if (m) { s = -1; mutex_enter(m); } else s = splusb()
 #define usbd_unlock(m)	if (m) { s = -1; mutex_exit(m); } else splx(s)
+#define usbd_lock_pipe(p)	do { \
+	if ((p)-device-bus-lock) { \
+		s = -1; \
+		mutex_enter((p)-device-bus-lock); \
+	} else \
+		s = splusb(); \
+} while (0)
+
+#define usbd_unlock_pipe(p)	do { \
+	if ((p)-device-bus-lock) { \
+		s = -1; \
+		mutex_exit((p)-device-bus-lock); \
+	} else \
+		splx(s); \
+} while (0)

Index: src/sys/dev/usb/utoppy.c
diff -u src/sys/dev/usb/utoppy.c:1.15 src/sys/dev/usb/utoppy.c:1.15.14.1
--- src/sys/dev/usb/utoppy.c:1.15	Wed Nov  3 22:34:24 2010
+++ src/sys/dev/usb/utoppy.c	Thu Dec  8 10:41:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: utoppy.c,v 1.15 2010/11/03 22:34:24 dyoung Exp $	*/
+/*	$NetBSD: utoppy.c,v 1.15.14.1 2011/12/08 10:41:28 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: utoppy.c,v 1.15 2010/11/03 22:34:24 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: utoppy.c,v 1.15.14.1 2011/12/08 10:41:28 mrg Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -43,9 +43,11 @@ 

CVS commit: [mrg-ohci-jmcneill-usbmp] src/sys/dev/usb

2011-12-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec  8 20:21:31 UTC 2011

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

Log Message:
pull across a few more of the changes from the main branch.


To generate a diff of this commit:
cvs rdiff -u -r1.218.6.2.2.6 -r1.218.6.2.2.7 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.134.2.1.2.2 -r1.134.2.1.2.3 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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.218.6.2.2.6 src/sys/dev/usb/ohci.c:1.218.6.2.2.7
--- src/sys/dev/usb/ohci.c:1.218.6.2.2.6	Thu Dec  8 10:22:40 2011
+++ src/sys/dev/usb/ohci.c	Thu Dec  8 20:21:31 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.218.6.2.2.6 2011/12/08 10:22:40 mrg Exp $	*/
+/*	$NetBSD: ohci.c,v 1.218.6.2.2.7 2011/12/08 20:21:31 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.6 2011/12/08 10:22:40 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: ohci.c,v 1.218.6.2.2.7 2011/12/08 20:21:31 mrg Exp $);
 
 #include opt_usb.h
 
@@ -1900,7 +1900,7 @@ ohci_rem_ed(ohci_softc_t *sc, ohci_soft_
 {
 	ohci_soft_ed_t *p;
 
-	KASSERT(mutex_owned(sc-sc_lock));
+	KASSERT(1 || mutex_owned(sc-sc_lock));
 
 	/* XXX */
 	for (p = head; p != NULL  p-next != sed; p = p-next)
@@ -1969,7 +1969,7 @@ ohci_hash_add_itd(ohci_softc_t *sc, ohci
 {
 	int h = HASH(sitd-physaddr);
 
-	KASSERT(1 || mutex_owned(sc-sc_lock));
+	KASSERT(mutex_owned(sc-sc_lock));
 
 	DPRINTFN(10,(ohci_hash_add_itd: sitd=%p physaddr=0x%08lx\n,
 		sitd, (u_long)sitd-physaddr));
@@ -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;
@@ -2249,7 +2251,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(1 || mutex_owned(sc-sc_lock));
 
 #ifdef DIAGNOSTIC
 	sed-ed.ed_flags |= HTOO32(OHCI_ED_SKIP);
@@ -3433,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,
@@ -3464,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,
@@ -3643,11 +3649,11 @@ ohci_device_isoc_close(usbd_pipe_handle 
 	ohci_softc_t *sc = pipe-device-bus-hci_private;
 
 	DPRINTF((ohci_device_isoc_close: pipe=%p\n, pipe));
-	mutex_enter(sc-sc_lock);
+	//mutex_enter(sc-sc_lock);
 	ohci_close_pipe(pipe, sc-sc_isoc_head);
 #ifdef DIAGNOSTIC
 	opipe-tail.itd-isdone = 1;
 #endif
-	mutex_exit(sc-sc_lock);
+	//mutex_exit(sc-sc_lock);
 	ohci_free_sitd(sc, opipe-tail.itd);
 }

Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.134.2.1.2.2 src/sys/dev/usb/usbdi.c:1.134.2.1.2.3
--- src/sys/dev/usb/usbdi.c:1.134.2.1.2.2	Thu Dec  8 10:22:40 2011
+++ src/sys/dev/usb/usbdi.c	Thu Dec  8 20:21:31 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.134.2.1.2.2 2011/12/08 10:22:40 mrg Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.134.2.1.2.3 2011/12/08 20:21:31 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.1.2.2 2011/12/08 10:22:40 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: usbdi.c,v 1.134.2.1.2.3 2011/12/08 20:21:31 mrg Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_usb.h
@@ -229,6 +229,8 @@ usbd_open_pipe_intr(usbd_interface_handl
 usbd_status
 usbd_close_pipe(usbd_pipe_handle pipe)
 {
+	//int s;
+
 #ifdef DIAGNOSTIC
 	if (pipe == NULL) {
 		printf(usbd_close_pipe: pipe==NULL\n);
@@ -236,6 +238,7 @@ usbd_close_pipe(usbd_pipe_handle pipe)
 	}
 #endif
 
+	//usbd_lock_pipe(pipe);
 	if (--pipe-refcnt != 0)
 		return (USBD_NORMAL_COMPLETION);
 	if (! SIMPLEQ_EMPTY(pipe-queue))
@@ -243,6 +246,7 @@ usbd_close_pipe(usbd_pipe_handle pipe)
 	LIST_REMOVE(pipe, next);
 	pipe-endpoint-refcnt--;
 	pipe-methods-close(pipe);
+	//usbd_lock_pipe(pipe);
 	if (pipe-intrxfer != NULL)
 		usbd_free_xfer(pipe-intrxfer);
 	free(pipe, M_USB);
@@ -310,17 +314,17 @@ usbd_transfer(usbd_xfer_handle xfer)
 	/* Sync transfer, wait for completion. */
 	if (err != USBD_IN_PROGRESS)
 		return (err);
-	

CVS commit: [mrg-ohci-jmcneill-usbmp] src/sys/dev/usb

2011-12-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec  8 22:04:56 UTC 2011

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

Log Message:
sync usb_subr.c and usbdivar.h with the branch entirely, and most of
usbdi.c as well.


To generate a diff of this commit:
cvs rdiff -u -r1.180.6.1.2.3 -r1.180.6.1.2.4 src/sys/dev/usb/usb_subr.c
cvs rdiff -u -r1.134.2.1.2.3 -r1.134.2.1.2.4 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.93.8.1.2.2 -r1.93.8.1.2.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/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.180.6.1.2.3 src/sys/dev/usb/usb_subr.c:1.180.6.1.2.4
--- src/sys/dev/usb/usb_subr.c:1.180.6.1.2.3	Thu Dec  8 10:41:28 2011
+++ src/sys/dev/usb/usb_subr.c	Thu Dec  8 22:04:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.180.6.1.2.3 2011/12/08 10:41:28 mrg Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.180.6.1.2.4 2011/12/08 22:04:56 mrg 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 sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: usb_subr.c,v 1.180.6.1.2.3 2011/12/08 10:41:28 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: usb_subr.c,v 1.180.6.1.2.4 2011/12/08 22:04:56 mrg Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_usbverbose.h
@@ -751,13 +751,6 @@ usbd_setup_pipe(usbd_device_handle dev, 
 		free(p, M_USB);
 		return (err);
 	}
-#if 1
-	if (dev-bus-methods-get_locks) {
-		dev-bus-methods-get_locks(dev-bus, p-intr_lock, p-lock);
-	} else {
-		p-intr_lock = p-lock = NULL;
-	}
-#endif
 	*pipe = p;
 	return (USBD_NORMAL_COMPLETION);
 }

Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.134.2.1.2.3 src/sys/dev/usb/usbdi.c:1.134.2.1.2.4
--- src/sys/dev/usb/usbdi.c:1.134.2.1.2.3	Thu Dec  8 20:21:31 2011
+++ src/sys/dev/usb/usbdi.c	Thu Dec  8 22:04:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.134.2.1.2.3 2011/12/08 20:21:31 mrg Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.134.2.1.2.4 2011/12/08 22:04:56 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.1.2.3 2011/12/08 20:21:31 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: usbdi.c,v 1.134.2.1.2.4 2011/12/08 22:04:56 mrg Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_usb.h
@@ -229,7 +229,6 @@ usbd_open_pipe_intr(usbd_interface_handl
 usbd_status
 usbd_close_pipe(usbd_pipe_handle pipe)
 {
-	//int s;
 
 #ifdef DIAGNOSTIC
 	if (pipe == NULL) {
@@ -238,7 +237,6 @@ usbd_close_pipe(usbd_pipe_handle pipe)
 	}
 #endif
 
-	//usbd_lock_pipe(pipe);
 	if (--pipe-refcnt != 0)
 		return (USBD_NORMAL_COMPLETION);
 	if (! SIMPLEQ_EMPTY(pipe-queue))
@@ -246,7 +244,6 @@ usbd_close_pipe(usbd_pipe_handle pipe)
 	LIST_REMOVE(pipe, next);
 	pipe-endpoint-refcnt--;
 	pipe-methods-close(pipe);
-	//usbd_lock_pipe(pipe);
 	if (pipe-intrxfer != NULL)
 		usbd_free_xfer(pipe-intrxfer);
 	free(pipe, M_USB);
@@ -319,8 +316,8 @@ usbd_transfer(usbd_xfer_handle xfer)
 		if (pipe-device-bus-use_polling)
 			panic(usbd_transfer: not done);
 
-		if (pipe-lock)
-			cv_wait(xfer-cv, pipe-lock);
+		if (pipe-device-bus-lock)
+			cv_wait(xfer-cv, pipe-device-bus-lock);
 		else
 			tsleep(xfer, PRIBIO, usbsyn, 0);
 	}
@@ -838,9 +835,11 @@ usb_transfer_complete(usbd_xfer_handle x
 
 	if (repeat) {
 		if (xfer-callback) {
-			if (pipe-lock) mutex_exit(pipe-lock);
+			if (pipe-device-bus-lock)
+mutex_exit(pipe-device-bus-lock);
 			xfer-callback(xfer, xfer-priv, xfer-status);
-			if (pipe-lock) mutex_enter(pipe-lock);
+			if (pipe-device-bus-lock)
+mutex_enter(pipe-device-bus-lock);
 		}
 		pipe-methods-done(xfer);
 	} else {
@@ -909,6 +908,8 @@ usbd_start_next(usbd_pipe_handle pipe)
 	usbd_xfer_handle xfer;
 	usbd_status err;
 
+	KASSERT(pipe-device-bus-lock == NULL || mutex_owned(pipe-device-bus-lock));
+
 #ifdef DIAGNOSTIC
 	if (pipe == NULL) {
 		printf(usbd_start_next: pipe == NULL\n);

Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.93.8.1.2.2 src/sys/dev/usb/usbdivar.h:1.93.8.1.2.3
--- src/sys/dev/usb/usbdivar.h:1.93.8.1.2.2	Thu Dec  8 10:41:28 2011
+++ src/sys/dev/usb/usbdivar.h	Thu Dec  8 22:04:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdivar.h,v 1.93.8.1.2.2 2011/12/08 10:41:28 mrg Exp $	*/
+/*	$NetBSD: usbdivar.h,v 1.93.8.1.2.3 2011/12/08 22:04:56 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $	*/
 
 /*
@@ -215,9 +215,6 @@ struct usbd_pipe {
 	char			repeat;
 	int			interval;
 
-	kmutex_t		*intr_lock;
-	kmutex_t		*lock;
-
 	/* Filled by HC driver. */
 	const struct usbd_pipe_methods *methods;
 };
@@ -304,8 +301,6 @@ void		usb_needs_explore(usbd_device_hand
 void		usb_needs_reattach(usbd_device_handle);
 void		usb_schedsoftintr(struct usbd_bus *);
 
-#define usbd_lock(m)	

CVS commit: [mrg-ohci-jmcneill-usbmp] src/sys/dev/usb

2011-12-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec  8 07:53:56 UTC 2011

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

Log Message:
there's something wrong with uaudio@ohci on the usbmp branch.
this is the minimally working port of ohci to mpusb, and it works
with uaudio but is lacking many other changes, yet.


To generate a diff of this commit:
cvs rdiff -u -r1.218.6.2 -r1.218.6.2.2.1 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.134.2.1 -r1.134.2.1.2.1 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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.218.6.2 src/sys/dev/usb/ohci.c:1.218.6.2.2.1
--- src/sys/dev/usb/ohci.c:1.218.6.2	Sun Dec  4 21:02:27 2011
+++ src/sys/dev/usb/ohci.c	Thu Dec  8 07:53:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.218.6.2 2011/12/04 21:02:27 jmcneill Exp $	*/
+/*	$NetBSD: ohci.c,v 1.218.6.2.2.1 2011/12/08 07:53:56 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 2011/12/04 21:02:27 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: ohci.c,v 1.218.6.2.2.1 2011/12/08 07:53:56 mrg Exp $);
 
 #include opt_usb.h
 
@@ -2245,7 +2245,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);
@@ -3363,15 +3363,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)
@@ -3496,7 +3496,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);
@@ -3505,7 +3505,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) {
@@ -3540,6 +3540,8 @@ ohci_device_isoc_start(usbd_xfer_handle 
 
 	/* XXX anything to do? */
 
+	mutex_exit(sc-sc_lock);
+
 	return (USBD_IN_PROGRESS);
 }
 
@@ -3553,7 +3555,7 @@ ohci_device_isoc_abort(usbd_xfer_handle 
 
 	DPRINTFN(1,(ohci_device_isoc_abort: xfer=%p\n, xfer));
 
-	KASSERT(mutex_owned(sc-sc_lock));
+	//KASSERT(mutex_owned(sc-sc_lock));
 
 	/* Transfer is already done. */
 	if (xfer-status != USBD_NOT_STARTED 
@@ -3587,22 +3589,24 @@ ohci_device_isoc_abort(usbd_xfer_handle 
 #endif
 	}
 
-	mutex_exit(sc-sc_lock);
+	//mutex_exit(sc-sc_lock);
 
 	usb_delay_ms(sc-sc_bus, OHCI_ITD_NOFFSET);
 
-	mutex_enter(sc-sc_lock);
+	//mutex_enter(sc-sc_lock);
 
 	/* Run callback. */
+mutex_enter(sc-sc_lock);
 	usb_transfer_complete(xfer);
+mutex_exit(sc-sc_lock);
 
 	sed-ed.ed_headp = HTOO32(sitd-physaddr); /* unlink TDs */
 	sed-ed.ed_flags = HTOO32(~OHCI_ED_SKIP); /* remove hardware skip */
 	usb_syncmem(sed-dma, sed-offs, sizeof(sed-ed),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 
- done:
-	mutex_exit(sc-sc_lock);
+ done: ;
+	//mutex_exit(sc-sc_lock);
 }
 
 void

Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.134.2.1 src/sys/dev/usb/usbdi.c:1.134.2.1.2.1
--- src/sys/dev/usb/usbdi.c:1.134.2.1	Sun Dec  4 13:23:17 2011
+++ src/sys/dev/usb/usbdi.c	Thu Dec  8 07:53:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.134.2.1 2011/12/04 13:23:17 jmcneill Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.134.2.1.2.1 2011/12/08 07:53:56 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.1 2011/12/04 13:23:17 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: usbdi.c,v 1.134.2.1.2.1 2011/12/08 07:53:56 mrg Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_usb.h
@@ -878,7 +878,7 @@ usb_insert_transfer(usbd_xfer_handle xfe
 	DPRINTFN(5,(usb_insert_transfer: pipe=%p running=%d timeout=%d\n,
 		pipe, pipe-running, xfer-timeout));
 
-	KASSERT(pipe-lock == NULL || mutex_owned(pipe-lock));
+	//KASSERT(pipe-lock == NULL || mutex_owned(pipe-lock));
 
 #ifdef DIAGNOSTIC
 	if (xfer-busy_free != XFER_BUSY) {