Module Name:    src
Committed By:   jmcneill
Date:           Tue Jan 22 12:40:44 UTC 2013

Modified Files:
        src/sys/dev/usb: auvitek_dtv.c ehci.c emdtv_dtv.c if_atu.c if_aue.c
            if_axe.c if_cue.c if_otus.c if_rum.c if_run.c if_smsc.c if_udav.c
            if_upgt.c if_ural.c if_url.c if_urtw.c if_urtwn.c if_zyd.c ohci.c
            uaudio.c uhci.c usb.c usb_subr.c usbdi.c usbdi.h usbdivar.h

Log Message:
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
  before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
  present, acquire KERNEL_LOCK before invoking the task callback.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/auvitek_dtv.c \
    src/sys/dev/usb/if_smsc.c
cvs rdiff -u -r1.202 -r1.203 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/usb/emdtv_dtv.c
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/usb/if_atu.c
cvs rdiff -u -r1.129 -r1.130 src/sys/dev/usb/if_aue.c
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/usb/if_axe.c
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/usb/if_cue.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/usb/if_otus.c
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/usb/if_rum.c src/sys/dev/usb/if_url.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/usb/if_run.c src/sys/dev/usb/if_upgt.c
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/usb/if_udav.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/usb/if_ural.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/if_urtw.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/usb/if_zyd.c
cvs rdiff -u -r1.230 -r1.231 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.133 -r1.134 src/sys/dev/usb/uaudio.c
cvs rdiff -u -r1.251 -r1.252 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.139 -r1.140 src/sys/dev/usb/usb.c
cvs rdiff -u -r1.187 -r1.188 src/sys/dev/usb/usb_subr.c
cvs rdiff -u -r1.147 -r1.148 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/usb/usbdi.h
cvs rdiff -u -r1.100 -r1.101 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/auvitek_dtv.c
diff -u src/sys/dev/usb/auvitek_dtv.c:1.5 src/sys/dev/usb/auvitek_dtv.c:1.6
--- src/sys/dev/usb/auvitek_dtv.c:1.5	Mon Jan  9 10:57:34 2012
+++ src/sys/dev/usb/auvitek_dtv.c	Tue Jan 22 12:40:42 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_dtv.c,v 1.5 2012/01/09 10:57:34 jmcneill Exp $ */
+/* $NetBSD: auvitek_dtv.c,v 1.6 2013/01/22 12:40:42 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.5 2012/01/09 10:57:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.6 2013/01/22 12:40:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -259,7 +259,7 @@ auvitek_dtv_init_pipes(struct auvitek_so
 
 	KERNEL_LOCK(1, curlwp);
 	err = usbd_open_pipe(sc->sc_bulk_iface, sc->sc_ab.ab_endpt,
-	    USBD_EXCLUSIVE_USE, &sc->sc_ab.ab_pipe);
+	    USBD_EXCLUSIVE_USE|USBD_MPSAFE, &sc->sc_ab.ab_pipe);
 	KERNEL_UNLOCK_ONE(curlwp);
 
 	if (err) {
Index: src/sys/dev/usb/if_smsc.c
diff -u src/sys/dev/usb/if_smsc.c:1.5 src/sys/dev/usb/if_smsc.c:1.6
--- src/sys/dev/usb/if_smsc.c:1.5	Sun Jan 13 15:34:03 2013
+++ src/sys/dev/usb/if_smsc.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_smsc.c,v 1.5 2013/01/13 15:34:03 skrll Exp $	*/
+/*	$NetBSD: if_smsc.c,v 1.6 2013/01/22 12:40:43 jmcneill Exp $	*/
 
 /*	$OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $	*/
 /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -996,8 +996,8 @@ smsc_attach(device_t parent, device_t se
 		return;
 	}
 	/* Setup the endpoints for the SMSC LAN95xx device(s) */
-	usb_init_task(&sc->sc_tick_task, smsc_tick_task, sc);
-	usb_init_task(&sc->sc_stop_task, (void (*)(void *))smsc_stop, sc);
+	usb_init_task(&sc->sc_tick_task, smsc_tick_task, sc, 0);
+	usb_init_task(&sc->sc_stop_task, (void (*)(void *))smsc_stop, sc, 0);
 	mutex_init(&sc->sc_mii_lock, MUTEX_DEFAULT, IPL_NONE);
 
 	err = usbd_device2interface_handle(dev, SMSC_IFACE_IDX, &sc->sc_iface);

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.202 src/sys/dev/usb/ehci.c:1.203
--- src/sys/dev/usb/ehci.c:1.202	Tue Jan 15 17:45:05 2013
+++ src/sys/dev/usb/ehci.c	Tue Jan 22 12:40:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.202 2013/01/15 17:45:05 christos Exp $ */
+/*	$NetBSD: ehci.c,v 1.203 2013/01/22 12:40:42 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.202 2013/01/15 17:45:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.203 2013/01/22 12:40:42 jmcneill Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -3228,7 +3228,8 @@ ehci_timeout(void *addr)
 	}
 
 	/* Execute the abort in a process context. */
