Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Jan 2009 19:03:01 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r187172 - head/sys/dev/usb2/controller
Message-ID:  <200901131903.n0DJ31oX012408@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Tue Jan 13 19:03:01 2009
New Revision: 187172
URL: http://svn.freebsd.org/changeset/base/187172

Log:
  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

Modified:
  head/sys/dev/usb2/controller/at91dci.c
  head/sys/dev/usb2/controller/at91dci.h
  head/sys/dev/usb2/controller/at91dci_atmelarm.c
  head/sys/dev/usb2/controller/ehci2.c
  head/sys/dev/usb2/controller/ehci2.h
  head/sys/dev/usb2/controller/ehci2_pci.c
  head/sys/dev/usb2/controller/musb2_otg.c
  head/sys/dev/usb2/controller/musb2_otg.h
  head/sys/dev/usb2/controller/musb2_otg_atmelarm.c
  head/sys/dev/usb2/controller/ohci2.c
  head/sys/dev/usb2/controller/ohci2.h
  head/sys/dev/usb2/controller/ohci2_atmelarm.c
  head/sys/dev/usb2/controller/ohci2_pci.c
  head/sys/dev/usb2/controller/uhci2.c
  head/sys/dev/usb2/controller/uhci2.h
  head/sys/dev/usb2/controller/uhci2_pci.c
  head/sys/dev/usb2/controller/usb2_bus.h
  head/sys/dev/usb2/controller/usb2_controller.c
  head/sys/dev/usb2/controller/usb2_controller.h
  head/sys/dev/usb2/controller/uss820dci.c
  head/sys/dev/usb2/controller/uss820dci.h
  head/sys/dev/usb2/controller/uss820dci_atmelarm.c

Modified: head/sys/dev/usb2/controller/at91dci.c
==============================================================================
--- head/sys/dev/usb2/controller/at91dci.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/at91dci.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -50,14 +50,11 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/include/usb2_defs.h>
 
 #define	USB_DEBUG_VAR at91dcidebug
-#define	usb2_config_td_cc at91dci_config_copy
-#define	usb2_config_td_softc at91dci_softc
 
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_debug.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_transfer.h>
 #include <dev/usb2/core/usb2_device.h>
