From owner-p4-projects@FreeBSD.ORG Mon Feb 2 23:13:11 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8A1D81065675; Mon, 2 Feb 2009 23:13:11 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 467BF1065670 for ; Mon, 2 Feb 2009 23:13:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 323C78FC1A for ; Mon, 2 Feb 2009 23:13:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n12NDBMi085843 for ; Mon, 2 Feb 2009 23:13:11 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n12NDBeb085841 for perforce@freebsd.org; Mon, 2 Feb 2009 23:13:11 GMT (envelope-from hselasky@FreeBSD.org) Date: Mon, 2 Feb 2009 23:13:11 GMT Message-Id: <200902022313.n12NDBeb085841@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 157069 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Feb 2009 23:13:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=157069 Change 157069 by hselasky@hselasky_laptop001 on 2009/02/02 23:12:27 Integrate USB serial patches from Andrew Thompson. The changes are mostly about refactoring the code, renaming fields, and preparing for tasqueue conversion of usb2_proc_xxx() . Change "usb2_pause_mtx" so that it takes the timeout value in ticks instead of milliseconds, hence this is more close to the behaviour of pause() . Propagate this change to the rest of the USB code. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/controller/at91dci.c#26 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/at91dci_atmelarm.c#20 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/atmegadci.c#4 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.c#29 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/ehci2_pci.c#24 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/musb2_otg.c#25 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/ohci2.c#26 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.c#27 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/uss820dci.c#22 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#50 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#37 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_msctest.c#17 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_process.c#15 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_process.h#7 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_request.c#31 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_transfer.c#41 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_util.c#11 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_util.h#7 edit .. //depot/projects/usb/src/sys/dev/usb2/misc/ufm2.c#11 edit .. //depot/projects/usb/src/sys/dev/usb2/serial/uipaq2.c#18 edit .. //depot/projects/usb/src/sys/dev/usb2/serial/usb2_serial.c#23 edit .. //depot/projects/usb/src/sys/dev/usb2/serial/usb2_serial.h#12 edit .. //depot/projects/usb/src/sys/dev/usb2/sound/uaudio2.c#27 edit .. //depot/projects/usb/src/sys/dev/usb2/storage/umass2.c#26 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/controller/at91dci.c#26 (text+ko) ==== @@ -275,7 +275,7 @@ 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 @@ (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 */ ==== //depot/projects/usb/src/sys/dev/usb2/controller/at91dci_atmelarm.c#20 (text+ko) ==== @@ -168,7 +168,7 @@ 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"); ==== //depot/projects/usb/src/sys/dev/usb2/controller/atmegadci.c#4 (text+ko) ==== @@ -221,7 +221,7 @@ 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 @@ (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, ==== //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.c#29 (text+ko) ==== @@ -177,7 +177,7 @@ 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 @@ 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) @@ -479,7 +479,7 @@ EOWRITE4(sc, EHCI_CONFIGFLAG, EHCI_CONF_CF); for (i = 0; i < 100; i++) { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH; if (!hcr) { break; @@ -516,7 +516,7 @@ DPRINTF("reset failed!\n"); } /* XXX let stray task complete */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 50); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 20); USB_BUS_UNLOCK(&sc->sc_bus); @@ -553,7 +553,7 @@ 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) { @@ -567,7 +567,7 @@ 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) { @@ -611,7 +611,7 @@ 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)); @@ -629,16 +629,17 @@ 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); } @@ -3216,9 +3217,9 @@ /* 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 | @@ -3227,9 +3228,9 @@ /* 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: @@ -3385,7 +3386,7 @@ } 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. */ @@ -3398,7 +3399,7 @@ } 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); ==== //depot/projects/usb/src/sys/dev/usb2/controller/ehci2_pci.c#24 (text+ko) ==== @@ -455,7 +455,7 @@ "timed out waiting for BIOS\n"); break; } - usb2_pause_mtx(NULL, 10); /* wait 10ms */ + usb2_pause_mtx(NULL, hz / 100); /* wait 10ms */ } } } ==== //depot/projects/usb/src/sys/dev/usb2/controller/musb2_otg.c#25 (text+ko) ==== @@ -223,7 +223,7 @@ 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 @@ (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_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); ==== //depot/projects/usb/src/sys/dev/usb2/controller/ohci2.c#26 (text+ko) ==== @@ -168,7 +168,7 @@ 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(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); ctl = OREAD4(sc, OHCI_CONTROL); } if (ctl & OHCI_IR) { @@ -182,7 +182,7 @@ reset: /* controller was cold started */ usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_BUS_RESET_DELAY); + USB_MS_TO_TICKS(USB_BUS_RESET_DELAY)); } /* @@ -193,7 +193,7 @@ OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET); usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_BUS_RESET_DELAY); + 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)); @@ -256,7 +256,7 @@ OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca | OHCI_NOCP); OWRITE4(sc, OHCI_RH_STATUS, OHCI_LPSC); /* Enable port power */ usb2_pause_mtx(&sc->sc_bus.bus_mtx, - OHCI_ENABLE_POWER_DELAY); + USB_MS_TO_TICKS(OHCI_ENABLE_POWER_DELAY)); OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca); /* @@ -266,7 +266,7 @@ sc->sc_noport = 0; for (i = 0; (i < 10) && (sc->sc_noport == 0); i++) { usb2_pause_mtx(&sc->sc_bus.bus_mtx, - OHCI_READ_DESC_DELAY); + USB_MS_TO_TICKS(OHCI_READ_DESC_DELAY)); sc->sc_noport = OHCI_GET_NDP(OREAD4(sc, OHCI_RH_DESCRIPTOR_A)); } @@ -425,10 +425,10 @@ OWRITE4(sc, OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS); OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET); + USB_BUS_UNLOCK(&sc->sc_bus); + /* XXX let stray task complete */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 50); - - USB_BUS_UNLOCK(&sc->sc_bus); + usb2_pause_mtx(NULL, hz / 20); usb2_callout_drain(&sc->sc_tmo_rhsc); } @@ -463,7 +463,7 @@ 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); } @@ -494,10 +494,12 @@ 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); @@ -2410,7 +2412,7 @@ 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) { ==== //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.c#27 (text+ko) ==== @@ -271,7 +271,7 @@ /* 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 @@ 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 @@ 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 @@ 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 */ @@ -638,7 +638,8 @@ 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); } @@ -657,7 +658,7 @@ 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 */ @@ -2410,7 +2411,7 @@ 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); } } @@ -2422,7 +2423,7 @@ 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", @@ -2455,7 +2456,7 @@ 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); @@ -2782,9 +2783,9 @@ /* 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 */ @@ -2792,7 +2793,7 @@ 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); ==== //depot/projects/usb/src/sys/dev/usb2/controller/uss820dci.c#22 (text+ko) ==== @@ -1335,7 +1335,7 @@ 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); ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#50 (text+ko) ==== @@ -1401,7 +1401,8 @@ "(ignored)\n", udev->address); } /* allow device time to set new address */ - usb2_pause_mtx(&Giant, USB_SET_ADDRESS_SETTLE); + usb2_pause_mtx(&Giant, + USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE)); } else { /* We are not self powered */ udev->flags.self_powered = 0; ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#37 (text+ko) ==== @@ -335,7 +335,8 @@ /* wait for maximum device power up time */ - usb2_pause_mtx(&Giant, USB_PORT_POWERUP_DELAY); + usb2_pause_mtx(&Giant, + USB_MS_TO_TICKS(USB_PORT_POWERUP_DELAY)); /* reset port, which implies enabling it */ @@ -736,7 +737,7 @@ goto error; } /* wait with power off for a while */ - usb2_pause_mtx(&Giant, USB_POWER_DOWN_TIME); + usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(USB_POWER_DOWN_TIME)); /* * To have the best chance of success we do things in the exact same @@ -794,7 +795,7 @@ portno); /* wait for stable power */ - usb2_pause_mtx(&Giant, pwrdly); + usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(pwrdly)); } device_printf(dev, "%d port%s with %d " @@ -1666,7 +1667,7 @@ return; } /* resume settle time */ - usb2_pause_mtx(&Giant, USB_PORT_RESUME_DELAY); + usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(USB_PORT_RESUME_DELAY)); if (bus->methods->device_resume != NULL) { /* resume USB device on the USB controller */ @@ -1802,7 +1803,7 @@ /* do DMA delay */ temp = usb2_get_dma_delay(udev->bus); - usb2_pause_mtx(&Giant, temp); + usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(temp)); } /* suspend current port */ ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_msctest.c#17 (text+ko) ==== @@ -562,7 +562,7 @@ goto done; } } else if ((err != 2) && --timeout) { - usb2_pause_mtx(&sc->mtx, USB_MS_HZ); + usb2_pause_mtx(&sc->mtx, hz); goto repeat_inquiry; } err = USB_ERR_INVAL; ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_process.c#15 (text+ko) ==== @@ -176,8 +176,9 @@ * 0: success * Else: failure *------------------------------------------------------------------------*/ -uint8_t -usb2_proc_setup(struct usb2_process *up, struct mtx *p_mtx, uint8_t prio) +int +usb2_proc_create(struct usb2_process *up, struct mtx *p_mtx, + const char *pmesg, uint8_t prio) { up->up_mtx = p_mtx; up->up_prio = prio; @@ -188,7 +189,7 @@ usb2_cv_init(&up->up_drain, "dmsg"); if (USB_THREAD_CREATE(&usb2_process, up, - &up->up_ptr, "usbproc")) { + &up->up_ptr, pmesg)) { DPRINTFN(0, "Unable to create USB process."); up->up_ptr = NULL; goto error; @@ -197,7 +198,13 @@ error: usb2_proc_unsetup(up); - return (1); + return (ENOMEM); +} + +uint8_t +usb2_proc_setup(struct usb2_process *up, struct mtx *p_mtx, uint8_t prio) +{ + return (usb2_proc_create(up, p_mtx, "usbproc", prio) ? 1 : 0); } /*------------------------------------------------------------------------* @@ -225,6 +232,12 @@ up->up_mtx = NULL; } +void +usb2_proc_free(struct usb2_process *up) +{ + usb2_proc_unsetup(up); +} + /*------------------------------------------------------------------------* * usb2_proc_msignal * ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_process.h#7 (text+ko) ==== @@ -81,10 +81,13 @@ uint8_t usb2_proc_is_gone(struct usb2_process *up); uint8_t usb2_proc_setup(struct usb2_process *up, struct mtx *p_mtx, uint8_t prio); +int usb2_proc_create(struct usb2_process *up, struct mtx *p_mtx, + const char *pmesg, uint8_t prio); void usb2_proc_csignal(struct usb2_process *up); void usb2_proc_drain(struct usb2_process *up); void usb2_proc_mwait(struct usb2_process *up, void *pm0, void *pm1); void usb2_proc_unsetup(struct usb2_process *up); +void usb2_proc_free(struct usb2_process *up); void *usb2_proc_msignal(struct usb2_process *up, void *pm0, void *pm1); #endif /* _USB2_PROCESS_H_ */ ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_request.c#31 (text+ko) ==== @@ -371,7 +371,7 @@ if (temp > 0) { usb2_pause_mtx( xfer->xroot->xfer_mtx, - temp); + USB_MS_TO_TICKS(temp)); } #endif xfer->flags.manual_status = 0; @@ -520,11 +520,11 @@ while (1) { #if USB_DEBUG /* wait for the device to recover from reset */ - usb2_pause_mtx(mtx, pr_poll_delay); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(pr_poll_delay)); n += pr_poll_delay; #else /* wait for the device to recover from reset */ - usb2_pause_mtx(mtx, USB_PORT_RESET_DELAY); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_DELAY)); n += USB_PORT_RESET_DELAY; #endif err = usb2_req_get_port_status(udev, mtx, &ps, port); @@ -559,10 +559,10 @@ } #if USB_DEBUG /* wait for the device to recover from reset */ - usb2_pause_mtx(mtx, pr_recovery_delay); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(pr_recovery_delay)); #else /* wait for the device to recover from reset */ - usb2_pause_mtx(mtx, USB_PORT_RESET_RECOVERY); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_RECOVERY)); #endif done: @@ -624,7 +624,7 @@ } retries--; - usb2_pause_mtx(mtx, 200); + usb2_pause_mtx(mtx, hz / 5); continue; } @@ -1369,7 +1369,7 @@ udev->address = old_addr; /* allow device time to set new address */ - usb2_pause_mtx(mtx, USB_SET_ADDRESS_SETTLE); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE)); /* get the device descriptor */ err = usb2_req_get_desc(udev, mtx, &udev->ddesc, @@ -1389,7 +1389,7 @@ done: if (err && do_retry) { /* give the USB firmware some time to load */ - usb2_pause_mtx(mtx, 500); + usb2_pause_mtx(mtx, hz / 2); /* no more retries after this retry */ do_retry = 0; /* try again */ ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_transfer.c#41 (text+ko) ==== @@ -1066,7 +1066,8 @@ if (needs_delay) { temp = usb2_get_dma_delay(info->bus); - usb2_pause_mtx(&info->bus->bus_mtx, temp); + usb2_pause_mtx(&info->bus->bus_mtx, + USB_MS_TO_TICKS(temp)); } /* make sure that our done messages are not queued anywhere */ ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_util.c#11 (text+ko) ==== @@ -124,36 +124,37 @@ /*------------------------------------------------------------------------* * usb2_pause_mtx - factored out code * - * This function will delay the code by the passed number of - * milliseconds. The passed mutex "mtx" will be dropped while waiting, - * if "mtx" is not NULL. The number of milliseconds per second is 1024 - * for sake of optimisation. + * This function will delay the code by the passed number of system + * ticks. The passed mutex "mtx" will be dropped while waiting, if + * "mtx" is not NULL. *------------------------------------------------------------------------*/ void -usb2_pause_mtx(struct mtx *mtx, uint32_t ms) +usb2_pause_mtx(struct mtx *mtx, int _ticks) { + if (mtx != NULL) + mtx_unlock(mtx); + if (cold) { - ms = (ms + 1) * 1024; - DELAY(ms); + /* convert to milliseconds */ + _ticks = (_ticks * 1000) / hz; + /* convert to microseconds, rounded up */ + _ticks = (_ticks + 1) * 1000; + DELAY(_ticks); } else { - ms = USB_MS_TO_TICKS(ms); /* * Add one to the number of ticks so that we don't return * too early! */ - ms++; + _ticks++; - if (mtx != NULL) - mtx_unlock(mtx); - - if (pause("USBWAIT", ms)) { + if (pause("USBWAIT", _ticks)) { /* ignore */ } - if (mtx != NULL) - mtx_lock(mtx); } + if (mtx != NULL) + mtx_lock(mtx); } /*------------------------------------------------------------------------* ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_util.h#7 (text+ko) ==== @@ -31,7 +31,7 @@ uint32_t usb2_get_devid(device_t dev); uint8_t usb2_make_str_desc(void *ptr, uint16_t max_len, const char *s); void device_set_usb2_desc(device_t dev); -void usb2_pause_mtx(struct mtx *mtx, uint32_t ms); +void usb2_pause_mtx(struct mtx *mtx, int _ticks); void usb2_printBCD(char *p, uint16_t p_len, uint16_t bcd); void usb2_trim_spaces(char *p); ==== //depot/projects/usb/src/sys/dev/usb2/misc/ufm2.c#11 (text+ko) ==== @@ -288,10 +288,7 @@ * Note, there's a 240ms settle time before the status * will be valid, so sleep that amount. */ - - mtx_lock(&sc->sc_mtx); - usb2_pause_mtx(&sc->sc_mtx, USB_MS_HZ / 4); - mtx_unlock(&sc->sc_mtx); + usb2_pause_mtx(NULL, hz / 4); if (ufm_do_req(sc, UFM_CMD0, 0x00, 0x24, &ret)) { ==== //depot/projects/usb/src/sys/dev/usb2/serial/uipaq2.c#18 (text+ko) ==== @@ -1149,7 +1149,7 @@ NULL, 0, NULL, 100); if (error == 0) break; - usb2_pause_mtx(NULL, 100); + usb2_pause_mtx(NULL, hz / 10); } iface_index = UIPAQ_IFACE_INDEX; ==== //depot/projects/usb/src/sys/dev/usb2/serial/usb2_serial.c#23 (text+ko) ==== @@ -67,11 +67,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* - * NOTE: all function names beginning like "usb2_com_cfg_" can only - * be called from within the config thread function ! - */ - #include #include #include @@ -110,14 +105,12 @@ static uint8_t usb2_com_units_alloc(uint32_t, uint32_t *); static void usb2_com_units_free(uint32_t, uint32_t); -static int usb2_com_attach_sub(struct usb2_com_softc *); -static void usb2_com_detach_sub(struct usb2_com_softc *); -static void usb2_com_queue_command(struct usb2_com_softc *sc, - uint8_t cmd); -static void usb2_com_wait_command(struct usb2_com_softc *sc, - uint8_t cmd); +static int usb2_com_attach_tty(struct usb2_com_softc *); +static void usb2_com_detach_tty(struct usb2_com_softc *); +static void usb2_com_queue_command(struct usb2_com_softc *, + usb2_proc_callback_t *, struct termios *pt, + struct usb2_proc_msg *t0, struct usb2_proc_msg *t1); static void usb2_com_shutdown(struct usb2_com_softc *); -static void usb2_com_start_transfers(struct usb2_com_softc *); static void usb2_com_break(struct usb2_com_softc *, uint8_t); static void usb2_com_dtr(struct usb2_com_softc *, uint8_t); static void usb2_com_rts(struct usb2_com_softc *, uint8_t); @@ -127,14 +120,14 @@ static tsw_ioctl_t usb2_com_ioctl; static tsw_modem_t usb2_com_modem; static tsw_param_t usb2_com_param; -static tsw_outwakeup_t usb2_com_start_write; +static tsw_outwakeup_t usb2_com_outwakeup; static tsw_free_t usb2_com_free; static struct ttydevsw usb2_com_class = { .tsw_flags = TF_INITLOCK | TF_CALLOUT, .tsw_open = usb2_com_open, .tsw_close = usb2_com_close, - .tsw_outwakeup = usb2_com_start_write, + .tsw_outwakeup = usb2_com_outwakeup, .tsw_ioctl = usb2_com_ioctl, .tsw_param = usb2_com_param, .tsw_modem = usb2_com_modem, @@ -221,15 +214,14 @@ * sub-units can be used to differentiate among * different types of devices. * - * The mutex pointed to by "p_mtx" is applied before all - * callbacks are called back. Also "p_mtx" must be applied - * before calling into the ucom-layer! Currently only Giant - * is supported. + * The mutex pointed to by "mtx" is applied before all + * callbacks are called back. Also "mtx" must be applied + * before calling into the ucom-layer! */ int usb2_com_attach(struct usb2_com_super_softc *ssc, struct usb2_com_softc *sc, uint32_t sub_units, void *parent, - const struct usb2_com_callback *callback, struct mtx *p_mtx) + const struct usb2_com_callback *callback, struct mtx *mtx) { uint32_t n; uint32_t root_unit; @@ -241,33 +233,39 @@ (callback == NULL)) { return (EINVAL); } + + /* XXX unit management does not really belong here */ if (usb2_com_units_alloc(sub_units, &root_unit)) { return (ENOMEM); } - if (usb2_proc_setup(&ssc->sc_config_td, p_mtx, USB_PRI_MED)) { + + error = usb2_proc_create(&ssc->sc_tq, mtx, "ucom", USB_PRI_MED); + if (error) { usb2_com_units_free(root_unit, sub_units); - return (ENOMEM); + return (error); } - for (n = 0; n < sub_units; n++, sc++) { + + for (n = 0; n != sub_units; n++, sc++) { sc->sc_unit = root_unit + n; sc->sc_local_unit = n; sc->sc_super = ssc; - sc->sc_parent_mtx = p_mtx; + sc->sc_mtx = mtx; sc->sc_parent = parent; sc->sc_callback = callback; - error = usb2_com_attach_sub(sc); + error = usb2_com_attach_tty(sc); if (error) { usb2_com_detach(ssc, sc - n, n); usb2_com_units_free(root_unit + n, sub_units - n); - break; + return (error); } sc->sc_flag |= UCOM_FLAG_ATTACHED; } - return (error); + return (0); } -/* NOTE: the following function will do nothing if +/* + * NOTE: the following function will do nothing if * the structure pointed to by "ssc" and "sc" is zero. */ void @@ -276,12 +274,12 @@ { uint32_t n; - usb2_proc_drain(&ssc->sc_config_td); + usb2_proc_drain(&ssc->sc_tq); - for (n = 0; n < sub_units; n++, sc++) { + for (n = 0; n != sub_units; n++, sc++) { if (sc->sc_flag & UCOM_FLAG_ATTACHED) { - usb2_com_detach_sub(sc); + usb2_com_detach_tty(sc); usb2_com_units_free(sc->sc_unit, 1); @@ -289,18 +287,17 @@ sc->sc_flag &= ~UCOM_FLAG_ATTACHED; } } - usb2_proc_unsetup(&ssc->sc_config_td); + usb2_proc_free(&ssc->sc_tq); } static int -usb2_com_attach_sub(struct usb2_com_softc *sc) +usb2_com_attach_tty(struct usb2_com_softc *sc) { struct tty *tp; int error = 0; - uint8_t n; char buf[32]; /* temporary TTY device name buffer */ - tp = tty_alloc(&usb2_com_class, sc, sc->sc_parent_mtx); + tp = tty_alloc(&usb2_com_class, sc, sc->sc_mtx); if (tp == NULL) { error = ENOMEM; goto done; @@ -327,45 +324,12 @@ DPRINTF("ttycreate: %s\n", buf); usb2_cv_init(&sc->sc_cv, "usb2_com"); - /* - * Set all function callback pointers for deferred COM - * operations: - */ - for (n = 0; n != 2; n++) { - sc->sc_cmds[(2*USB_COM_CFG_START_TRANSFERS) + n].hdr.pm_callback = - &usb2_com_cfg_start_transfers; - sc->sc_cmds[(2*USB_COM_CFG_OPEN) + n].hdr.pm_callback = - &usb2_com_cfg_open; - sc->sc_cmds[(2*USB_COM_CFG_CLOSE) + n].hdr.pm_callback = - &usb2_com_cfg_close; - sc->sc_cmds[(2*USB_COM_CFG_BREAK_ON) + n].hdr.pm_callback = - &usb2_com_cfg_break_on; - sc->sc_cmds[(2*USB_COM_CFG_BREAK_OFF) + n].hdr.pm_callback = - &usb2_com_cfg_break_off; - sc->sc_cmds[(2*USB_COM_CFG_DTR_ON) + n].hdr.pm_callback = - &usb2_com_cfg_dtr_on; - sc->sc_cmds[(2*USB_COM_CFG_DTR_OFF) + n].hdr.pm_callback = - &usb2_com_cfg_dtr_off; - sc->sc_cmds[(2*USB_COM_CFG_RTS_ON) + n].hdr.pm_callback = - &usb2_com_cfg_rts_on; - sc->sc_cmds[(2*USB_COM_CFG_RTS_OFF) + n].hdr.pm_callback = - &usb2_com_cfg_rts_off; - sc->sc_cmds[(2*USB_COM_CFG_STATUS_CHANGE) + n].hdr.pm_callback = - &usb2_com_cfg_status_change; - sc->sc_cmds[(2*USB_COM_CFG_PARAM) + n].hdr.pm_callback = - &usb2_com_cfg_param; - } - - /* initialise all callback pointer arguments */ - for (n = 0; n != (2*USB_COM_CFG_MAX); n++) { - sc->sc_cmds[n].cc_softc = sc; - } done: return (error); } static void -usb2_com_detach_sub(struct usb2_com_softc *sc) +usb2_com_detach_tty(struct usb2_com_softc *sc) { struct tty *tp = sc->sc_tty; >>> TRUNCATED FOR MAIL (1000 lines) <<<