-	usb_init_task(&exfer->abort_task, ehci_timeout_task, addr);
+	usb_init_task(&exfer->abort_task, ehci_timeout_task, addr,
+	    USB_TASKQ_MPSAFE);
 	usb_add_task(exfer->xfer.pipe->device, &exfer->abort_task,
 	    USB_TASKQ_HC);
 }

Index: src/sys/dev/usb/emdtv_dtv.c
diff -u src/sys/dev/usb/emdtv_dtv.c:1.9 src/sys/dev/usb/emdtv_dtv.c:1.10
--- src/sys/dev/usb/emdtv_dtv.c:1.9	Sun Mar 11 01:06:06 2012
+++ src/sys/dev/usb/emdtv_dtv.c	Tue Jan 22 12:40:42 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv_dtv.c,v 1.9 2012/03/11 01:06:06 mrg Exp $ */
+/* $NetBSD: emdtv_dtv.c,v 1.10 2013/01/22 12:40:42 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2008, 2011 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.9 2012/03/11 01:06:06 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.10 2013/01/22 12:40:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -103,7 +103,7 @@ emdtv_dtv_attach(struct emdtv_softc *sc)
 	aprint_debug_dev(sc->sc_dev, "calling usbd_open_pipe, ep 0x%02x\n",
 	    ed->bEndpointAddress);
 	status = usbd_open_pipe(sc->sc_iface, 
-	    ed->bEndpointAddress, USBD_EXCLUSIVE_USE,
+	    ed->bEndpointAddress, USBD_EXCLUSIVE_USE|USBD_MPSAFE,
 	    &sc->sc_isoc_pipe);
 	if (status != USBD_NORMAL_COMPLETION) {
 		aprint_error_dev(sc->sc_dev, "couldn't open isoc pipe\n");

Index: src/sys/dev/usb/if_atu.c
diff -u src/sys/dev/usb/if_atu.c:1.47 src/sys/dev/usb/if_atu.c:1.48
--- src/sys/dev/usb/if_atu.c:1.47	Sat Jan  5 23:34:16 2013
+++ src/sys/dev/usb/if_atu.c	Tue Jan 22 12:40:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_atu.c,v 1.47 2013/01/05 23:34:16 christos Exp $ */
+/*	$NetBSD: if_atu.c,v 1.48 2013/01/22 12:40:42 jmcneill Exp $ */
 /*	$OpenBSD: if_atu.c,v 1.48 2004/12/30 01:53:21 dlg Exp $ */
 /*
  * Copyright (c) 2003, 2004
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.47 2013/01/05 23:34:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.48 2013/01/22 12:40:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -1461,7 +1461,7 @@ atu_complete_attach(struct atu_softc *sc
 	/* setup ifmedia interface */
 	ieee80211_media_init(ic, atu_media_change, atu_media_status);
 
-	usb_init_task(&sc->sc_task, atu_task, sc);
+	usb_init_task(&sc->sc_task, atu_task, sc, 0);
 
 	sc->sc_state = ATU_S_OK;
 }

