summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2010-10-23 15:42:11 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2010-10-23 15:42:11 +0000
commit8e12f85560fc6cbe21ee1d99ef2a764d08702ed2 (patch)
treeb9bbbae0787b3b58b834bb8bac476ea50fe8f4a2 /sys
parent645084637a0c51eccc7292eb827eb5f5294adac8 (diff)
create another kthread to run xfer abort tasks. xfer abort tasks cannot
be run from the generic task kthread, because xfers that need to be aborted block newly queued tasks from running (i.e. the xfer to be aborted blocks the abort of that task). as there are now three types of usb tasks, add an argument to usb_init_task() and another member to struct usb_task to specify the task type. fixes boot hangs that are showing up because we now use usb tasks to attach/detach usb devices.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/ehci.c4
-rw-r--r--sys/dev/usb/if_atu.c4
-rw-r--r--sys/dev/usb/if_aue.c8
-rw-r--r--sys/dev/usb/if_axe.c8
-rw-r--r--sys/dev/usb/if_cue.c8
-rw-r--r--sys/dev/usb/if_mos.c8
-rw-r--r--sys/dev/usb/if_otus.c4
-rw-r--r--sys/dev/usb/if_ral.c4
-rw-r--r--sys/dev/usb/if_rum.c4
-rw-r--r--sys/dev/usb/if_run.c4
-rw-r--r--sys/dev/usb/if_uath.c4
-rw-r--r--sys/dev/usb/if_udav.c8
-rw-r--r--sys/dev/usb/if_upgt.c7
-rw-r--r--sys/dev/usb/if_url.c8
-rw-r--r--sys/dev/usb/if_urtw.c7
-rw-r--r--sys/dev/usb/if_zyd.c4
-rw-r--r--sys/dev/usb/ohci.c5
-rw-r--r--sys/dev/usb/udcf.c13
-rw-r--r--sys/dev/usb/ueagle.c5
-rw-r--r--sys/dev/usb/uhci.c5
-rw-r--r--sys/dev/usb/umbg.c4
-rw-r--r--sys/dev/usb/usb.c111
-rw-r--r--sys/dev/usb/usbdi.h13
-rw-r--r--sys/dev/usb/uvideo.c5
24 files changed, 175 insertions, 80 deletions
diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index 7c43fb59a89..8ddb3e3de0c 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ehci.c,v 1.112 2010/09/29 20:06:38 kettenis Exp $ */
+/* $OpenBSD: ehci.c,v 1.113 2010/10/23 15:42:09 jakemsr Exp $ */
/* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */
/*
@@ -1221,7 +1221,7 @@ ehci_allocx(struct usbd_bus *bus)
if (xfer != NULL) {
memset(xfer, 0, sizeof(struct ehci_xfer));
usb_init_task(&EXFER(xfer)->abort_task, ehci_timeout_task,
- xfer);
+ xfer, USB_TASK_TYPE_ABORT);
EXFER(xfer)->ehci_xfer_flags = 0;
#ifdef DIAGNOSTIC
EXFER(xfer)->isdone = 1;
diff --git a/sys/dev/usb/if_atu.c b/sys/dev/usb/if_atu.c
index 02163dec98b..0485204b400 100644
--- a/sys/dev/usb/if_atu.c
+++ b/sys/dev/usb/if_atu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_atu.c,v 1.94 2009/11/21 14:18:34 deraadt Exp $ */
+/* $OpenBSD: if_atu.c,v 1.95 2010/10/23 15:42:09 jakemsr Exp $ */
/*
* Copyright (c) 2003, 2004
* Daan Vreeken <Danovitsch@Vitsch.net>. All rights reserved.
@@ -1467,7 +1467,7 @@ atu_complete_attach(struct atu_softc *sc)
/* setup ifmedia interface */
ieee80211_media_init(ifp, atu_media_change, atu_media_status);
- usb_init_task(&sc->sc_task, atu_task, sc);
+ usb_init_task(&sc->sc_task, atu_task, sc, USB_TASK_TYPE_GENERIC);
#if NBPFILTER > 0
bpfattach(&sc->sc_radiobpf, &sc->sc_ic.ic_if, DLT_IEEE802_11_RADIO,
diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c
index 576e9618c9b..673c12be3d3 100644
--- a/sys/dev/usb/if_aue.c
+++ b/sys/dev/usb/if_aue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_aue.c,v 1.79 2010/09/24 08:33:58 yuo Exp $ */
+/* $OpenBSD: if_aue.c,v 1.80 2010/10/23 15:42:09 jakemsr Exp $ */
/* $NetBSD: if_aue.c,v 1.82 2003/03/05 17:37:36 shiba Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -734,8 +734,10 @@ aue_attach(struct device *parent, struct device *self, void *aux)
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,
+ USB_TASK_TYPE_GENERIC);
+ usb_init_task(&sc->aue_stop_task, (void (*)(void *))aue_stop, sc,
+ USB_TASK_TYPE_GENERIC);
rw_init(&sc->aue_mii_lock, "auemii");
err = usbd_device2interface_handle(dev, AUE_IFACE_IDX, &iface);
diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c
index bbb136cd385..3d8fe570ab0 100644
--- a/sys/dev/usb/if_axe.c
+++ b/sys/dev/usb/if_axe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_axe.c,v 1.99 2010/09/24 03:21:21 deraadt Exp $ */
+/* $OpenBSD: if_axe.c,v 1.100 2010/10/23 15:42:09 jakemsr Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Jonathan Gray <jsg@openbsd.org>
@@ -676,9 +676,11 @@ axe_attach(struct device *parent, struct device *self, void *aux)
sc->axe_flags = axe_lookup(uaa->vendor, uaa->product)->axe_flags;
- usb_init_task(&sc->axe_tick_task, axe_tick_task, sc);
+ usb_init_task(&sc->axe_tick_task, axe_tick_task, sc,
+ USB_TASK_TYPE_GENERIC);
rw_init(&sc->axe_mii_lock, "axemii");
- usb_init_task(&sc->axe_stop_task, (void (*)(void *))axe_stop, sc);
+ usb_init_task(&sc->axe_stop_task, (void (*)(void *))axe_stop, sc,
+ USB_TASK_TYPE_GENERIC);
err = usbd_device2interface_handle(dev, AXE_IFACE_IDX, &sc->axe_iface);
if (err) {
diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c
index 5a964f6c539..ddfc87d8aed 100644
--- a/sys/dev/usb/if_cue.c
+++ b/sys/dev/usb/if_cue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_cue.c,v 1.53 2010/09/24 08:33:58 yuo Exp $ */
+/* $OpenBSD: if_cue.c,v 1.54 2010/10/23 15:42:09 jakemsr Exp $ */
/* $NetBSD: if_cue.c,v 1.40 2002/07/11 21:14:26 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -470,8 +470,10 @@ cue_attach(struct device *parent, struct device *self, void *aux)
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_stop_task, (void (*)(void *))cue_stop, sc);
+ usb_init_task(&sc->cue_tick_task, cue_tick_task, sc,
+ USB_TASK_TYPE_GENERIC);
+ usb_init_task(&sc->cue_stop_task, (void (*)(void *))cue_stop, sc,
+ USB_TASK_TYPE_GENERIC);
err = usbd_device2interface_handle(dev, CUE_IFACE_IDX, &iface);
if (err) {
diff --git a/sys/dev/usb/if_mos.c b/sys/dev/usb/if_mos.c
index 622c023c160..a23c4ffa5cb 100644
--- a/sys/dev/usb/if_mos.c
+++ b/sys/dev/usb/if_mos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mos.c,v 1.8 2010/09/24 08:33:58 yuo Exp $ */
+/* $OpenBSD: if_mos.c,v 1.9 2010/10/23 15:42:09 jakemsr Exp $ */
/*
* Copyright (c) 2008 Johann Christian Rode <jcrode@gmx.net>
@@ -652,9 +652,11 @@ mos_attach(struct device *parent, struct device *self, void *aux)
return;
}
- usb_init_task(&sc->mos_tick_task, mos_tick_task, sc);
+ usb_init_task(&sc->mos_tick_task, mos_tick_task, sc,
+ USB_TASK_TYPE_GENERIC);
rw_init(&sc->mos_mii_lock, "mosmii");
- usb_init_task(&sc->mos_stop_task, (void (*)(void *))mos_stop, sc);
+ usb_init_task(&sc->mos_stop_task, (void (*)(void *))mos_stop, sc,
+ USB_TASK_TYPE_GENERIC);
err = usbd_device2interface_handle(dev, MOS_IFACE_IDX, &sc->mos_iface);
if (err) {
diff --git a/sys/dev/usb/if_otus.c b/sys/dev/usb/if_otus.c
index 00104ad12a6..67bd16654af 100644
--- a/sys/dev/usb/if_otus.c
+++ b/sys/dev/usb/if_otus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $ */
+/* $OpenBSD: if_otus.c,v 1.19 2010/10/23 15:42:09 jakemsr Exp $ */
/*-
* Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
@@ -203,7 +203,7 @@ otus_attach(struct device *parent, struct device *self, void *aux)
sc->sc_udev = uaa->device;
- usb_init_task(&sc->sc_task, otus_task, sc);
+ usb_init_task(&sc->sc_task, otus_task, sc, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->scan_to, otus_next_scan, sc);
timeout_set(&sc->calib_to, otus_calibrate_to, sc);
diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c
index 5d345e51d0a..db26e36e055 100644
--- a/sys/dev/usb/if_ral.c
+++ b/sys/dev/usb/if_ral.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ral.c,v 1.113 2010/08/27 17:08:01 jsg Exp $ */
+/* $OpenBSD: if_ral.c,v 1.114 2010/10/23 15:42:09 jakemsr Exp $ */
/*-
* Copyright (c) 2005, 2006
@@ -273,7 +273,7 @@ ural_attach(struct device *parent, struct device *self, void *aux)
return;
}
- usb_init_task(&sc->sc_task, ural_task, sc);
+ usb_init_task(&sc->sc_task, ural_task, sc, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->scan_to, ural_next_scan, sc);
sc->amrr.amrr_min_success_threshold = 1;
diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c
index 0cbff7282c6..ddffda0332d 100644
--- a/sys/dev/usb/if_rum.c
+++ b/sys/dev/usb/if_rum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rum.c,v 1.90 2010/08/27 17:08:01 jsg Exp $ */
+/* $OpenBSD: if_rum.c,v 1.91 2010/10/23 15:42:09 jakemsr Exp $ */
/*-
* Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr>
@@ -328,7 +328,7 @@ rum_attach(struct device *parent, struct device *self, void *aux)
return;
}
- usb_init_task(&sc->sc_task, rum_task, sc);
+ usb_init_task(&sc->sc_task, rum_task, sc, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->scan_to, rum_next_scan, sc);
sc->amrr.amrr_min_success_threshold = 1;
diff --git a/sys/dev/usb/if_run.c b/sys/dev/usb/if_run.c
index 805b3b06ac2..091f89bacb6 100644
--- a/sys/dev/usb/if_run.c
+++ b/sys/dev/usb/if_run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_run.c,v 1.72 2010/10/22 15:45:36 damien Exp $ */
+/* $OpenBSD: if_run.c,v 1.73 2010/10/23 15:42:09 jakemsr Exp $ */
/*-
* Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -473,7 +473,7 @@ run_attach(struct device *parent, struct device *self, void *aux)
return;
}
- usb_init_task(&sc->sc_task, run_task, sc);
+ usb_init_task(&sc->sc_task, run_task, sc, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->scan_to, run_next_scan, sc);
timeout_set(&sc->calib_to, run_calibrate_to, sc);
diff --git a/sys/dev/usb/if_uath.c b/sys/dev/usb/if_uath.c
index 37bfc6e8c66..4fe2392ff16 100644
--- a/sys/dev/usb/if_uath.c
+++ b/sys/dev/usb/if_uath.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_uath.c,v 1.43 2010/08/27 17:08:01 jsg Exp $ */
+/* $OpenBSD: if_uath.c,v 1.44 2010/10/23 15:42:09 jakemsr Exp $ */
/*-
* Copyright (c) 2006
@@ -298,7 +298,7 @@ uath_attach(struct device *parent, struct device *self, void *aux)
/*
* Only post-firmware devices here.
*/
- usb_init_task(&sc->sc_task, uath_task, sc);
+ usb_init_task(&sc->sc_task, uath_task, sc, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->scan_to, uath_next_scan, sc);
timeout_set(&sc->stat_to, uath_stat, sc);
diff --git a/sys/dev/usb/if_udav.c b/sys/dev/usb/if_udav.c
index 8ce56017a9f..158edc8b8c3 100644
--- a/sys/dev/usb/if_udav.c
+++ b/sys/dev/usb/if_udav.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_udav.c,v 1.46 2010/08/27 07:08:22 deraadt Exp $ */
+/* $OpenBSD: if_udav.c,v 1.47 2010/10/23 15:42:09 jakemsr Exp $ */
/* $NetBSD: if_udav.c,v 1.3 2004/04/23 17:25:25 itojun Exp $ */
/* $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $ */
/*
@@ -211,9 +211,11 @@ udav_attach(struct device *parent, struct device *self, void *aux)
goto bad;
}
- usb_init_task(&sc->sc_tick_task, udav_tick_task, sc);
+ usb_init_task(&sc->sc_tick_task, udav_tick_task, sc,
+ USB_TASK_TYPE_GENERIC);
rw_init(&sc->sc_mii_lock, "udavmii");
- 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,
+ USB_TASK_TYPE_GENERIC);
/* get control interface */
err = usbd_device2interface_handle(dev, UDAV_IFACE_INDEX, &iface);
diff --git a/sys/dev/usb/if_upgt.c b/sys/dev/usb/if_upgt.c
index 90a6528df84..9041549656e 100644
--- a/sys/dev/usb/if_upgt.c
+++ b/sys/dev/usb/if_upgt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_upgt.c,v 1.50 2010/08/27 17:08:01 jsg Exp $ */
+/* $OpenBSD: if_upgt.c,v 1.51 2010/10/23 15:42:09 jakemsr Exp $ */
/*
* Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
@@ -273,8 +273,9 @@ upgt_attach(struct device *parent, struct device *self, void *aux)
}
/* 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,
+ USB_TASK_TYPE_GENERIC);
+ usb_init_task(&sc->sc_task_tx, upgt_tx_task, sc, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->scan_to, upgt_next_scan, sc);
timeout_set(&sc->led_to, upgt_set_led_blink, sc);
diff --git a/sys/dev/usb/if_url.c b/sys/dev/usb/if_url.c
index 8e4ea55b2c0..42fe68d4111 100644
--- a/sys/dev/usb/if_url.c
+++ b/sys/dev/usb/if_url.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_url.c,v 1.56 2010/08/27 07:08:22 deraadt Exp $ */
+/* $OpenBSD: if_url.c,v 1.57 2010/10/23 15:42:09 jakemsr Exp $ */
/* $NetBSD: if_url.c,v 1.6 2002/09/29 10:19:21 martin Exp $ */
/*
* Copyright (c) 2001, 2002
@@ -208,9 +208,11 @@ url_attach(struct device *parent, struct device *self, void *aux)
goto bad;
}
- usb_init_task(&sc->sc_tick_task, url_tick_task, sc);
+ usb_init_task(&sc->sc_tick_task, url_tick_task, sc,
+ USB_TASK_TYPE_GENERIC);
rw_init(&sc->sc_mii_lock, "urlmii");
- 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,
+ USB_TASK_TYPE_GENERIC);
/* get control interface */
err = usbd_device2interface_handle(dev, URL_IFACE_INDEX, &iface);
diff --git a/sys/dev/usb/if_urtw.c b/sys/dev/usb/if_urtw.c
index 0b150b356b2..fbb076fcf4a 100644
--- a/sys/dev/usb/if_urtw.c
+++ b/sys/dev/usb/if_urtw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_urtw.c,v 1.31 2010/08/27 17:08:01 jsg Exp $ */
+/* $OpenBSD: if_urtw.c,v 1.32 2010/10/23 15:42:09 jakemsr Exp $ */
/*-
* Copyright (c) 2009 Martynas Venckus <martynas@openbsd.org>
@@ -690,8 +690,9 @@ urtw_attach(struct device *parent, struct device *self, void *aux)
/* 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, USB_TASK_TYPE_GENERIC);
+ usb_init_task(&sc->sc_ledtask, urtw_ledusbtask, sc,
+ USB_TASK_TYPE_GENERIC);
timeout_set(&sc->scan_to, urtw_next_scan, sc);
timeout_set(&sc->sc_led_ch, urtw_ledtask, sc);
diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c
index fad1dec65f9..ca1cdc28939 100644
--- a/sys/dev/usb/if_zyd.c
+++ b/sys/dev/usb/if_zyd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_zyd.c,v 1.82 2010/08/27 17:08:01 jsg Exp $ */
+/* $OpenBSD: if_zyd.c,v 1.83 2010/10/23 15:42:09 jakemsr Exp $ */
/*-
* Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr>
@@ -323,7 +323,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, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->scan_to, zyd_next_scan, sc);
sc->amrr.amrr_min_success_threshold = 1;
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index fa543d0fe29..5b1c1544ccd 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ohci.c,v 1.99 2010/09/07 16:21:46 deraadt Exp $ */
+/* $OpenBSD: ohci.c,v 1.100 2010/10/23 15:42:09 jakemsr Exp $ */
/* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
@@ -1894,7 +1894,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_TASK_TYPE_ABORT);
usb_add_task(oxfer->xfer.pipe->device, &oxfer->abort_task);
}
diff --git a/sys/dev/usb/udcf.c b/sys/dev/usb/udcf.c
index 81947e31097..6716aa390d8 100644
--- a/sys/dev/usb/udcf.c
+++ b/sys/dev/usb/udcf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udcf.c,v 1.48 2010/09/24 08:33:59 yuo Exp $ */
+/* $OpenBSD: udcf.c,v 1.49 2010/10/23 15:42:09 jakemsr Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Marc Balmer <mbalmer@openbsd.org>
@@ -206,10 +206,10 @@ udcf_attach(struct device *parent, struct device *self, void *aux)
break;
}
- usb_init_task(&sc->sc_task, udcf_probe, sc);
- usb_init_task(&sc->sc_bv_task, udcf_bv_probe, sc);
- usb_init_task(&sc->sc_mg_task, udcf_mg_probe, sc);
- usb_init_task(&sc->sc_sl_task, udcf_sl_probe, sc);
+ usb_init_task(&sc->sc_task, udcf_probe, sc, USB_TASK_TYPE_GENERIC);
+ usb_init_task(&sc->sc_bv_task, udcf_bv_probe, sc, USB_TASK_TYPE_GENERIC);
+ usb_init_task(&sc->sc_mg_task, udcf_mg_probe, sc, USB_TASK_TYPE_GENERIC);
+ usb_init_task(&sc->sc_sl_task, udcf_sl_probe, sc, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->sc_to, udcf_intr, sc);
timeout_set(&sc->sc_bv_to, udcf_bv_intr, sc);
@@ -218,7 +218,8 @@ udcf_attach(struct device *parent, struct device *self, void *aux)
timeout_set(&sc->sc_it_to, udcf_it_intr, sc);
if (sc->sc_detect_ct) {
- usb_init_task(&sc->sc_ct_task, udcf_ct_probe, sc);
+ usb_init_task(&sc->sc_ct_task, udcf_ct_probe, sc,
+ USB_TASK_TYPE_GENERIC);
timeout_set(&sc->sc_ct_to, udcf_ct_intr, sc);
}
strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname,
diff --git a/sys/dev/usb/ueagle.c b/sys/dev/usb/ueagle.c
index ff1a00d3976..4cb390e2df3 100644
--- a/sys/dev/usb/ueagle.c
+++ b/sys/dev/usb/ueagle.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ueagle.c,v 1.28 2010/09/24 08:33:59 yuo Exp $ */
+/* $OpenBSD: ueagle.c,v 1.29 2010/10/23 15:42:09 jakemsr Exp $ */
/*-
* Copyright (c) 2003-2006
@@ -210,7 +210,8 @@ ueagle_attach(struct device *parent, struct device *self, void *aux)
sc->sc_dev.dv_xname, addr[0], addr[1], addr[2], addr[3],
addr[4], addr[5]);
- usb_init_task(&sc->sc_swap_task, ueagle_loadpage, sc);
+ usb_init_task(&sc->sc_swap_task, ueagle_loadpage, sc,
+ USB_TASK_TYPE_GENERIC);
ifp->if_softc = sc;
ifp->if_flags = IFF_SIMPLEX;
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index 24e4f5cd7c0..193bd8de910 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhci.c,v 1.83 2010/09/20 06:54:10 deraadt Exp $ */
+/* $OpenBSD: uhci.c,v 1.84 2010/10/23 15:42:09 jakemsr Exp $ */
/* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -1447,7 +1447,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_TASK_TYPE_ABORT);
usb_add_task(uxfer->xfer.pipe->device, &uxfer->abort_task);
}
diff --git a/sys/dev/usb/umbg.c b/sys/dev/usb/umbg.c
index e5724f9fe06..c4eb55831bc 100644
--- a/sys/dev/usb/umbg.c
+++ b/sys/dev/usb/umbg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: umbg.c,v 1.12 2010/09/24 08:33:59 yuo Exp $ */
+/* $OpenBSD: umbg.c,v 1.13 2010/10/23 15:42:09 jakemsr Exp $ */
/*
* Copyright (c) 2007 Marc Balmer <mbalmer@openbsd.org>
@@ -200,7 +200,7 @@ umbg_attach(struct device *parent, struct device *self, void *aux)
sensor_attach(&sc->sc_sensordev, &sc->sc_signal);
sensordev_install(&sc->sc_sensordev);
- usb_init_task(&sc->sc_task, umbg_task, sc);
+ usb_init_task(&sc->sc_task, umbg_task, sc, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->sc_to, umbg_intr, sc);
timeout_set(&sc->sc_it_to, umbg_it_intr, sc);
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index dd61f4e4037..3787a4eace3 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.c,v 1.68 2010/09/23 06:30:37 jakemsr Exp $ */
+/* $OpenBSD: usb.c,v 1.69 2010/10/23 15:42:09 jakemsr Exp $ */
/* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */
/*
@@ -100,17 +100,20 @@ struct usb_softc {
struct timeval sc_ptime;
};
+TAILQ_HEAD(, usb_task) usb_abort_tasks;
TAILQ_HEAD(, usb_task) usb_explore_tasks;
-TAILQ_HEAD(, usb_task) usb_tasks;
+TAILQ_HEAD(, usb_task) usb_generic_tasks;
-int usb_run_tasks;
+int usb_run_tasks, usb_run_abort_tasks;
int explore_pending;
void usb_explore(void *);
void usb_first_explore(void *);
-void usb_create_task_thread(void *);
+void usb_create_task_threads(void *);
void usb_task_thread(void *);
struct proc *usb_task_thread_proc = NULL;
+void usb_abort_task_thread(void *);
+struct proc *usb_abort_task_thread_proc = NULL;
#define USB_MAX_EVENTS 100
struct usb_event_q {
@@ -195,7 +198,8 @@ usb_attach(struct device *parent, struct device *self, void *aux)
sc->sc_bus->flags |= USB_BUS_CONFIG_PENDING;
/* explore task */
- usb_init_task(&sc->sc_explore_task, usb_explore, sc);
+ usb_init_task(&sc->sc_explore_task, usb_explore, sc,
+ USB_TASK_TYPE_EXPLORE);
ue.u.ue_ctrlr.ue_bus = sc->sc_dev.dv_unit;
usb_add_event(USB_EVENT_CTRLR_ATTACH, &ue);
@@ -252,10 +256,11 @@ usb_attach(struct device *parent, struct device *self, void *aux)
void
usb_begin_tasks(void)
{
+ TAILQ_INIT(&usb_abort_tasks);
TAILQ_INIT(&usb_explore_tasks);
- TAILQ_INIT(&usb_tasks);
- usb_run_tasks = 1;
- kthread_create_deferred(usb_create_task_thread, NULL);
+ TAILQ_INIT(&usb_generic_tasks);
+ usb_run_tasks = usb_run_abort_tasks = 1;
+ kthread_create_deferred(usb_create_task_threads, NULL);
}
/*
@@ -264,13 +269,18 @@ usb_begin_tasks(void)
void
usb_end_tasks(void)
{
- usb_run_tasks = 0;
+ usb_run_tasks = usb_run_abort_tasks = 0;
+ wakeup(&usb_run_abort_tasks);
wakeup(&usb_run_tasks);
}
void
-usb_create_task_thread(void *arg)
+usb_create_task_threads(void *arg)
{
+ if (kthread_create(usb_abort_task_thread, NULL,
+ &usb_abort_task_thread_proc, "usbatsk"))
+ panic("unable to create usb abort task thread");
+
if (kthread_create(usb_task_thread, NULL,
&usb_task_thread_proc, "usbtask"))
panic("unable to create usb task thread");
@@ -286,7 +296,8 @@ usb_add_task(usbd_device_handle dev, struct usb_task *task)
{
int s;
- DPRINTFN(2,("%s: task=%p onqueue=%d\n", __func__, task, task->onqueue));
+ DPRINTFN(2,("%s: task=%p onqueue=%d type=%d\n", __func__, task,
+ task->onqueue, task->type));
/* Don't add task if the device's root hub is dying. */
if (dev->bus->dying)
@@ -294,14 +305,24 @@ usb_add_task(usbd_device_handle dev, struct usb_task *task)
s = splusb();
if (!task->onqueue) {
- if (task->fun == usb_explore)
+ switch (task->type) {
+ case USB_TASK_TYPE_ABORT:
+ TAILQ_INSERT_TAIL(&usb_abort_tasks, task, next);
+ break;
+ case USB_TASK_TYPE_EXPLORE:
TAILQ_INSERT_TAIL(&usb_explore_tasks, task, next);
- else
- TAILQ_INSERT_TAIL(&usb_tasks, task, next);
+ break;
+ case USB_TASK_TYPE_GENERIC:
+ TAILQ_INSERT_TAIL(&usb_generic_tasks, task, next);
+ break;
+ }
task->onqueue = 1;
task->dev = dev;
}
- wakeup(&usb_run_tasks);
+ if (task->type == USB_TASK_TYPE_ABORT)
+ wakeup(&usb_run_abort_tasks);
+ else
+ wakeup(&usb_run_tasks);
splx(s);
}
@@ -310,14 +331,22 @@ usb_rem_task(usbd_device_handle dev, struct usb_task *task)
{
int s;
- DPRINTFN(2,("%s: task=%p onqueue=%d\n", __func__, task, task->onqueue));
+ DPRINTFN(2,("%s: task=%p onqueue=%d type=%d\n", __func__, task,
+ task->onqueue, task->type));
s = splusb();
if (task->onqueue) {
- if (task->fun == usb_explore)
+ switch (task->type) {
+ case USB_TASK_TYPE_ABORT:
+ TAILQ_REMOVE(&usb_abort_tasks, task, next);
+ break;
+ case USB_TASK_TYPE_EXPLORE:
TAILQ_REMOVE(&usb_explore_tasks, task, next);
- else
- TAILQ_REMOVE(&usb_tasks, task, next);
+ break;
+ case USB_TASK_TYPE_GENERIC:
+ TAILQ_REMOVE(&usb_generic_tasks, task, next);
+ break;
+ }
task->onqueue = 0;
}
splx(s);
@@ -328,7 +357,8 @@ usb_rem_wait_task(usbd_device_handle dev, struct usb_task *task)
{
int s;
- DPRINTFN(2,("%s: task=%p onqueue=%d\n", __func__, task, task->onqueue));
+ DPRINTFN(2,("%s: task=%p onqueue=%d type=%d\n", __func__, task,
+ task->onqueue, task->type));
s = splusb();
usb_rem_task(dev, task);
@@ -391,8 +421,8 @@ usb_task_thread(void *arg)
while (usb_run_tasks) {
if ((task = TAILQ_FIRST(&usb_explore_tasks)) != NULL)
TAILQ_REMOVE(&usb_explore_tasks, task, next);
- else if ((task = TAILQ_FIRST(&usb_tasks)) != NULL)
- TAILQ_REMOVE(&usb_tasks, task, next);
+ else if ((task = TAILQ_FIRST(&usb_generic_tasks)) != NULL)
+ TAILQ_REMOVE(&usb_generic_tasks, task, next);
else {
tsleep(&usb_run_tasks, PWAIT, "usbtsk", 0);
continue;
@@ -413,6 +443,43 @@ usb_task_thread(void *arg)
kthread_exit(0);
}
+/*
+ * This thread is ONLY for the HCI drivers to be able to abort xfers.
+ * Synchronous xfers sleep the task thread, so the aborts need to happen
+ * in a different thread.
+ */
+void
+usb_abort_task_thread(void *arg)
+{
+ struct usb_task *task;
+ int s;
+
+ DPRINTF(("usb_xfer_abort_thread: start\n"));
+
+ s = splusb();
+ while (usb_run_abort_tasks) {
+ if ((task = TAILQ_FIRST(&usb_abort_tasks)) != NULL)
+ TAILQ_REMOVE(&usb_abort_tasks, task, next);
+ else {
+ tsleep(&usb_run_abort_tasks, PWAIT, "usbatsk", 0);
+ continue;
+ }
+ task->onqueue = 0;
+ /* Don't execute the task if the root hub is gone. */
+ if (task->dev->bus->dying)
+ continue;
+ task->running = 1;
+ splx(s);
+ task->fun(task->arg);
+ s = splusb();
+ task->running = 0;
+ wakeup(task);
+ }
+ splx(s);
+
+ kthread_exit(0);
+}
+
int
usbctlprint(void *aux, const char *pnp)
{
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index 960b380bfa9..34f60858d96 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi.h,v 1.34 2010/09/23 06:30:37 jakemsr Exp $ */
+/* $OpenBSD: usbdi.h,v 1.35 2010/10/23 15:42:09 jakemsr Exp $ */
/* $NetBSD: usbdi.h,v 1.62 2002/07/11 21:14:35 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
@@ -184,6 +184,10 @@ struct usb_task {
usbd_device_handle dev;
void (*fun)(void *);
void *arg;
+ char type;
+#define USB_TASK_TYPE_GENERIC 0
+#define USB_TASK_TYPE_EXPLORE 1
+#define USB_TASK_TYPE_ABORT 2
char onqueue;
char running;
};
@@ -191,7 +195,12 @@ struct usb_task {
void usb_add_task(usbd_device_handle, struct usb_task *);
void usb_rem_task(usbd_device_handle, struct usb_task *);
void usb_rem_wait_task(usbd_device_handle, struct usb_task *);
-#define usb_init_task(t, f, a) ((t)->fun = (f), (t)->arg = (a), (t)->onqueue = 0, (t)->running = 0)
+#define usb_init_task(t, f, a, y) \
+ ((t)->fun = (f), \
+ (t)->arg = (a), \
+ (t)->type = (y), \
+ (t)->onqueue = 0, \
+ (t)->running = 0)
struct usb_devno {
u_int16_t ud_vendor;
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index 770ee5f8510..98e2f3cf520 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.c,v 1.145 2010/10/18 23:25:31 jakemsr Exp $ */
+/* $OpenBSD: uvideo.c,v 1.146 2010/10/23 15:42:10 jakemsr Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -1802,7 +1802,8 @@ uvideo_vs_init(struct uvideo_softc *sc)
#ifdef UVIDEO_DUMP
if (uvideo_debug_file_open(sc) != 0)
return (USBD_INVAL);
- usb_init_task(&sc->sc_task_write, uvideo_debug_file_write_frame, sc);
+ usb_init_task(&sc->sc_task_write, uvideo_debug_file_write_frame, sc,
+ USB_TASK_TYPE_GENERIC);
#endif
return (USBD_NORMAL_COMPLETION);
}