@@ -106,7 +103,6 @@ static void	at91dci_standard_done(struct
 
 static usb2_sw_transfer_func_t at91dci_root_intr_done;
 static usb2_sw_transfer_func_t at91dci_root_ctrl_done;
-static usb2_config_td_command_t at91dci_root_ctrl_task;
 
 /*
  * NOTE: Some of the bits in the CSR register have inverse meaning so
@@ -1817,15 +1813,13 @@ at91dci_root_ctrl_start(struct usb2_xfer
 
 	sc->sc_root_ctrl.xfer = xfer;
 
-	usb2_config_td_queue_command(
-	    &sc->sc_config_td, NULL, &at91dci_root_ctrl_task, 0, 0);
+	usb2_bus_roothub_exec(xfer->udev->bus);
 }
 
 static void
-at91dci_root_ctrl_task(struct at91dci_softc *sc,
-    struct at91dci_config_copy *cc, uint16_t refcount)
+at91dci_root_ctrl_task(struct usb2_bus *bus)
 {
-	at91dci_root_ctrl_poll(sc);
+	at91dci_root_ctrl_poll(AT9100_DCI_BUS2SC(bus));
 }
 
 static void
@@ -2478,4 +2472,5 @@ struct usb2_bus_methods at91dci_bus_meth
 	.set_stall = &at91dci_set_stall,
 	.clear_stall = &at91dci_clear_stall,
 	.vbus_interrupt = &at91dci_vbus_interrupt,
+	.roothub_exec = &at91dci_root_ctrl_task,
 };

Modified: head/sys/dev/usb2/controller/at91dci.h
==============================================================================
--- head/sys/dev/usb2/controller/at91dci.h	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/at91dci.h	Tue Jan 13 19:03:01 2009	(r187172)
@@ -206,7 +206,6 @@ struct at91dci_softc {
 	LIST_HEAD(, usb2_xfer) sc_interrupt_list_head;
 	struct usb2_sw_transfer sc_root_ctrl;
 	struct usb2_sw_transfer sc_root_intr;
-	struct usb2_config_td sc_config_td;
 
 	struct usb2_device *sc_devices[AT91_MAX_DEVICES];
 	struct resource *sc_io_res;

Modified: head/sys/dev/usb2/controller/at91dci_atmelarm.c
==============================================================================
--- head/sys/dev/usb2/controller/at91dci_atmelarm.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/at91dci_atmelarm.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_util.h>
 
@@ -208,12 +207,6 @@ at91_udp_attach(device_t dev)
 	}
 	device_set_ivars(sc->sc_dci.sc_bus.bdev, &sc->sc_dci.sc_bus);
 
-	err = usb2_config_td_setup(&sc->sc_dci.sc_config_td, sc,
-	    &sc->sc_dci.sc_bus.bus_mtx, NULL, 0, 4);
-	if (err) {
-		device_printf(dev, "could not setup config thread!\n");
-		goto error;
-	}
 #if (__FreeBSD_version >= 700031)
 	err = bus_setup_intr(dev, sc->sc_dci.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
 	    NULL, (void *)at91dci_interrupt, sc, &sc->sc_dci.sc_intr_hdl);
@@ -308,8 +301,6 @@ at91_udp_detach(device_t dev)
 		    sc->sc_dci.sc_io_res);
 		sc->sc_dci.sc_io_res = NULL;
 	}
-	usb2_config_td_unsetup(&sc->sc_dci.sc_config_td);
-
 	usb2_bus_mem_free_all(&sc->sc_dci.sc_bus, NULL);
 
 	/* disable clocks */

Modified: head/sys/dev/usb2/controller/ehci2.c
==============================================================================
--- head/sys/dev/usb2/controller/ehci2.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/ehci2.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -52,14 +52,11 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/include/usb2_defs.h>
 
 #define	USB_DEBUG_VAR ehcidebug
-#define	usb2_config_td_cc ehci_config_copy
-#define	usb2_config_td_softc ehci_softc
 
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_debug.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_transfer.h>
 #include <dev/usb2/core/usb2_device.h>
@@ -99,7 +96,6 @@ extern struct usb2_pipe_methods ehci_dev
 extern struct usb2_pipe_methods ehci_root_ctrl_methods;
 extern struct usb2_pipe_methods ehci_root_intr_methods;
 
-static usb2_config_td_command_t ehci_root_ctrl_task;
 static void ehci_do_poll(struct usb2_bus *bus);
 static void ehci_root_ctrl_poll(ehci_softc_t *sc);
 static void ehci_device_done(struct usb2_xfer *xfer, usb2_error_t error);
@@ -3031,15 +3027,13 @@ ehci_root_ctrl_start(struct usb2_xfer *x
 
 	sc->sc_root_ctrl.xfer = xfer;
 
-	usb2_config_td_queue_command
-	    (&sc->sc_config_td, NULL, &ehci_root_ctrl_task, 0, 0);
+	usb2_bus_roothub_exec(xfer->udev->bus);
 }
 
 static void
-ehci_root_ctrl_task(ehci_softc_t *sc,
-    struct usb2_config_td_cc *cc, uint16_t refcount)
+ehci_root_ctrl_task(struct usb2_bus *bus)
 {
-	ehci_root_ctrl_poll(sc);
+	ehci_root_ctrl_poll(EHCI_BUS2SC(bus));
 }
 
 static void
@@ -3969,4 +3963,5 @@ struct usb2_bus_methods ehci_bus_methods
 	.device_resume = ehci_device_resume,
 	.device_suspend = ehci_device_suspend,
 	.set_hw_power = ehci_set_hw_power,
+	.roothub_exec = ehci_root_ctrl_task,
 };

