summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2013-02-05 14:44:25 +0000
committerhselasky <hselasky@FreeBSD.org>2013-02-05 14:44:25 +0000
commit2e6231f8ebe6ac7a9374e9c72531a220a8aa2d9d (patch)
tree6f7e7bb33464657571c7932da58bed2b52ea622a /sys/dev/usb
parent72c8e2de5282a2d1848447691f49c30e83e28950 (diff)
downloadFreeBSD-src-2e6231f8ebe6ac7a9374e9c72531a220a8aa2d9d.zip
FreeBSD-src-2e6231f8ebe6ac7a9374e9c72531a220a8aa2d9d.tar.gz
Add defines to more easily allow a single threaded version of the FreeBSD
USB stack. This is useful for non-kernel purposes, like the loader.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/controller/usb_controller.c58
-rw-r--r--sys/dev/usb/controller/xhci.c11
-rw-r--r--sys/dev/usb/controller/xhci.h3
-rw-r--r--sys/dev/usb/usb_bus.h8
-rw-r--r--sys/dev/usb/usb_device.c2
-rw-r--r--sys/dev/usb/usb_freebsd.h1
-rw-r--r--sys/dev/usb/usb_freebsd_loader.h1
-rw-r--r--sys/dev/usb/usb_hub.c2
-rw-r--r--sys/dev/usb/usb_transfer.c22
9 files changed, 56 insertions, 52 deletions
diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c
index 204569f..cf2ae7a 100644
--- a/sys/dev/usb/controller/usb_controller.c
+++ b/sys/dev/usb/controller/usb_controller.c
@@ -214,27 +214,29 @@ usb_detach(device_t dev)
USB_BUS_LOCK(bus);
/* Queue detach job */
- usb_proc_msignal(&bus->explore_proc,
+ usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus),
&bus->detach_msg[0], &bus->detach_msg[1]);
/* Wait for detach to complete */
- usb_proc_mwait(&bus->explore_proc,
+ usb_proc_mwait(USB_BUS_EXPLORE_PROC(bus),
&bus->detach_msg[0], &bus->detach_msg[1]);
USB_BUS_UNLOCK(bus);
+#if USB_HAVE_PER_BUS_PROCESS
/* Get rid of USB callback processes */
- usb_proc_free(&bus->giant_callback_proc);
- usb_proc_free(&bus->non_giant_callback_proc);
+ usb_proc_free(USB_BUS_GIANT_PROC(bus));
+ usb_proc_free(USB_BUS_NON_GIANT_PROC(bus));
/* Get rid of USB explore process */
- usb_proc_free(&bus->explore_proc);
+ usb_proc_free(USB_BUS_EXPLORE_PROC(bus));
/* Get rid of control transfer process */
- usb_proc_free(&bus->control_xfer_proc);
+ usb_proc_free(USB_BUS_CONTROL_XFER_PROC(bus));
+#endif
#if USB_HAVE_PF
usbpf_detach(bus);
@@ -258,11 +260,11 @@ usb_suspend(device_t dev)
}
USB_BUS_LOCK(bus);
- usb_proc_msignal(&bus->explore_proc,
+ usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus),
&bus->suspend_msg[0], &bus->suspend_msg[1]);
if (usb_no_suspend_wait == 0) {
/* wait for suspend callback to be executed */
- usb_proc_mwait(&bus->explore_proc,
+ usb_proc_mwait(USB_BUS_EXPLORE_PROC(bus),
&bus->suspend_msg[0], &bus->suspend_msg[1]);
}
USB_BUS_UNLOCK(bus);
@@ -286,7 +288,7 @@ usb_resume(device_t dev)
}
USB_BUS_LOCK(bus);
- usb_proc_msignal(&bus->explore_proc,
+ usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus),
&bus->resume_msg[0], &bus->resume_msg[1]);
USB_BUS_UNLOCK(bus);
@@ -311,11 +313,11 @@ usb_shutdown(device_t dev)
device_printf(bus->bdev, "Controller shutdown\n");
USB_BUS_LOCK(bus);
- usb_proc_msignal(&bus->explore_proc,
+ usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus),
&bus->shutdown_msg[0], &bus->shutdown_msg[1]);
if (usb_no_shutdown_wait == 0) {
/* wait for shutdown callback to be executed */
- usb_proc_mwait(&bus->explore_proc,
+ usb_proc_mwait(USB_BUS_EXPLORE_PROC(bus),
&bus->shutdown_msg[0], &bus->shutdown_msg[1]);
}
USB_BUS_UNLOCK(bus);
@@ -358,9 +360,9 @@ usb_bus_explore(struct usb_proc_msg *pm)
* The following three lines of code are only here to
* recover from DDB:
*/
- usb_proc_rewakeup(&bus->control_xfer_proc);
- usb_proc_rewakeup(&bus->giant_callback_proc);
- usb_proc_rewakeup(&bus->non_giant_callback_proc);
+ usb_proc_rewakeup(USB_BUS_CONTROL_XFER_PROC(bus));
+ usb_proc_rewakeup(USB_BUS_GIANT_PROC(bus));
+ usb_proc_rewakeup(USB_BUS_NON_GIANT_PROC(bus));
#endif
USB_BUS_UNLOCK(bus);
@@ -585,7 +587,7 @@ usb_power_wdog(void *arg)
* The following line of code is only here to recover from
* DDB:
*/
- usb_proc_rewakeup(&bus->explore_proc); /* recover from DDB */
+ usb_proc_rewakeup(USB_BUS_EXPLORE_PROC(bus)); /* recover from DDB */
#endif
#if USB_HAVE_POWERD
@@ -708,8 +710,6 @@ usb_bus_attach(struct usb_proc_msg *pm)
static void
usb_attach_sub(device_t dev, struct usb_bus *bus)
{
- const char *pname = device_get_nameunit(dev);
-
mtx_lock(&Giant);
if (usb_devclass_ptr == NULL)
usb_devclass_ptr = devclass_find("usbus");
@@ -749,28 +749,31 @@ usb_attach_sub(device_t dev, struct usb_bus *bus)
bus->shutdown_msg[1].hdr.pm_callback = &usb_bus_shutdown;
bus->shutdown_msg[1].bus = bus;
+#if USB_HAVE_PER_BUS_PROCESS
/* Create USB explore and callback processes */
- if (usb_proc_create(&bus->giant_callback_proc,
- &bus->bus_mtx, pname, USB_PRI_MED)) {
+ if (usb_proc_create(USB_BUS_GIANT_PROC(bus),
+ &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_MED)) {
device_printf(dev, "WARNING: Creation of USB Giant "
"callback process failed.\n");
- } else if (usb_proc_create(&bus->non_giant_callback_proc,
- &bus->bus_mtx, pname, USB_PRI_HIGH)) {
+ } else if (usb_proc_create(USB_BUS_NON_GIANT_PROC(bus),
+ &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_HIGH)) {
device_printf(dev, "WARNING: Creation of USB non-Giant "
"callback process failed.\n");
- } else if (usb_proc_create(&bus->explore_proc,
- &bus->bus_mtx, pname, USB_PRI_MED)) {
+ } else if (usb_proc_create(USB_BUS_EXPLORE_PROC(bus),
+ &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_MED)) {
device_printf(dev, "WARNING: Creation of USB explore "
"process failed.\n");
- } else if (usb_proc_create(&bus->control_xfer_proc,
- &bus->bus_mtx, pname, USB_PRI_MED)) {
+ } else if (usb_proc_create(USB_BUS_CONTROL_XFER_PROC(bus),
+ &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_MED)) {
device_printf(dev, "WARNING: Creation of USB control transfer "
"process failed.\n");
- } else {
+ } else
+#endif
+ {
/* Get final attach going */
USB_BUS_LOCK(bus);
- usb_proc_msignal(&bus->explore_proc,
+ usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus),
&bus->attach_msg[0], &bus->attach_msg[1]);
USB_BUS_UNLOCK(bus);
@@ -778,7 +781,6 @@ usb_attach_sub(device_t dev, struct usb_bus *bus)
usb_needs_explore(bus, 1);
}
}
-
SYSUNINIT(usb_bus_unload, SI_SUB_KLD, SI_ORDER_ANY, usb_bus_unload, NULL);
/*------------------------------------------------------------------------*
diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c
index 4023ecc..9f84b39 100644
--- a/sys/dev/usb/controller/xhci.c
+++ b/sys/dev/usb/controller/xhci.c
@@ -547,19 +547,12 @@ xhci_init(struct xhci_softc *sc, device_t self)
sc->sc_config_msg[1].hdr.pm_callback = &xhci_configure_msg;
sc->sc_config_msg[1].bus = &sc->sc_bus;
- if (usb_proc_create(&sc->sc_config_proc,
- &sc->sc_bus.bus_mtx, device_get_nameunit(self), USB_PRI_MED)) {
- printf("WARNING: Creation of XHCI configure "
- "callback process failed.\n");
- }
return (0);
}
void
xhci_uninit(struct xhci_softc *sc)
{
- usb_proc_free(&sc->sc_config_proc);
-
usb_bus_mem_free_all(&sc->sc_bus, &xhci_iterate_hw_softc);
cv_destroy(&sc->sc_cmd_cv);
@@ -2684,7 +2677,7 @@ xhci_transfer_insert(struct usb_xfer *xfer)
DPRINTFN(8, "Not running\n");
/* start configuration */
- (void)usb_proc_msignal(&sc->sc_config_proc,
+ (void)usb_proc_msignal(USB_BUS_CONTROL_XFER_PROC(&sc->sc_bus),
&sc->sc_config_msg[0], &sc->sc_config_msg[1]);
return (0);
}
@@ -3652,7 +3645,7 @@ xhci_start_dma_delay(struct usb_xfer *xfer)
/* put transfer on interrupt queue (again) */
usbd_transfer_enqueue(&sc->sc_bus.intr_q, xfer);
- (void)usb_proc_msignal(&sc->sc_config_proc,
+ (void)usb_proc_msignal(USB_BUS_CONTROL_XFER_PROC(&sc->sc_bus),
&sc->sc_config_msg[0], &sc->sc_config_msg[1]);
}
diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h
index 01e60ee..2a08ba7 100644
--- a/sys/dev/usb/controller/xhci.h
+++ b/sys/dev/usb/controller/xhci.h
@@ -434,8 +434,7 @@ struct xhci_softc {
struct xhci_hw_softc sc_hw;
/* base device */
struct usb_bus sc_bus;
- /* configure process */
- struct usb_process sc_config_proc;
+ /* configure message */
struct usb_bus_msg sc_config_msg[2];
union xhci_hub_desc sc_hub_desc;
diff --git a/sys/dev/usb/usb_bus.h b/sys/dev/usb/usb_bus.h
index 95c1632..dea15f8 100644
--- a/sys/dev/usb/usb_bus.h
+++ b/sys/dev/usb/usb_bus.h
@@ -54,6 +54,13 @@ struct usb_bus {
#if USB_HAVE_ROOT_MOUNT_HOLD
struct root_hold_token *bus_roothold;
#endif
+
+#if USB_HAVE_PER_BUS_PROCESS
+#define USB_BUS_GIANT_PROC(bus) (&(bus)->giant_callback_proc)
+#define USB_BUS_NON_GIANT_PROC(bus) (&(bus)->non_giant_callback_proc)
+#define USB_BUS_EXPLORE_PROC(bus) (&(bus)->explore_proc)
+#define USB_BUS_CONTROL_XFER_PROC(bus) (&(bus)->control_xfer_proc)
+
/*
* There are two callback processes. One for Giant locked
* callbacks. One for non-Giant locked callbacks. This should
@@ -67,6 +74,7 @@ struct usb_bus {
/* Control request process */
struct usb_process control_xfer_proc;
+#endif
struct usb_bus_msg explore_msg[2];
struct usb_bus_msg detach_msg[2];
diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c
index 8d88bf5..a9aab53 100644
--- a/sys/dev/usb/usb_device.c
+++ b/sys/dev/usb/usb_device.c
@@ -2128,7 +2128,7 @@ usb_free_device(struct usb_device *udev, uint8_t flag)
* anywhere:
*/
USB_BUS_LOCK(udev->bus);
- usb_proc_mwait(&udev->bus->non_giant_callback_proc,
+ usb_proc_mwait(USB_BUS_NON_GIANT_PROC(udev->bus),
&udev->cs_msg[0], &udev->cs_msg[1]);
USB_BUS_UNLOCK(udev->bus);
diff --git a/sys/dev/usb/usb_freebsd.h b/sys/dev/usb/usb_freebsd.h
index e93bee7..026baab 100644
--- a/sys/dev/usb/usb_freebsd.h
+++ b/sys/dev/usb/usb_freebsd.h
@@ -44,6 +44,7 @@
#define USB_HAVE_PF 1
#define USB_HAVE_ROOT_MOUNT_HOLD 1
#define USB_HAVE_ID_SECTION 1
+#define USB_HAVE_PER_BUS_PROCESS 1
#define USB_TD_GET_PROC(td) (td)->td_proc
#define USB_PROC_GET_GID(td) (td)->p_pgid
diff --git a/sys/dev/usb/usb_freebsd_loader.h b/sys/dev/usb/usb_freebsd_loader.h
index 566f922..b21c229 100644
--- a/sys/dev/usb/usb_freebsd_loader.h
+++ b/sys/dev/usb/usb_freebsd_loader.h
@@ -44,6 +44,7 @@
#define USB_HAVE_PF 0
#define USB_HAVE_ROOT_MOUNT_HOLD 0
#define USB_HAVE_ID_SECTION 0
+#define USB_HAVE_PER_BUS_PROCESS 0
#define USB_TD_GET_PROC(td) (td)->td_proc
#define USB_PROC_GET_GID(td) (td)->p_pgid
diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c
index 5e372c8..1d87a3f 100644
--- a/sys/dev/usb/usb_hub.c
+++ b/sys/dev/usb/usb_hub.c
@@ -1917,7 +1917,7 @@ usb_needs_explore(struct usb_bus *bus, uint8_t do_probe)
if (do_probe) {
bus->do_probe = 1;
}
- if (usb_proc_msignal(&bus->explore_proc,
+ if (usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus),
&bus->explore_msg[0], &bus->explore_msg[1])) {
/* ignore */
}
diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c
index 397b0b7..edcc596 100644
--- a/sys/dev/usb/usb_transfer.c
+++ b/sys/dev/usb/usb_transfer.c
@@ -965,14 +965,14 @@ usbd_transfer_setup(struct usb_device *udev,
* deadlock!
*/
if (setup_start == usb_control_ep_cfg)
- info->done_p =
- &udev->bus->control_xfer_proc;
+ info->done_p =
+ USB_BUS_CONTROL_XFER_PROC(udev->bus);
else if (xfer_mtx == &Giant)
- info->done_p =
- &udev->bus->giant_callback_proc;
+ info->done_p =
+ USB_BUS_GIANT_PROC(udev->bus);
else
- info->done_p =
- &udev->bus->non_giant_callback_proc;
+ info->done_p =
+ USB_BUS_NON_GIANT_PROC(udev->bus);
}
/* reset sizes */
@@ -2614,7 +2614,7 @@ usbd_pipe_start(struct usb_xfer_queue *pq)
} else if (udev->ctrl_xfer[1]) {
info = udev->ctrl_xfer[1]->xroot;
usb_proc_msignal(
- &info->bus->non_giant_callback_proc,
+ USB_BUS_NON_GIANT_PROC(info->bus),
&udev->cs_msg[0], &udev->cs_msg[1]);
} else {
/* should not happen */
@@ -3216,10 +3216,10 @@ usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
}
/* Make sure cv_signal() and cv_broadcast() is not called */
- udev->bus->control_xfer_proc.up_msleep = 0;
- udev->bus->explore_proc.up_msleep = 0;
- udev->bus->giant_callback_proc.up_msleep = 0;
- udev->bus->non_giant_callback_proc.up_msleep = 0;
+ USB_BUS_CONTROL_XFER_PROC(udev->bus)->up_msleep = 0;
+ USB_BUS_EXPLORE_PROC(udev->bus)->up_msleep = 0;
+ USB_BUS_GIANT_PROC(udev->bus)->up_msleep = 0;
+ USB_BUS_NON_GIANT_PROC(udev->bus)->up_msleep = 0;
/* poll USB hardware */
(udev->bus->methods->xfer_poll) (udev->bus);
OpenPOWER on IntegriCloud