Author: thompsa
Date: Mon Feb  9 21:47:39 2009
New Revision: 188409
URL: http://svn.freebsd.org/changeset/base/188409

Log:
  MFp4 //depot/projects/usb; 157069,157296,157375,157384,157430
  
   - Change "usb2_pause_mtx" so that it takes the timeout value in ticks
   - USB controller: EHCI High Speed Interrupt endpoint fix.
   - Fix OHCI and EHCI counting bug when multiple TD's are involved in
     a short USB transfer and a short packet happens on the non-last TD in the
     USB transfer frame.
   - USB process naming cleanup.
  
  Submitted by: Hans Petter Selasky

Modified:
  head/sys/dev/usb2/controller/at91dci.c
  head/sys/dev/usb2/controller/at91dci_atmelarm.c
  head/sys/dev/usb2/controller/atmegadci.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/ohci2.c
  head/sys/dev/usb2/controller/uhci2.c
  head/sys/dev/usb2/controller/usb2_controller.c
  head/sys/dev/usb2/controller/uss820dci.c

Modified: head/sys/dev/usb2/controller/at91dci.c
==============================================================================
--- head/sys/dev/usb2/controller/at91dci.c      Mon Feb  9 21:34:06 2009        
(r188408)
+++ head/sys/dev/usb2/controller/at91dci.c      Mon Feb  9 21:47:39 2009        
(r188409)
@@ -275,7 +275,7 @@ at91dci_wakeup_peer(struct usb2_xfer *xf
                DELAY(8000);
        } else {
                /* Wait for reset to complete. */
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 8);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
        }
 
        AT91_UDP_WRITE_4(sc, AT91_UDP_GSTATE, 0);
@@ -1395,7 +1395,7 @@ at91dci_init(struct at91dci_softc *sc)
                (sc->sc_clocks_on) (sc->sc_clocks_arg);
        }
        /* wait a little for things to stabilise */
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+       usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
 
        /* disable and clear all interrupts */
 

Modified: head/sys/dev/usb2/controller/at91dci_atmelarm.c
==============================================================================
--- head/sys/dev/usb2/controller/at91dci_atmelarm.c     Mon Feb  9 21:34:06 
2009        (r188408)
+++ head/sys/dev/usb2/controller/at91dci_atmelarm.c     Mon Feb  9 21:47:39 
2009        (r188409)
@@ -168,7 +168,7 @@ at91_udp_attach(device_t dev)
        at91_udp_pull_down(sc);
 
        /* wait 10ms for pulldown to stabilise */
-       usb2_pause_mtx(NULL, 10);
+       usb2_pause_mtx(NULL, hz / 100);
 
        sc->sc_iclk = at91_pmc_clock_ref("udc_clk");
        sc->sc_fclk = at91_pmc_clock_ref("udpck");

Modified: head/sys/dev/usb2/controller/atmegadci.c
==============================================================================
--- head/sys/dev/usb2/controller/atmegadci.c    Mon Feb  9 21:34:06 2009        
(r188408)
+++ head/sys/dev/usb2/controller/atmegadci.c    Mon Feb  9 21:47:39 2009        
(r188409)
@@ -221,7 +221,7 @@ atmegadci_wakeup_peer(struct usb2_xfer *
                DELAY(8000);
        } else {
                /* Wait for reset to complete. */
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 8);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
        }
 
        /* hardware should have cleared RMWKUP bit */