Index: src/sys/dev/usb/if_aue.c
diff -u src/sys/dev/usb/if_aue.c:1.129 src/sys/dev/usb/if_aue.c:1.130
--- src/sys/dev/usb/if_aue.c:1.129	Sat Jan  5 01:30:15 2013
+++ src/sys/dev/usb/if_aue.c	Tue Jan 22 12:40:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_aue.c,v 1.129 2013/01/05 01:30:15 christos Exp $	*/
+/*	$NetBSD: if_aue.c,v 1.130 2013/01/22 12:40:42 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.129 2013/01/05 01:30:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.130 2013/01/22 12:40:42 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -752,8 +752,8 @@ aue_attach(device_t parent, device_t sel
 		return;
 	}
 
-	usb_init_task(&sc->aue_tick_task, aue_tick_task, sc);
-	usb_init_task(&sc->aue_stop_task, (void (*)(void *))aue_stop, sc);
+	usb_init_task(&sc->aue_tick_task, aue_tick_task, sc, 0);
+	usb_init_task(&sc->aue_stop_task, (void (*)(void *))aue_stop, sc, 0);
 	mutex_init(&sc->aue_mii_lock, MUTEX_DEFAULT, IPL_NONE);
 
 	err = usbd_device2interface_handle(dev, AUE_IFACE_IDX, &iface);

Index: src/sys/dev/usb/if_axe.c
diff -u src/sys/dev/usb/if_axe.c:1.63 src/sys/dev/usb/if_axe.c:1.64
--- src/sys/dev/usb/if_axe.c:1.63	Wed Jan 16 17:18:55 2013
+++ src/sys/dev/usb/if_axe.c	Tue Jan 22 12:40:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axe.c,v 1.63 2013/01/16 17:18:55 christos Exp $	*/
+/*	$NetBSD: if_axe.c,v 1.64 2013/01/22 12:40:42 jmcneill Exp $	*/
 /*	$OpenBSD: if_axe.c,v 1.96 2010/01/09 05:33:08 jsg Exp $ */
 
 /*
@@ -89,7 +89,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.63 2013/01/16 17:18:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.64 2013/01/22 12:40:42 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -611,7 +611,7 @@ axe_attach(device_t parent, device_t sel
 	sc->axe_flags = axe_lookup(uaa->vendor, uaa->product)->axe_flags;
 
 	mutex_init(&sc->axe_mii_lock, MUTEX_DEFAULT, IPL_NONE);
-	usb_init_task(&sc->axe_tick_task, axe_tick_task, sc);
+	usb_init_task(&sc->axe_tick_task, axe_tick_task, sc, 0);
 
 	err = usbd_device2interface_handle(dev, AXE_IFACE_IDX, &sc->axe_iface);
 	if (err) {

Index: src/sys/dev/usb/if_cue.c
diff -u src/sys/dev/usb/if_cue.c:1.65 src/sys/dev/usb/if_cue.c:1.66
--- src/sys/dev/usb/if_cue.c:1.65	Sat Jan  5 01:30:15 2013
+++ src/sys/dev/usb/if_cue.c	Tue Jan 22 12:40:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cue.c,v 1.65 2013/01/05 01:30:15 christos Exp $	*/
+/*	$NetBSD: if_cue.c,v 1.66 2013/01/22 12:40:42 jmcneill Exp $	*/
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *	Bill Paul <wp...@ee.columbia.edu>.  All rights reserved.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.65 2013/01/05 01:30:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.66 2013/01/22 12:40:42 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -488,7 +488,7 @@ cue_attach(device_t parent, device_t sel
 	sc->cue_product = uaa->product;
 	sc->cue_vendor = uaa->vendor;
 
-	usb_init_task(&sc->cue_tick_task, cue_tick_task, sc);
+	usb_init_task(&sc->cue_tick_task, cue_tick_task, sc, 0);
 	usb_init_task(&sc->cue_stop_task, (void (*)(void *))cue_stop, sc);
 
 	err = usbd_device2interface_handle(dev, CUE_IFACE_IDX, &iface);

Index: src/sys/dev/usb/if_otus.c
diff -u src/sys/dev/usb/if_otus.c:1.21 src/sys/dev/usb/if_otus.c:1.22
--- src/sys/dev/usb/if_otus.c:1.21	Mon Jan 21 16:52:56 2013
+++ src/sys/dev/usb/if_otus.c	Tue Jan 22 12:40:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_otus.c,v 1.21 2013/01/21 16:52:56 christos Exp $	*/
+/*	$NetBSD: if_otus.c,v 1.22 2013/01/22 12:40:42 jmcneill Exp $	*/
 /*	$OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.21 2013/01/21 16:52:56 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.22 2013/01/22 12:40:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -637,7 +637,7 @@ otus_attach(device_t parent, device_t se
 	mutex_init(&sc->sc_tx_mtx,    MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(&sc->sc_write_mtx, MUTEX_DEFAULT, IPL_NONE);
 
-	usb_init_task(&sc->sc_task, otus_task, sc);
+	usb_init_task(&sc->sc_task, otus_task, sc, 0);
 
 	callout_init(&sc->sc_scan_to, 0);
 	callout_setfunc(&sc->sc_scan_to, otus_next_scan, sc);

Index: src/sys/dev/usb/if_rum.c
diff -u src/sys/dev/usb/if_rum.c:1.46 src/sys/dev/usb/if_rum.c:1.47
--- src/sys/dev/usb/if_rum.c:1.46	Sat Jan  5 23:34:17 2013
+++ src/sys/dev/usb/if_rum.c	Tue Jan 22 12:40:42 2013
@@ -1,5 +1,5 @@
 /*	$OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $	*/
-/*	$NetBSD: if_rum.c,v 1.46 2013/01/05 23:34:17 christos Exp $	*/
+/*	$NetBSD: if_rum.c,v 1.47 2013/01/22 12:40:42 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2005-2007 Damien Bergamini <damien.bergam...@free.fr>
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.46 2013/01/05 23:34:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.47 2013/01/22 12:40:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -366,7 +366,7 @@ rum_attach(device_t parent, device_t sel
 		return;
 	}
 
-	usb_init_task(&sc->sc_task, rum_task, sc);
+	usb_init_task(&sc->sc_task, rum_task, sc, 0);
 	callout_init(&sc->sc_scan_ch, 0);
 
 	sc->amrr.amrr_min_success_threshold =  1;
Index: src/sys/dev/usb/if_url.c
diff -u src/sys/dev/usb/if_url.c:1.46 src/sys/dev/usb/if_url.c:1.47
--- src/sys/dev/usb/if_url.c:1.46	Sat Jan  5 01:30:16 2013
+++ src/sys/dev/usb/if_url.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_url.c,v 1.46 2013/01/05 01:30:16 christos Exp $	*/
+/*	$NetBSD: if_url.c,v 1.47 2013/01/22 12:40:43 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.46 2013/01/05 01:30:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.47 2013/01/22 12:40:43 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -209,9 +209,9 @@ url_attach(device_t parent, device_t sel
 		goto bad;
 	}
 
-	usb_init_task(&sc->sc_tick_task, url_tick_task, sc);
+	usb_init_task(&sc->sc_tick_task, url_tick_task, sc, 0);
 	rw_init(&sc->sc_mii_rwlock);
-	usb_init_task(&sc->sc_stop_task, (void (*)(void *)) url_stop_task, sc);
+	usb_init_task(&sc->sc_stop_task, (void (*)(void *))url_stop_task, sc, 0);
 
 	/* get control interface */
 	err = usbd_device2interface_handle(dev, URL_IFACE_INDEX, &iface);

Index: src/sys/dev/usb/if_run.c
diff -u src/sys/dev/usb/if_run.c:1.7 src/sys/dev/usb/if_run.c:1.8
--- src/sys/dev/usb/if_run.c:1.7	Sat Jan  5 23:34:17 2013
+++ src/sys/dev/usb/if_run.c	Tue Jan 22 12:40:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_run.c,v 1.7 2013/01/05 23:34:17 christos Exp $	*/
+/*	$NetBSD: if_run.c,v 1.8 2013/01/22 12:40:42 jmcneill Exp $	*/
 /*	$OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.7 2013/01/05 23:34:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.8 2013/01/22 12:40:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -538,7 +538,7 @@ run_attach(device_t parent, device_t sel
 		return;
 	}
 
-	usb_init_task(&sc->sc_task, run_task, sc);
+	usb_init_task(&sc->sc_task, run_task, sc, 0);
 	callout_init(&sc->scan_to, 0);
 	callout_setfunc(&sc->scan_to, run_next_scan, sc);
 	callout_init(&sc->calib_to, 0);
Index: src/sys/dev/usb/if_upgt.c
diff -u src/sys/dev/usb/if_upgt.c:1.7 src/sys/dev/usb/if_upgt.c:1.8
--- src/sys/dev/usb/if_upgt.c:1.7	Thu Dec 27 16:42:32 2012
+++ src/sys/dev/usb/if_upgt.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_upgt.c,v 1.7 2012/12/27 16:42:32 skrll Exp $	*/
+/*	$NetBSD: if_upgt.c,v 1.8 2013/01/22 12:40:43 jmcneill Exp $	*/
 /*	$OpenBSD: if_upgt.c,v 1.49 2010/04/20 22:05:43 tedu Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.7 2012/12/27 16:42:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.8 2013/01/22 12:40:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -295,8 +295,8 @@ upgt_attach(device_t parent, device_t se
 	}
 
 	/* setup tasks and timeouts */
-	usb_init_task(&sc->sc_task_newstate, upgt_newstate_task, sc);
-	usb_init_task(&sc->sc_task_tx, upgt_tx_task, sc);
+	usb_init_task(&sc->sc_task_newstate, upgt_newstate_task, sc, 0);
+	usb_init_task(&sc->sc_task_tx, upgt_tx_task, sc, 0);
 	callout_init(&sc->scan_to, 0);
 	callout_setfunc(&sc->scan_to, upgt_next_scan, sc);
 	callout_init(&sc->led_to, 0);

Index: src/sys/dev/usb/if_udav.c
diff -u src/sys/dev/usb/if_udav.c:1.40 src/sys/dev/usb/if_udav.c:1.41
--- src/sys/dev/usb/if_udav.c:1.40	Sat Jan  5 01:30:16 2013
+++ src/sys/dev/usb/if_udav.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_udav.c,v 1.40 2013/01/05 01:30:16 christos Exp $	*/
+/*	$NetBSD: if_udav.c,v 1.41 2013/01/22 12:40:43 jmcneill Exp $	*/
 /*	$nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $	*/
 
 /*
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.40 2013/01/05 01:30:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.41 2013/01/22 12:40:43 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -212,9 +212,9 @@ udav_attach(device_t parent, device_t se
 		goto bad;
 	}
 
-	usb_init_task(&sc->sc_tick_task, udav_tick_task, sc);
+	usb_init_task(&sc->sc_tick_task, udav_tick_task, sc, 0);
 	mutex_init(&sc->sc_mii_lock, MUTEX_DEFAULT, IPL_NONE);
-	usb_init_task(&sc->sc_stop_task, (void (*)(void *)) udav_stop_task, sc);
+	usb_init_task(&sc->sc_stop_task, (void (*)(void *))udav_stop_task, sc, 0);
 
 	/* get control interface */
 	err = usbd_device2interface_handle(dev, UDAV_IFACE_INDEX, &iface);

Index: src/sys/dev/usb/if_ural.c
diff -u src/sys/dev/usb/if_ural.c:1.43 src/sys/dev/usb/if_ural.c:1.44
--- src/sys/dev/usb/if_ural.c:1.43	Sat Jan  5 23:34:17 2013
+++ src/sys/dev/usb/if_ural.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ural.c,v 1.43 2013/01/05 23:34:17 christos Exp $ */
+/*	$NetBSD: if_ural.c,v 1.44 2013/01/22 12:40:43 jmcneill Exp $ */
 /*	$FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $	*/
 
 /*-
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.43 2013/01/05 23:34:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.44 2013/01/22 12:40:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -424,7 +424,7 @@ ural_attach(device_t parent, device_t se
 		return;
 	}
 
-	usb_init_task(&sc->sc_task, ural_task, sc);
+	usb_init_task(&sc->sc_task, ural_task, sc, 0);
 	callout_init(&sc->sc_scan_ch, 0);
 	sc->amrr.amrr_min_success_threshold = 1;
 	sc->amrr.amrr_max_success_threshold = 15;

Index: src/sys/dev/usb/if_urtw.c
diff -u src/sys/dev/usb/if_urtw.c:1.4 src/sys/dev/usb/if_urtw.c:1.5
--- src/sys/dev/usb/if_urtw.c:1.4	Sat Jan  5 23:34:17 2013
+++ src/sys/dev/usb/if_urtw.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtw.c,v 1.4 2013/01/05 23:34:17 christos Exp $	*/
+/*	$NetBSD: if_urtw.c,v 1.5 2013/01/22 12:40:43 jmcneill Exp $	*/
 /*	$OpenBSD: if_urtw.c,v 1.39 2011/07/03 15:47:17 matthew Exp $	*/
 
 /*-
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtw.c,v 1.4 2013/01/05 23:34:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtw.c,v 1.5 2013/01/22 12:40:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -681,8 +681,8 @@ urtw_attach(device_t parent, device_t se
 	/* XXX for what? */
 	sc->sc_preamble_mode = 2;
 
-	usb_init_task(&sc->sc_task, urtw_task, sc);
-	usb_init_task(&sc->sc_ledtask, urtw_ledusbtask, sc);
+	usb_init_task(&sc->sc_task, urtw_task, sc, 0);
+	usb_init_task(&sc->sc_ledtask, urtw_ledusbtask, sc, 0);
 	callout_init(&sc->scan_to, 0);
 	callout_setfunc(&sc->scan_to, urtw_next_scan, sc);
 	callout_init(&sc->sc_led_ch, 0);

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.17 src/sys/dev/usb/if_urtwn.c:1.18
--- src/sys/dev/usb/if_urtwn.c:1.17	Tue Jan 22 12:04:58 2013
+++ src/sys/dev/usb/if_urtwn.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.17 2013/01/22 12:04:58 jmcneill Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.18 2013/01/22 12:40:43 jmcneill Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.20 2011/11/26 06:39:33 ckuethe Exp $	*/
 
 /*-
@@ -22,7 +22,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.17 2013/01/22 12:04:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.18 2013/01/22 12:40:43 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -286,7 +286,7 @@ urtwn_attach(device_t parent, device_t s
 	mutex_init(&sc->sc_fwcmd_mtx, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(&sc->sc_write_mtx, MUTEX_DEFAULT, IPL_NONE);
 
-	usb_init_task(&sc->sc_task, urtwn_task, sc);
+	usb_init_task(&sc->sc_task, urtwn_task, sc, 0);
 
 	callout_init(&sc->sc_scan_to, 0);
 	callout_setfunc(&sc->sc_scan_to, urtwn_next_scan, sc);
@@ -689,9 +689,7 @@ urtwn_task(void *arg)
 		mutex_spin_exit(&sc->sc_task_mtx);
 		splx(s);
 		/* Invoke callback with kernel lock held. */
-		KERNEL_LOCK(1, curlwp);
 		cmd->cb(sc, cmd->data);
-		KERNEL_UNLOCK_ONE(curlwp);
 		s = splusb();
 		mutex_spin_enter(&sc->sc_task_mtx);
 		ring->queued--;
@@ -2080,9 +2078,7 @@ urtwn_rxeof(usbd_xfer_handle xfer, usbd_
 		}
 
 		/* Process 802.11 frame. */
-		KERNEL_LOCK(1, curlwp);
 		urtwn_rx_frame(sc, buf, pktlen);
-		KERNEL_UNLOCK_ONE(curlwp);
 
 		/* Next chunk is 128-byte aligned. */
 		totlen = roundup2(totlen, 128);
@@ -2128,9 +2124,7 @@ urtwn_txeof(usbd_xfer_handle xfer, usbd_
 		return;
 	}
 
-	KERNEL_LOCK(1, curlwp);
 	urtwn_start(ifp);
-	KERNEL_UNLOCK_ONE(curlwp);
 
 	splx(s);
 }