Modified: head/sys/dev/usb2/controller/ehci2.h
==============================================================================
--- head/sys/dev/usb2/controller/ehci2.h	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/ehci2.h	Tue Jan 13 19:03:01 2009	(r187172)
@@ -455,7 +455,6 @@ union ehci_hub_desc {
 typedef struct ehci_softc {
 	struct ehci_hw_softc sc_hw;
 	struct usb2_bus sc_bus;		/* base device */
-	struct usb2_config_td sc_config_td;
 	struct usb2_callout sc_tmo_pcd;
 	union ehci_hub_desc sc_hub_desc;
 	struct usb2_sw_transfer sc_root_ctrl;

Modified: head/sys/dev/usb2/controller/ehci2_pci.c
==============================================================================
--- head/sys/dev/usb2/controller/ehci2_pci.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/ehci2_pci.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_util.h>
 
@@ -341,12 +340,6 @@ ehci_pci_attach(device_t self)
 		sprintf(sc->sc_vendor, "(0x%04x)", pci_get_vendor(self));
 	}
 
-	err = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_bus.bus_mtx,
-	    NULL, 0, 4);
-	if (err) {
-		device_printf(self, "could not setup config thread!\n");
-		goto error;
-	}
 #if (__FreeBSD_version >= 700031)
 	err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
 	    NULL, (void *)(void *)ehci_interrupt, sc, &sc->sc_intr_hdl);
@@ -381,8 +374,6 @@ ehci_pci_detach(device_t self)
 	ehci_softc_t *sc = device_get_softc(self);
 	device_t bdev;
 
-	usb2_config_td_drain(&sc->sc_config_td);
-
 	if (sc->sc_bus.bdev) {
 		bdev = sc->sc_bus.bdev;
 		device_detach(bdev);
@@ -422,8 +413,6 @@ ehci_pci_detach(device_t self)
 		    sc->sc_io_res);
 		sc->sc_io_res = NULL;
 	}
-	usb2_config_td_unsetup(&sc->sc_config_td);
-
 	usb2_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);
 
 	return (0);

Modified: head/sys/dev/usb2/controller/musb2_otg.c
==============================================================================
--- head/sys/dev/usb2/controller/musb2_otg.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/musb2_otg.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -42,14 +42,11 @@
 #include <dev/usb2/include/usb2_defs.h>
 
 #define	USB_DEBUG_VAR musbotgdebug
-#define	usb2_config_td_cc musbotg_config_copy
-#define	usb2_config_td_softc musbotg_softc
 
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_debug.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_transfer.h>
 #include <dev/usb2/core/usb2_device.h>