@@ -1253,7 +1253,7 @@ atmegadci_init(struct atmegadci_softc *s
        (sc->sc_clocks_on) (&sc->sc_bus);
 
        /* wait a little for things to stabilise */
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+       usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
 
        /* enable interrupts */
        ATMEGA_WRITE_1(sc, ATMEGA_UDIEN,

Modified: head/sys/dev/usb2/controller/ehci2.c
==============================================================================
--- head/sys/dev/usb2/controller/ehci2.c        Mon Feb  9 21:34:06 2009        
(r188408)
+++ head/sys/dev/usb2/controller/ehci2.c        Mon Feb  9 21:47:39 2009        
(r188409)
@@ -177,7 +177,7 @@ ehci_hc_reset(ehci_softc_t *sc)
        EOWRITE4(sc, EHCI_USBCMD, 0);   /* Halt controller */
 
        for (n = 0; n != 100; n++) {
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
                hcr = EOREAD4(sc, EHCI_USBSTS);
                if (hcr & EHCI_STS_HCH) {
                        hcr = 0;
@@ -193,7 +193,7 @@ ehci_hc_reset(ehci_softc_t *sc)
 
        EOWRITE4(sc, EHCI_USBCMD, EHCI_CMD_HCRESET);
        for (n = 0; n != 100; n++) {
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
                hcr = EOREAD4(sc, EHCI_USBCMD);
                if (!(hcr & EHCI_CMD_HCRESET)) {
                        if (sc->sc_flags & EHCI_SCFLG_SETMODE)
@@ -478,7 +478,7 @@ ehci_init(ehci_softc_t *sc)
        EOWRITE4(sc, EHCI_CONFIGFLAG, EHCI_CONF_CF);
 
        for (i = 0; i < 100; i++) {
-               usb2_pause_mtx(NULL, 1);
+               usb2_pause_mtx(NULL, hz / 1000);
                hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH;
                if (!hcr) {
                        break;
@@ -511,11 +511,12 @@ ehci_detach(ehci_softc_t *sc)
        if (ehci_hc_reset(sc)) {
                DPRINTF("reset failed!\n");
        }
-       /* XXX let stray task complete */
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 50);
 
        USB_BUS_UNLOCK(&sc->sc_bus);
 
+       /* XXX let stray task complete */
+       usb2_pause_mtx(NULL, hz / 20);
+
        usb2_callout_drain(&sc->sc_tmo_pcd);
 }
 
@@ -549,7 +550,7 @@ ehci_suspend(ehci_softc_t *sc)
                if (hcr == 0) {
                        break;
                }
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
        }
 
        if (hcr != 0) {
@@ -563,7 +564,7 @@ ehci_suspend(ehci_softc_t *sc)
                if (hcr == EHCI_STS_HCH) {
                        break;
                }
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
        }
 
        if (hcr != EHCI_STS_HCH) {
@@ -607,7 +608,7 @@ ehci_resume(ehci_softc_t *sc)
 
        if (hcr) {
                usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-                   USB_RESUME_WAIT);
+                   USB_MS_TO_TICKS(USB_RESUME_WAIT));
 
                for (i = 1; i <= sc->sc_noport; i++) {
                        cmd = EOREAD4(sc, EHCI_PORTSC(i));
@@ -625,16 +626,17 @@ ehci_resume(ehci_softc_t *sc)
                if (hcr != EHCI_STS_HCH) {
                        break;
                }
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
        }
        if (hcr == EHCI_STS_HCH) {
                device_printf(sc->sc_bus.bdev, "config timeout\n");
        }
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-           USB_RESUME_WAIT);
 
        USB_BUS_UNLOCK(&sc->sc_bus);
 
+       usb2_pause_mtx(NULL,
+           USB_MS_TO_TICKS(USB_RESUME_WAIT));
+
        /* catch any lost interrupts */
        ehci_do_poll(&sc->sc_bus);
 }
@@ -1140,6 +1142,9 @@ ehci_non_isoc_done_sub(struct usb2_xfer 
        td = xfer->td_transfer_cache;
        td_alt_next = td->alt_next;
 
+       if (xfer->aframes != xfer->nframes) {
+               xfer->frlengths[xfer->aframes] = 0;
+       }
        while (1) {
 
                usb2_pc_cpu_invalidate(td->page_cache);
@@ -1148,8 +1153,8 @@ ehci_non_isoc_done_sub(struct usb2_xfer 
                len = EHCI_QTD_GET_BYTES(status);
 
                /*
-                * Verify the status length and subtract
-                * the remainder from "frlengths[]":
+                * Verify the status length and
+                * add the length to "frlengths[]":
                 */
                if (len > td->len) {
                        /* should not happen */
@@ -1157,7 +1162,7 @@ ehci_non_isoc_done_sub(struct usb2_xfer 
                            "0x%04x/0x%04x bytes\n", len, td->len);
                        status |= EHCI_QTD_HALTED;
                } else if (xfer->aframes != xfer->nframes) {
-                       xfer->frlengths[xfer->aframes] -= len;
+                       xfer->frlengths[xfer->aframes] += td->len - len;
                }
                /* Check for last transfer */
                if (((void *)td) == xfer->td_transfer_last) {
@@ -3214,9 +3219,9 @@ ehci_root_ctrl_done(struct usb2_xfer *xf
                        /* wait 20ms for resume sequence to complete */
                        if (use_polling) {
                                /* polling */
-                               DELAY(20 * 1000);
+                               DELAY(20000);
                        } else {
-                               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 20);
+                               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50);
                        }
 
                        EOWRITE4(sc, port, v & ~(EHCI_PS_SUSP |
@@ -3225,9 +3230,9 @@ ehci_root_ctrl_done(struct usb2_xfer *xf
                        /* settle time */
                        if (use_polling) {
                                /* polling */
-                               DELAY(4 * 1000);
+                               DELAY(4000);
                        } else {
-                               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 4);
+                               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 250);
                        }
                        break;
                case UHF_PORT_POWER:
@@ -3383,7 +3388,7 @@ ehci_root_ctrl_done(struct usb2_xfer *xf
                        } else {
                                /* Wait for reset to complete. */
                                usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-                                   USB_PORT_ROOT_RESET_DELAY);
+                                   USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
                        }
 
                        /* Terminate reset sequence. */
@@ -3396,7 +3401,7 @@ ehci_root_ctrl_done(struct usb2_xfer *xf
                        } else {
                                /* Wait for HC to complete reset. */
                                usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-                                   EHCI_PORT_RESET_COMPLETE);
+                                   USB_MS_TO_TICKS(EHCI_PORT_RESET_COMPLETE));
                        }
 
                        v = EOREAD4(sc, port);

Modified: head/sys/dev/usb2/controller/ehci2.h
==============================================================================
--- head/sys/dev/usb2/controller/ehci2.h        Mon Feb  9 21:34:06 2009        
(r188408)
+++ head/sys/dev/usb2/controller/ehci2.h        Mon Feb  9 21:47:39 2009        
(r188409)
@@ -468,7 +468,6 @@ typedef struct ehci_softc {
        struct ehci_sitd *sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT];
        struct ehci_itd *sc_isoc_hs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT];
        void   *sc_intr_hdl;
-       device_t sc_dev;
        bus_size_t sc_io_size;
        bus_space_tag_t sc_io_tag;
        bus_space_handle_t sc_io_hdl;

Modified: head/sys/dev/usb2/controller/ehci2_pci.c
==============================================================================
--- head/sys/dev/usb2/controller/ehci2_pci.c    Mon Feb  9 21:34:06 2009        
(r188408)
+++ head/sys/dev/usb2/controller/ehci2_pci.c    Mon Feb  9 21:47:39 2009        
(r188409)
@@ -237,7 +237,6 @@ ehci_pci_attach(device_t self)
            USB_GET_DMA_TAG(self), &ehci_iterate_hw_softc)) {
                return (ENOMEM);
        }
-       sc->sc_dev = self;
 
        pci_enable_busmaster(self);
 
@@ -456,7 +455,7 @@ ehci_pci_takecontroller(device_t self)
                                    "timed out waiting for BIOS\n");
                                break;
                        }