Index: src/sys/dev/usb/if_zyd.c
diff -u src/sys/dev/usb/if_zyd.c:1.35 src/sys/dev/usb/if_zyd.c:1.36
--- src/sys/dev/usb/if_zyd.c:1.35	Sat Jan  5 23:34:18 2013
+++ src/sys/dev/usb/if_zyd.c	Tue Jan 22 12:40:43 2013
@@ -1,5 +1,5 @@
 /*	$OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $	*/
-/*	$NetBSD: if_zyd.c,v 1.35 2013/01/05 23:34:18 christos Exp $	*/
+/*	$NetBSD: if_zyd.c,v 1.36 2013/01/22 12:40:43 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2006 by Damien Bergamini <damien.bergam...@free.fr>
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.35 2013/01/05 23:34:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.36 2013/01/22 12:40:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -352,7 +352,7 @@ zyd_complete_attach(struct zyd_softc *sc
 	usbd_status error;
 	int i;
 
-	usb_init_task(&sc->sc_task, zyd_task, sc);
+	usb_init_task(&sc->sc_task, zyd_task, sc, 0);
 	callout_init(&(sc->sc_scan_ch), 0);
 
 	sc->amrr.amrr_min_success_threshold =  1;

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.230 src/sys/dev/usb/ohci.c:1.231
--- src/sys/dev/usb/ohci.c:1.230	Sun Jan 13 01:10:59 2013
+++ src/sys/dev/usb/ohci.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.230 2013/01/13 01:10:59 jmcneill Exp $	*/
+/*	$NetBSD: ohci.c,v 1.231 2013/01/22 12:40:43 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.230 2013/01/13 01:10:59 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.231 2013/01/22 12:40:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -2009,7 +2009,8 @@ ohci_timeout(void *addr)
 	}
 
 	/* Execute the abort in a process context. */