@@ -101,7 +98,6 @@ static void	musbotg_interrupt_poll(struc
 
 static usb2_sw_transfer_func_t musbotg_root_intr_done;
 static usb2_sw_transfer_func_t musbotg_root_ctrl_done;
-static usb2_config_td_command_t musbotg_root_ctrl_task;
 
 /*
  * Here is a configuration that the chip supports.
@@ -2222,15 +2218,13 @@ musbotg_root_ctrl_start(struct usb2_xfer
 
 	sc->sc_root_ctrl.xfer = xfer;
 
-	usb2_config_td_queue_command(
-	    &sc->sc_config_td, NULL, &musbotg_root_ctrl_task, 0, 0);
+	usb2_bus_roothub_exec(xfer->udev->bus);
 }
 
 static void
-musbotg_root_ctrl_task(struct musbotg_softc *sc,
-    struct musbotg_config_copy *cc, uint16_t refcount)
+musbotg_root_ctrl_task(struct usb2_bus *bus)
 {
-	musbotg_root_ctrl_poll(sc);
+	musbotg_root_ctrl_poll(MUSBOTG_BUS2SC(bus));
 }
 
 static void
@@ -2885,4 +2879,5 @@ struct usb2_bus_methods musbotg_bus_meth
 	.set_stall = &musbotg_set_stall,
 	.clear_stall = &musbotg_clear_stall,
 	.vbus_interrupt = &musbotg_vbus_interrupt,
+	.roothub_exec = &musbotg_root_ctrl_task,
 };

Modified: head/sys/dev/usb2/controller/musb2_otg.h
==============================================================================
--- head/sys/dev/usb2/controller/musb2_otg.h	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/musb2_otg.h	Tue Jan 13 19:03:01 2009	(r187172)
@@ -365,7 +365,6 @@ struct musbotg_softc {
 	union musbotg_hub_temp sc_hub_temp;
 	struct usb2_sw_transfer sc_root_ctrl;
 	struct usb2_sw_transfer sc_root_intr;
-	struct usb2_config_td sc_config_td;
 	struct usb2_hw_ep_profile sc_hw_ep_profile[16];
 
 	struct usb2_device *sc_devices[MUSB2_MAX_DEVICES];

Modified: head/sys/dev/usb2/controller/musb2_otg_atmelarm.c
==============================================================================
--- head/sys/dev/usb2/controller/musb2_otg_atmelarm.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/musb2_otg_atmelarm.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -31,7 +31,6 @@
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_util.h>
 
@@ -136,12 +135,6 @@ musbotg_attach(device_t dev)
 	}
 	device_set_ivars(sc->sc_otg.sc_bus.bdev, &sc->sc_otg.sc_bus);
 
-	err = usb2_config_td_setup(&sc->sc_otg.sc_config_td, sc,
-	    &sc->sc_otg.sc_bus.bus_mtx, NULL, 0, 4);
-	if (err) {
-		device_printf(dev, "could not setup config thread!\n");
-		goto error;
-	}
 #if (__FreeBSD_version >= 700031)
 	err = bus_setup_intr(dev, sc->sc_otg.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
 	    NULL, (void *)musbotg_interrupt, sc, &sc->sc_otg.sc_intr_hdl);
@@ -207,8 +200,6 @@ musbotg_detach(device_t dev)
 		    sc->sc_otg.sc_io_res);
 		sc->sc_otg.sc_io_res = NULL;
 	}
-	usb2_config_td_unsetup(&sc->sc_otg.sc_config_td);
-
 	usb2_bus_mem_free_all(&sc->sc_otg.sc_bus, NULL);
 
 	return (0);

Modified: head/sys/dev/usb2/controller/ohci2.c
==============================================================================
--- head/sys/dev/usb2/controller/ohci2.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/ohci2.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -41,14 +41,11 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/include/usb2_defs.h>
 
 #define	USB_DEBUG_VAR ohcidebug
-#define	usb2_config_td_cc ohci_config_copy
-#define	usb2_config_td_softc ohci_softc
 
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_debug.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_transfer.h>
 #include <dev/usb2/core/usb2_device.h>
@@ -99,7 +96,6 @@ extern struct usb2_pipe_methods ohci_dev
 extern struct usb2_pipe_methods ohci_root_ctrl_methods;
 extern struct usb2_pipe_methods ohci_root_intr_methods;
 
-static usb2_config_td_command_t ohci_root_ctrl_task;
 static void ohci_root_ctrl_poll(struct ohci_softc *sc);
 static void ohci_do_poll(struct usb2_bus *bus);
 static void ohci_device_done(struct usb2_xfer *xfer, usb2_error_t error);
@@ -2135,15 +2131,13 @@ ohci_root_ctrl_start(struct usb2_xfer *x
 
 	sc->sc_root_ctrl.xfer = xfer;
 
-	usb2_config_td_queue_command
-	    (&sc->sc_config_td, NULL, &ohci_root_ctrl_task, 0, 0);
+	usb2_bus_roothub_exec(xfer->udev->bus);
 }
 
 static void
-ohci_root_ctrl_task(struct ohci_softc *sc,
-    struct ohci_config_copy *cc, uint16_t refcount)
+ohci_root_ctrl_task(struct usb2_bus *bus)
 {
-	ohci_root_ctrl_poll(sc);
+	ohci_root_ctrl_poll(OHCI_BUS2SC(bus));
 }
 
 static void
@@ -2864,4 +2858,5 @@ struct usb2_bus_methods ohci_bus_methods
 	.device_resume = ohci_device_resume,
 	.device_suspend = ohci_device_suspend,
 	.set_hw_power = ohci_set_hw_power,
+	.roothub_exec = ohci_root_ctrl_task,
 };

Modified: head/sys/dev/usb2/controller/ohci2.h
==============================================================================
--- head/sys/dev/usb2/controller/ohci2.h	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/ohci2.h	Tue Jan 13 19:03:01 2009	(r187172)
@@ -320,7 +320,6 @@ union ohci_hub_desc {
 typedef struct ohci_softc {
 	struct ohci_hw_softc sc_hw;
 	struct usb2_bus sc_bus;		/* base device */
-	struct usb2_config_td sc_config_td;
 	struct usb2_callout sc_tmo_rhsc;
 	union ohci_hub_desc sc_hub_desc;
 	struct usb2_sw_transfer sc_root_ctrl;

Modified: head/sys/dev/usb2/controller/ohci2_atmelarm.c
==============================================================================
--- head/sys/dev/usb2/controller/ohci2_atmelarm.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/ohci2_atmelarm.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -32,7 +32,6 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_util.h>
 
@@ -114,12 +113,6 @@ ohci_atmelarm_attach(device_t dev)
 
 	strlcpy(sc->sc_ohci.sc_vendor, "Atmel", sizeof(sc->sc_ohci.sc_vendor));
 
-	err = usb2_config_td_setup(&sc->sc_ohci.sc_config_td, sc,
-	    &sc->sc_ohci.sc_bus.bus_mtx, NULL, 0, 4);
-	if (err) {
-		device_printf(dev, "could not setup config thread!\n");
-		goto error;
-	}
 #if (__FreeBSD_version >= 700031)
 	err = bus_setup_intr(dev, sc->sc_ohci.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
 	    NULL, (void *)ohci_interrupt, sc, &sc->sc_ohci.sc_intr_hdl);
@@ -203,8 +196,6 @@ ohci_atmelarm_detach(device_t dev)
 		    sc->sc_ohci.sc_io_res);
 		sc->sc_ohci.sc_io_res = NULL;
 	}