-                       usb2_pause_mtx(NULL, 10);       /* wait 10ms */
+                       usb2_pause_mtx(NULL, hz / 100); /* wait 10ms */
                }
        }
 }

Modified: head/sys/dev/usb2/controller/musb2_otg.c
==============================================================================
--- head/sys/dev/usb2/controller/musb2_otg.c    Mon Feb  9 21:34:06 2009        
(r188408)
+++ head/sys/dev/usb2/controller/musb2_otg.c    Mon Feb  9 21:47:39 2009        
(r188409)
@@ -223,7 +223,7 @@ musbotg_wakeup_peer(struct usb2_xfer *xf
                DELAY(8000);
        } else {
                /* Wait for reset to complete. */
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 8);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
        }
 
        temp = MUSB2_READ_1(sc, MUSB2_REG_POWER);
@@ -1708,7 +1708,7 @@ musbotg_init(struct musbotg_softc *sc)
                (sc->sc_clocks_on) (sc->sc_clocks_arg);
        }
        /* wait a little for things to stabilise */
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+       usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
 
        /* disable all interrupts */
 
@@ -1721,7 +1721,7 @@ musbotg_init(struct musbotg_softc *sc)
        musbotg_pull_common(sc, 0);
 
        /* wait a little bit (10ms) */
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 10);
+       usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100);
 
        /* disable double packet buffering */
        MUSB2_WRITE_2(sc, MUSB2_REG_RXDBDIS, 0xFFFF);

