ChangeSet 1.1474.81.24, 2004/01/16 16:42:42-08:00, david-b@pacbell.net

[PATCH] USB: ehci update:  1/3, misc

This is minor "obvious" fixes plus two tweaks to help later
patches:

    - Interrupt QH has a link to the device, needed to implement
      schedule trees (like OHCI does today) that are TT-aware
      (essential for most keyboards and mice).

    - Export the macros that do high bandwidth packetsize stuff.
      They're also needed for high bandwidth ISO transfers.

It also morphs some existing "too much debug info" urb tracing
so it's kicked in by a manual #define EHCI_URB_TRACE.  If some
generic version of that gets added to usbcore, this sort
of debug code can vanish (from all hcds).


 drivers/usb/host/ehci-dbg.c |    4 ++--
 drivers/usb/host/ehci-hcd.c |    4 +++-
 drivers/usb/host/ehci-mem.c |    3 ++-
 drivers/usb/host/ehci-q.c   |   28 ++++++++++++++++++++++------
 drivers/usb/host/ehci.h     |    2 +-
 5 files changed, 30 insertions(+), 11 deletions(-)


diff -Nru a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
--- a/drivers/usb/host/ehci-dbg.c	Tue Jan 20 17:35:23 2004
+++ b/drivers/usb/host/ehci-dbg.c	Tue Jan 20 17:35:23 2004
@@ -116,7 +116,7 @@
 #ifdef	DEBUG
 
 static void __attribute__((__unused__))
-dbg_qtd (char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd)
+dbg_qtd (const char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd)
 {
 	ehci_dbg (ehci, "%s td %p n%08x %08x t%08x p0=%08x\n", label, qtd,
 		cpu_to_le32p (&qtd->hw_next),
@@ -132,7 +132,7 @@
 }
 
 static void __attribute__((__unused__))
-dbg_qh (char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
+dbg_qh (const char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
 {
 	ehci_dbg (ehci, "%s qh %p n%08x info %x %x qtd %x\n", label,
 		qh, qh->hw_next, qh->hw_info1, qh->hw_info2,
diff -Nru a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
--- a/drivers/usb/host/ehci-hcd.c	Tue Jan 20 17:35:23 2004
+++ b/drivers/usb/host/ehci-hcd.c	Tue Jan 20 17:35:23 2004
@@ -97,7 +97,9 @@
 static const char	hcd_name [] = "ehci_hcd";
 
 
-// #define EHCI_VERBOSE_DEBUG
+#undef EHCI_VERBOSE_DEBUG
+#undef EHCI_URB_TRACE
+
 // #define have_split_iso
 
 #ifdef DEBUG
diff -Nru a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
--- a/drivers/usb/host/ehci-mem.c	Tue Jan 20 17:35:23 2004
+++ b/drivers/usb/host/ehci-mem.c	Tue Jan 20 17:35:23 2004
@@ -28,7 +28,7 @@
  *	- driver buffers, read/written by HC ... single shot DMA mapped 
  *
  * There's also PCI "register" data, which is memory mapped.
- * No memory seen by this driver is pagable.
+ * No memory seen by this driver is pageable.
  */
 
 /*-------------------------------------------------------------------------*/
@@ -131,6 +131,7 @@
 	}
 	if (qh->dummy)
 		ehci_qtd_free (ehci, qh->dummy);
+	usb_put_dev (qh->dev);
 	pci_pool_free (ehci->qh_pool, qh, qh->qh_dma);
 }
 
diff -Nru a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
--- a/drivers/usb/host/ehci-q.c	Tue Jan 20 17:35:23 2004
+++ b/drivers/usb/host/ehci-q.c	Tue Jan 20 17:35:23 2004
@@ -164,7 +164,8 @@
 
 		/* if async CSPLIT failed, try cleaning out the TT buffer */
 		} else if (urb->dev->tt && !usb_pipeint (urb->pipe)
-				&& QTD_CERR(token) == 0) {
+				&& ((token & QTD_STS_MMF) != 0
+					|| QTD_CERR(token) == 0)) {
 #ifdef DEBUG
 			struct usb_device *tt = urb->dev->tt->hub;
 			dev_dbg (&tt->dev,
@@ -212,6 +213,16 @@
 	}
 	spin_unlock (&urb->lock);
 
+#ifdef EHCI_URB_TRACE
+	ehci_dbg (ehci,
+		"%s %s urb %p ep%d%s status %d len %d/%d\n",
+		__FUNCTION__, urb->dev->devpath, urb,
+		usb_pipeendpoint (urb->pipe),
+		usb_pipein (urb->pipe) ? "in" : "out",
+		urb->status,
+		urb->actual_length, urb->transfer_buffer_length);
+#endif
+
 	/* complete() can reenter this HCD */
 	spin_unlock (&ehci->lock);
 	usb_hcd_giveback_urb (&ehci->hcd, urb, regs);
@@ -640,6 +651,9 @@
 
 			qh->period = urb->interval;
 		}
+
+		/* support for tt scheduling */
+		qh->dev = usb_get_dev (urb->dev);
 	}
 
 	/* using TT? */
@@ -699,8 +713,6 @@
 	usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1);
 	return qh;
 }
-#undef hb_mult
-#undef hb_packet
 
 /*-------------------------------------------------------------------------*/
 
@@ -887,10 +899,14 @@
 	if (usb_pipein (urb->pipe) && !usb_pipecontrol (urb->pipe))
 		epnum |= 0x10;
 
-	ehci_vdbg (ehci, "submit_async urb %p len %d ep%d%s qtd %p [qh %p]\n",
-		urb, urb->transfer_buffer_length,
-		epnum & 0x0f, (epnum & 0x10) ? "in" : "out",
+#ifdef EHCI_URB_TRACE
+	ehci_dbg (ehci,
+		"%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
+		__FUNCTION__, urb->dev->devpath, urb,
+		epnum & 0x0f, usb_pipein (urb->pipe) ? "in" : "out",
+		urb->transfer_buffer_length,
 		qtd, dev ? dev->ep [epnum] : (void *)~0);
+#endif
 
 	spin_lock_irqsave (&ehci->lock, flags);
 	qh = qh_append_tds (ehci, urb, qtd_list, epnum, &dev->ep [epnum]);
diff -Nru a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
--- a/drivers/usb/host/ehci.h	Tue Jan 20 17:35:23 2004
+++ b/drivers/usb/host/ehci.h	Tue Jan 20 17:35:23 2004
@@ -381,7 +381,7 @@
 	unsigned short		period;		/* polling interval */
 	unsigned short		start;		/* where polling starts */
 #define NO_FRAME ((unsigned short)~0)			/* pick new start */
-
+	struct usb_device	*dev;		/* access to TT */
 } __attribute__ ((aligned (32)));
 
 /*-------------------------------------------------------------------------*/
