diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2011-02-23 15:28:18 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-02-25 14:38:32 -0500 |
commit | 969e3033ae7733a0af8f7742ca74cd16c0857e71 (patch) | |
tree | 2aa76d00720d20304f318b8a7fd247c804d0e2cf | |
parent | 22ced6874fc47bb051e7460443e454ca8efc457e (diff) |
USB: serial drivers need to use larger bulk-in buffers
When a driver doesn't know how much data a device is going to send,
the buffer size should be at least as big as the endpoint's maxpacket
value. The serial drivers don't follow this rule; many of them
request only 256-byte bulk-in buffers. As a result, they suffer
overflow errors if a high-speed device wants to send a lot of data,
because high-speed bulk endpoints are required to have a maxpacket
size of 512.
This patch (as1450) fixes the problem by using the driver's
bulk_in_size value as a minimum, always allocating buffers no smaller
than the endpoint's maxpacket size.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Flynn Marquardt <flynn@flynnux.de>
CC: <stable@kernel.org> [after .39-rc1 is out]
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 5 | ||||
-rw-r--r-- | include/linux/usb/serial.h | 3 |
2 files changed, 4 insertions, 4 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 546a52179bec..2ff90a9c8f47 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -911,9 +911,8 @@ int usb_serial_probe(struct usb_interface *interface, | |||
911 | dev_err(&interface->dev, "No free urbs available\n"); | 911 | dev_err(&interface->dev, "No free urbs available\n"); |
912 | goto probe_error; | 912 | goto probe_error; |
913 | } | 913 | } |
914 | buffer_size = serial->type->bulk_in_size; | 914 | buffer_size = max_t(int, serial->type->bulk_in_size, |
915 | if (!buffer_size) | 915 | le16_to_cpu(endpoint->wMaxPacketSize)); |
916 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | ||
917 | port->bulk_in_size = buffer_size; | 916 | port->bulk_in_size = buffer_size; |
918 | port->bulk_in_endpointAddress = endpoint->bEndpointAddress; | 917 | port->bulk_in_endpointAddress = endpoint->bEndpointAddress; |
919 | port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); | 918 | port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); |
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index c9049139a7a5..45f3b9db4258 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
@@ -191,7 +191,8 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data) | |||
191 | * @id_table: pointer to a list of usb_device_id structures that define all | 191 | * @id_table: pointer to a list of usb_device_id structures that define all |
192 | * of the devices this structure can support. | 192 | * of the devices this structure can support. |
193 | * @num_ports: the number of different ports this device will have. | 193 | * @num_ports: the number of different ports this device will have. |
194 | * @bulk_in_size: bytes to allocate for bulk-in buffer (0 = end-point size) | 194 | * @bulk_in_size: minimum number of bytes to allocate for bulk-in buffer |
195 | * (0 = end-point size) | ||
195 | * @bulk_out_size: bytes to allocate for bulk-out buffer (0 = end-point size) | 196 | * @bulk_out_size: bytes to allocate for bulk-out buffer (0 = end-point size) |
196 | * @calc_num_ports: pointer to a function to determine how many ports this | 197 | * @calc_num_ports: pointer to a function to determine how many ports this |
197 | * device has dynamically. It will be called after the probe() | 198 | * device has dynamically. It will be called after the probe() |