MLK-12883 usb: limit usb storage max_xfer_blk to 256
For Some USB mass storage devices, such as:
"
- Kingston DataTraveler 2.0 001D7D06CF09B04199C7B3EA
- Class: (from Interface) Mass Storage
- PacketSize: 64 Configurations: 1
- Vendor: 0x0930 Product 0x6545 Version 1.16
"
When `usb read 0x80000000 0 0x2000`, we met
"EHCI timed out on TD - token=0x80008d80".
The devices does not support scsi VPD page, we are not able
to get the maximum transfer length for READ(10)/WRITE(10).
So we limit this to 256 blocks as READ(6).
Signed-off-by: Peng Fan <peng.fan@nxp.com>
(cherry picked from commit df0052575b2bc9d66ae73584768e1a457ed5d914)
(cherry picked from commit 0716cc14a3739e9d161f5d0c3a0bebf0272759f9)
Signed-off-by: Ye Li <ye.li@nxp.com>
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 8c889bb..08244a9 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -949,7 +949,7 @@
* there is enough free heap space left, but the SCSI READ(10) and
* WRITE(10) commands are limited to 65535 blocks.
*/
- blk = USHRT_MAX;
+ blk = 256;
#else
blk = 20;
#endif
@@ -959,8 +959,8 @@
/* unimplemented, let's use default 20 */
blk = 20;
} else {
- if (size > USHRT_MAX * 512)
- size = USHRT_MAX * 512;
+ if (size > 256 * 512)
+ size = 256 * 512;
blk = size / 512;
}
#endif