Modified: head/sys/dev/usb2/controller/ohci2.c
==============================================================================
--- head/sys/dev/usb2/controller/ohci2.c        Mon Feb  9 21:34:06 2009        
(r188408)
+++ head/sys/dev/usb2/controller/ohci2.c        Mon Feb  9 21:47:39 2009        
(r188409)
@@ -168,7 +168,7 @@ ohci_controller_init(ohci_softc_t *sc)
                DPRINTF("SMM active, request owner change\n");
                OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_OCR);
                for (i = 0; (i < 100) && (ctl & OHCI_IR); i++) {
-                       usb2_pause_mtx(NULL, 1);
+                       usb2_pause_mtx(NULL, hz / 1000);
                        ctl = OREAD4(sc, OHCI_CONTROL);
                }
                if (ctl & OHCI_IR) {
@@ -181,7 +181,8 @@ ohci_controller_init(ohci_softc_t *sc)
                DPRINTF("cold started\n");
 reset:
                /* controller was cold started */
-               usb2_pause_mtx(NULL, USB_BUS_RESET_DELAY);
+               usb2_pause_mtx(NULL,
+                   USB_MS_TO_TICKS(USB_BUS_RESET_DELAY));
        }
 
        /*
@@ -191,7 +192,8 @@ reset:
        DPRINTF("%s: resetting\n", device_get_nameunit(sc->sc_bus.bdev));
        OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET);
 
-       usb2_pause_mtx(NULL, USB_BUS_RESET_DELAY);
+       usb2_pause_mtx(NULL,
+           USB_MS_TO_TICKS(USB_BUS_RESET_DELAY));
 
        /* we now own the host controller and the bus has been reset */
        ival = OHCI_GET_IVAL(OREAD4(sc, OHCI_FM_INTERVAL));
@@ -253,7 +255,8 @@ reset:
        desca = OREAD4(sc, OHCI_RH_DESCRIPTOR_A);
        OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca | OHCI_NOCP);
        OWRITE4(sc, OHCI_RH_STATUS, OHCI_LPSC); /* Enable port power */
-       usb2_pause_mtx(NULL, OHCI_ENABLE_POWER_DELAY);
+       usb2_pause_mtx(NULL,
+           USB_MS_TO_TICKS(OHCI_ENABLE_POWER_DELAY));
        OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca);
 
        /*
@@ -262,7 +265,8 @@ reset:
         */
        sc->sc_noport = 0;
        for (i = 0; (i < 10) && (sc->sc_noport == 0); i++) {
-               usb2_pause_mtx(NULL, OHCI_READ_DESC_DELAY);
+               usb2_pause_mtx(NULL,
+                   USB_MS_TO_TICKS(OHCI_READ_DESC_DELAY));
                sc->sc_noport = OHCI_GET_NDP(OREAD4(sc, OHCI_RH_DESCRIPTOR_A));
        }
 
@@ -417,11 +421,11 @@ ohci_detach(struct ohci_softc *sc)
        OWRITE4(sc, OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS);
        OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET);
 
-       /* XXX let stray task complete */
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 50);
-
        USB_BUS_UNLOCK(&sc->sc_bus);
 
+       /* XXX let stray task complete */
+       usb2_pause_mtx(NULL, hz / 20);
+
        usb2_callout_drain(&sc->sc_tmo_rhsc);
 }
 
@@ -455,7 +459,7 @@ ohci_suspend(ohci_softc_t *sc)
        OWRITE4(sc, OHCI_CONTROL, ctl);
 
        usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-           USB_RESUME_WAIT);
+           USB_MS_TO_TICKS(USB_RESUME_WAIT));
 
        USB_BUS_UNLOCK(&sc->sc_bus);
 }
@@ -485,10 +489,12 @@ ohci_resume(ohci_softc_t *sc)
                ctl = OREAD4(sc, OHCI_CONTROL);
        ctl |= OHCI_HCFS_RESUME;
        OWRITE4(sc, OHCI_CONTROL, ctl);
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, USB_RESUME_DELAY);
+       usb2_pause_mtx(&sc->sc_bus.bus_mtx,
+           USB_MS_TO_TICKS(USB_RESUME_DELAY));
        ctl = (ctl & ~OHCI_HCFS_MASK) | OHCI_HCFS_OPERATIONAL;
        OWRITE4(sc, OHCI_CONTROL, ctl);
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, USB_RESUME_RECOVERY);
+       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 
+           USB_MS_TO_TICKS(USB_RESUME_RECOVERY));
        sc->sc_control = sc->sc_intre = 0;
 
        USB_BUS_UNLOCK(&sc->sc_bus);
