Re: dwc3 gadget breaks on system suspend/resume

Roger Quadros
2017-01-31T13:25:07Z

On 31/01/17 14:03, Felipe Balbi wrote:
>
> Hi,
>
> Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org> writes:
>>>>>>>> -DALEPENA = 0x0000000f
>>>>>>>> +DALEPENA = 0x00000000
>>>>>>>
>>>>>>> Thanks for the hints.
>>>>>>>
>>>>>>> This problem is because reason dwc3_gadget_run_stop() is timing out
>>>>>>> during the suspend sequence and so dwc3_disconnect_gadget() and
>>>>>>> __dwc3_gadget_stop() are not being called.
>>>>>>
>>>>>> I see
>>>>>>
>>>>>>> dwc3_suspend() does not consider dwc3_gadget_suspend()'s return value
>>>>>>> and happily continues suspending the machine.
>>>>>>>
>>>>>>> If I force dwc3_gadget_run_stop() to return 0 then everything works fine.
>>>>>>>
>>>>>>> Any ideas why DWC3_DSTS_DEVCTRLHLT is not getting set?
>>>>>>
>>>>>> no idea. It should always get set when run_stop is cleared. Can you
>>>>>> check if suspending with cable detached has any difference?
>>>>>
>>>>> After cable detach, it still timed out the next suspend. But on
>>>>> subsequent suspends there were no timeouts. (I didn't plug the cable
>>>>> back at all)
>>>>>
>>>>> This behaviour is on dra7. I will test the behaviour on am43x as well.
>>>>
>>>> wonder if there's something odd with 2.02a. AM437x is 2.40a IIRC,
>>>> testing that is, indeed, a good idea.
>>
>> Tried on am437x which is 2.40a but same timeout problem there as well.
>>
>>>
>>> What if your platform just takes longer to halt?
>>>
>>> Can you try below?
>>>
>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>>> index 4db97ecae885..d2e405793b1f 100644
>>> --- a/drivers/usb/dwc3/gadget.c
>>> +++ b/drivers/usb/dwc3/gadget.c
>>> @@ -1586,7 +1586,7 @@ static int dwc3_gadget_set_selfpowered(struct usb_gadget *g,
>>> static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
>>> {
>>> u32 reg;
>>> - u32 timeout = 500;
>>> + u32 timeout = 500000;
>>>
>>> if (pm_runtime_suspended(dwc->dev))
>>> return 0;
>>>
>>>
>>
>> Tried this but it doesn't resolve the issue.
>
> Interesting. I have no idea what to try now. How about checking if that
> susphy quirk flags help? Maybe your platform can't accept PHY being
> suspended, or something.
>

The susphy quirks are already enabled for both dra7 and am43 platforms.
I too don't have any clues as to what's going on. :(