From owner-p4-projects@FreeBSD.ORG Thu Jul 27 16:46:09 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5CD3616A4E1; Thu, 27 Jul 2006 16:46:09 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3583716A4DE for ; Thu, 27 Jul 2006 16:46:09 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id E2C4643D46 for ; Thu, 27 Jul 2006 16:46:08 +0000 (GMT) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6RGk8QB091886 for ; Thu, 27 Jul 2006 16:46:08 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6RGk8Ek091883 for perforce@freebsd.org; Thu, 27 Jul 2006 16:46:08 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 27 Jul 2006 16:46:08 GMT Message-Id: <200607271646.k6RGk8Ek091883@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 102572 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: Thu, 27 Jul 2006 16:46:09 -0000 http://perforce.freebsd.org/chv.cgi?CH=102572 Change 102572 by hselasky@hselasky_mini_itx on 2006/07/27 16:45:46 Make sure that STALL is cleared before starting access to BULK/INTERRUPT endpoints and not afterwards. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/ubsa.c#6 edit .. //depot/projects/usb/src/sys/dev/usb/ukbd.c#8 edit .. //depot/projects/usb/src/sys/dev/usb/ulpt.c#10 edit .. //depot/projects/usb/src/sys/dev/usb/umodem.c#8 edit .. //depot/projects/usb/src/sys/dev/usb/ums.c#8 edit .. //depot/projects/usb/src/sys/dev/usb/uplcom.c#7 edit .. //depot/projects/usb/src/sys/dev/usb/uvisor.c#6 edit .. //depot/projects/usb/src/sys/dev/usb/uvscom.c#8 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/ubsa.c#6 (text+ko) ==== @@ -742,6 +742,12 @@ ubsa_open(struct ucom_softc *ucom) { struct ubsa_softc *sc = ucom->sc_parent; + + /* clear stall first: */ + sc->sc_flag |= (UBSA_FLAG_WRITE_STALL| + UBSA_FLAG_READ_STALL| + UBSA_FLAG_INTR_STALL); + usbd_transfer_start(sc->sc_xfer[4]); return 0; } ==== //depot/projects/usb/src/sys/dev/usb/ukbd.c#8 (text+ko) ==== @@ -136,7 +136,7 @@ #define UKBD_FLAG_COMPOSE 0x0001 #define UKBD_FLAG_POLLING 0x0002 #define UKBD_FLAG_SET_LEDS 0x0004 -#define UKBD_FLAG_PIPE_ERROR 0x0008 +#define UKBD_FLAG_INTR_STALL 0x0008 #define UKBD_FLAG_ATTACHED 0x0010 #define UKBD_FLAG_GONE 0x0020 @@ -437,42 +437,29 @@ } static void -ukbd_clear_stall_callback(struct usbd_xfer *xfer1) +ukbd_clear_stall_callback(struct usbd_xfer *xfer) { - usb_device_request_t *req = xfer1->buffer; - struct ukbd_softc *sc = xfer1->priv_sc; - struct usbd_xfer *xfer0 = sc->sc_xfer[0]; + struct ukbd_softc *sc = xfer->priv_sc; + struct usbd_xfer *xfer_other = sc->sc_xfer[0]; - USBD_CHECK_STATUS(xfer1); + USBD_CHECK_STATUS(xfer); tr_setup: + /* start clear stall */ + usbd_clear_stall_tr_setup(xfer, xfer_other); + return; - /* setup a CLEAR STALL packet */ + tr_transferred: + usbd_clear_stall_tr_transferred(xfer, xfer_other); - req->bmRequestType = UT_WRITE_ENDPOINT; - req->bRequest = UR_CLEAR_FEATURE; - USETW(req->wValue, UF_ENDPOINT_HALT); - req->wIndex[0] = xfer0->pipe->edesc->bEndpointAddress; - req->wIndex[1] = 0; - USETW(req->wLength, 0); + sc->sc_flags &= ~UKBD_FLAG_INTR_STALL; + usbd_transfer_start(xfer_other); + return; - usbd_start_hardware(xfer1); - return; - tr_error: - DPRINTF(0, "error=%s\n", usbd_errstr(xfer1->error)); - - tr_transferred: - - sc->sc_flags &= ~UKBD_FLAG_PIPE_ERROR; - - if (xfer1->error != USBD_CANCELLED) { - - xfer0->pipe->clearstall = 0; - xfer0->pipe->toggle_next = 0; - - usbd_transfer_start(xfer0); - } + /* bomb out */ + sc->sc_flags &= ~UKBD_FLAG_INTR_STALL; + DPRINTF(0, "error=%s\n", usbd_errstr(xfer->error)); return; } @@ -510,12 +497,14 @@ } tr_setup: - if (!(sc->sc_flags & UKBD_FLAG_PIPE_ERROR)) { - if (sc->sc_inputs < UKBD_IN_BUF_FULL) { - usbd_start_hardware(xfer); - } else { - DPRINTF(0, "input queue is full!\n"); - } + if (sc->sc_flags & UKBD_FLAG_INTR_STALL) { + usbd_transfer_start(sc->sc_xfer[1]); + return; + } + if (sc->sc_inputs < UKBD_IN_BUF_FULL) { + usbd_start_hardware(xfer); + } else { + DPRINTF(0, "input queue is full!\n"); } return; @@ -523,10 +512,8 @@ DPRINTF(0, "error=%s\n", usbd_errstr(xfer->error)); if (xfer->error != USBD_CANCELLED) { - - /* start clear stall */ - sc->sc_flags |= UKBD_FLAG_PIPE_ERROR; - + /* try to clear stall first */ + sc->sc_flags |= UKBD_FLAG_INTR_STALL; usbd_transfer_start(sc->sc_xfer[1]); } return; @@ -718,6 +705,10 @@ genkbd_diag(kbd, bootverbose); } + /* clear stall first */ + + sc->sc_flags |= UKBD_FLAG_INTR_STALL; + /* start the keyboard */ usbd_transfer_start(sc->sc_xfer[0]); ==== //depot/projects/usb/src/sys/dev/usb/ulpt.c#10 (text+ko) ==== @@ -452,6 +452,16 @@ struct ulpt_softc *sc = cdev->sc_priv_ptr; int32_t error = 0; + if (fflags & FREAD) { + /* clear stall first */ + sc->sc_flags |= ULPT_FLAG_READ_STALL; + } + + if (fflags & FWRITE) { + /* clear stall first */ + sc->sc_flags |= ULPT_FLAG_WRITE_STALL; + } + if (prime) { DPRINTF(0, "opening prime device (reset)\n"); ==== //depot/projects/usb/src/sys/dev/usb/umodem.c#8 (text+ko) ==== @@ -536,6 +536,11 @@ DPRINTF(0, "sc=%p\n", sc); + /* clear stall first */ + sc->sc_flag |= (UMODEM_FLAG_READ_STALL| + UMODEM_FLAG_WRITE_STALL| + UMODEM_FLAG_INTR_STALL); + if (sc->sc_xfer_intr[0]) { usbd_transfer_start(sc->sc_xfer_intr[0]); } ==== //depot/projects/usb/src/sys/dev/usb/ums.c#8 (text+ko) ==== @@ -735,6 +735,10 @@ sc->sc_status.dz = 0; /* sc->sc_status.dt = 0; */ + /* clear stall first */ + + sc->sc_flags |= UMS_FLAG_INTR_STALL; + /* start interrupt transfer */ usbd_transfer_start(sc->sc_xfer[0]); ==== //depot/projects/usb/src/sys/dev/usb/uplcom.c#7 (text+ko) ==== @@ -775,6 +775,11 @@ DPRINTF(0, "sc=%p\n", sc); + /* clear stall first */ + sc->sc_flag |= (UPLCOM_FLAG_INTR_STALL| + UPLCOM_FLAG_READ_STALL| + UPLCOM_FLAG_WRITE_STALL); + usbd_transfer_start(sc->sc_xfer_intr[0]); return (0); ==== //depot/projects/usb/src/sys/dev/usb/uvisor.c#6 (text+ko) ==== @@ -184,6 +184,9 @@ usbd_status uvisor_init(struct uvisor_softc *sc, struct usbd_device *udev, struct usbd_config *config); +static int +uvisor_open(struct ucom_softc *ucom); + static void uvisor_close(struct ucom_softc *ucom); @@ -264,6 +267,7 @@ }; static const struct ucom_callback uvisor_callback = { + .ucom_open = &uvisor_open, .ucom_close = &uvisor_close, .ucom_start_read = &uvisor_start_read, .ucom_stop_read = &uvisor_stop_read, @@ -589,6 +593,17 @@ return err; } +static int +uvisor_open(struct ucom_softc *ucom) +{ + struct uvisor_softc *sc = ucom->sc_parent; + + /* clear stall first */ + sc->sc_flag |= (UVISOR_FLAG_WRITE_STALL| + UVISOR_FLAG_READ_STALL); + return 0; +} + static void uvisor_close(struct ucom_softc *ucom) { ==== //depot/projects/usb/src/sys/dev/usb/uvscom.c#8 (text+ko) ==== @@ -473,6 +473,10 @@ goto detach; } + /* clear stall first */ + + sc->sc_flag |= UVSCOM_FLAG_INTR_STALL; + /* start interrupt pipe */ usbd_transfer_start(sc->sc_xfer[4]); @@ -971,7 +975,10 @@ DPRINTF(0, "sc = %p\n", sc); - sc->sc_flag |= UVSCOM_FLAG_OPEN; + /* clear stall first */ + sc->sc_flag |= (UVSCOM_FLAG_OPEN| + UVSCOM_FLAG_WRITE_STALL| + UVSCOM_FLAG_READ_STALL); /* check if PC card was inserted */