@@ -827,6 +833,9 @@ ohci_non_isoc_done_sub(struct usb2_xfer 
        td_alt_next = td->alt_next;
        td_flags = 0;
 
+       if (xfer->aframes != xfer->nframes) {
+               xfer->frlengths[xfer->aframes] = 0;
+       }
        while (1) {
 
                usb2_pc_cpu_invalidate(td->page_cache);
@@ -850,10 +859,15 @@ ohci_non_isoc_done_sub(struct usb2_xfer 
                                cc = OHCI_CC_STALL;
                        } else if (xfer->aframes != xfer->nframes) {
                                /*
-                                * subtract remaining length from
-                                * "frlengths[]"
+                                * Sum up total transfer length
+                                * in "frlengths[]":
                                 */
-                               xfer->frlengths[xfer->aframes] -= temp;
+                               xfer->frlengths[xfer->aframes] += td->len - 
temp;
+                       }
+               } else {
+                       if (xfer->aframes != xfer->nframes) {
+                               /* transfer was complete */
+                               xfer->frlengths[xfer->aframes] += td->len;
                        }
                }
                /* Check for last transfer */
@@ -2401,7 +2415,7 @@ ohci_root_ctrl_done(struct usb2_xfer *xf
                                                DELAY(USB_PORT_ROOT_RESET_DELAY 
* 1000);
                                        } else {
                                                
usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-                                                   USB_PORT_ROOT_RESET_DELAY);
+                                                   
USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
                                        }
 
                                        if ((OREAD4(sc, port) & UPS_RESET) == 
0) {

Modified: head/sys/dev/usb2/controller/uhci2.c
==============================================================================
--- head/sys/dev/usb2/controller/uhci2.c        Mon Feb  9 21:34:06 2009        
(r188408)
+++ head/sys/dev/usb2/controller/uhci2.c        Mon Feb  9 21:47:39 2009        
(r188409)
@@ -271,7 +271,7 @@ uhci_reset(uhci_softc_t *sc)
        /* wait */
 
        usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-           USB_BUS_RESET_DELAY);
+           USB_MS_TO_TICKS(USB_BUS_RESET_DELAY));
 
        /* terminate all transfers */
 
@@ -283,7 +283,7 @@ uhci_reset(uhci_softc_t *sc)
        while (n--) {
                /* wait one millisecond */
 
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
 
                if (!(UREAD2(sc, UHCI_CMD) & UHCI_CMD_HCRESET)) {
                        goto done_1;
@@ -299,7 +299,7 @@ done_1:
        while (n--) {
                /* wait one millisecond */
 
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
 
                /* check if HC is stopped */
                if (UREAD2(sc, UHCI_STS) & UHCI_STS_HCH) {
@@ -345,7 +345,7 @@ uhci_start(uhci_softc_t *sc)
        while (n--) {
                /* wait one millisecond */
 
-               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
+               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
 
                /* check that controller has started */
 
@@ -636,7 +636,8 @@ uhci_suspend(uhci_softc_t *sc)
 
        UHCICMD(sc, UHCI_CMD_EGSM);
 
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, USB_RESUME_WAIT);
+       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 
+           USB_MS_TO_TICKS(USB_RESUME_WAIT));
 
        USB_BUS_UNLOCK(&sc->sc_bus);
 }
@@ -655,7 +656,7 @@ uhci_resume(uhci_softc_t *sc)
        UHCICMD(sc, UHCI_CMD_FGR);
 
        usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-           USB_RESUME_DELAY);
+           USB_MS_TO_TICKS(USB_RESUME_DELAY));
 
        /* and start traffic again */
 
@@ -2408,7 +2409,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_
                if (use_polling) {
                        DELAY(10000);
                } else {
-                       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 10);
+                       usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100);
                }
        }
 
@@ -2420,7 +2421,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_
                DELAY(USB_PORT_ROOT_RESET_DELAY * 1000);
        } else {
                usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-                   USB_PORT_ROOT_RESET_DELAY);
+                   USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY));
        }
 
        DPRINTFN(4, "uhci port %d reset, status0 = 0x%04x\n",
@@ -2453,7 +2454,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_
                        DELAY(USB_PORT_RESET_DELAY * 1000);
                } else {
                        usb2_pause_mtx(&sc->sc_bus.bus_mtx,
-                           USB_PORT_RESET_DELAY);
+                           USB_MS_TO_TICKS(USB_PORT_RESET_DELAY));
                }
 
                x = UREAD2(sc, port);
