Module Name:    src
Committed By:   drochner
Date:           Fri May 27 17:19:18 UTC 2011

Modified Files:
        src/sys/dev/usb: ehci.c uhci.c usb_subr.c usbdivar.h

Log Message:
remember the data toggle bit per (bulk) endpoint rather than per
pipe, as required by the spec
This helps in cases where pipes are opened/closed without reconfiguring
the device in between, eg with the ugen driver.
only for UHCI/EHCI, don't have an OHCI to test


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.235 -r1.236 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.178 -r1.179 src/sys/dev/usb/usb_subr.c
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/usb/usbdivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.174 src/sys/dev/usb/ehci.c:1.175
--- src/sys/dev/usb/ehci.c:1.174	Wed Apr 20 09:32:43 2011
+++ src/sys/dev/usb/ehci.c	Fri May 27 17:19:18 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.174 2011/04/20 09:32:43 drochner Exp $ */
+/*	$NetBSD: ehci.c,v 1.175 2011/05/27 17:19:18 drochner Exp $ */
 
 /*
  * Copyright (c) 2004-2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.174 2011/04/20 09:32:43 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.175 2011/05/27 17:19:18 drochner Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -1567,7 +1567,8 @@
 	if (sc->sc_dying)
 		return (USBD_IOERROR);
 
-	epipe->nexttoggle = 0;
+	/* toggle state needed for bulk endpoints */
+	epipe->nexttoggle = pipe->endpoint->datatoggle;
 
 	if (addr == sc->sc_addr) {
 		switch (ed->bEndpointAddress) {
@@ -3569,8 +3570,10 @@
 ehci_device_bulk_close(usbd_pipe_handle pipe)
 {
 	ehci_softc_t *sc = pipe->device->bus->hci_private;
+	struct ehci_pipe *epipe = (struct ehci_pipe *)pipe;
 
 	DPRINTF(("ehci_device_bulk_close: pipe=%p\n", pipe));
+	pipe->endpoint->datatoggle = epipe->nexttoggle;
 	ehci_close_pipe(pipe, sc->sc_async_head);
 }
 

Index: src/sys/dev/usb/uhci.c
diff -u src/sys/dev/usb/uhci.c:1.235 src/sys/dev/usb/uhci.c:1.236
--- src/sys/dev/usb/uhci.c:1.235	Sat Nov 13 13:52:12 2010
+++ src/sys/dev/usb/uhci.c	Fri May 27 17:19:18 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhci.c,v 1.235 2010/11/13 13:52:12 uebayasi Exp $	*/
+/*	$NetBSD: uhci.c,v 1.236 2011/05/27 17:19:18 drochner Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $	*/
 
 /*
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.235 2010/11/13 13:52:12 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.236 2011/05/27 17:19:18 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -2175,6 +2175,8 @@
 	uhci_softc_t *sc = dev->bus->hci_private;
 
 	uhci_free_sqh(sc, upipe->u.bulk.sqh);
+
+	pipe->endpoint->datatoggle = upipe->nexttoggle;
 }
 
 usbd_status
@@ -3183,7 +3185,8 @@
 		     ed->bEndpointAddress, sc->sc_addr));
 
 	upipe->aborting = 0;
-	upipe->nexttoggle = 0;
+	/* toggle state needed for bulk endpoints */
+	upipe->nexttoggle = pipe->endpoint->datatoggle;
 
 	if (pipe->device->address == sc->sc_addr) {
 		switch (ed->bEndpointAddress) {

Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.178 src/sys/dev/usb/usb_subr.c:1.179
--- src/sys/dev/usb/usb_subr.c:1.178	Sun Mar 20 17:38:11 2011
+++ src/sys/dev/usb/usb_subr.c	Fri May 27 17:19:18 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.178 2011/03/20 17:38:11 tsutsui Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.179 2011/05/27 17:19:18 drochner Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.178 2011/03/20 17:38:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.179 2011/05/27 17:19:18 drochner Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_usbverbose.h"
@@ -495,6 +495,7 @@
 			}
 		}
 		ifc->endpoints[endpt].refcnt = 0;
+		ifc->endpoints[endpt].datatoggle = 0;
 		p += ed->bLength;
 	}
 #undef ed
@@ -1105,6 +1106,9 @@
 	USETW(dev->def_ep_desc.wMaxPacketSize, 64);
 	dev->def_ep_desc.bInterval = 0;
 
+	/* doesn't matter, just don't let it uninitialized */
+	dev->def_ep.datatoggle = 0;
+
 	dev->quirks = &usbd_no_quirk;
 	dev->address = USB_START_ADDR;
 	dev->ddesc.bMaxPacketSize = 0;

Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.92 src/sys/dev/usb/usbdivar.h:1.93
--- src/sys/dev/usb/usbdivar.h:1.92	Mon Dec 20 18:49:12 2010
+++ src/sys/dev/usb/usbdivar.h	Fri May 27 17:19:18 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdivar.h,v 1.92 2010/12/20 18:49:12 phx Exp $	*/
+/*	$NetBSD: usbdivar.h,v 1.93 2011/05/27 17:19:18 drochner Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $	*/
 
 /*
@@ -46,6 +46,7 @@
 struct usbd_endpoint {
 	usb_endpoint_descriptor_t *edesc;
 	int			refcnt;
+	int datatoggle;
 };
 
 struct usbd_bus_methods {

Reply via email to