-	usb2_config_td_unsetup(&sc->sc_ohci.sc_config_td);
-
 	usb2_bus_mem_free_all(&sc->sc_ohci.sc_bus, &ohci_iterate_hw_softc);
 
 	return (0);

Modified: head/sys/dev/usb2/controller/ohci2_pci.c
==============================================================================
--- head/sys/dev/usb2/controller/ohci2_pci.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/ohci2_pci.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -57,7 +57,6 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_util.h>
 
@@ -291,12 +290,6 @@ ohci_pci_attach(device_t self)
 		sprintf(sc->sc_vendor, "(0x%04x)", pci_get_vendor(self));
 	}
 
-	err = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_bus.bus_mtx,
-	    NULL, 0, 4);
-	if (err) {
-		device_printf(self, "could not setup config thread!\n");
-		goto error;
-	}
 	/* sc->sc_bus.usbrev; set by ohci_init() */
 
 #if (__FreeBSD_version >= 700031)
@@ -332,8 +325,6 @@ ohci_pci_detach(device_t self)
 	ohci_softc_t *sc = device_get_softc(self);
 	device_t bdev;
 
-	usb2_config_td_drain(&sc->sc_config_td);
-
 	if (sc->sc_bus.bdev) {
 		bdev = sc->sc_bus.bdev;
 		device_detach(bdev);
@@ -368,8 +359,6 @@ ohci_pci_detach(device_t self)
 		    sc->sc_io_res);
 		sc->sc_io_res = NULL;
 	}
