summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb2/controller/usb2_controller.c
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2009-01-13 19:03:01 +0000
committerthompsa <thompsa@FreeBSD.org>2009-01-13 19:03:01 +0000
commit1263247651c133a3702a35f9c27c6e1b72dca6cf (patch)
tree8540e3650d8f334e6c158c377bb935ad6b0e3dcc /sys/dev/usb2/controller/usb2_controller.c
parent7906c47b626b305182f260caf65a2b24771dc011 (diff)
downloadFreeBSD-src-1263247651c133a3702a35f9c27c6e1b72dca6cf.zip
FreeBSD-src-1263247651c133a3702a35f9c27c6e1b72dca6cf.tar.gz
MFp4: //depot/projects/usb@155834
Factor out roothub process into the USB bus structure for all USB controller drivers. Essentially I am trying to save some processes on the root HUB and get away from the config thread pradigm. There will be a follow up commit where the root HUB control and interrupt callback will be moved over to run from the roothub process. Total win: 3 processes become 1 for every USB controller. Submitted by: Hans Petter Selasky
Diffstat (limited to 'sys/dev/usb2/controller/usb2_controller.c')
-rw-r--r--sys/dev/usb2/controller/usb2_controller.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/sys/dev/usb2/controller/usb2_controller.c b/sys/dev/usb2/controller/usb2_controller.c
index 8e407bb..61ce314 100644
--- a/sys/dev/usb2/controller/usb2_controller.c
+++ b/sys/dev/usb2/controller/usb2_controller.c
@@ -59,6 +59,7 @@ static void usb2_bus_mem_alloc_all_cb(struct usb2_bus *,
static void usb2_bus_mem_free_all_cb(struct usb2_bus *,
struct usb2_page_cache *, struct usb2_page *, uint32_t,
uint32_t);
+static void usb2_bus_roothub(struct usb2_proc_msg *pm);
/* static variables */
@@ -165,6 +166,10 @@ usb2_detach(device_t dev)
USB_BUS_UNLOCK(bus);
+ /* Get rid of USB roothub process */
+
+ usb2_proc_unsetup(&bus->roothub_proc);
+
/* Get rid of USB explore process */
usb2_proc_unsetup(&bus->explore_proc);
@@ -381,10 +386,20 @@ usb2_attach_sub(device_t dev, struct usb2_bus *bus)
bus->attach_msg[1].hdr.pm_callback = &usb2_bus_attach;
bus->attach_msg[1].bus = bus;
- /* Create a new USB process */
- if (usb2_proc_setup(&bus->explore_proc,
+ bus->roothub_msg[0].hdr.pm_callback = &usb2_bus_roothub;
+ bus->roothub_msg[0].bus = bus;
+ bus->roothub_msg[1].hdr.pm_callback = &usb2_bus_roothub;
+ bus->roothub_msg[1].bus = bus;
+
+ /* Create USB explore and roothub processes */
+ if (usb2_proc_setup(&bus->roothub_proc,
+ &bus->bus_mtx, USB_PRI_HIGH)) {
+ printf("WARNING: Creation of USB roothub "
+ "process failed.\n");
+ } else if (usb2_proc_setup(&bus->explore_proc,
&bus->bus_mtx, USB_PRI_MED)) {
- printf("WARNING: Creation of USB explore process failed.\n");
+ printf("WARNING: Creation of USB explore "
+ "process failed.\n");
} else {
/* Get final attach going */
USB_BUS_LOCK(bus);
@@ -543,3 +558,38 @@ usb2_bus_mem_free_all(struct usb2_bus *bus, usb2_bus_mem_cb_t *cb)
mtx_destroy(&bus->bus_mtx);
}
+
+/*------------------------------------------------------------------------*
+ * usb2_bus_roothub
+ *
+ * This function is used to execute roothub control requests on the
+ * roothub and is called from the roothub process.
+ *------------------------------------------------------------------------*/
+static void
+usb2_bus_roothub(struct usb2_proc_msg *pm)
+{
+ struct usb2_bus *bus;
+
+ bus = ((struct usb2_bus_msg *)pm)->bus;
+
+ USB_BUS_LOCK_ASSERT(bus, MA_OWNED);
+
+ (bus->methods->roothub_exec) (bus);
+}
+
+/*------------------------------------------------------------------------*
+ * usb2_bus_roothub_exec
+ *
+ * This function is used to schedule the "roothub_done" bus callback
+ * method. The bus lock must be locked when calling this function.
+ *------------------------------------------------------------------------*/
+void
+usb2_bus_roothub_exec(struct usb2_bus *bus)
+{
+ USB_BUS_LOCK_ASSERT(bus, MA_OWNED);
+
+ if (usb2_proc_msignal(&bus->roothub_proc,
+ &bus->roothub_msg[0], &bus->roothub_msg[1])) {
+ /* ignore */
+ }
+}
OpenPOWER on IntegriCloud