-	usb_init_task(&oxfer->abort_task, ohci_timeout_task, addr);
+	usb_init_task(&oxfer->abort_task, ohci_timeout_task, addr,
+	    USB_TASKQ_MPSAFE);
 	usb_add_task(oxfer->xfer.pipe->device, &oxfer->abort_task,
 	    USB_TASKQ_HC);
 }

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.133 src/sys/dev/usb/uaudio.c:1.134
--- src/sys/dev/usb/uaudio.c:1.133	Sun Jun 10 06:15:53 2012
+++ src/sys/dev/usb/uaudio.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.133 2012/06/10 06:15:53 mrg Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.134 2013/01/22 12:40:43 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.133 2012/06/10 06:15:53 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.134 2013/01/22 12:40:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -2692,13 +2692,14 @@ uaudio_chan_open(struct uaudio_softc *sc
 	ch->pipe = 0;
 	ch->sync_pipe = 0;
 	DPRINTF("create pipe to 0x%02x\n", endpt);
-	err = usbd_open_pipe(as->ifaceh, endpt, 0, &ch->pipe);
+	err = usbd_open_pipe(as->ifaceh, endpt, USBD_MPSAFE, &ch->pipe);
 	if (err)
 		return err;
 	if (as->edesc1 != NULL) {
 		endpt = as->edesc1->bEndpointAddress;
 		DPRINTF("create sync-pipe to 0x%02x\n", endpt);
-		err = usbd_open_pipe(as->ifaceh, endpt, 0, &ch->sync_pipe);
+		err = usbd_open_pipe(as->ifaceh, endpt, USBD_MPSAFE,
+		    &ch->sync_pipe);
 	}
 	return err;
 }