-	usb2_config_td_unsetup(&sc->sc_config_td);
-
 	usb2_bus_mem_free_all(&sc->sc_bus, &ohci_iterate_hw_softc);
 
 	return (0);

Modified: head/sys/dev/usb2/controller/uhci2.c
==============================================================================
--- head/sys/dev/usb2/controller/uhci2.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/uhci2.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -44,14 +44,11 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/include/usb2_defs.h>
 
 #define	USB_DEBUG_VAR uhcidebug
-#define	usb2_config_td_cc uhci_config_copy
-#define	usb2_config_td_softc uhci_softc
 
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_debug.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_transfer.h>
 #include <dev/usb2/core/usb2_device.h>
@@ -138,7 +135,6 @@ extern struct usb2_pipe_methods uhci_dev
 extern struct usb2_pipe_methods uhci_root_ctrl_methods;
 extern struct usb2_pipe_methods uhci_root_intr_methods;
 
-static usb2_config_td_command_t uhci_root_ctrl_task;
 static void	uhci_root_ctrl_poll(struct uhci_softc *);
 static void	uhci_do_poll(struct usb2_bus *);
 static void	uhci_device_done(struct usb2_xfer *, usb2_error_t);
@@ -2502,15 +2498,13 @@ uhci_root_ctrl_start(struct usb2_xfer *x
 
 	sc->sc_root_ctrl.xfer = xfer;
 
-	usb2_config_td_queue_command
-	    (&sc->sc_config_td, NULL, &uhci_root_ctrl_task, 0, 0);
+	usb2_bus_roothub_exec(xfer->udev->bus);
 }
 
 static void
-uhci_root_ctrl_task(struct uhci_softc *sc,
-    struct uhci_config_copy *cc, uint16_t refcount)
+uhci_root_ctrl_task(struct usb2_bus *bus)
 {
-	uhci_root_ctrl_poll(sc);
+	uhci_root_ctrl_poll(UHCI_BUS2SC(bus));
 }
 
 static void
@@ -3361,4 +3355,5 @@ struct usb2_bus_methods uhci_bus_methods
 	.device_resume = uhci_device_resume,
 	.device_suspend = uhci_device_suspend,
 	.set_hw_power = uhci_set_hw_power,
+	.roothub_exec = uhci_root_ctrl_task,
 };

Modified: head/sys/dev/usb2/controller/uhci2.h
==============================================================================
--- head/sys/dev/usb2/controller/uhci2.h	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/uhci2.h	Tue Jan 13 19:03:01 2009	(r187172)
@@ -270,7 +270,6 @@ struct uhci_hw_softc {
 typedef struct uhci_softc {
 	struct uhci_hw_softc sc_hw;
 	struct usb2_bus sc_bus;		/* base device */
-	struct usb2_config_td sc_config_td;
 	union uhci_hub_desc sc_hub_desc;
 	struct usb2_sw_transfer sc_root_ctrl;
 	struct usb2_sw_transfer sc_root_intr;

Modified: head/sys/dev/usb2/controller/uhci2_pci.c
==============================================================================
--- head/sys/dev/usb2/controller/uhci2_pci.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/uhci2_pci.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_util.h>
 #include <dev/usb2/core/usb2_debug.h>
@@ -325,12 +324,6 @@ uhci_pci_attach(device_t self)
 		break;
 	}
 
-	err = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_bus.bus_mtx,
-	    NULL, 0, 4);
-	if (err) {
-		device_printf(self, "could not setup config thread!\n");
-		goto error;
-	}
 #if (__FreeBSD_version >= 700031)
 	err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
 	    NULL, (void *)(void *)uhci_interrupt, sc, &sc->sc_intr_hdl);
