linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>Thinh Nguyen
	<Thinh.Nguyen@synopsys.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Cc: John Youn <John.Youn@synopsys.com>
Subject: [10/15] usb: dwc3: gadget: Set maxpacket size for ep0 IN
Date: Thu, 11 Jan 2018 10:29:18 +0200	[thread overview]
Message-ID: <87fu7cyf1d.fsf@linux.intel.com> (raw)

Hi,

Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
>>>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>>>>> index bdf2a2014ebd..6ae924d95cbc 100644
>>>>> --- a/drivers/usb/dwc3/gadget.c
>>>>> +++ b/drivers/usb/dwc3/gadget.c
>>>>> @@ -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 :-)
>>>>
>>>
>>> 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_storage driver
> * 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 String Descriptor(Index = 4, Length = 255)
>   41.787093: dwc3_prepare_trb: ep0in: 0/0 trb 0000000070a29ad1 buf 
> 00000000b8d67800 size 128 ctrl 00000c53 (HLcs:SC:data)
>   41.787094: dwc3_readl: addr 000000008008901e value 00002400
>   41.787095: dwc3_writel: addr 00000000831c6d00 value 00000000
>   41.787095: dwc3_writel: addr 000000003e4167b3 value 37820000
>   41.787095: dwc3_writel: addr 00000000f504c84e value 00000000
>   41.787095: dwc3_writel: addr 00000000ca003fac value 00000406
>   41.787095: dwc3_readl: addr 00000000ca003fac value 00000406
>   41.787098: dwc3_readl: addr 00000000ca003fac value 00010006
>   41.787100: dwc3_gadget_ep_cmd: ep0in: cmd 'Start Transfer' [1030] 
> params 00000000 37820000 00000000 --> status: Successful
>   41.787101: dwc3_readl: addr 00000000ca003fac value 00010006
>   41.787103: dwc3_readl: addr 000000007bcb1278 value 80001000
>   41.787105: dwc3_writel: addr 000000007bcb1278 value 00001000
>   41.787107: dwc3_readl: addr 000000008eea6144 value 00000000
>   41.787216: dwc3_readl: addr 000000008eea6144 value 00000008
>   41.787218: dwc3_readl: addr 000000007bcb1278 value 00001000
>   41.787219: dwc3_writel: addr 000000007bcb1278 value 80001000
>   41.787220: dwc3_writel: addr 000000008eea6144 value 00000008
>   41.787220: dwc3_event: event (0000c042): ep0in: Transfer Complete 
> [Data Phase]
>   41.787220: dwc3_complete_trb: ep0out: 0/1 trb 0000000070a29ad1 buf 
> 00000000b8d67800 size 0 ctrl 00000c52 (hLcs:SC:data)
>   41.787221: dwc3_complete_trb: ep0out: 0/1 trb 00000000cba79c85 buf 
> 0000000000000000 size 0 ctrl 00000000 (hlcs:sc:UNKNOWN)
>   41.787221: dwc3_gadget_giveback: ep0out: req 00000000fd996780 length 
> 128/128 ZsI ==> 0
>   41.787221: dwc3_event: event (000010c2): ep0in: Transfer Not Ready 
> (Not Active) [Data Phase]
>   41.787221: dwc3_readl: addr 000000007bcb1278 value 80001000
>   41.787223: dwc3_writel: addr 000000007bcb1278 value 00001000
>   41.787223: dwc3_readl: addr 000000008eea6144 value 00000000
>   46.294697: dwc3_readl: addr 000000008eea6144 value 00000004
>   46.294698: dwc3_readl: addr 000000007bcb1278 value 00001000
>   46.294699: dwc3_writel: addr 000000007bcb1278 value 80001000
>   46.294700: dwc3_writel: addr 000000008eea6144 value 00000004
>
>
>
>
> Below is the snippet of the trace with the fix:
>
>   34.079018: dwc3_ctrl_req: Get String Descriptor(Index = 4, Length = 255)
>   34.079020: dwc3_prepare_trb: ep0in: 0/0 trb 000000006ece9b4d buf 
> 00000000b8d67800 size 128 ctrl 00000455 (HlCs:Sc:data)
>   34.079020: dwc3_prepare_trb: ep0in: 0/0 trb 000000001b323efa buf 
> 0000000037821000 size 0 ctrl 00000c53 (HLcs:SC:data)
>   34.079020: dwc3_readl: addr 00000000a90978f8 value 00002400
>   34.079021: dwc3_writel: addr 00000000c8f7ea9f value 00000000
>   34.079021: dwc3_writel: addr 000000000217f085 value 37820000
>   34.079021: dwc3_writel: addr 00000000b5593ec9 value 00000000
>   34.079021: dwc3_writel: addr 000000008b9e5492 value 00000406
>   34.079022: dwc3_readl: addr 000000008b9e5492 value 00000406
>   34.079024: dwc3_readl: addr 000000008b9e5492 value 00010006
>   34.079027: dwc3_gadget_ep_cmd: ep0in: cmd 'Start Transfer' [1030] 
> params 00000000 37820000 00000000 --> status: Successful
>   34.079027: dwc3_readl: addr 000000008b9e5492 value 00010006
>   34.079029: dwc3_readl: addr 00000000e9897a1c value 80001000
>   34.079031: dwc3_writel: addr 00000000e9897a1c value 00001000
>   34.079031: dwc3_readl: addr 0000000034bddbfc value 00000000
>   34.079144: dwc3_readl: addr 0000000034bddbfc value 00000004
>   34.079146: dwc3_readl: addr 00000000e9897a1c value 00001000
>   34.079147: dwc3_writel: addr 00000000e9897a1c value 80001000
>   34.079148: dwc3_writel: addr 0000000034bddbfc value 00000004
>   34.079148: dwc3_event: event (0000c042): ep0in: Transfer Complete 
> [Data Phase]
>   34.079148: dwc3_complete_trb: ep0out: 0/1 trb 000000006ece9b4d buf 
> 00000000b8d67800 size 0 ctrl 00000454 (hlCs:Sc:data)
>   34.079149: dwc3_complete_trb: ep0out: 0/1 trb 000000001b323efa buf 
> 0000000037821000 size 0 ctrl 00000c52 (hLcs:SC:data)
>   34.079149: dwc3_gadget_giveback: ep0out: req 00000000bbc62204 length 
> 128/128 ZsI ==> 0
>   34.079149: dwc3_readl: addr 00000000e9897a1c value 80001000
>   34.079150: dwc3_writel: addr 00000000e9897a1c value 00001000

now I see the problem, thank you :-)

             reply	other threads:[~2018-01-11  8:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11  8:29 Felipe Balbi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-01-09 23:47 [10/15] usb: dwc3: gadget: Set maxpacket size for ep0 IN Thinh Nguyen
2018-01-09  8:42 Felipe Balbi
2018-01-08 23:14 Thinh Nguyen
2018-01-08 12:05 Felipe Balbi
2018-01-05 20:15 Thinh Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fu7cyf1d.fsf@linux.intel.com \
    --to=balbi@kernel.org \
    --cc=John.Youn@synopsys.com \
    --cc=Thinh.Nguyen@synopsys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).