Index: src/sys/dev/usb/uhci.c
diff -u src/sys/dev/usb/uhci.c:1.251 src/sys/dev/usb/uhci.c:1.252
--- src/sys/dev/usb/uhci.c:1.251	Sat Jan  5 23:34:18 2013
+++ src/sys/dev/usb/uhci.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhci.c,v 1.251 2013/01/05 23:34:18 christos Exp $	*/
+/*	$NetBSD: uhci.c,v 1.252 2013/01/22 12:40:43 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.251 2013/01/05 23:34:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.252 2013/01/22 12:40:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1649,7 +1649,8 @@ uhci_timeout(void *addr)
 	}
 
 	/* Execute the abort in a process context. */
-	usb_init_task(&uxfer->abort_task, uhci_timeout_task, ii->xfer);
+	usb_init_task(&uxfer->abort_task, uhci_timeout_task, ii->xfer,
+	    USB_TASKQ_MPSAFE);
 	usb_add_task(uxfer->xfer.pipe->device, &uxfer->abort_task,
 	    USB_TASKQ_HC);
 }

Index: src/sys/dev/usb/usb.c
diff -u src/sys/dev/usb/usb.c:1.139 src/sys/dev/usb/usb.c:1.140
--- src/sys/dev/usb/usb.c:1.139	Tue Jan  8 06:47:45 2013
+++ src/sys/dev/usb/usb.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.c,v 1.139 2013/01/08 06:47:45 skrll Exp $	*/
+/*	$NetBSD: usb.c,v 1.140 2013/01/22 12:40:43 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.139 2013/01/08 06:47:45 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.140 2013/01/22 12:40:43 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -453,7 +453,13 @@ usb_task_thread(void *arg)
 			TAILQ_REMOVE(&taskq->tasks, task, next);
 			task->queue = -1;
 			mutex_exit(&taskq->lock);
+
+			if (!(task->flags & USB_TASKQ_MPSAFE))
+				KERNEL_LOCK(1, curlwp);
 			task->fun(task->arg);
+			if (!(task->flags & USB_TASKQ_MPSAFE))
+				KERNEL_UNLOCK_ONE(curlwp);
+
 			mutex_enter(&taskq->lock);
 		}
 	}

Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.187 src/sys/dev/usb/usb_subr.c:1.188
--- src/sys/dev/usb/usb_subr.c:1.187	Sat Jan  5 23:34:20 2013
+++ src/sys/dev/usb/usb_subr.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.187 2013/01/05 23:34:20 christos Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.188 2013/01/22 12:40:43 jmcneill 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.187 2013/01/05 23:34:20 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.188 2013/01/22 12:40:43 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -739,6 +739,13 @@ usbd_status
 usbd_setup_pipe(usbd_device_handle dev, usbd_interface_handle iface,
 		struct usbd_endpoint *ep, int ival, usbd_pipe_handle *pipe)
 {
+	return usbd_setup_pipe_flags(dev, iface, ep, ival, pipe, 0);
+}
+
+usbd_status
+usbd_setup_pipe_flags(usbd_device_handle dev, usbd_interface_handle iface,
+    struct usbd_endpoint *ep, int ival, usbd_pipe_handle *pipe, uint8_t flags)
+{
 	usbd_pipe_handle p;
 	usbd_status err;
 
@@ -757,6 +764,7 @@ usbd_setup_pipe(usbd_device_handle dev, 
 	p->aborting = 0;
 	p->repeat = 0;
 	p->interval = ival;
+	p->flags = flags;
 	SIMPLEQ_INIT(&p->queue);
 	err = dev->bus->methods->open_pipe(p);
 	if (err) {
@@ -766,7 +774,8 @@ usbd_setup_pipe(usbd_device_handle dev, 
 		free(p, M_USB);
 		return (err);
 	}
-	usb_init_task(&p->async_task, usbd_clear_endpoint_stall_async_cb, p);
+	usb_init_task(&p->async_task, usbd_clear_endpoint_stall_async_cb, p,
+	    USB_TASKQ_MPSAFE);
 	*pipe = p;
 	return (USBD_NORMAL_COMPLETION);
 }

Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.147 src/sys/dev/usb/usbdi.c:1.148
--- src/sys/dev/usb/usbdi.c:1.147	Tue Jan 22 08:33:18 2013
+++ src/sys/dev/usb/usbdi.c	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.147 2013/01/22 08:33:18 skrll Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.148 2013/01/22 12:40:43 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.147 2013/01/22 08:33:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.148 2013/01/22 12:40:43 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -869,7 +869,13 @@ usb_transfer_complete(usbd_xfer_handle x
 		if (xfer->callback) {
 			if (pipe->device->bus->lock)
 				mutex_exit(pipe->device->bus->lock);
+
+			if (!(pipe->flags & USBD_MPSAFE))
+				KERNEL_LOCK(1, curlwp);
 			xfer->callback(xfer, xfer->priv, xfer->status);
+			if (!(pipe->flags & USBD_MPSAFE))
+				KERNEL_UNLOCK_ONE(curlwp);
+
 			if (pipe->device->bus->lock)
 				mutex_enter(pipe->device->bus->lock);
 		}
@@ -879,7 +885,13 @@ usb_transfer_complete(usbd_xfer_handle x
 		if (xfer->callback) {
 			if (pipe->device->bus->lock)
 				mutex_exit(pipe->device->bus->lock);
+
+			if (!(pipe->flags & USBD_MPSAFE))
+				KERNEL_LOCK(1, curlwp);
 			xfer->callback(xfer, xfer->priv, xfer->status);
+			if (!(pipe->flags & USBD_MPSAFE))
+				KERNEL_UNLOCK_ONE(curlwp);
+
 			if (pipe->device->bus->lock)
 				mutex_enter(pipe->device->bus->lock);
 		}

Index: src/sys/dev/usb/usbdi.h
diff -u src/sys/dev/usb/usbdi.h:1.84 src/sys/dev/usb/usbdi.h:1.85
--- src/sys/dev/usb/usbdi.h:1.84	Sun Jul 15 21:13:31 2012
+++ src/sys/dev/usb/usbdi.h	Tue Jan 22 12:40:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.h,v 1.84 2012/07/15 21:13:31 mrg Exp $	*/
+/*	$NetBSD: usbdi.h,v 1.85 2013/01/22 12:40:43 jmcneill Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $	*/
 
 /*
@@ -71,6 +71,7 @@ typedef void (*usbd_callback)(usbd_xfer_
 
 /* Open flags */
 #define USBD_EXCLUSIVE_USE	0x01