@@ -379,8 +372,6 @@ uhci_pci_detach(device_t self)
 	uhci_softc_t *sc = device_get_softc(self);
 	device_t bdev;
 
-	usb2_config_td_drain(&sc->sc_config_td);
-
 	if (sc->sc_bus.bdev) {
 		bdev = sc->sc_bus.bdev;
 		device_detach(bdev);
@@ -422,8 +413,6 @@ uhci_pci_detach(device_t self)
 		    sc->sc_io_res);
 		sc->sc_io_res = NULL;
 	}
-	usb2_config_td_unsetup(&sc->sc_config_td);
-
 	usb2_bus_mem_free_all(&sc->sc_bus, &uhci_iterate_hw_softc);
 
 	return (0);

Modified: head/sys/dev/usb2/controller/usb2_bus.h
==============================================================================
--- head/sys/dev/usb2/controller/usb2_bus.h	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/usb2_bus.h	Tue Jan 13 19:03:01 2009	(r187172)
@@ -52,9 +52,11 @@ struct usb2_bus {
 	struct usb2_bus_stat stats_err;
 	struct usb2_bus_stat stats_ok;
 	struct usb2_process explore_proc;
+	struct usb2_process roothub_proc;
 	struct usb2_bus_msg explore_msg[2];
 	struct usb2_bus_msg detach_msg[2];
 	struct usb2_bus_msg attach_msg[2];
+	struct usb2_bus_msg roothub_msg[2];
 	/*
 	 * This mutex protects the USB hardware:
 	 */

Modified: head/sys/dev/usb2/controller/usb2_controller.c
==============================================================================
--- head/sys/dev/usb2/controller/usb2_controller.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/usb2_controller.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -59,6 +59,7 @@ static void	usb2_bus_mem_alloc_all_cb(st
 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 usb
 	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 *b
 
 	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 */
+	}
+}

