diff mbox series

[V2,16/17] usb: gadget: fastboot: use correct max packet size

Message ID 20210125134400.780-17-peng.fan@nxp.com
State New
Headers show
Series usb: gadget: update | expand

Commit Message

Peng Fan Jan. 25, 2021, 1:43 p.m. UTC
From: Li Jun <jun.li@nxp.com>


Change to use wMaxPacketSize of current speed EP desc for request
length wrap up.

Reviewed-by: Peter Chen <peter.chen@nxp.com>

Signed-off-by: Li Jun <jun.li@nxp.com>

Signed-off-by: Peng Fan <peng.fan@nxp.com>

---
 drivers/usb/gadget/f_fastboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.28.0

Comments

Maxime Ripard June 23, 2021, 10:15 a.m. UTC | #1
Hi,

Adding Andre, Lukasz and Marek in Cc

On Mon, Jan 25, 2021 at 09:43:59PM +0800, peng.fan at nxp.com wrote:
> From: Li Jun <jun.li@nxp.com>

> 

> Change to use wMaxPacketSize of current speed EP desc for request

> length wrap up.

> 

> Reviewed-by: Peter Chen <peter.chen@nxp.com>

> Signed-off-by: Li Jun <jun.li@nxp.com>

> Signed-off-by: Peng Fan <peng.fan@nxp.com>

> ---

>  drivers/usb/gadget/f_fastboot.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c

> index c2abdd66a8..2ef75a1388 100644

> --- a/drivers/usb/gadget/f_fastboot.c

> +++ b/drivers/usb/gadget/f_fastboot.c

> @@ -427,7 +427,7 @@ static unsigned int rx_bytes_expected(struct usb_ep *ep)

>  {

>  	int rx_remain = fastboot_data_remaining();

>  	unsigned int rem;

> -	unsigned int maxpacket = ep->maxpacket;

> +	unsigned int maxpacket = usb_endpoint_maxp(ep->desc);


Unfortunately this introduces a regression on sunxi, where a fastboot
flash command will stall on the download part forever.

Interestingly, this occurs on the last packet of the download and only
if the packet size is a power of two, and over 512.

This can be easily tested using

dd if=/dev/random of=test-custom.bin bs=1 count=512
fastboot flash uboot test-custom.bin

However, 511, 513 (or any other size, really) will work just fine.

Maxime
diff mbox series

Patch

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index c2abdd66a8..2ef75a1388 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -427,7 +427,7 @@  static unsigned int rx_bytes_expected(struct usb_ep *ep)
 {
 	int rx_remain = fastboot_data_remaining();
 	unsigned int rem;
-	unsigned int maxpacket = ep->maxpacket;
+	unsigned int maxpacket = usb_endpoint_maxp(ep->desc);
 
 	if (rx_remain <= 0)
 		return 0;