diff mbox

[2/3] usb: s3c-otg: Fix short packet for request size > ep.maxpacket

Message ID 1461050221-9268-3-git-send-email-rogerq@ti.com
State Superseded
Headers show

Commit Message

Roger Quadros April 19, 2016, 7:17 a.m. UTC
Request size can be greater than ep.packet and still end in a
short packet. We need to tackle this case as end of transfer
(if short_not_ok is not set) as indicated in USB 2.0 Specification [1],
else we get stuck up on certain protocols like fastboot.

[1] - USB2.0 Specification, Section 5.3.2 Pipes

Reported-by: Steve Rae <steve.rae@broadcom.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>

Tested-by: Steve Rae <steve.rae@broadcom.com>

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

-- 
2.5.0

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Comments

Roger Quadros April 19, 2016, 10:21 a.m. UTC | #1
Hi Lukasz,

On 19/04/16 12:02, Lukasz Majewski wrote:
> Hi Roger,

> 

>> Request size can be greater than ep.packet and still end in a

>> short packet. We need to tackle this case as end of transfer

>> (if short_not_ok is not set) as indicated in USB 2.0 Specification

>> [1], else we get stuck up on certain protocols like fastboot.

>>

>> [1] - USB2.0 Specification, Section 5.3.2 Pipes

>>

>> Reported-by: Steve Rae <steve.rae@broadcom.com>

>> Signed-off-by: Roger Quadros <rogerq@ti.com>

>> Tested-by: Steve Rae <steve.rae@broadcom.com>

>> ---

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

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

>>

>> diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c

>> b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c index bce9c30..a31d875

>> 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c

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

>> @@ -229,7 +229,7 @@ static void complete_rx(struct dwc2_udc *dev, u8

>> ep_num) ROUND(xfer_size, CONFIG_SYS_CACHELINE_SIZE));

>>  

>>  	req->req.actual += min(xfer_size, req->req.length -

>> req->req.actual);

>> -	is_short = (xfer_size < ep->ep.maxpacket);

>> +	is_short = xfer_size % ep->ep.maxpacket;

> 

> is_short is a flag - so maybe it would be better to write something

> like:


but it is defined as u32 so I thought it might as well print the
short packet length instead of just 1/0.

> 

> is_short = !!(xfer_size % ep->ep.maxpacket)) ?

> 

> I'm going to test those patches on my boards. I will share the results

> ASAP.

> 

>>  

>>  	debug_cond(DEBUG_OUT_EP != 0,

>>  		   "%s: RX DMA done : ep = %d, rx bytes = %d/%d, "

> 

> 

> 


--
cheers,
-roger
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Roger Quadros April 19, 2016, 11:52 a.m. UTC | #2
On 19/04/16 14:25, Lukasz Majewski wrote:
> Hi Roger,

> 

>> Hi Lukasz,

>>

>> On 19/04/16 12:02, Lukasz Majewski wrote:

>>> Hi Roger,

>>>

>>>> Request size can be greater than ep.packet and still end in a

>>>> short packet. We need to tackle this case as end of transfer

>>>> (if short_not_ok is not set) as indicated in USB 2.0 Specification

>>>> [1], else we get stuck up on certain protocols like fastboot.

>>>>

>>>> [1] - USB2.0 Specification, Section 5.3.2 Pipes

>>>>

>>>> Reported-by: Steve Rae <steve.rae@broadcom.com>

>>>> Signed-off-by: Roger Quadros <rogerq@ti.com>

>>>> Tested-by: Steve Rae <steve.rae@broadcom.com>

>>>> ---

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

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

>>>>

>>>> diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c

>>>> b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c index bce9c30..a31d875

>>>> 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c

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

>>>> @@ -229,7 +229,7 @@ static void complete_rx(struct dwc2_udc *dev,

>>>> u8 ep_num) ROUND(xfer_size, CONFIG_SYS_CACHELINE_SIZE));

>>>>  

>>>>  	req->req.actual += min(xfer_size, req->req.length -

>>>> req->req.actual);

>>>> -	is_short = (xfer_size < ep->ep.maxpacket);

>>>> +	is_short = xfer_size % ep->ep.maxpacket;

>>>

>>> is_short is a flag - so maybe it would be better to write something

>>> like:

>>

>> but it is defined as u32 so I thought it might as well print the

>> short packet length instead of just 1/0.

> 

> I mean that it looks strange for me in debug message when one see:

> 

> "is_short: 8" (as it was shown at Steve's output).


Agreed. I'll convert it to boolean then.

--
cheers,
-roger
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
index bce9c30..a31d875 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
@@ -229,7 +229,7 @@  static void complete_rx(struct dwc2_udc *dev, u8 ep_num)
 				ROUND(xfer_size, CONFIG_SYS_CACHELINE_SIZE));
 
 	req->req.actual += min(xfer_size, req->req.length - req->req.actual);
-	is_short = (xfer_size < ep->ep.maxpacket);
+	is_short = xfer_size % ep->ep.maxpacket;
 
 	debug_cond(DEBUG_OUT_EP != 0,
 		   "%s: RX DMA done : ep = %d, rx bytes = %d/%d, "