Re: [PATCH] usb: dwc2: gadget: On disconnect reset device address to zero
From: Minas Harutyunyan
Date: Tue Jul 11 2017 - 06:30:12 EST
Hi Felipe,
On 7/11/2017 11:34 AM, Felipe Balbi wrote:
>
> Hi,
>
> Minas Harutyunyan <Minas.Harutyunyan@xxxxxxxxxxxx> writes:
>>> Minas Harutyunyan <Minas.Harutyunyan@xxxxxxxxxxxx> writes:
>>>> USB CV driver stack doesn't perform USB RESET after device disconnect/
>>>> connect, so need to reset to zero DEVADDR field in DCFG to pass
>>>> enumeration again.
>>>>
>>>> Signed-off-by: Minas Harutyunyan <hminas@xxxxxxxxxxxx>
>>>> ---
>>>> drivers/usb/dwc2/gadget.c | 3 +++
>>>> 1 file changed, 3 insertions(+)
>>>>
>>>> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
>>>> index 98a4a79e7f6e..deb3d901b99d 100644
>>>> --- a/drivers/usb/dwc2/gadget.c
>>>> +++ b/drivers/usb/dwc2/gadget.c
>>>> @@ -3174,6 +3174,9 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg)
>>>> return;
>>>>
>>>> hsotg->connected = 0;
>>>> + /* On disconnect reset device address to zero */
>>>> + __bic32(hsotg->regs + DCFG, DCFG_DEVADDR_MASK);
>>>> +
>>>
>>> Which of the tests are you talking about? Which particular USB CV are
>>> you running?
>>>
>> I used USB 3 Gen X CV (downloaded from usb.org 1-2 week ago). Tests are:
>> 1. "Device Summary" - after 1st pass, disconnect then connect again test
>> failed. Actually it show as "test passed" but not able to enumerate
>> device again.
>> 2. MSC "USB Mass Storage Power Up Test". After disconnect, by suite
>> request, and then connect test failed (pass, if reloading driver).
>
> I'll try these tests tomorrow next time I'm in the office. Woke up sick,
> working from home today :-s
>
>>> I don't remember ever seeing this with dwc3. How should I go about
>>> triggering this problem? If this was really the case, then we would have
>>> this on *all* UDCs.
>>>
>> dwc2 driver resetting DEVADDR in DCFG register only in function
>> dwc2_hsotg_core_init_disconnected() by soft reset. This function not
>> called on disconnect/connect with CV SW stack (function call not seen in
>> dmesg).
>
> right, this is a bug in dwc2. You should clear DEVADDR from your Reset
> handler, not disconnect.
>
>> This issue not seen with any other EHCI/XHCI hosts either on
>> Linux/Windows because these hosts issuing USB RESET, as result called
>> dwc2_hsotg_core_init_disconnected().
>>
>> In dwc3 per my understanding same stuff done in function
>> dwc3_gadget_reset_interrupt(), am I right?
>
> right, as it should. If dwc3_gadget_reset_interrupt() runs, this means
> the host *is* issuing USB reset signalling.
>
>>> I just did a fresh install of USB 3 Gen X CV (that I just download from
>>> usb.org). Ran Chapter 9 tests against a HS dwc3 board I have around and
>>> I can't see the problem you're talking about.
>>>
>> Yes, this issue not seen with dwc3.
>
> because we clear DEVADDR on Reset.
>
Thank you for review and feedback.
New patch "[PATCH] usb: dwc2: gadget: On USB RESET reset device address
to zero" sent for review.
Thanks,
Minas