usb: dwc3: gadget: Set maxpacket size for ep0 IN
PATCH 10/15 usb: dwc3: gadget: Set maxpacket size for ep0 IN
Hi,
Quoted 105 lines · Thinh Nguyen
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
drivers/usb/dwc3/gadget.c static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) · line 2754
Quoted 9 lines
drivers/usb/dwc3/gadget.c +1
-0@@ -2751,6 +2751,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)break ; } + dwc->eps[1 ]->endpoint.maxpacket = dwc->gadget.ep0->maxpacket;thanks :-) I've had that on my list for a while but never got to it since it has no real effects other than reporting properly on tracepoints :-)
Quoted 7 lines
Quoted 2 lines
Just to clarify, this is a bug. We found this issue when we test for HS/FS 3-stage control read transfer for ZLP.
interesting... I have never seen such bug before. Got some tracepoints of the problem? Also, if it's a bug, why wasn't it sent as a separate patch with a Cc stable and a Fixes tag?
DWC3 gadget starts with max packet size (mps) 512 as default for ep0. That value should be updated after ConnectDone event when DWC3 checks for the connected speed. In HS/FS, the 3-stage control read transfer sends ZLP based on the mps for IN ep0, but that value is not updated.
Here's a quick test with the 3-stage HS control read.
Setup:
*mass_storagedriver
* Modify driver string description to 128 bytes
* Enumerate device in highspeed (mps = 64)Below is the snippet of trace with GetDescriptor(STRING) request for the driver string description. Device did not prepare and send ZLP packet.
41.787092:
dwc3_ctrl_req: Get StringDescriptor(Index = 4, Length = 255)41.787093:dwc3_prepare_trb: ep0in: 0/0 trb0000000070a29ad1buf00000000b8d67800size 128 ctrl00000c53(HLcs:SC:data)
41.787094:dwc3_readl: addr000000008008901evalue 00002400 41.787095:dwc3_writel: addr00000000831c6d00value 00000000 41.787095:dwc3_writel: addr000000003e4167b3value 37820000 41.787095:dwc3_writel: addr00000000f504c84evalue 00000000 41.787095:dwc3_writel: addr00000000ca003facvalue 00000406 41.787095:dwc3_readl: addr00000000ca003facvalue 00000406 41.787098:dwc3_readl: addr00000000ca003facvalue 00010006 41.787100:dwc3_gadget_ep_cmd: ep0in: cmd 'Start Transfer' [1030]
params 00000000 37820000 00000000 --> status: Successful
41.787101:dwc3_readl: addr00000000ca003facvalue 00010006 41.787103:dwc3_readl: addr000000007bcb1278value 80001000 41.787105:dwc3_writel: addr000000007bcb1278value 00001000 41.787107:dwc3_readl: addr000000008eea6144value 00000000 41.787216:dwc3_readl: addr000000008eea6144value 00000008 41.787218:dwc3_readl: addr000000007bcb1278value 00001000 41.787219:dwc3_writel: addr000000007bcb1278value 80001000 41.787220:dwc3_writel: addr000000008eea6144value 00000008 41.787220:dwc3_event: event (0000c042): ep0in: Transfer Complete
[Data Phase]
41.787220:dwc3_complete_trb: ep0out: 0/1 trb0000000070a29ad1buf00000000b8d67800size 0 ctrl00000c52(hLcs:SC:data)
41.787221:dwc3_complete_trb: ep0out: 0/1 trb00000000cba79c85buf
0000000000000000 size 0 ctrl 00000000 (hlcs:sc:UNKNOWN)
41.787221:dwc3_gadget_giveback: ep0out: req00000000fd996780length
128/128 ZsI ==> 0
41.787221:dwc3_event: event (000010c2): ep0in: Transfer Not Ready
(Not Active) [Data Phase]
41.787221:dwc3_readl: addr000000007bcb1278value 80001000 41.787223:dwc3_writel: addr000000007bcb1278value 00001000 41.787223:dwc3_readl: addr000000008eea6144value 00000000 46.294697:dwc3_readl: addr000000008eea6144value 00000004 46.294698:dwc3_readl: addr000000007bcb1278value 00001000 46.294699:dwc3_writel: addr000000007bcb1278value 80001000 46.294700:dwc3_writel: addr000000008eea6144value 00000004Below is the snippet of the trace with the fix:
34.079018:
dwc3_ctrl_req: Get StringDescriptor(Index = 4, Length = 255)34.079020:dwc3_prepare_trb: ep0in: 0/0 trb000000006ece9b4dbuf00000000b8d67800size 128 ctrl 00000455 (HlCs:Sc:data)
34.079020:dwc3_prepare_trb: ep0in: 0/0 trb000000001b323efabuf
0000000037821000 size 0 ctrl00000c53(HLcs:SC:data)
34.079020:dwc3_readl: addr00000000a90978f8value 00002400 34.079021:dwc3_writel: addr00000000c8f7ea9fvalue 00000000 34.079021:dwc3_writel: addr000000000217f085value 37820000 34.079021:dwc3_writel: addr00000000b5593ec9value 00000000 34.079021:dwc3_writel: addr000000008b9e5492value 00000406 34.079022:dwc3_readl: addr000000008b9e5492value 00000406 34.079024:dwc3_readl: addr000000008b9e5492value 00010006 34.079027:dwc3_gadget_ep_cmd: ep0in: cmd 'Start Transfer' [1030]
params 00000000 37820000 00000000 --> status: Successful
34.079027:dwc3_readl: addr000000008b9e5492value 00010006 34.079029:dwc3_readl: addr00000000e9897a1cvalue 80001000 34.079031:dwc3_writel: addr00000000e9897a1cvalue 00001000 34.079031:dwc3_readl: addr0000000034bddbfcvalue 00000000 34.079144:dwc3_readl: addr0000000034bddbfcvalue 00000004 34.079146:dwc3_readl: addr00000000e9897a1cvalue 00001000 34.079147:dwc3_writel: addr00000000e9897a1cvalue 80001000 34.079148:dwc3_writel: addr0000000034bddbfcvalue 00000004 34.079148:dwc3_event: event (0000c042): ep0in: Transfer Complete
[Data Phase]
Quoted 8 lines
34.079148:
dwc3_complete_trb: ep0out: 0/1 trb000000006ece9b4dbuf00000000b8d67800size 0 ctrl 00000454 (hlCs:Sc:data)
34.079149:dwc3_complete_trb: ep0out: 0/1 trb000000001b323efabuf
0000000037821000 size 0 ctrl00000c52(hLcs:SC:data)
34.079149:dwc3_gadget_giveback: ep0out: req00000000bbc62204length
128/128 ZsI ==> 0
34.079149:dwc3_readl: addr00000000e9897a1cvalue 80001000 34.079150:dwc3_writel: addr00000000e9897a1cvalue 00001000
now I see the problem, thank you :-)