Message ID | 1423850351-14660-1-git-send-email-dileep.katta@linaro.org |
---|---|
State | Superseded |
Headers | show |
Hi Dileep, > -----Original Message----- > From: Dileep Katta [mailto:dileep.katta@linaro.org] > Sent: Friday, February 13, 2015 11:59 AM > To: u-boot@lists.denx.de; robherring2@gmail.com; Rini, Tom; > rob.herring@linaro.org; srae@broadcom.com; l.majewski@samsung.com; > Stegmaier, Angela > Cc: Dileep Katta > Subject: [U-Boot][PATCH v2 1/3] fastboot: OUT transaction length must be > aligned to wMaxPacketSize > > OUT transactions must be aligned to wMaxPacketSize for each transfer, or > else transfer will not complete successfully. This patch modifies > rx_bytes_expected to return a transfer length that is aligned to > wMaxPacketSize. > > Note that the value of wMaxPacketSize and ep->maxpacket may not be the > same value, and it is the value of wMaxPacketSize that should be used for > alignment. > > Signed-off-by: Dileep Katta <dileep.katta@linaro.org> > --- > Changes from v1: > - Corrected source of wMaxPacketSize > drivers/usb/gadget/f_fastboot.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/gadget/f_fastboot.c > b/drivers/usb/gadget/f_fastboot.c index a8d8205..b18452e 100644 > --- a/drivers/usb/gadget/f_fastboot.c > +++ b/drivers/usb/gadget/f_fastboot.c > @@ -370,13 +370,20 @@ static void cb_getvar(struct usb_ep *ep, struct > usb_request *req) > fastboot_tx_write_str(response); > } > > -static unsigned int rx_bytes_expected(void) > +static unsigned int rx_bytes_expected(unsigned maxpacket) > { > int rx_remain = download_size - download_bytes; > + int rem = 0; > if (rx_remain < 0) > return 0; > if (rx_remain > EP_BUFFER_SIZE) > return EP_BUFFER_SIZE; > + if (rx_remain < maxpacket) { > + rx_remain = maxpacket; > + } else if (rx_remain % maxpacket != 0) { > + rem = rx_remain % maxpacket; > + rx_remain = rx_remain + (maxpacket - rem); > + } > return rx_remain; > } > > @@ -425,7 +432,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, > struct usb_request *req) > > printf("\ndownloading of %d bytes finished\n", > download_bytes); > } else { > - req->length = rx_bytes_expected(); > + req->length = > rx_bytes_expected(fs_ep_out.wMaxPacketSize); This will not be the correct value in the case of HS connections. Thanks, Angela > if (req->length < ep->maxpacket) > req->length = ep->maxpacket; > } > @@ -453,7 +460,7 @@ static void cb_download(struct usb_ep *ep, struct > usb_request *req) > } else { > sprintf(response, "DATA%08x", download_size); > req->complete = rx_handler_dl_image; > - req->length = rx_bytes_expected(); > + req->length = > rx_bytes_expected(fs_ep_out.wMaxPacketSize); > if (req->length < ep->maxpacket) > req->length = ep->maxpacket; > } > -- > 1.8.3.2
On 15-02-13 09:59 AM, Dileep Katta wrote: > OUT transactions must be aligned to wMaxPacketSize for each transfer, > or else transfer will not complete successfully. This patch modifies > rx_bytes_expected to return a transfer length that is aligned to > wMaxPacketSize. > > Note that the value of wMaxPacketSize and ep->maxpacket may not be > the same value, and it is the value of wMaxPacketSize that should be > used for alignment. > > Signed-off-by: Dileep Katta <dileep.katta@linaro.org> > --- > Changes from v1: > - Corrected source of wMaxPacketSize > drivers/usb/gadget/f_fastboot.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c > index a8d8205..b18452e 100644 > --- a/drivers/usb/gadget/f_fastboot.c > +++ b/drivers/usb/gadget/f_fastboot.c > @@ -370,13 +370,20 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) > fastboot_tx_write_str(response); > } > > -static unsigned int rx_bytes_expected(void) > +static unsigned int rx_bytes_expected(unsigned maxpacket) > { > int rx_remain = download_size - download_bytes; > + int rem = 0; > if (rx_remain < 0) > return 0; > if (rx_remain > EP_BUFFER_SIZE) > return EP_BUFFER_SIZE; > + if (rx_remain < maxpacket) { > + rx_remain = maxpacket; > + } else if (rx_remain % maxpacket != 0) { > + rem = rx_remain % maxpacket; > + rx_remain = rx_remain + (maxpacket - rem); > + } > return rx_remain; > } > > @@ -425,7 +432,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) > > printf("\ndownloading of %d bytes finished\n", download_bytes); > } else { > - req->length = rx_bytes_expected(); > + req->length = rx_bytes_expected(fs_ep_out.wMaxPacketSize); > if (req->length < ep->maxpacket) > req->length = ep->maxpacket; > } > @@ -453,7 +460,7 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req) > } else { > sprintf(response, "DATA%08x", download_size); > req->complete = rx_handler_dl_image; > - req->length = rx_bytes_expected(); > + req->length = rx_bytes_expected(fs_ep_out.wMaxPacketSize); > if (req->length < ep->maxpacket) > req->length = ep->maxpacket; > } > I don't understand... Why are we always limiting this to the "Full Speed" size? ( see fs_ep_out versus hs_ep_out defined previously in this file... ) Thanks, Steve
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index a8d8205..b18452e 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -370,13 +370,20 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) fastboot_tx_write_str(response); } -static unsigned int rx_bytes_expected(void) +static unsigned int rx_bytes_expected(unsigned maxpacket) { int rx_remain = download_size - download_bytes; + int rem = 0; if (rx_remain < 0) return 0; if (rx_remain > EP_BUFFER_SIZE) return EP_BUFFER_SIZE; + if (rx_remain < maxpacket) { + rx_remain = maxpacket; + } else if (rx_remain % maxpacket != 0) { + rem = rx_remain % maxpacket; + rx_remain = rx_remain + (maxpacket - rem); + } return rx_remain; } @@ -425,7 +432,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) printf("\ndownloading of %d bytes finished\n", download_bytes); } else { - req->length = rx_bytes_expected(); + req->length = rx_bytes_expected(fs_ep_out.wMaxPacketSize); if (req->length < ep->maxpacket) req->length = ep->maxpacket; } @@ -453,7 +460,7 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req) } else { sprintf(response, "DATA%08x", download_size); req->complete = rx_handler_dl_image; - req->length = rx_bytes_expected(); + req->length = rx_bytes_expected(fs_ep_out.wMaxPacketSize); if (req->length < ep->maxpacket) req->length = ep->maxpacket; }
OUT transactions must be aligned to wMaxPacketSize for each transfer, or else transfer will not complete successfully. This patch modifies rx_bytes_expected to return a transfer length that is aligned to wMaxPacketSize. Note that the value of wMaxPacketSize and ep->maxpacket may not be the same value, and it is the value of wMaxPacketSize that should be used for alignment. Signed-off-by: Dileep Katta <dileep.katta@linaro.org> --- Changes from v1: - Corrected source of wMaxPacketSize drivers/usb/gadget/f_fastboot.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)