Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OysOK-0006Ub-DP for mharc-grub-devel@gnu.org; Thu, 23 Sep 2010 16:27:40 -0400 Received: from [140.186.70.92] (port=43070 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OysOG-0006Rn-QN for grub-devel@gnu.org; Thu, 23 Sep 2010 16:27:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OysOD-00005q-0D for grub-devel@gnu.org; Thu, 23 Sep 2010 16:27:34 -0400 Received: from smtp-out3.iol.cz ([194.228.2.91]:39127) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OysOC-00005b-LF for grub-devel@gnu.org; Thu, 23 Sep 2010 16:27:32 -0400 Received: from antivir5.iol.cz (unknown [192.168.30.212]) by smtp-out3.iol.cz (Postfix) with ESMTP id B4B2BBC9A9D for ; Thu, 23 Sep 2010 20:27:29 +0000 (UTC) Received: from localhost (antivir5.iol.cz [127.0.0.1]) by antivir5.iol.cz (Postfix) with ESMTP id A1DCD1E8031 for ; Thu, 23 Sep 2010 22:27:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at iol.cz Received: from antivir5.iol.cz ([127.0.0.1]) by localhost (antivir5.iol.cz [127.0.0.1]) (amavisd-new, port 10224) with LMTP id 2n3a8JSw7JqS for ; Thu, 23 Sep 2010 22:27:29 +0200 (CEST) Received: from port8.iol.cz (unknown [192.168.30.90]) by antivir5.iol.cz (Postfix) with ESMTP id 692341E802F for ; Thu, 23 Sep 2010 22:27:29 +0200 (CEST) X-SBRS: None X-SBRS-none: None X-RECVLIST: MTA-OUT-IOL X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhYKAFv8mkxVRnXk/2dsb2JhbAAHgxSBAdInkiiETnME Received: from 228.117.broadband3.iol.cz (HELO [192.168.6.160]) ([85.70.117.228]) by port8.iol.cz with ESMTP; 23 Sep 2010 22:27:29 +0200 From: =?UTF-8?Q?Ale=C5=A1?= Nesrsta To: The development of GNU GRUB In-Reply-To: <20100923130819.GV21862@riva.ucam.org> References: <20100921183525.GP21862@riva.ucam.org> <20100923130819.GV21862@riva.ucam.org> Content-Type: multipart/mixed; boundary="=-5AHNFQVXlAelO8iz8MXt" Date: Thu, 23 Sep 2010 22:27:27 +0200 Message-Id: <1285273648.6015.30.camel@pracovna> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [PATCH] Trunk: usbtrans.c - wrong max packet size for bulk transfer X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2010 20:27:39 -0000 --=-5AHNFQVXlAelO8iz8MXt Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 --=-5AHNFQVXlAelO8iz8MXt Content-Disposition: attachment; filename=usb_maxpacketbulk_100923_0 Content-Type: text/x-patch; name=usb_maxpacketbulk_100923_0; charset=UTF-8 Content-Transfer-Encoding: 7bit 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; --=-5AHNFQVXlAelO8iz8MXt--