3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/stdint.h>
30 #include <sys/stddef.h>
31 #include <sys/param.h>
32 #include <sys/queue.h>
33 #include <sys/types.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
37 #include <sys/module.h>
39 #include <sys/mutex.h>
40 #include <sys/condvar.h>
41 #include <sys/sysctl.h>
43 #include <sys/unistd.h>
44 #include <sys/callout.h>
45 #include <sys/malloc.h>
48 #include <dev/usb/usb.h>
49 #include <dev/usb/usbdi.h>
51 #define USB_DEBUG_VAR usb_ctrl_debug
53 #include <dev/usb/usb_core.h>
54 #include <dev/usb/usb_debug.h>
55 #include <dev/usb/usb_process.h>
56 #include <dev/usb/usb_busdma.h>
57 #include <dev/usb/usb_dynamic.h>
58 #include <dev/usb/usb_device.h>
59 #include <dev/usb/usb_hub.h>
61 #include <dev/usb/usb_controller.h>
62 #include <dev/usb/usb_bus.h>
63 #include <dev/usb/usb_pf.h>
66 /* function prototypes */
68 static device_probe_t usb_probe;
69 static device_attach_t usb_attach;
70 static device_detach_t usb_detach;
71 static device_suspend_t usb_suspend;
72 static device_resume_t usb_resume;
73 static device_shutdown_t usb_shutdown;
75 static void usb_attach_sub(device_t, struct usb_bus *);
77 /* static variables */
80 static int usb_ctrl_debug = 0;
82 SYSCTL_NODE(_hw_usb, OID_AUTO, ctrl, CTLFLAG_RW, 0, "USB controller");
83 SYSCTL_INT(_hw_usb_ctrl, OID_AUTO, debug, CTLFLAG_RW, &usb_ctrl_debug, 0,
87 static int usb_no_boot_wait = 0;
88 TUNABLE_INT("hw.usb.no_boot_wait", &usb_no_boot_wait);
89 SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RD|CTLFLAG_TUN, &usb_no_boot_wait, 0,
90 "No USB device enumerate waiting at boot.");
92 static int usb_no_suspend_wait = 0;
93 TUNABLE_INT("hw.usb.no_suspend_wait", &usb_no_suspend_wait);
94 SYSCTL_INT(_hw_usb, OID_AUTO, no_suspend_wait, CTLFLAG_RW|CTLFLAG_TUN,
95 &usb_no_suspend_wait, 0, "No USB device waiting at system suspend.");
97 static int usb_no_shutdown_wait = 0;
98 TUNABLE_INT("hw.usb.no_shutdown_wait", &usb_no_shutdown_wait);
99 SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RW|CTLFLAG_TUN,
100 &usb_no_shutdown_wait, 0, "No USB device waiting at system shutdown.");
102 static devclass_t usb_devclass;
104 static device_method_t usb_methods[] = {
105 DEVMETHOD(device_probe, usb_probe),
106 DEVMETHOD(device_attach, usb_attach),
107 DEVMETHOD(device_detach, usb_detach),
108 DEVMETHOD(device_suspend, usb_suspend),
109 DEVMETHOD(device_resume, usb_resume),
110 DEVMETHOD(device_shutdown, usb_shutdown),
114 static driver_t usb_driver = {
116 .methods = usb_methods,
120 /* Host Only Drivers */
121 DRIVER_MODULE(usbus, ohci, usb_driver, usb_devclass, 0, 0);
122 DRIVER_MODULE(usbus, uhci, usb_driver, usb_devclass, 0, 0);
123 DRIVER_MODULE(usbus, ehci, usb_driver, usb_devclass, 0, 0);
124 DRIVER_MODULE(usbus, xhci, usb_driver, usb_devclass, 0, 0);
126 /* Device Only Drivers */
127 DRIVER_MODULE(usbus, at91_udp, usb_driver, usb_devclass, 0, 0);
128 DRIVER_MODULE(usbus, musbotg, usb_driver, usb_devclass, 0, 0);
129 DRIVER_MODULE(usbus, uss820, usb_driver, usb_devclass, 0, 0);
131 /*------------------------------------------------------------------------*
134 * This function is called from "{ehci,ohci,uhci}_pci_attach()".
135 *------------------------------------------------------------------------*/
137 usb_probe(device_t dev)
144 usb_root_mount_rel(struct usb_bus *bus)
146 if (bus->bus_roothold != NULL) {
147 DPRINTF("Releasing root mount hold %p\n", bus->bus_roothold);
148 root_mount_rel(bus->bus_roothold);
149 bus->bus_roothold = NULL;
153 /*------------------------------------------------------------------------*
155 *------------------------------------------------------------------------*/
157 usb_attach(device_t dev)
159 struct usb_bus *bus = device_get_ivars(dev);
164 device_printf(dev, "USB device has no ivars\n");
168 if (usb_no_boot_wait == 0) {
169 /* delay vfs_mountroot until the bus is explored */
170 bus->bus_roothold = root_mount_hold(device_get_nameunit(dev));
173 usb_attach_sub(dev, bus);
175 return (0); /* return success */
178 /*------------------------------------------------------------------------*
180 *------------------------------------------------------------------------*/
182 usb_detach(device_t dev)
184 struct usb_bus *bus = device_get_softc(dev);
189 /* was never setup properly */
192 /* Stop power watchdog */
193 usb_callout_drain(&bus->power_wdog);
195 /* Let the USB explore process detach all devices. */
196 usb_root_mount_rel(bus);
200 /* Queue detach job */
201 usb_proc_msignal(&bus->explore_proc,
202 &bus->detach_msg[0], &bus->detach_msg[1]);
204 /* Wait for detach to complete */
205 usb_proc_mwait(&bus->explore_proc,
206 &bus->detach_msg[0], &bus->detach_msg[1]);
210 /* Get rid of USB callback processes */
212 usb_proc_free(&bus->giant_callback_proc);
213 usb_proc_free(&bus->non_giant_callback_proc);
215 /* Get rid of USB explore process */
217 usb_proc_free(&bus->explore_proc);
219 /* Get rid of control transfer process */
221 usb_proc_free(&bus->control_xfer_proc);
229 /*------------------------------------------------------------------------*
231 *------------------------------------------------------------------------*/
233 usb_suspend(device_t dev)
235 struct usb_bus *bus = device_get_softc(dev);
240 /* was never setup properly */
245 usb_proc_msignal(&bus->explore_proc,
246 &bus->suspend_msg[0], &bus->suspend_msg[1]);
247 if (usb_no_suspend_wait == 0) {
248 /* wait for suspend callback to be executed */
249 usb_proc_mwait(&bus->explore_proc,
250 &bus->suspend_msg[0], &bus->suspend_msg[1]);
257 /*------------------------------------------------------------------------*
259 *------------------------------------------------------------------------*/
261 usb_resume(device_t dev)
263 struct usb_bus *bus = device_get_softc(dev);
268 /* was never setup properly */
273 usb_proc_msignal(&bus->explore_proc,
274 &bus->resume_msg[0], &bus->resume_msg[1]);
280 /*------------------------------------------------------------------------*
281 * usb_bus_reset_async_locked
282 *------------------------------------------------------------------------*/
284 usb_bus_reset_async_locked(struct usb_bus *bus)
286 USB_BUS_LOCK_ASSERT(bus, MA_OWNED);
290 if (bus->reset_msg[0].hdr.pm_qentry.tqe_prev != NULL ||
291 bus->reset_msg[1].hdr.pm_qentry.tqe_prev != NULL) {
292 DPRINTF("Reset already pending\n");
296 device_printf(bus->parent, "Resetting controller\n");
298 usb_proc_msignal(&bus->explore_proc,
299 &bus->reset_msg[0], &bus->reset_msg[1]);
302 /*------------------------------------------------------------------------*
304 *------------------------------------------------------------------------*/
306 usb_shutdown(device_t dev)
308 struct usb_bus *bus = device_get_softc(dev);
313 /* was never setup properly */
317 device_printf(bus->bdev, "Controller shutdown\n");
320 usb_proc_msignal(&bus->explore_proc,
321 &bus->shutdown_msg[0], &bus->shutdown_msg[1]);
322 if (usb_no_shutdown_wait == 0) {
323 /* wait for shutdown callback to be executed */
324 usb_proc_mwait(&bus->explore_proc,
325 &bus->shutdown_msg[0], &bus->shutdown_msg[1]);
329 device_printf(bus->bdev, "Controller shutdown complete\n");
334 /*------------------------------------------------------------------------*
337 * This function is used to explore the device tree from the root.
338 *------------------------------------------------------------------------*/
340 usb_bus_explore(struct usb_proc_msg *pm)
343 struct usb_device *udev;
345 bus = ((struct usb_bus_msg *)pm)->bus;
346 udev = bus->devices[USB_ROOT_HUB_ADDR];
348 if (bus->no_explore != 0)
351 if (udev && udev->hub) {
355 bus->driver_added_refcount++;
357 if (bus->driver_added_refcount == 0) {
358 /* avoid zero, hence that is memory default */
359 bus->driver_added_refcount = 1;
364 * The following three lines of code are only here to
367 usb_proc_rewakeup(&bus->control_xfer_proc);
368 usb_proc_rewakeup(&bus->giant_callback_proc);
369 usb_proc_rewakeup(&bus->non_giant_callback_proc);
376 * First update the USB power state!
380 /* Explore the Root USB HUB. */
381 (udev->hub->explore) (udev);
384 usb_root_mount_rel(bus);
387 /*------------------------------------------------------------------------*
390 * This function is used to detach the device tree from the root.
391 *------------------------------------------------------------------------*/
393 usb_bus_detach(struct usb_proc_msg *pm)
396 struct usb_device *udev;
399 bus = ((struct usb_bus_msg *)pm)->bus;
400 udev = bus->devices[USB_ROOT_HUB_ADDR];
402 /* clear the softc */
403 device_set_softc(dev, NULL);
406 /* detach children first */
408 bus_generic_detach(dev);
412 * Free USB device and all subdevices, if any.
414 usb_free_device(udev, 0);
417 /* clear bdev variable last */
421 /*------------------------------------------------------------------------*
424 * This function is used to suspend the USB controller.
425 *------------------------------------------------------------------------*/
427 usb_bus_suspend(struct usb_proc_msg *pm)
430 struct usb_device *udev;
436 bus = ((struct usb_bus_msg *)pm)->bus;
437 udev = bus->devices[USB_ROOT_HUB_ADDR];
439 if (udev == NULL || bus->bdev == NULL)
445 * We use the shutdown event here because the suspend and
446 * resume events are reserved for the USB port suspend and
447 * resume. The USB system suspend is implemented like full
448 * shutdown and all connected USB devices will be disconnected
449 * subsequently. At resume all USB devices will be
450 * re-connected again.
453 bus_generic_shutdown(bus->bdev);
455 do_unlock = usbd_enum_lock(udev);
457 err = usbd_set_config_index(udev, USB_UNCONFIG_INDEX);
459 device_printf(bus->bdev, "Could not unconfigure root HUB\n");
462 bus->hw_power_state = 0;
466 if (bus->methods->set_hw_power != NULL)
467 (bus->methods->set_hw_power) (bus);
469 if (bus->methods->set_hw_power_sleep != NULL)
470 (bus->methods->set_hw_power_sleep) (bus, USB_HW_POWER_SUSPEND);
473 usbd_enum_unlock(udev);
478 /*------------------------------------------------------------------------*
481 * This function is used to resume the USB controller.
482 *------------------------------------------------------------------------*/
484 usb_bus_resume(struct usb_proc_msg *pm)
487 struct usb_device *udev;
493 bus = ((struct usb_bus_msg *)pm)->bus;
494 udev = bus->devices[USB_ROOT_HUB_ADDR];
496 if (udev == NULL || bus->bdev == NULL)
501 do_unlock = usbd_enum_lock(udev);
503 DEVMETHOD(usb_take_controller, NULL); /* dummy */
505 USB_TAKE_CONTROLLER(device_get_parent(bus->bdev));
508 bus->hw_power_state =
509 USB_HW_POWER_CONTROL |
511 USB_HW_POWER_INTERRUPT |
513 USB_HW_POWER_NON_ROOT_HUB;
517 if (bus->methods->set_hw_power_sleep != NULL)
518 (bus->methods->set_hw_power_sleep) (bus, USB_HW_POWER_RESUME);
520 if (bus->methods->set_hw_power != NULL)
521 (bus->methods->set_hw_power) (bus);
523 /* restore USB configuration to index 0 */
524 err = usbd_set_config_index(udev, 0);
526 device_printf(bus->bdev, "Could not configure root HUB\n");
528 /* probe and attach */
529 err = usb_probe_and_attach(udev, USB_IFACE_INDEX_ANY);
531 device_printf(bus->bdev, "Could not probe and "
532 "attach root HUB\n");
536 usbd_enum_unlock(udev);
541 /*------------------------------------------------------------------------*
544 * This function is used to reset the USB controller.
545 *------------------------------------------------------------------------*/
547 usb_bus_reset(struct usb_proc_msg *pm)
553 bus = ((struct usb_bus_msg *)pm)->bus;
555 if (bus->bdev == NULL || bus->no_explore != 0)
558 /* a suspend and resume will reset the USB controller */
563 /*------------------------------------------------------------------------*
566 * This function is used to shutdown the USB controller.
567 *------------------------------------------------------------------------*/
569 usb_bus_shutdown(struct usb_proc_msg *pm)
572 struct usb_device *udev;
576 bus = ((struct usb_bus_msg *)pm)->bus;
577 udev = bus->devices[USB_ROOT_HUB_ADDR];
579 if (udev == NULL || bus->bdev == NULL)
584 bus_generic_shutdown(bus->bdev);
586 do_unlock = usbd_enum_lock(udev);
588 err = usbd_set_config_index(udev, USB_UNCONFIG_INDEX);
590 device_printf(bus->bdev, "Could not unconfigure root HUB\n");
593 bus->hw_power_state = 0;
597 if (bus->methods->set_hw_power != NULL)
598 (bus->methods->set_hw_power) (bus);
600 if (bus->methods->set_hw_power_sleep != NULL)
601 (bus->methods->set_hw_power_sleep) (bus, USB_HW_POWER_SHUTDOWN);
604 usbd_enum_unlock(udev);
610 usb_power_wdog(void *arg)
612 struct usb_bus *bus = arg;
614 USB_BUS_LOCK_ASSERT(bus, MA_OWNED);
616 usb_callout_reset(&bus->power_wdog,
617 4 * hz, usb_power_wdog, arg);
621 * The following line of code is only here to recover from
624 usb_proc_rewakeup(&bus->explore_proc); /* recover from DDB */
630 usb_bus_power_update(bus);
636 /*------------------------------------------------------------------------*
639 * This function attaches USB in context of the explore thread.
640 *------------------------------------------------------------------------*/
642 usb_bus_attach(struct usb_proc_msg *pm)
645 struct usb_device *child;
648 enum usb_dev_speed speed;
650 bus = ((struct usb_bus_msg *)pm)->bus;
655 switch (bus->usbrev) {
657 speed = USB_SPEED_FULL;
658 device_printf(bus->bdev, "12Mbps Full Speed USB v1.0\n");
662 speed = USB_SPEED_FULL;
663 device_printf(bus->bdev, "12Mbps Full Speed USB v1.1\n");
667 speed = USB_SPEED_HIGH;
668 device_printf(bus->bdev, "480Mbps High Speed USB v2.0\n");
672 speed = USB_SPEED_VARIABLE;
673 device_printf(bus->bdev, "480Mbps Wireless USB v2.5\n");
677 speed = USB_SPEED_SUPER;
678 device_printf(bus->bdev, "5.0Gbps Super Speed USB v3.0\n");
682 device_printf(bus->bdev, "Unsupported USB revision\n");
683 usb_root_mount_rel(bus);
687 /* default power_mask value */
688 bus->hw_power_state =
689 USB_HW_POWER_CONTROL |
691 USB_HW_POWER_INTERRUPT |
693 USB_HW_POWER_NON_ROOT_HUB;
697 /* make sure power is set at least once */
699 if (bus->methods->set_hw_power != NULL) {
700 (bus->methods->set_hw_power) (bus);
703 /* allocate the Root USB device */
705 child = usb_alloc_device(bus->bdev, bus, NULL, 0, 0, 1,
706 speed, USB_MODE_HOST);
708 err = usb_probe_and_attach(child,
709 USB_IFACE_INDEX_ANY);
711 if ((bus->devices[USB_ROOT_HUB_ADDR] == NULL) ||
712 (bus->devices[USB_ROOT_HUB_ADDR]->hub == NULL)) {
713 err = USB_ERR_NO_ROOT_HUB;
723 device_printf(bus->bdev, "Root HUB problem, error=%s\n",
725 usb_root_mount_rel(bus);
728 /* set softc - we are ready */
729 device_set_softc(dev, bus);
735 /*------------------------------------------------------------------------*
738 * This function creates a thread which runs the USB attach code.
739 *------------------------------------------------------------------------*/
741 usb_attach_sub(device_t dev, struct usb_bus *bus)
743 const char *pname = device_get_nameunit(dev);
746 if (usb_devclass_ptr == NULL)
747 usb_devclass_ptr = devclass_find("usbus");
753 /* Initialise USB process messages */
754 bus->explore_msg[0].hdr.pm_callback = &usb_bus_explore;
755 bus->explore_msg[0].bus = bus;
756 bus->explore_msg[1].hdr.pm_callback = &usb_bus_explore;
757 bus->explore_msg[1].bus = bus;
759 bus->detach_msg[0].hdr.pm_callback = &usb_bus_detach;
760 bus->detach_msg[0].bus = bus;
761 bus->detach_msg[1].hdr.pm_callback = &usb_bus_detach;
762 bus->detach_msg[1].bus = bus;
764 bus->attach_msg[0].hdr.pm_callback = &usb_bus_attach;
765 bus->attach_msg[0].bus = bus;
766 bus->attach_msg[1].hdr.pm_callback = &usb_bus_attach;
767 bus->attach_msg[1].bus = bus;
769 bus->suspend_msg[0].hdr.pm_callback = &usb_bus_suspend;
770 bus->suspend_msg[0].bus = bus;
771 bus->suspend_msg[1].hdr.pm_callback = &usb_bus_suspend;
772 bus->suspend_msg[1].bus = bus;
774 bus->resume_msg[0].hdr.pm_callback = &usb_bus_resume;
775 bus->resume_msg[0].bus = bus;
776 bus->resume_msg[1].hdr.pm_callback = &usb_bus_resume;
777 bus->resume_msg[1].bus = bus;
779 bus->reset_msg[0].hdr.pm_callback = &usb_bus_reset;
780 bus->reset_msg[0].bus = bus;
781 bus->reset_msg[1].hdr.pm_callback = &usb_bus_reset;
782 bus->reset_msg[1].bus = bus;
784 bus->shutdown_msg[0].hdr.pm_callback = &usb_bus_shutdown;
785 bus->shutdown_msg[0].bus = bus;
786 bus->shutdown_msg[1].hdr.pm_callback = &usb_bus_shutdown;
787 bus->shutdown_msg[1].bus = bus;
789 /* Create USB explore and callback processes */
791 if (usb_proc_create(&bus->giant_callback_proc,
792 &bus->bus_mtx, pname, USB_PRI_MED)) {
793 device_printf(dev, "WARNING: Creation of USB Giant "
794 "callback process failed.\n");
795 } else if (usb_proc_create(&bus->non_giant_callback_proc,
796 &bus->bus_mtx, pname, USB_PRI_HIGH)) {
797 device_printf(dev, "WARNING: Creation of USB non-Giant "
798 "callback process failed.\n");
799 } else if (usb_proc_create(&bus->explore_proc,
800 &bus->bus_mtx, pname, USB_PRI_MED)) {
801 device_printf(dev, "WARNING: Creation of USB explore "
802 "process failed.\n");
803 } else if (usb_proc_create(&bus->control_xfer_proc,
804 &bus->bus_mtx, pname, USB_PRI_MED)) {
805 device_printf(dev, "WARNING: Creation of USB control transfer "
806 "process failed.\n");
808 /* Get final attach going */
810 usb_proc_msignal(&bus->explore_proc,
811 &bus->attach_msg[0], &bus->attach_msg[1]);
814 /* Do initial explore */
815 usb_needs_explore(bus, 1);
819 SYSUNINIT(usb_bus_unload, SI_SUB_KLD, SI_ORDER_ANY, usb_bus_unload, NULL);
821 /*------------------------------------------------------------------------*
822 * usb_bus_mem_flush_all_cb
823 *------------------------------------------------------------------------*/
826 usb_bus_mem_flush_all_cb(struct usb_bus *bus, struct usb_page_cache *pc,
827 struct usb_page *pg, usb_size_t size, usb_size_t align)
829 usb_pc_cpu_flush(pc);
833 /*------------------------------------------------------------------------*
834 * usb_bus_mem_flush_all - factored out code
835 *------------------------------------------------------------------------*/
838 usb_bus_mem_flush_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb)
841 cb(bus, &usb_bus_mem_flush_all_cb);
846 /*------------------------------------------------------------------------*
847 * usb_bus_mem_alloc_all_cb
848 *------------------------------------------------------------------------*/
851 usb_bus_mem_alloc_all_cb(struct usb_bus *bus, struct usb_page_cache *pc,
852 struct usb_page *pg, usb_size_t size, usb_size_t align)
854 /* need to initialize the page cache */
855 pc->tag_parent = bus->dma_parent_tag;
857 if (usb_pc_alloc_mem(pc, pg, size, align)) {
858 bus->alloc_failed = 1;
863 /*------------------------------------------------------------------------*
864 * usb_bus_mem_alloc_all - factored out code
869 *------------------------------------------------------------------------*/
871 usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat,
872 usb_bus_mem_cb_t *cb)
874 bus->alloc_failed = 0;
876 mtx_init(&bus->bus_mtx, device_get_nameunit(bus->parent),
877 NULL, MTX_DEF | MTX_RECURSE);
879 usb_callout_init_mtx(&bus->power_wdog,
882 TAILQ_INIT(&bus->intr_q.head);
885 usb_dma_tag_setup(bus->dma_parent_tag, bus->dma_tags,
886 dmat, &bus->bus_mtx, NULL, 32, USB_BUS_DMA_TAG_MAX);
888 if ((bus->devices_max > USB_MAX_DEVICES) ||
889 (bus->devices_max < USB_MIN_DEVICES) ||
890 (bus->devices == NULL)) {
891 DPRINTFN(0, "Devices field has not been "
892 "initialised properly\n");
893 bus->alloc_failed = 1; /* failure */
897 cb(bus, &usb_bus_mem_alloc_all_cb);
900 if (bus->alloc_failed) {
901 usb_bus_mem_free_all(bus, cb);
903 return (bus->alloc_failed);
906 /*------------------------------------------------------------------------*
907 * usb_bus_mem_free_all_cb
908 *------------------------------------------------------------------------*/
911 usb_bus_mem_free_all_cb(struct usb_bus *bus, struct usb_page_cache *pc,
912 struct usb_page *pg, usb_size_t size, usb_size_t align)
918 /*------------------------------------------------------------------------*
919 * usb_bus_mem_free_all - factored out code
920 *------------------------------------------------------------------------*/
922 usb_bus_mem_free_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb)
926 cb(bus, &usb_bus_mem_free_all_cb);
928 usb_dma_tag_unsetup(bus->dma_parent_tag);
931 mtx_destroy(&bus->bus_mtx);
934 /* convenience wrappers */
936 usb_proc_explore_mwait(struct usb_device *udev, void *pm1, void *pm2)
938 usb_proc_mwait(&udev->bus->explore_proc, pm1, pm2);
942 usb_proc_explore_msignal(struct usb_device *udev, void *pm1, void *pm2)
944 return (usb_proc_msignal(&udev->bus->explore_proc, pm1, pm2));
948 usb_proc_explore_lock(struct usb_device *udev)
950 USB_BUS_LOCK(udev->bus);
954 usb_proc_explore_unlock(struct usb_device *udev)
956 USB_BUS_UNLOCK(udev->bus);