+#define USBD_MPSAFE		0x02
 
 /* Use default (specified by ep. desc.) interval on interrupt pipe */
 #define USBD_DEFAULT_INTERVAL	(-1)
@@ -202,15 +203,17 @@ struct usb_task {
 	void (*fun)(void *);
 	void *arg;
 	int queue;
+	int flags;
 };
 #define	USB_TASKQ_HC		0
 #define	USB_TASKQ_DRIVER	1
 #define	USB_NUM_TASKQS		2
 #define	USB_TASKQ_NAMES		{"usbtask-hc", "usbtask-dr"}
+#define	USB_TASKQ_MPSAFE	0x01
 
 void usb_add_task(usbd_device_handle, struct usb_task *, int);
 void usb_rem_task(usbd_device_handle, struct usb_task *);
-#define usb_init_task(t, f, a) ((t)->fun = (f), (t)->arg = (a), (t)->queue = -1)
+#define usb_init_task(t, f, a, fl) ((t)->fun = (f), (t)->arg = (a), (t)->queue = -1, (t)->flags = (fl))
 
 struct usb_devno {
 	u_int16_t ud_vendor;

Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.100 src/sys/dev/usb/usbdivar.h:1.101
--- src/sys/dev/usb/usbdivar.h:1.100	Tue Jan  8 06:50:07 2013
+++ src/sys/dev/usb/usbdivar.h	Tue Jan 22 12:40:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdivar.h,v 1.100 2013/01/08 06:50:07 skrll Exp $	*/
+/*	$NetBSD: usbdivar.h,v 1.101 2013/01/22 12:40:44 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -217,6 +217,7 @@ struct usbd_pipe {
 	usbd_xfer_handle	intrxfer; /* used for repeating requests */
 	char			repeat;
 	int			interval;
+	uint8_t			flags;
 
 	/* Filled by HC driver. */
 	const struct usbd_pipe_methods *methods;
@@ -288,6 +289,11 @@ usbd_status	usbd_setup_pipe(usbd_device_
 				usbd_interface_handle iface,
 				struct usbd_endpoint *, int,
 				usbd_pipe_handle *pipe);
+usbd_status	usbd_setup_pipe_flags(usbd_device_handle dev,
+				      usbd_interface_handle iface,
+				      struct usbd_endpoint *, int,
+				      usbd_pipe_handle *pipe,
+				      uint8_t flags);
 usbd_status	usbd_new_device(device_t, usbd_bus_handle, int, int, int,
                                 struct usbd_port *);
 usbd_status	usbd_reattach_device(device_t, usbd_device_handle,

Reply via email to