Hi,

I discovered problem which happens if bulk EP has shorter wMaxPacketSize
value than control (zero) EP.
There was bug in usbtrans.c, see patch.

Another problem happens when bulk EP has wMaxPacketSize <= 16 - in this
case transfer error happens because it is not possible to allocate
sufficient number of TDs.
It can happen - according USB1.1 specification, any bulk EP can have
wMaxPacketSize value equal to 8, 16, 32 or 64 (USB 2.0 capable bulk EP
can have 512).
So I increased number of TDs in UHCI and OHCI driver to 640 - it should
be enough for the worse case wMaxPacketSize=8, with some reserve for
"background" communication.

I successfully tested included patch on UHCI with GARMIN OREGON 300
which has:
EP1 (OUT) wMaxPacketSize = 64
EP3 (IN)  wMaxPacketSize = 16
(i.e. this device is related to both problems)

Regards
Ales

diff -urB ./grub/grub-core/bus/usb/ohci.c ./grub_patched/grub-core/bus/usb/ohci.c
--- ./grub/grub-core/bus/usb/ohci.c	2010-09-23 21:45:45.000000000 +0200
+++ ./grub_patched/grub-core/bus/usb/ohci.c	2010-09-23 21:13:00.000000000 +0200
@@ -150,7 +150,7 @@
 #define GRUB_OHCI_RESET_CONNECT_CHANGE (1 << 16)
 #define GRUB_OHCI_CTRL_EDS 256
 #define GRUB_OHCI_BULK_EDS 510
-#define GRUB_OHCI_TDS 256
+#define GRUB_OHCI_TDS 640
 
 #define GRUB_OHCI_ED_ADDR_MASK 0x7ff
 
diff -urB ./grub/grub-core/bus/usb/uhci.c ./grub_patched/grub-core/bus/usb/uhci.c
--- ./grub/grub-core/bus/usb/uhci.c	2010-09-23 21:45:45.000000000 +0200
+++ ./grub_patched/grub-core/bus/usb/uhci.c	2010-09-23 21:11:58.000000000 +0200
@@ -29,6 +29,7 @@
 #define GRUB_UHCI_IOMASK	(0x7FF << 5)
 
 #define N_QH  256
+#define N_TD  640
 
 typedef enum
   {
@@ -105,7 +106,7 @@
   /* N_QH Queue Heads.  */
   grub_uhci_qh_t qh;
 
-  /* 256 Transfer Descriptors.  */
+  /* N_TD Transfer Descriptors.  */
   grub_uhci_td_t td;
 
   /* Free Transfer Descriptors.  */
@@ -227,7 +228,7 @@
 
   /* The TD pointer of UHCI is only 32 bits, make sure this
      code works on on 64 bits architectures.  */
-  u->td = (grub_uhci_td_t) grub_memalign (4096, 4096*2);
+  u->td = (grub_uhci_td_t) grub_memalign (4096, 32*N_TD);
   if (! u->td)
     goto fail;
 
@@ -244,9 +245,9 @@
 
   /* Link all Transfer Descriptors in a list of available Transfer
      Descriptors.  */
-  for (i = 0; i < 256; i++)
+  for (i = 0; i < N_TD; i++)
     u->td[i].linkptr = (grub_uint32_t) (grub_addr_t) &u->td[i + 1];
-  u->td[255 - 1].linkptr = 0;
+  u->td[N_TD - 2].linkptr = 0;
   u->tdfree = u->td;
 
   /* Make sure UHCI is disabled!  */
diff -urB ./grub/grub-core/bus/usb/usbtrans.c ./grub_patched/grub-core/bus/usb/usbtrans.c
--- ./grub/grub-core/bus/usb/usbtrans.c	2010-09-23 21:45:45.000000000 +0200
+++ ./grub_patched/grub-core/bus/usb/usbtrans.c	2010-09-23 21:13:56.000000000 +0200
@@ -228,7 +228,7 @@
   if (dev->initialized)
     {
       struct grub_usb_desc_endp *endpdesc;
-      endpdesc = grub_usb_get_endpdescriptor (dev, 0);
+      endpdesc = grub_usb_get_endpdescriptor (dev, endpoint);
 
       if (endpdesc)
 	max = endpdesc->maxpacket;
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to