mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-07-12 22:26:16 +09:00
usb: dwc2: remove restriction on buffer length
Each USB transfer is split up into chunks that are held in an aligned buffer. This imposes a limit on the size of each chunk, but no limit on the total size of transferred data. Fix the logic in chunk_msg() not to reject large transfers, but simply take the size of the aligned buffer into account when calculating the chunk size. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
This commit is contained in:
parent
d1c880c66c
commit
805b67e1ea
|
@ -756,24 +756,18 @@ int chunk_msg(struct usb_device *dev, unsigned long pipe, int *pid, int in,
|
||||||
debug("%s: msg: pipe %lx pid %d in %d len %d\n", __func__, pipe, *pid,
|
debug("%s: msg: pipe %lx pid %d in %d len %d\n", __func__, pipe, *pid,
|
||||||
in, len);
|
in, len);
|
||||||
|
|
||||||
if (len > DWC2_DATA_BUF_SIZE) {
|
|
||||||
printf("%s: %d is more then available buffer size (%d)\n",
|
|
||||||
__func__, len, DWC2_DATA_BUF_SIZE);
|
|
||||||
dev->status = 0;
|
|
||||||
dev->act_len = 0;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Initialize channel */
|
/* Initialize channel */
|
||||||
dwc_otg_hc_init(regs, DWC2_HC_CHANNEL, devnum, ep, in, eptype,
|
dwc_otg_hc_init(regs, DWC2_HC_CHANNEL, devnum, ep, in, eptype,
|
||||||
max);
|
max);
|
||||||
|
|
||||||
xfer_len = len - done;
|
xfer_len = len - done;
|
||||||
/* Make sure that xfer_len is a multiple of max packet size. */
|
|
||||||
if (xfer_len > CONFIG_DWC2_MAX_TRANSFER_SIZE)
|
if (xfer_len > CONFIG_DWC2_MAX_TRANSFER_SIZE)
|
||||||
xfer_len = CONFIG_DWC2_MAX_TRANSFER_SIZE - max + 1;
|
xfer_len = CONFIG_DWC2_MAX_TRANSFER_SIZE - max + 1;
|
||||||
|
if (xfer_len > DWC2_DATA_BUF_SIZE)
|
||||||
|
xfer_len = DWC2_DATA_BUF_SIZE - max + 1;
|
||||||
|
|
||||||
|
/* Make sure that xfer_len is a multiple of max packet size. */
|
||||||
if (xfer_len > 0) {
|
if (xfer_len > 0) {
|
||||||
num_packets = (xfer_len + max - 1) / max;
|
num_packets = (xfer_len + max - 1) / max;
|
||||||
if (num_packets > CONFIG_DWC2_MAX_PACKET_COUNT) {
|
if (num_packets > CONFIG_DWC2_MAX_PACKET_COUNT) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user