Modified: head/sys/dev/usb2/controller/usb2_controller.h
==============================================================================
--- head/sys/dev/usb2/controller/usb2_controller.h	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/usb2_controller.h	Tue Jan 13 19:03:01 2009	(r187172)
@@ -94,6 +94,10 @@ struct usb2_bus_methods {
 	/* USB Device mode only - Optional */
 
 	void    (*vbus_interrupt) (struct usb2_bus *, uint8_t is_on);
+
+	/* USB Device and Host mode - Optional */
+
+	void	(*roothub_exec) (struct usb2_bus *);
 };
 
 /*
@@ -186,6 +190,7 @@ struct usb2_temp_setup {
 void	usb2_bus_mem_flush_all(struct usb2_bus *bus, usb2_bus_mem_cb_t *cb);
 uint8_t	usb2_bus_mem_alloc_all(struct usb2_bus *bus, bus_dma_tag_t dmat, usb2_bus_mem_cb_t *cb);
 void	usb2_bus_mem_free_all(struct usb2_bus *bus, usb2_bus_mem_cb_t *cb);
+void	usb2_bus_roothub_exec(struct usb2_bus *bus);
 uint16_t usb2_isoc_time_expand(struct usb2_bus *bus, uint16_t isoc_time_curr);
 uint16_t usb2_fs_isoc_schedule_isoc_time_expand(struct usb2_device *udev, struct usb2_fs_isoc_schedule **pp_start, struct usb2_fs_isoc_schedule **pp_end, uint16_t isoc_time);
 uint8_t	usb2_fs_isoc_schedule_alloc(struct usb2_fs_isoc_schedule *fss, uint8_t *pstart, uint16_t len);

Modified: head/sys/dev/usb2/controller/uss820dci.c
==============================================================================
--- head/sys/dev/usb2/controller/uss820dci.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/uss820dci.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -39,14 +39,11 @@
 #include <dev/usb2/include/usb2_defs.h>
 
 #define	USB_DEBUG_VAR uss820dcidebug
-#define	usb2_config_td_cc uss820dci_config_copy
-#define	usb2_config_td_softc uss820dci_softc
 
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_debug.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_transfer.h>
 #include <dev/usb2/core/usb2_device.h>
@@ -98,7 +95,6 @@ static void	uss820dci_update_shared_1(st
 
 static usb2_sw_transfer_func_t uss820dci_root_intr_done;
 static usb2_sw_transfer_func_t uss820dci_root_ctrl_done;
-static usb2_config_td_command_t uss820dci_root_ctrl_task;
 
 /*
  * Here is a list of what the USS820D chip can support. The main
@@ -1832,15 +1828,13 @@ uss820dci_root_ctrl_start(struct usb2_xf
 
 	sc->sc_root_ctrl.xfer = xfer;
 
-	usb2_config_td_queue_command(
-	    &sc->sc_config_td, NULL, &uss820dci_root_ctrl_task, 0, 0);
+	usb2_bus_roothub_exec(xfer->udev->bus);
 }
 
 static void
-uss820dci_root_ctrl_task(struct uss820dci_softc *sc,
-    struct uss820dci_config_copy *cc, uint16_t refcount)
+uss820dci_root_ctrl_task(struct usb2_bus *bus)
 {
-	uss820dci_root_ctrl_poll(sc);
+	uss820dci_root_ctrl_poll(USS820_DCI_BUS2SC(bus));
 }
 
 static void
@@ -2496,4 +2490,5 @@ struct usb2_bus_methods uss820dci_bus_me
 	.get_hw_ep_profile = &uss820dci_get_hw_ep_profile,
 	.set_stall = &uss820dci_set_stall,
 	.clear_stall = &uss820dci_clear_stall,
+	.roothub_exec = &uss820dci_root_ctrl_task,
 };

Modified: head/sys/dev/usb2/controller/uss820dci.h
==============================================================================
--- head/sys/dev/usb2/controller/uss820dci.h	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/uss820dci.h	Tue Jan 13 19:03:01 2009	(r187172)
@@ -347,7 +347,6 @@ struct uss820dci_softc {
 	LIST_HEAD(, usb2_xfer) sc_interrupt_list_head;
 	struct usb2_sw_transfer sc_root_ctrl;
 	struct usb2_sw_transfer sc_root_intr;
-	struct usb2_config_td sc_config_td;
 
 	struct usb2_device *sc_devices[USS820_MAX_DEVICES];
 	struct resource *sc_io_res;

Modified: head/sys/dev/usb2/controller/uss820dci_atmelarm.c
==============================================================================
--- head/sys/dev/usb2/controller/uss820dci_atmelarm.c	Tue Jan 13 19:02:50 2009	(r187171)
+++ head/sys/dev/usb2/controller/uss820dci_atmelarm.c	Tue Jan 13 19:03:01 2009	(r187172)
@@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/core/usb2_core.h>
 #include <dev/usb2/core/usb2_busdma.h>
 #include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
 #include <dev/usb2/core/usb2_sw_transfer.h>
 #include <dev/usb2/core/usb2_util.h>
 
@@ -175,12 +174,6 @@ uss820_atmelarm_attach(device_t dev)
 	}
 	device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
 
-	err = usb2_config_td_setup(&sc->sc_config_td, sc,
-	    &sc->sc_bus.bus_mtx, NULL, 0, 4);
-	if (err) {
-		device_printf(dev, "could not setup config thread!\n");
-		goto error;
-	}
 #if (__FreeBSD_version >= 700031)
 	err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
 	    NULL, (void *)uss820dci_interrupt, sc, &sc->sc_intr_hdl);
@@ -244,8 +237,6 @@ uss820_atmelarm_detach(device_t dev)
 		    sc->sc_io_res);
 		sc->sc_io_res = NULL;
 	}
-	usb2_config_td_unsetup(&sc->sc_config_td);
-
 	usb2_bus_mem_free_all(&sc->sc_bus, NULL);
 
 	return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901131903.n0DJ31oX012408>