@@ -2780,9 +2781,9 @@ uhci_root_ctrl_done(struct usb2_xfer *xf
                        /* wait 20ms for resume sequence to complete */
                        if (use_polling) {
                                /* polling */
-                               DELAY(20 * 1000);
+                               DELAY(20000);
                        } else {
-                               usb2_pause_mtx(&sc->sc_bus.bus_mtx, 20);
+                               usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50);
                        }
 
                        /* clear suspend and resume detect */
@@ -2790,7 +2791,7 @@ uhci_root_ctrl_done(struct usb2_xfer *xf
                            UHCI_PORTSC_SUSP));
 
                        /* wait a little bit */
-                       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 2);
+                       usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 500);
 
                        sc->sc_isresumed |= (1 << index);
 

Modified: head/sys/dev/usb2/controller/usb2_controller.c
==============================================================================
--- head/sys/dev/usb2/controller/usb2_controller.c      Mon Feb  9 21:34:06 
2009        (r188408)
+++ head/sys/dev/usb2/controller/usb2_controller.c      Mon Feb  9 21:47:39 
2009        (r188409)
@@ -168,16 +168,16 @@ usb2_detach(device_t dev)
 
        /* Get rid of USB callback processes */
 
-       usb2_proc_unsetup(&bus->giant_callback_proc);
-       usb2_proc_unsetup(&bus->non_giant_callback_proc);
+       usb2_proc_free(&bus->giant_callback_proc);
+       usb2_proc_free(&bus->non_giant_callback_proc);
 
        /* Get rid of USB roothub process */
 
-       usb2_proc_unsetup(&bus->roothub_proc);
+       usb2_proc_free(&bus->roothub_proc);
 
        /* Get rid of USB explore process */
 
-       usb2_proc_unsetup(&bus->explore_proc);
+       usb2_proc_free(&bus->explore_proc);
 
        return (0);
 }
@@ -375,6 +375,8 @@ usb2_bus_attach(struct usb2_proc_msg *pm
 static void
 usb2_attach_sub(device_t dev, struct usb2_bus *bus)
 {
+       const char *pname = device_get_nameunit(dev);
+
        /* Initialise USB process messages */
        bus->explore_msg[0].hdr.pm_callback = &usb2_bus_explore;
        bus->explore_msg[0].bus = bus;
@@ -398,20 +400,20 @@ usb2_attach_sub(device_t dev, struct usb
 
        /* Create USB explore, roothub and callback processes */
 
-       if (usb2_proc_setup(&bus->giant_callback_proc,
-           &bus->bus_mtx, USB_PRI_MED)) {
+       if (usb2_proc_create(&bus->giant_callback_proc,
+           &bus->bus_mtx, pname, USB_PRI_MED)) {
                printf("WARNING: Creation of USB Giant "
                    "callback process failed.\n");
-       } else if (usb2_proc_setup(&bus->non_giant_callback_proc,
-           &bus->bus_mtx, USB_PRI_HIGH)) {
+       } else if (usb2_proc_create(&bus->non_giant_callback_proc,
+           &bus->bus_mtx, pname, USB_PRI_HIGH)) {
                printf("WARNING: Creation of USB non-Giant "
                    "callback process failed.\n");
-       } else if (usb2_proc_setup(&bus->roothub_proc,
-           &bus->bus_mtx, USB_PRI_HIGH)) {
+       } else if (usb2_proc_create(&bus->roothub_proc,
+           &bus->bus_mtx, pname, 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)) {
+       } else if (usb2_proc_create(&bus->explore_proc,
+           &bus->bus_mtx, pname, USB_PRI_MED)) {
                printf("WARNING: Creation of USB explore "
                    "process failed.\n");
        } else {

Modified: head/sys/dev/usb2/controller/uss820dci.c
==============================================================================
--- head/sys/dev/usb2/controller/uss820dci.c    Mon Feb  9 21:34:06 2009        
(r188408)
+++ head/sys/dev/usb2/controller/uss820dci.c    Mon Feb  9 21:47:39 2009        
(r188409)
@@ -1335,7 +1335,7 @@ uss820dci_init(struct uss820dci_softc *s
        uss820dci_pull_down(sc);
 
        /* wait 10ms for pulldown to stabilise */
-       usb2_pause_mtx(&sc->sc_bus.bus_mtx, 10);
+       usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100);
 
        /* check hardware revision */
        temp = USS820_READ_1(sc, USS820_REV);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to