diff mbox

[Bug] usb: dwc2: Add functions to set and clear force mode

Message ID 2B3535C5ECE8B5419E3ECBE30077290901DC4322F0@US01WEMBX2.internal.synopsys.com (mailing list archive)
State New, archived
Headers show

Commit Message

John Youn Feb. 3, 2016, 1:08 a.m. UTC
On 2/2/2016 4:36 PM, Caesar Wang wrote:
> Hi John,
> 
> ? 2016?02?03? 08:03, John Youn ??:
>> On 2/1/2016 6:53 PM, Caesar Wang wrote:
>>> John,
>>>
>>> I will suggest the msleep(25) delay should  put in
>>> 'dwc2_force_dr_mode()' instead of the 'dwc2_clear_force_mode()'
>>>
>> Hi Caesar,
>>
>> Are you saying that just msleep(25) in that function like this solves
>> your issue?
>>
>> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
>> index 39a0fa8..e8a9688 100644
>> --- a/drivers/usb/dwc2/core.c
>> +++ b/drivers/usb/dwc2/core.c
>> @@ -625,6 +625,8 @@ void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
>>                           __func__, hsotg->dr_mode);
>>                  break;
>>          }
>> +
>> +       msleep(25);
> 
> Yep, that will solve this issue.
> 

Ok thanks. Though that still seems strange since you should be getting
the msleep(25) from either the dwc2_force_mode() or
dwc2_clear_force_mode().

Can you check if the following patch works?

If so, I think we can go with that to fix the regression for
now. Otherwise I'll just add the extra msleep(25) and revisit this
later.

Regards,
John

---->8----

Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Comments

Caesar Wang Feb. 3, 2016, 1:10 a.m. UTC | #1
? 2016?02?03? 09:08, John Youn ??:
> On 2/2/2016 4:36 PM, Caesar Wang wrote:
>> Hi John,
>>
>> ? 2016?02?03? 08:03, John Youn ??:
>>> On 2/1/2016 6:53 PM, Caesar Wang wrote:
>>>> John,
>>>>
>>>> I will suggest the msleep(25) delay should  put in
>>>> 'dwc2_force_dr_mode()' instead of the 'dwc2_clear_force_mode()'
>>>>
>>> Hi Caesar,
>>>
>>> Are you saying that just msleep(25) in that function like this solves
>>> your issue?
>>>
>>> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
>>> index 39a0fa8..e8a9688 100644
>>> --- a/drivers/usb/dwc2/core.c
>>> +++ b/drivers/usb/dwc2/core.c
>>> @@ -625,6 +625,8 @@ void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
>>>                            __func__, hsotg->dr_mode);
>>>                   break;
>>>           }
>>> +
>>> +       msleep(25);
>> Yep, that will solve this issue.
>>
> Ok thanks. Though that still seems strange since you should be getting
> the msleep(25) from either the dwc2_force_mode() or
> dwc2_clear_force_mode().
>
> Can you check if the following patch works?
>
> If so, I think we can go with that to fix the regression for
> now. Otherwise I'll just add the extra msleep(25) and revisit this
> later.
>
> Regards,
> John
>
> ---->8----
>
> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
> index e991d55..13c060c 100644
> --- a/drivers/usb/dwc2/core.c
> +++ b/drivers/usb/dwc2/core.c
> @@ -576,7 +576,6 @@ static bool dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host)
>          gusbcfg |= set;
>          dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
>   
> -       msleep(25);
>          return true;
>   }
>   
> @@ -596,7 +595,6 @@ static void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
>           * NOTE: This long sleep is _very_ important, otherwise the core will
>           * not stay in host mode after a connector ID change!
>           */
> -       msleep(25);
>   }
>   
>   /*
> @@ -619,6 +617,8 @@ void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
>                           __func__, hsotg->dr_mode);
>                  break;
>          }
> +
> +       msleep(25);
>   }

Right, that works for me.
John Youn Feb. 3, 2016, 1:32 a.m. UTC | #2
On 2/2/2016 5:10 PM, Caesar Wang wrote:
> 
> 
> ? 2016?02?03? 09:08, John Youn ??:
>> On 2/2/2016 4:36 PM, Caesar Wang wrote:
>>> Hi John,
>>>
>>> ? 2016?02?03? 08:03, John Youn ??:
>>>> On 2/1/2016 6:53 PM, Caesar Wang wrote:
>>>>> John,
>>>>>
>>>>> I will suggest the msleep(25) delay should  put in
>>>>> 'dwc2_force_dr_mode()' instead of the 'dwc2_clear_force_mode()'
>>>>>
>>>> Hi Caesar,
>>>>
>>>> Are you saying that just msleep(25) in that function like this solves
>>>> your issue?
>>>>
>>>> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
>>>> index 39a0fa8..e8a9688 100644
>>>> --- a/drivers/usb/dwc2/core.c
>>>> +++ b/drivers/usb/dwc2/core.c
>>>> @@ -625,6 +625,8 @@ void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
>>>>                            __func__, hsotg->dr_mode);
>>>>                   break;
>>>>           }
>>>> +
>>>> +       msleep(25);
>>> Yep, that will solve this issue.
>>>
>> Ok thanks. Though that still seems strange since you should be getting
>> the msleep(25) from either the dwc2_force_mode() or
>> dwc2_clear_force_mode().
>>
>> Can you check if the following patch works?
>>
>> If so, I think we can go with that to fix the regression for
>> now. Otherwise I'll just add the extra msleep(25) and revisit this
>> later.
>>
>> Regards,
>> John
>>
>> ---->8----
>>
>> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
>> index e991d55..13c060c 100644
>> --- a/drivers/usb/dwc2/core.c
>> +++ b/drivers/usb/dwc2/core.c
>> @@ -576,7 +576,6 @@ static bool dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host)
>>          gusbcfg |= set;
>>          dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
>>   
>> -       msleep(25);
>>          return true;
>>   }
>>   
>> @@ -596,7 +595,6 @@ static void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
>>           * NOTE: This long sleep is _very_ important, otherwise the core will
>>           * not stay in host mode after a connector ID change!
>>           */
>> -       msleep(25);
>>   }
>>   
>>   /*
>> @@ -619,6 +617,8 @@ void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
>>                           __func__, hsotg->dr_mode);
>>                  break;
>>          }
>> +
>> +       msleep(25);
>>   }
> 
> Right, that works for me.
> 

Ok, interesting. Actually this won't work either since we need the
separate msleeps when those functions are called from other contexts.

Is your controller by chance *not* OTG capable, i.e.

dwc2_hw_is_otg(hsotg) == false

Then the msleep in dwc2_force_mode() is skipped.

Then, for some reason, skipping it (even though nothing was forced)
causes the failure on your platform.

Regards,
John
diff mbox

Patch

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index e991d55..13c060c 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -576,7 +576,6 @@  static bool dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host)
        gusbcfg |= set;
        dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
 
-       msleep(25);
        return true;
 }
 
@@ -596,7 +595,6 @@  static void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
         * NOTE: This long sleep is _very_ important, otherwise the core will
         * not stay in host mode after a connector ID change!
         */
-       msleep(25);
 }
 
 /*
@@ -619,6 +617,8 @@  void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
                         __func__, hsotg->dr_mode);
                break;
        }
+
+       msleep(25);
 }
_______________________________________________
Linux-rockchip mailing list