From: "Jeremy C. Andrus" <jeremy@jeremya.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] usb bulk transfer: 1024 byte packets
Date: Fri, 13 Apr 2007 12:56:47 -0400 [thread overview]
Message-ID: <200704131256.47570.jeremy@jeremya.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 738 bytes --]
Hello,
I recently ran into a couple of USB devices which insisted on using 1024
byte packets in bulk transfer mode (despite the hard limit of 512
established in the spec). I really wanted to use these devices, so I
created a kernel patch which allows the use of 1024 byte URBs, but does
not interfere with normal (512 byte) operation. I did this through a
bit in the transfer_flags bitfield.
I found this patch useful and un-obtrusive, so I figured that I would
post it here to see if anyone else thinks it interesting enough to
patch in.
I am not subscribed to the list, and would appreciate a personal CC on
reply :-).
-Jeremy
--
-----------------------
Jeremy C. Andrus
http://www.jeremya.com/
-----------------------
[-- Attachment #2: linux-2.6.20.6-usb_1024byte_packets.patch --]
[-- Type: text/x-diff, Size: 3531 bytes --]
diff -Naur linux-2.6.20.6/Documentation/usb/bulk_tx_hacks.txt linux-2.6.20.6_jca/Documentation/usb/bulk_tx_hacks.txt
--- linux-2.6.20.6/Documentation/usb/bulk_tx_hacks.txt 1969-12-31 19:00:00.000000000 -0500
+++ linux-2.6.20.6_jca/Documentation/usb/bulk_tx_hacks.txt 2007-04-13 09:59:19.000000000 -0400
@@ -0,0 +1,28 @@
+bulk_tx_hacks.txt
+Copyright (C) 2007 Jeremy C. Andrus <jeremy@jeremya.com>
+Started: 2007-April-13
+
+
+How to use a 1024-byte bulk transfer packet
+
+There are some devices/companies which have decided to use
+a bulk transfer packet size which is larger than the maximum
+specified in the USB spec. Because I was interested in using
+such a device, I found it necessary to devise a way to allow
+this functionality in the linux kernel.
+
+It is reasonably simple to create a 1024-byte bulk transfer
+URB. Simply OR the 'URB_1024_BYTE_PKT' value into the URB's
+transfer_flags field before submitting it to the system:
+
+ urb = usb_alloc_urb(0, GFP_KERNEL);
+
+ usb_fill_bulk_urb( urb, ... );
+
+ /* this allows the URB's buffer to be 1024 bytes */
+ urb->transfer_flags |= URB_1024_BYTE_PKT;
+
+ retval = usb_submit_urb( urb, GFP_KERNEL );
+
+ usb_free_urb( urb );
+
diff -Naur linux-2.6.20.6/drivers/usb/host/Kconfig linux-2.6.20.6_jca/drivers/usb/host/Kconfig
--- linux-2.6.20.6/drivers/usb/host/Kconfig 2007-04-06 16:02:48.000000000 -0400
+++ linux-2.6.20.6_jca/drivers/usb/host/Kconfig 2007-04-13 10:00:36.000000000 -0400
@@ -67,6 +67,20 @@
If unsure, say N.
+config USB_EHCI_1024BYTE_BULK_PKTS
+ bool "Allow 1024-byte packets in Bulk Transfer mode"
+ depends on USB_EHCI_HCD && EXPERIMENTAL
+ ---help---
+ The USB specification allows a maximum bulk transfer packet size
+ of 512 bytes. There are a few devices which have decided to break
+ this specification and use 1024 byte packets. This option allows
+ the use of the larger packet size with a very specific flag set
+ in the URB.
+
+ See the Documentation/usb/bulk_tx_hacks.txt file for details.
+
+ If unsure, say N.
+
config USB_ISP116X_HCD
tristate "ISP116X HCD support"
depends on USB
diff -Naur linux-2.6.20.6/drivers/usb/host/ehci-q.c linux-2.6.20.6_jca/drivers/usb/host/ehci-q.c
--- linux-2.6.20.6/drivers/usb/host/ehci-q.c 2007-04-06 16:02:48.000000000 -0400
+++ linux-2.6.20.6_jca/drivers/usb/host/ehci-q.c 2007-04-13 09:47:09.000000000 -0400
@@ -751,7 +751,12 @@
info2 |= (EHCI_TUNE_MULT_HS << 30);
} else if (type == PIPE_BULK) {
info1 |= (EHCI_TUNE_RL_HS << 28);
- info1 |= 512 << 16; /* usb2 fixed maxpacket */
+#ifdef USB_EHCI_1024BYTE_BULK_PKTS
+ if ( urb->transfer_flags & URB_1024_BYTE_PKT )
+ info1 |= 1024 << 16; /* HACK for Micron Dev Kits requiring 1024 byte packets... */
+ else
+#endif
+ info1 |= 512 << 16; /* usb2 fixed maxpacket */
info2 |= (EHCI_TUNE_MULT_HS << 30);
} else { /* PIPE_INTERRUPT */
info1 |= max_packet (maxp) << 16;
diff -Naur linux-2.6.20.6/include/linux/usb.h linux-2.6.20.6_jca/include/linux/usb.h
--- linux-2.6.20.6/include/linux/usb.h 2007-04-06 16:02:48.000000000 -0400
+++ linux-2.6.20.6_jca/include/linux/usb.h 2007-04-13 09:47:09.000000000 -0400
@@ -904,6 +904,9 @@
#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt
* needed */
+#ifdef USB_EHCI_1024BYTE_BULK_PKTS
+#define URB_1024_BYTE_PKT 0x8000 /* Use a max packet length of 1024 bytes instead of 512 */
+#endif
struct usb_iso_packet_descriptor {
unsigned int offset;
next reply other threads:[~2007-04-13 17:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-13 16:56 Jeremy C. Andrus [this message]
2007-04-13 18:47 ` Jeremy C. Andrus
2007-04-14 2:16 ` Pete Zaitcev
2007-04-14 13:14 ` Jeremy C. Andrus
2007-04-14 16:58 ` Pete Zaitcev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200704131256.47570.jeremy@jeremya.com \
--to=jeremy@jeremya.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®