RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-21 Thread Jun Li
Hi Felipe,

> -Original Message-
> From: Felipe Balbi  On Behalf Of Felipe Balbi
> Sent: 2020年5月21日 14:23
> To: Thinh Nguyen ; Jun Li ; Jun Li
> 
> Cc: John Stultz ; lkml 
> ; Yu
> Chen ; Greg Kroah-Hartman ; 
> Rob
> Herring ; Mark Rutland ; ShuFan Lee
> ; Heikki Krogerus ;
> Suzuki K Poulose ; Chunfeng Yun
> ; Hans de Goede ; Andy 
> Shevchenko
> ; Valentin Schneider ;
> Jack Pham ; Linux USB List ; 
> open
> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
> ;
> Peter Chen 
> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by 
> device
> controller
> 
> 
> Hi Jun,
> 
> Felipe Balbi  writes:
> >> In any case, increasing the timeout should be fine with me. It maybe
> >> difficult to determine the max timeout base on the slowest clock rate
> >> and number of cycles. Different controller and controller versions
> >> behave differently and may have different number of clock cycles to
> >> complete a command.
> >>
> >> The RTL engineer recommended timeout to be at least 1ms (which maybe
> >> more than the polling rate of this patch). I'm fine with either the
> >> rate provided by this tested patch or higher.
> >
> > A whole ms waiting for a command to complete? Wow, that's a lot of
> > time blocking the CPU. It looks like, perhaps, we should move to
> > command completion interrupts. The difficulty here is that we issue
> > commands from within the interrupt handler and, as such, can't
> > wait_for_completion().
> >
> > Meanwhile, we will take the timeout increase I guess, otherwise NXP
> > won't have a working setup.
> 
> patch 1 in this series doesn't apply to testing/next. Care to rebase and 
> resend?

Sure, I will rebase and resend this patch with timeout loop 5000.

Thanks
Li Jun
> 
> Thank you
> 
> --
> balbi


RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-21 Thread Jun Li
Hi Thinh,
> -Original Message-
> From: Thinh Nguyen 
> Sent: 2020年5月21日 9:56
> To: Jun Li ; Felipe Balbi ; Jun Li
> 
> Cc: John Stultz ; lkml 
> ; Yu
> Chen ; Greg Kroah-Hartman ; 
> Rob
> Herring ; Mark Rutland ; ShuFan Lee
> ; Heikki Krogerus ;
> Suzuki K Poulose ; Chunfeng Yun
> ; Hans de Goede ; Andy 
> Shevchenko
> ; Valentin Schneider ;
> Jack Pham ; Linux USB List ; 
> open
> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
> ;
> Peter Chen 
> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by 
> device
> controller
> 
> Thinh Nguyen wrote:
> > Jun Li wrote:
> >> Hi
> >>
> >>> -Original Message-
> >>> From: Thinh Nguyen 
> >>> Sent: 2020年5月19日 14:46
> >>> To: Jun Li ; Felipe Balbi ; Jun Li
> >>> 
> >>> Cc: John Stultz ; lkml
> >>> ; Yu Chen ; Greg
> >>> Kroah-Hartman ; Rob Herring
> >>> ; Mark Rutland ; ShuFan
> >>> Lee ; Heikki Krogerus
> >>> ;
> >>> Suzuki K Poulose ; Chunfeng Yun
> >>> ; Hans de Goede ;
> >>> Andy Shevchenko ; Valentin Schneider
> >>> ; Jack Pham ;
> >>> Linux USB List ; open list:OPEN FIRMWARE
> >>> AND FLATTENED DEVICE TREE BINDINGS ;
> >>> Peter Chen 
> >>> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct
> >>> cleared by device controller
> >>>
> >>> Thinh Nguyen wrote:
> >>>> Jun Li wrote:
> >>>>>> -Original Message-
> >>>>>> From: Felipe Balbi  On Behalf Of Felipe Balbi
> >>>>>> Sent: 2020年5月16日 19:57
> >>>>>> To: Jun Li ; Thinh Nguyen
> >>>>>> ; Jun Li 
> >>>>>> Cc: John Stultz ; lkml
> >>>>>> ; Yu Chen ;
> >>>>>> Greg Kroah-Hartman ; Rob Herring
> >>>>>> ; Mark Rutland ; ShuFan
> >>>>>> Lee ; Heikki Krogerus
> >>>>>> ;
> >>>>>> Suzuki K Poulose ; Chunfeng Yun
> >>>>>> ; Hans de Goede ;
> >>>>>> Andy Shevchenko ; Valentin Schneider
> >>>>>> ; Jack Pham ;
> >>>>>> Linux USB List ; open list:OPEN
> >>>>>> FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
> >>>>>> ; Peter Chen ;
> >>>>>> Thinh Nguyen 
> >>>>>> Subject: RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for
> >>>>>> CmdAct cleared by device controller
> >>>>>>
> >>>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>> Jun Li  writes:
> >>>>>>>>>> Hi Thinh, could you comment this?
> >>>>>>>>> You only need to wake up the usb2 phy when issuing the command
> >>>>>>>>> while running in highspeed or below. If you're running in SS
> >>>>>>>>> or higher, internally the controller does it for you for usb3 phy.
> >>>>>>>>> In Jun's case, it seems like it takes longer for his phy to wake up.
> >>>>>>>>>
> >>>>>>>>> IMO, in this case, I think it's fine to increase the command 
> >>>>>>>>> timeout.
> >>>>>>>> Is there an upper limit to this? Is 32k clock the slowest that
> >>>>>>>> can be fed to the PHY as a suspend clock?
> >>>>>>> Yes, 32K clock is the slowest, Per DWC3 document on Power Down
> >>>>>>> Scale (bits 31:19 of GCTL):
> >>>>>>>
> >>>>>>> "Power Down Scale (PwrDnScale)
> >>>>>>> The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock
> >>>>>>> source to a small part of the USB3 controller that operates when
> >>>>>>> the SS PHY is in its lowest power (P3) state, and therefore does not 
> >>>>>>> provide
> a clock.
> >>>>>>> The Power Down Scale field specifies how many suspend_clk
> >>>>>>> periods fit into a 16 kHz clock period. When performing the
> >>>>>>> division, round up the remainder.
> >>>>>>> For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz
> >>>>>>> Suspend clock, Power Down Scale = 25000 kHz/16 kHz = 13'd1563
> 

Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-21 Thread Felipe Balbi

Hi Jun,

Felipe Balbi  writes:
>> In any case, increasing the timeout should be fine with me. It maybe 
>> difficult to determine the max timeout base on the slowest clock rate 
>> and number of cycles. Different controller and controller versions 
>> behave differently and may have different number of clock cycles to 
>> complete a command.
>>
>> The RTL engineer recommended timeout to be at least 1ms (which maybe 
>> more than the polling rate of this patch). I'm fine with either the rate 
>> provided by this tested patch or higher.
>
> A whole ms waiting for a command to complete? Wow, that's a lot of time
> blocking the CPU. It looks like, perhaps, we should move to command
> completion interrupts. The difficulty here is that we issue commands
> from within the interrupt handler and, as such, can't
> wait_for_completion().
>
> Meanwhile, we will take the timeout increase I guess, otherwise NXP
> won't have a working setup.

patch 1 in this series doesn't apply to testing/next. Care to rebase and
resend?

Thank you

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-21 Thread Felipe Balbi

Hi,

Thinh Nguyen  writes:
 "Power Down Scale (PwrDnScale)
 The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock source
 to a small part of the USB3 controller that operates when the SS
 PHY is in its lowest power (P3) state, and therefore does not provide 
 a clock.
 The Power Down Scale field specifies how many suspend_clk periods
 fit into a 16 kHz clock period. When performing the division, round
 up the remainder.
 For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz
 Suspend clock, Power Down Scale = 25000 kHz/16 kHz = 13'd1563
 (rounder up)
 Note:
 - Minimum Suspend clock frequency is 32 kHz
 - Maximum Suspend clock frequency is 125 MHz"
>>> Cool, now do we have an upper bound for how many clock cycles it
>>> takes to wake up the PHY?
>> My understanding is this ep command does not wake up the SS PHY, the
>> SS PHY still stays at P3 when execute this ep command. The time
>> required here is to wait controller complete something for this ep
>> command with 32K clock.
> Sorry I made a mistake. You're right. Just checked with one of the RTL
> engineers, and it doesn't need to wake up the phy. However, if it is
> eSS speed, it may take longer time as the command may be completing
> with the suspend clock.
>
 What's the value for GCTL[7:6]?
>>> 2'b00
>>>
>>> Thanks
>>> Li Jun
>> (Sorry for the delay reply)
>>
>> If it's 0, then the ram clock should be the same as the bus_clk, which
>> is odd since you mentioned that the suspend_clk is used instead while in P3.
>
> Just checked with the RTL engineer, even if GCTL[7:6] is set to 0, 
> internally it can still run with suspend clock during P3.
>
>> Anyway, I was looking for a way maybe to improve the speed during
>> issuing a command. One way is to set GUSB3PIPECTL[17]=0, and it should
>> wakeup the phy anytime. I think Felipe suggested it. It's odd that it
>> doesn't work for you. I don't have other ideas beside increasing the
>> command timeout.
>>
>
> In any case, increasing the timeout should be fine with me. It maybe 
> difficult to determine the max timeout base on the slowest clock rate 
> and number of cycles. Different controller and controller versions 
> behave differently and may have different number of clock cycles to 
> complete a command.
>
> The RTL engineer recommended timeout to be at least 1ms (which maybe 
> more than the polling rate of this patch). I'm fine with either the rate 
> provided by this tested patch or higher.

A whole ms waiting for a command to complete? Wow, that's a lot of time
blocking the CPU. It looks like, perhaps, we should move to command
completion interrupts. The difficulty here is that we issue commands
from within the interrupt handler and, as such, can't
wait_for_completion().

Meanwhile, we will take the timeout increase I guess, otherwise NXP
won't have a working setup.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-20 Thread Thinh Nguyen
Thinh Nguyen wrote:
> Jun Li wrote:
>> Hi
>>
>>> -Original Message-
>>> From: Thinh Nguyen 
>>> Sent: 2020年5月19日 14:46
>>> To: Jun Li ; Felipe Balbi ; Jun Li
>>> 
>>> Cc: John Stultz ; lkml 
>>> ; Yu
>>> Chen ; Greg Kroah-Hartman 
>>> ; Rob
>>> Herring ; Mark Rutland ; ShuFan 
>>> Lee
>>> ; Heikki Krogerus ;
>>> Suzuki K Poulose ; Chunfeng Yun
>>> ; Hans de Goede ; Andy 
>>> Shevchenko
>>> ; Valentin Schneider 
>>> ;
>>> Jack Pham ; Linux USB List 
>>> ; open
>>> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
>>> ;
>>> Peter Chen 
>>> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared 
>>> by device
>>> controller
>>>
>>> Thinh Nguyen wrote:
>>>> Jun Li wrote:
>>>>>> -Original Message-
>>>>>> From: Felipe Balbi  On Behalf Of Felipe Balbi
>>>>>> Sent: 2020年5月16日 19:57
>>>>>> To: Jun Li ; Thinh Nguyen
>>>>>> ; Jun Li 
>>>>>> Cc: John Stultz ; lkml
>>>>>> ; Yu Chen ; Greg
>>>>>> Kroah-Hartman ; Rob Herring
>>>>>> ; Mark Rutland ; ShuFan
>>>>>> Lee ; Heikki Krogerus
>>>>>> ;
>>>>>> Suzuki K Poulose ; Chunfeng Yun
>>>>>> ; Hans de Goede ;
>>>>>> Andy Shevchenko ; Valentin Schneider
>>>>>> ; Jack Pham ;
>>>>>> Linux USB List ; open list:OPEN FIRMWARE
>>>>>> AND FLATTENED DEVICE TREE BINDINGS ;
>>>>>> Peter Chen ; Thinh Nguyen
>>>>>> 
>>>>>> Subject: RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct
>>>>>> cleared by device controller
>>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Jun Li  writes:
>>>>>>>>>> Hi Thinh, could you comment this?
>>>>>>>>> You only need to wake up the usb2 phy when issuing the command
>>>>>>>>> while running in highspeed or below. If you're running in SS or
>>>>>>>>> higher, internally the controller does it for you for usb3 phy.
>>>>>>>>> In Jun's case, it seems like it takes longer for his phy to wake up.
>>>>>>>>>
>>>>>>>>> IMO, in this case, I think it's fine to increase the command timeout.
>>>>>>>> Is there an upper limit to this? Is 32k clock the slowest that can
>>>>>>>> be fed to the PHY as a suspend clock?
>>>>>>> Yes, 32K clock is the slowest, Per DWC3 document on Power Down
>>>>>>> Scale (bits 31:19 of GCTL):
>>>>>>>
>>>>>>> "Power Down Scale (PwrDnScale)
>>>>>>> The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock source
>>>>>>> to a small part of the USB3 controller that operates when the SS
>>>>>>> PHY is in its lowest power (P3) state, and therefore does not provide a 
>>>>>>> clock.
>>>>>>> The Power Down Scale field specifies how many suspend_clk periods
>>>>>>> fit into a 16 kHz clock period. When performing the division, round
>>>>>>> up the remainder.
>>>>>>> For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz
>>>>>>> Suspend clock, Power Down Scale = 25000 kHz/16 kHz = 13'd1563
>>>>>>> (rounder up)
>>>>>>> Note:
>>>>>>> - Minimum Suspend clock frequency is 32 kHz
>>>>>>> - Maximum Suspend clock frequency is 125 MHz"
>>>>>> Cool, now do we have an upper bound for how many clock cycles it
>>>>>> takes to wake up the PHY?
>>>>> My understanding is this ep command does not wake up the SS PHY, the
>>>>> SS PHY still stays at P3 when execute this ep command. The time
>>>>> required here is to wait controller complete something for this ep
>>>>> command with 32K clock.
>>>> Sorry I made a mistake. You're right. Just checked with one of the RTL
>>>> engineers, and it doesn't need to wake up the phy. However, if it is
>>>> eSS speed, it may take longer time as the command may be completing
>>>> with the suspend clock.
>>>>
>>> What's the value for GCTL[7:6]?
>> 2'b00
>>
>> Thanks
>> Li Jun
> (Sorry for the delay reply)
>
> If it's 0, then the ram clock should be the same as the bus_clk, which
> is odd since you mentioned that the suspend_clk is used instead while in P3.

Just checked with the RTL engineer, even if GCTL[7:6] is set to 0, 
internally it can still run with suspend clock during P3.

> Anyway, I was looking for a way maybe to improve the speed during
> issuing a command. One way is to set GUSB3PIPECTL[17]=0, and it should
> wakeup the phy anytime. I think Felipe suggested it. It's odd that it
> doesn't work for you. I don't have other ideas beside increasing the
> command timeout.
>

In any case, increasing the timeout should be fine with me. It maybe 
difficult to determine the max timeout base on the slowest clock rate 
and number of cycles. Different controller and controller versions 
behave differently and may have different number of clock cycles to 
complete a command.

The RTL engineer recommended timeout to be at least 1ms (which maybe 
more than the polling rate of this patch). I'm fine with either the rate 
provided by this tested patch or higher.

BR,
Thinh


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-20 Thread Thinh Nguyen
Jun Li wrote:
> Hi
>
>> -Original Message-
>> From: Thinh Nguyen 
>> Sent: 2020年5月19日 14:46
>> To: Jun Li ; Felipe Balbi ; Jun Li
>> 
>> Cc: John Stultz ; lkml 
>> ; Yu
>> Chen ; Greg Kroah-Hartman ; 
>> Rob
>> Herring ; Mark Rutland ; ShuFan Lee
>> ; Heikki Krogerus ;
>> Suzuki K Poulose ; Chunfeng Yun
>> ; Hans de Goede ; Andy 
>> Shevchenko
>> ; Valentin Schneider ;
>> Jack Pham ; Linux USB List 
>> ; open
>> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
>> ;
>> Peter Chen 
>> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared 
>> by device
>> controller
>>
>> Thinh Nguyen wrote:
>>> Jun Li wrote:
>>>>> -Original Message-
>>>>> From: Felipe Balbi  On Behalf Of Felipe Balbi
>>>>> Sent: 2020年5月16日 19:57
>>>>> To: Jun Li ; Thinh Nguyen
>>>>> ; Jun Li 
>>>>> Cc: John Stultz ; lkml
>>>>> ; Yu Chen ; Greg
>>>>> Kroah-Hartman ; Rob Herring
>>>>> ; Mark Rutland ; ShuFan
>>>>> Lee ; Heikki Krogerus
>>>>> ;
>>>>> Suzuki K Poulose ; Chunfeng Yun
>>>>> ; Hans de Goede ;
>>>>> Andy Shevchenko ; Valentin Schneider
>>>>> ; Jack Pham ;
>>>>> Linux USB List ; open list:OPEN FIRMWARE
>>>>> AND FLATTENED DEVICE TREE BINDINGS ;
>>>>> Peter Chen ; Thinh Nguyen
>>>>> 
>>>>> Subject: RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct
>>>>> cleared by device controller
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> Jun Li  writes:
>>>>>>>>> Hi Thinh, could you comment this?
>>>>>>>> You only need to wake up the usb2 phy when issuing the command
>>>>>>>> while running in highspeed or below. If you're running in SS or
>>>>>>>> higher, internally the controller does it for you for usb3 phy.
>>>>>>>> In Jun's case, it seems like it takes longer for his phy to wake up.
>>>>>>>>
>>>>>>>> IMO, in this case, I think it's fine to increase the command timeout.
>>>>>>> Is there an upper limit to this? Is 32k clock the slowest that can
>>>>>>> be fed to the PHY as a suspend clock?
>>>>>> Yes, 32K clock is the slowest, Per DWC3 document on Power Down
>>>>>> Scale (bits 31:19 of GCTL):
>>>>>>
>>>>>> "Power Down Scale (PwrDnScale)
>>>>>> The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock source
>>>>>> to a small part of the USB3 controller that operates when the SS
>>>>>> PHY is in its lowest power (P3) state, and therefore does not provide a 
>>>>>> clock.
>>>>>> The Power Down Scale field specifies how many suspend_clk periods
>>>>>> fit into a 16 kHz clock period. When performing the division, round
>>>>>> up the remainder.
>>>>>> For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz
>>>>>> Suspend clock, Power Down Scale = 25000 kHz/16 kHz = 13'd1563
>>>>>> (rounder up)
>>>>>> Note:
>>>>>> - Minimum Suspend clock frequency is 32 kHz
>>>>>> - Maximum Suspend clock frequency is 125 MHz"
>>>>> Cool, now do we have an upper bound for how many clock cycles it
>>>>> takes to wake up the PHY?
>>>> My understanding is this ep command does not wake up the SS PHY, the
>>>> SS PHY still stays at P3 when execute this ep command. The time
>>>> required here is to wait controller complete something for this ep
>>>> command with 32K clock.
>>> Sorry I made a mistake. You're right. Just checked with one of the RTL
>>> engineers, and it doesn't need to wake up the phy. However, if it is
>>> eSS speed, it may take longer time as the command may be completing
>>> with the suspend clock.
>>>
>> What's the value for GCTL[7:6]?
> 2'b00
>
> Thanks
> Li Jun

(Sorry for the delay reply)

If it's 0, then the ram clock should be the same as the bus_clk, which 
is odd since you mentioned that the suspend_clk is used instead while in P3.

Anyway, I was looking for a way maybe to improve the speed during 
issuing a command. One way is to set GUSB3PIPECTL[17]=0, and it should 
wakeup the phy anytime. I think Felipe suggested it. It's odd that it 
doesn't work for you. I don't have other ideas beside increasing the 
command timeout.

Thanks,
Thinh



RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-19 Thread Jun Li
Hi

> -Original Message-
> From: Thinh Nguyen 
> Sent: 2020年5月19日 14:46
> To: Jun Li ; Felipe Balbi ; Jun Li
> 
> Cc: John Stultz ; lkml 
> ; Yu
> Chen ; Greg Kroah-Hartman ; 
> Rob
> Herring ; Mark Rutland ; ShuFan Lee
> ; Heikki Krogerus ;
> Suzuki K Poulose ; Chunfeng Yun
> ; Hans de Goede ; Andy 
> Shevchenko
> ; Valentin Schneider ;
> Jack Pham ; Linux USB List ; 
> open
> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
> ;
> Peter Chen 
> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by 
> device
> controller
> 
> Thinh Nguyen wrote:
> > Jun Li wrote:
> >>> -Original Message-
> >>> From: Felipe Balbi  On Behalf Of Felipe Balbi
> >>> Sent: 2020年5月16日 19:57
> >>> To: Jun Li ; Thinh Nguyen
> >>> ; Jun Li 
> >>> Cc: John Stultz ; lkml
> >>> ; Yu Chen ; Greg
> >>> Kroah-Hartman ; Rob Herring
> >>> ; Mark Rutland ; ShuFan
> >>> Lee ; Heikki Krogerus
> >>> ;
> >>> Suzuki K Poulose ; Chunfeng Yun
> >>> ; Hans de Goede ;
> >>> Andy Shevchenko ; Valentin Schneider
> >>> ; Jack Pham ;
> >>> Linux USB List ; open list:OPEN FIRMWARE
> >>> AND FLATTENED DEVICE TREE BINDINGS ;
> >>> Peter Chen ; Thinh Nguyen
> >>> 
> >>> Subject: RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct
> >>> cleared by device controller
> >>>
> >>>
> >>> Hi,
> >>>
> >>> Jun Li  writes:
> >>>>>>> Hi Thinh, could you comment this?
> >>>>>> You only need to wake up the usb2 phy when issuing the command
> >>>>>> while running in highspeed or below. If you're running in SS or
> >>>>>> higher, internally the controller does it for you for usb3 phy.
> >>>>>> In Jun's case, it seems like it takes longer for his phy to wake up.
> >>>>>>
> >>>>>> IMO, in this case, I think it's fine to increase the command timeout.
> >>>>> Is there an upper limit to this? Is 32k clock the slowest that can
> >>>>> be fed to the PHY as a suspend clock?
> >>>> Yes, 32K clock is the slowest, Per DWC3 document on Power Down
> >>>> Scale (bits 31:19 of GCTL):
> >>>>
> >>>> "Power Down Scale (PwrDnScale)
> >>>> The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock source
> >>>> to a small part of the USB3 controller that operates when the SS
> >>>> PHY is in its lowest power (P3) state, and therefore does not provide a 
> >>>> clock.
> >>>> The Power Down Scale field specifies how many suspend_clk periods
> >>>> fit into a 16 kHz clock period. When performing the division, round
> >>>> up the remainder.
> >>>> For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz
> >>>> Suspend clock, Power Down Scale = 25000 kHz/16 kHz = 13'd1563
> >>>> (rounder up)
> >>>> Note:
> >>>> - Minimum Suspend clock frequency is 32 kHz
> >>>> - Maximum Suspend clock frequency is 125 MHz"
> >>> Cool, now do we have an upper bound for how many clock cycles it
> >>> takes to wake up the PHY?
> >> My understanding is this ep command does not wake up the SS PHY, the
> >> SS PHY still stays at P3 when execute this ep command. The time
> >> required here is to wait controller complete something for this ep
> >> command with 32K clock.
> > Sorry I made a mistake. You're right. Just checked with one of the RTL
> > engineers, and it doesn't need to wake up the phy. However, if it is
> > eSS speed, it may take longer time as the command may be completing
> > with the suspend clock.
> >
> 
> What's the value for GCTL[7:6]?

2'b00

Thanks
Li Jun
> 
> BR,
> Thinh


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-19 Thread Thinh Nguyen
Thinh Nguyen wrote:
> Jun Li wrote:
>>> -Original Message-
>>> From: Felipe Balbi  On Behalf Of Felipe Balbi
>>> Sent: 2020年5月16日 19:57
>>> To: Jun Li ; Thinh Nguyen ; Jun 
>>> Li
>>> 
>>> Cc: John Stultz ; lkml 
>>> ; Yu
>>> Chen ; Greg Kroah-Hartman 
>>> ; Rob
>>> Herring ; Mark Rutland ; ShuFan 
>>> Lee
>>> ; Heikki Krogerus ;
>>> Suzuki K Poulose ; Chunfeng Yun
>>> ; Hans de Goede ; Andy 
>>> Shevchenko
>>> ; Valentin Schneider 
>>> ;
>>> Jack Pham ; Linux USB List 
>>> ; open
>>> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
>>> ;
>>> Peter Chen ; Thinh Nguyen 
>>> Subject: RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared 
>>> by device
>>> controller
>>>
>>>
>>> Hi,
>>>
>>> Jun Li  writes:
>>>>>>> Hi Thinh, could you comment this?
>>>>>> You only need to wake up the usb2 phy when issuing the command
>>>>>> while running in highspeed or below. If you're running in SS or
>>>>>> higher, internally the controller does it for you for usb3 phy. In
>>>>>> Jun's case, it seems like it takes longer for his phy to wake up.
>>>>>>
>>>>>> IMO, in this case, I think it's fine to increase the command timeout.
>>>>> Is there an upper limit to this? Is 32k clock the slowest that can be
>>>>> fed to the PHY as a suspend clock?
>>>> Yes, 32K clock is the slowest, Per DWC3 document on Power Down Scale
>>>> (bits 31:19 of GCTL):
>>>>
>>>> "Power Down Scale (PwrDnScale)
>>>> The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock source to
>>>> a small part of the USB3 controller that operates when the SS PHY is
>>>> in its lowest power (P3) state, and therefore does not provide a clock.
>>>> The Power Down Scale field specifies how many suspend_clk periods fit
>>>> into a 16 kHz clock period. When performing the division, round up the
>>>> remainder.
>>>> For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz Suspend
>>>> clock, Power Down Scale = 25000 kHz/16 kHz = 13'd1563 (rounder up)
>>>> Note:
>>>> - Minimum Suspend clock frequency is 32 kHz
>>>> - Maximum Suspend clock frequency is 125 MHz"
>>> Cool, now do we have an upper bound for how many clock cycles it takes to 
>>> wake up
>>> the PHY?
>> My understanding is this ep command does not wake up the SS PHY,
>> the SS PHY still stays at P3 when execute this ep command. The time
>> required here is to wait controller complete something for this ep
>> command with 32K clock.
> Sorry I made a mistake. You're right. Just checked with one of the RTL
> engineers, and it doesn't need to wake up the phy. However, if it is eSS
> speed, it may take longer time as the command may be completing with the
> suspend clock.
>

What's the value for GCTL[7:6]?

BR,
Thinh


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-19 Thread Thinh Nguyen
Jun Li wrote:
>> -Original Message-
>> From: Felipe Balbi  On Behalf Of Felipe Balbi
>> Sent: 2020年5月16日 19:57
>> To: Jun Li ; Thinh Nguyen ; Jun Li
>> 
>> Cc: John Stultz ; lkml 
>> ; Yu
>> Chen ; Greg Kroah-Hartman ; 
>> Rob
>> Herring ; Mark Rutland ; ShuFan Lee
>> ; Heikki Krogerus ;
>> Suzuki K Poulose ; Chunfeng Yun
>> ; Hans de Goede ; Andy 
>> Shevchenko
>> ; Valentin Schneider ;
>> Jack Pham ; Linux USB List 
>> ; open
>> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
>> ;
>> Peter Chen ; Thinh Nguyen 
>> Subject: RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared 
>> by device
>> controller
>>
>>
>> Hi,
>>
>> Jun Li  writes:
>>>>>> Hi Thinh, could you comment this?
>>>>> You only need to wake up the usb2 phy when issuing the command
>>>>> while running in highspeed or below. If you're running in SS or
>>>>> higher, internally the controller does it for you for usb3 phy. In
>>>>> Jun's case, it seems like it takes longer for his phy to wake up.
>>>>>
>>>>> IMO, in this case, I think it's fine to increase the command timeout.
>>>> Is there an upper limit to this? Is 32k clock the slowest that can be
>>>> fed to the PHY as a suspend clock?
>>> Yes, 32K clock is the slowest, Per DWC3 document on Power Down Scale
>>> (bits 31:19 of GCTL):
>>>
>>> "Power Down Scale (PwrDnScale)
>>> The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock source to
>>> a small part of the USB3 controller that operates when the SS PHY is
>>> in its lowest power (P3) state, and therefore does not provide a clock.
>>> The Power Down Scale field specifies how many suspend_clk periods fit
>>> into a 16 kHz clock period. When performing the division, round up the
>>> remainder.
>>> For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz Suspend
>>> clock, Power Down Scale = 25000 kHz/16 kHz = 13'd1563 (rounder up)
>>> Note:
>>> - Minimum Suspend clock frequency is 32 kHz
>>> - Maximum Suspend clock frequency is 125 MHz"
>> Cool, now do we have an upper bound for how many clock cycles it takes to 
>> wake up
>> the PHY?
> My understanding is this ep command does not wake up the SS PHY,
> the SS PHY still stays at P3 when execute this ep command. The time
> required here is to wait controller complete something for this ep
> command with 32K clock.

Sorry I made a mistake. You're right. Just checked with one of the RTL 
engineers, and it doesn't need to wake up the phy. However, if it is eSS 
speed, it may take longer time as the command may be completing with the 
suspend clock.

BR,
Thinh


>
>> Then we can just set the time to that upper bound.
> Per my test with trace, the time is about 400us(~13 cycles).
>
> Thanks
> Li Jun
>> --
>> balbi



RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-18 Thread Jun Li


> -Original Message-
> From: Felipe Balbi  On Behalf Of Felipe Balbi
> Sent: 2020年5月16日 19:57
> To: Jun Li ; Thinh Nguyen ; Jun Li
> 
> Cc: John Stultz ; lkml 
> ; Yu
> Chen ; Greg Kroah-Hartman ; 
> Rob
> Herring ; Mark Rutland ; ShuFan Lee
> ; Heikki Krogerus ;
> Suzuki K Poulose ; Chunfeng Yun
> ; Hans de Goede ; Andy 
> Shevchenko
> ; Valentin Schneider ;
> Jack Pham ; Linux USB List ; 
> open
> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
> ;
> Peter Chen ; Thinh Nguyen 
> Subject: RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by 
> device
> controller
> 
> 
> Hi,
> 
> Jun Li  writes:
> >> >> Hi Thinh, could you comment this?
> >> >
> >> > You only need to wake up the usb2 phy when issuing the command
> >> > while running in highspeed or below. If you're running in SS or
> >> > higher, internally the controller does it for you for usb3 phy. In
> >> > Jun's case, it seems like it takes longer for his phy to wake up.
> >> >
> >> > IMO, in this case, I think it's fine to increase the command timeout.
> >>
> >> Is there an upper limit to this? Is 32k clock the slowest that can be
> >> fed to the PHY as a suspend clock?
> >
> > Yes, 32K clock is the slowest, Per DWC3 document on Power Down Scale
> > (bits 31:19 of GCTL):
> >
> > "Power Down Scale (PwrDnScale)
> > The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock source to
> > a small part of the USB3 controller that operates when the SS PHY is
> > in its lowest power (P3) state, and therefore does not provide a clock.
> > The Power Down Scale field specifies how many suspend_clk periods fit
> > into a 16 kHz clock period. When performing the division, round up the
> > remainder.
> > For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz Suspend
> > clock, Power Down Scale = 25000 kHz/16 kHz = 13'd1563 (rounder up)
> > Note:
> > - Minimum Suspend clock frequency is 32 kHz
> > - Maximum Suspend clock frequency is 125 MHz"
> 
> Cool, now do we have an upper bound for how many clock cycles it takes to 
> wake up
> the PHY? 
My understanding is this ep command does not wake up the SS PHY,
the SS PHY still stays at P3 when execute this ep command. The time
required here is to wait controller complete something for this ep
command with 32K clock.

> Then we can just set the time to that upper bound.
Per my test with trace, the time is about 400us(~13 cycles).

Thanks
Li Jun
> 
> --
> balbi


RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-16 Thread Felipe Balbi

Hi,

Jun Li  writes:
>> >> Hi Thinh, could you comment this?
>> >
>> > You only need to wake up the usb2 phy when issuing the command while
>> > running in highspeed or below. If you're running in SS or higher,
>> > internally the controller does it for you for usb3 phy. In Jun's case,
>> > it seems like it takes longer for his phy to wake up.
>> >
>> > IMO, in this case, I think it's fine to increase the command timeout.
>> 
>> Is there an upper limit to this? Is 32k clock the slowest that can be fed to 
>> the
>> PHY as a suspend clock?
>
> Yes, 32K clock is the slowest, Per DWC3 document on Power Down Scale
> (bits 31:19 of GCTL):
>
> "Power Down Scale (PwrDnScale)
> The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock source
> to a small part of the USB3 controller that operates when the SS PHY
> is in its lowest power (P3) state, and therefore does not provide a clock.
> The Power Down Scale field specifies how many suspend_clk periods
> fit into a 16 kHz clock period. When performing the division, round up
> the remainder.
> For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz Suspend clock,
> Power Down Scale = 25000 kHz/16 kHz = 13'd1563 (rounder up)
> Note:
> - Minimum Suspend clock frequency is 32 kHz
> - Maximum Suspend clock frequency is 125 MHz"

Cool, now do we have an upper bound for how many clock cycles it takes
to wake up the PHY? Then we can just set the time to that upper bound.

-- 
balbi


signature.asc
Description: PGP signature


RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-16 Thread Jun Li
Hi,
> -Original Message-
> From: Felipe Balbi  On Behalf Of Felipe Balbi
> Sent: 2020年5月16日 15:13
> To: Thinh Nguyen ; Jun Li ; Jun Li
> 
> Cc: John Stultz ; lkml 
> ; Yu
> Chen ; Greg Kroah-Hartman ; 
> Rob
> Herring ; Mark Rutland ; ShuFan Lee
> ; Heikki Krogerus ;
> Suzuki K Poulose ; Chunfeng Yun
> ; Hans de Goede ; Andy 
> Shevchenko
> ; Valentin Schneider ;
> Jack Pham ; Linux USB List ; 
> open
> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
> ;
> Peter Chen ; Thinh Nguyen 
> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by 
> device
> controller
> 
> 
> Hi,
> 
> Thinh Nguyen  writes:
> > Jun Li wrote:
> >>> -Original Message-
> >>> From: Felipe Balbi  On Behalf Of Felipe Balbi
> >>> Sent: 2020年5月15日 17:31
> >>> To: Jun Li 
> >>> Cc: John Stultz ; lkml
> >>> ; Yu Chen ; Greg
> >>> Kroah-Hartman ; Rob Herring
> >>> ; Mark Rutland ; ShuFan
> >>> Lee ; Heikki Krogerus
> >>> ;
> >>> Suzuki K Poulose ; Chunfeng Yun
> >>> ; Hans de Goede ;
> >>> Andy Shevchenko ; Valentin Schneider
> >>> ; Jack Pham ;
> >>> Linux USB List ; open list:OPEN FIRMWARE
> >>> AND FLATTENED DEVICE TREE BINDINGS ;
> >>> Peter Chen ; Jun Li ; Thinh
> >>> Nguyen 
> >>> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct
> >>> cleared by device controller
> >>>
> >>>
> >>> Hi,
> >>>
> >>> Jun Li  writes:
> >>>>> @@ -397,12 +407,18 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep
> >>>>> *dep, unsigned
> >>> cmd,
> >>>>>  dwc3_gadget_ep_get_transfer_index(dep);
> >>>>>  }
> >>>>>
> >>>>> -   if (saved_config) {
> >>>>> +   if (saved_hs_config) {
> >>>>>  reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
> >>>>> -   reg |= saved_config;
> >>>>> +   reg |= saved_hs_config;
> >>>>>  dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
> >>>>>  }
> >>>>>
> >>>>> +   if (saved_ss_config) {
> >>>>> +   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
> >>>>> +   reg |= saved_ss_config;
> >>>>> +   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
> >>>>> +   }
> >>>>> +
> >>>>>  return ret;
> >>>>>   }
> >>>> Unfortunately this way can't work, once the SS PHY enters P3,
> >>>> disable suspend_en can't force SS PHY exit P3, unless do this at
> >>>> the very beginning to prevent SS PHY entering P3(e.g. add
> >>>> "snps,dis_u3_susphy_quirk" for
> >>> test).
> >>>
> >>> It sounds like you have a quirky PHY.
> >>  From what I got from the IC design, the behavior of
> >> DWC3_GUSB3PIPECTL_SUSPHY bit should be as what I said, not a quirky.
> >>
> >> Hi Thinh, could you comment this?
> >
> > You only need to wake up the usb2 phy when issuing the command while
> > running in highspeed or below. If you're running in SS or higher,
> > internally the controller does it for you for usb3 phy. In Jun's case,
> > it seems like it takes longer for his phy to wake up.
> >
> > IMO, in this case, I think it's fine to increase the command timeout.
> 
> Is there an upper limit to this? Is 32k clock the slowest that can be fed to 
> the
> PHY as a suspend clock?

Yes, 32K clock is the slowest, Per DWC3 document on Power Down Scale
(bits 31:19 of GCTL):

"Power Down Scale (PwrDnScale)
The USB3 suspend_clk input replaces pipe3_rx_pclk as a clock source
to a small part of the USB3 controller that operates when the SS PHY
is in its lowest power (P3) state, and therefore does not provide a clock.
The Power Down Scale field specifies how many suspend_clk periods
fit into a 16 kHz clock period. When performing the division, round up
the remainder.
For example, when using an 8-bit/16-bit/32-bit PHY and 25-MHz Suspend clock,
Power Down Scale = 25000 kHz/16 kHz = 13'd1563 (rounder up)
Note:
- Minimum Suspend clock frequency is 32 kHz
- Maximum Suspend clock frequency is 125 MHz"

Li Jun
> 
> --
> balbi


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-16 Thread Felipe Balbi

Hi,

Thinh Nguyen  writes:
> Jun Li wrote:
>>> -Original Message-
>>> From: Felipe Balbi  On Behalf Of Felipe Balbi
>>> Sent: 2020年5月15日 17:31
>>> To: Jun Li 
>>> Cc: John Stultz ; lkml 
>>> ; Yu
>>> Chen ; Greg Kroah-Hartman 
>>> ; Rob
>>> Herring ; Mark Rutland ; ShuFan 
>>> Lee
>>> ; Heikki Krogerus ;
>>> Suzuki K Poulose ; Chunfeng Yun
>>> ; Hans de Goede ; Andy 
>>> Shevchenko
>>> ; Valentin Schneider 
>>> ;
>>> Jack Pham ; Linux USB List 
>>> ; open
>>> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
>>> ;
>>> Peter Chen ; Jun Li ; Thinh Nguyen
>>> 
>>> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared 
>>> by device
>>> controller
>>>
>>>
>>> Hi,
>>>
>>> Jun Li  writes:
>>>>> @@ -397,12 +407,18 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, 
>>>>> unsigned
>>> cmd,
>>>>>  dwc3_gadget_ep_get_transfer_index(dep);
>>>>>  }
>>>>>
>>>>> -   if (saved_config) {
>>>>> +   if (saved_hs_config) {
>>>>>  reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
>>>>> -   reg |= saved_config;
>>>>> +   reg |= saved_hs_config;
>>>>>  dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
>>>>>  }
>>>>>
>>>>> +   if (saved_ss_config) {
>>>>> +   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
>>>>> +   reg |= saved_ss_config;
>>>>> +   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
>>>>> +   }
>>>>> +
>>>>>  return ret;
>>>>>   }
>>>> Unfortunately this way can't work, once the SS PHY enters P3, disable
>>>> suspend_en can't force SS PHY exit P3, unless do this at the very
>>>> beginning to prevent SS PHY entering P3(e.g. add 
>>>> "snps,dis_u3_susphy_quirk" for
>>> test).
>>>
>>> It sounds like you have a quirky PHY.
>>  From what I got from the IC design, the behavior of DWC3_GUSB3PIPECTL_SUSPHY
>> bit should be as what I said, not a quirky.
>>
>> Hi Thinh, could you comment this?
>
> You only need to wake up the usb2 phy when issuing the command while 
> running in highspeed or below. If you're running in SS or higher, 
> internally the controller does it for you for usb3 phy. In Jun's case, 
> it seems like it takes longer for his phy to wake up.
>
> IMO, in this case, I think it's fine to increase the command timeout.

Is there an upper limit to this? Is 32k clock the slowest that can be
fed to the PHY as a suspend clock?

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-15 Thread Thinh Nguyen
Hi,

Jun Li wrote:
>> -Original Message-
>> From: Felipe Balbi  On Behalf Of Felipe Balbi
>> Sent: 2020年5月15日 17:31
>> To: Jun Li 
>> Cc: John Stultz ; lkml 
>> ; Yu
>> Chen ; Greg Kroah-Hartman ; 
>> Rob
>> Herring ; Mark Rutland ; ShuFan Lee
>> ; Heikki Krogerus ;
>> Suzuki K Poulose ; Chunfeng Yun
>> ; Hans de Goede ; Andy 
>> Shevchenko
>> ; Valentin Schneider ;
>> Jack Pham ; Linux USB List 
>> ; open
>> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
>> ;
>> Peter Chen ; Jun Li ; Thinh Nguyen
>> 
>> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared 
>> by device
>> controller
>>
>>
>> Hi,
>>
>> Jun Li  writes:
>>>> @@ -397,12 +407,18 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, 
>>>> unsigned
>> cmd,
>>>>  dwc3_gadget_ep_get_transfer_index(dep);
>>>>  }
>>>>
>>>> -   if (saved_config) {
>>>> +   if (saved_hs_config) {
>>>>  reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
>>>> -   reg |= saved_config;
>>>> +   reg |= saved_hs_config;
>>>>  dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
>>>>  }
>>>>
>>>> +   if (saved_ss_config) {
>>>> +   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
>>>> +   reg |= saved_ss_config;
>>>> +   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
>>>> +   }
>>>> +
>>>>  return ret;
>>>>   }
>>> Unfortunately this way can't work, once the SS PHY enters P3, disable
>>> suspend_en can't force SS PHY exit P3, unless do this at the very
>>> beginning to prevent SS PHY entering P3(e.g. add "snps,dis_u3_susphy_quirk" 
>>> for
>> test).
>>
>> It sounds like you have a quirky PHY.
>  From what I got from the IC design, the behavior of DWC3_GUSB3PIPECTL_SUSPHY
> bit should be as what I said, not a quirky.
>
> Hi Thinh, could you comment this?

You only need to wake up the usb2 phy when issuing the command while 
running in highspeed or below. If you're running in SS or higher, 
internally the controller does it for you for usb3 phy. In Jun's case, 
it seems like it takes longer for his phy to wake up.

IMO, in this case, I think it's fine to increase the command timeout.

BR,
Thinh



RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-15 Thread Felipe Balbi

Hi,

Jun Li  writes:
>> Jun Li  writes:
>> >> @@ -397,12 +407,18 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, 
>> >> unsigned
>> cmd,
>> >> dwc3_gadget_ep_get_transfer_index(dep);
>> >> }
>> >>
>> >> -   if (saved_config) {
>> >> +   if (saved_hs_config) {
>> >> reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
>> >> -   reg |= saved_config;
>> >> +   reg |= saved_hs_config;
>> >> dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
>> >> }
>> >>
>> >> +   if (saved_ss_config) {
>> >> +   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
>> >> +   reg |= saved_ss_config;
>> >> +   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
>> >> +   }
>> >> +
>> >> return ret;
>> >>  }
>> >
>> > Unfortunately this way can't work, once the SS PHY enters P3, disable
>> > suspend_en can't force SS PHY exit P3, unless do this at the very
>> > beginning to prevent SS PHY entering P3(e.g. add 
>> > "snps,dis_u3_susphy_quirk" for
>> test).
>> 
>> It sounds like you have a quirky PHY. 
>
> From what I got from the IC design, the behavior of DWC3_GUSB3PIPECTL_SUSPHY
> bit should be as what I said, not a quirky.
>
> Hi Thinh, could you comment this?
>
>> If that's the case, then you probably need
>> to use the flag you mentioned above. Please verify with that.
>
> With quirk of "snps,dis_u3_susphy_quirk", I had verified it can
> resolve the problem, but this will make USB3 Super Speed PHY
> never enter P3, this is a huge impact on USB power consumption.
>
> The timeout increase has no impact on those platforms which have
> no this problem, but can give chance for platform with very low
> supspend clk(like my case 32k) to work.

I was under the impression that issuing a command would wake the PHY
up. I don't have access to DWC3 documentation to verify, but that's as I
remember. Is that not the case?

-- 
balbi


signature.asc
Description: PGP signature


RE: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-15 Thread Jun Li


> -Original Message-
> From: Felipe Balbi  On Behalf Of Felipe Balbi
> Sent: 2020年5月15日 17:31
> To: Jun Li 
> Cc: John Stultz ; lkml 
> ; Yu
> Chen ; Greg Kroah-Hartman ; 
> Rob
> Herring ; Mark Rutland ; ShuFan Lee
> ; Heikki Krogerus ;
> Suzuki K Poulose ; Chunfeng Yun
> ; Hans de Goede ; Andy 
> Shevchenko
> ; Valentin Schneider ;
> Jack Pham ; Linux USB List ; 
> open
> list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS 
> ;
> Peter Chen ; Jun Li ; Thinh Nguyen
> 
> Subject: Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by 
> device
> controller
> 
> 
> Hi,
> 
> Jun Li  writes:
> >> @@ -397,12 +407,18 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, 
> >> unsigned
> cmd,
> >> dwc3_gadget_ep_get_transfer_index(dep);
> >> }
> >>
> >> -   if (saved_config) {
> >> +   if (saved_hs_config) {
> >> reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
> >> -   reg |= saved_config;
> >> +   reg |= saved_hs_config;
> >> dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
> >> }
> >>
> >> +   if (saved_ss_config) {
> >> +   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
> >> +   reg |= saved_ss_config;
> >> +   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
> >> +   }
> >> +
> >> return ret;
> >>  }
> >
> > Unfortunately this way can't work, once the SS PHY enters P3, disable
> > suspend_en can't force SS PHY exit P3, unless do this at the very
> > beginning to prevent SS PHY entering P3(e.g. add "snps,dis_u3_susphy_quirk" 
> > for
> test).
> 
> It sounds like you have a quirky PHY. 

From what I got from the IC design, the behavior of DWC3_GUSB3PIPECTL_SUSPHY
bit should be as what I said, not a quirky.

Hi Thinh, could you comment this?

> If that's the case, then you probably need
> to use the flag you mentioned above. Please verify with that.

With quirk of "snps,dis_u3_susphy_quirk", I had verified it can
resolve the problem, but this will make USB3 Super Speed PHY
never enter P3, this is a huge impact on USB power consumption.

The timeout increase has no impact on those platforms which have
no this problem, but can give chance for platform with very low
supspend clk(like my case 32k) to work.

Thanks
Li Jun
> 
> --
> balbi


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-15 Thread Felipe Balbi

Hi,

Jun Li  writes:
>> @@ -397,12 +407,18 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, 
>> unsigned cmd,
>> dwc3_gadget_ep_get_transfer_index(dep);
>> }
>>
>> -   if (saved_config) {
>> +   if (saved_hs_config) {
>> reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
>> -   reg |= saved_config;
>> +   reg |= saved_hs_config;
>> dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
>> }
>>
>> +   if (saved_ss_config) {
>> +   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
>> +   reg |= saved_ss_config;
>> +   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
>> +   }
>> +
>> return ret;
>>  }
>
> Unfortunately this way can't work, once the SS PHY enters P3, disable
> suspend_en can't force SS PHY exit P3, unless do this at the very beginning
> to prevent SS PHY entering P3(e.g. add "snps,dis_u3_susphy_quirk" for test).

It sounds like you have a quirky PHY. If that's the case, then you
probably need to use the flag you mentioned above. Please verify with
that.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-09 Thread Jun Li
Felipe Balbi  于2020年5月8日周五 下午8:35写道:
>
>
> Hi,
>
> Jun Li  writes:
> > Jun Li  于2020年5月7日周四 上午11:08写道:
> >>
> >> John Stultz  于2020年5月7日周四 上午6:27写道:
> >> >
> >> > On Wed, May 6, 2020 at 2:00 AM Jun Li  wrote:
> >> > > John Stultz  于2019年10月30日周三 上午5:18写道:
> >> > > > On Tue, Oct 29, 2019 at 2:11 AM Felipe Balbi  
> >> > > > wrote:
> >> > > > > John Stultz  writes:
> >> > > > > > From: Yu Chen 
> >> > > > > >
> >> > > > > > It needs more time for the device controller to clear the CmdAct 
> >> > > > > > of
> >> > > > > > DEPCMD on Hisilicon Kirin Soc.
> >> > > > >
> >> > > > > Why does it need more time? Why is it so that no other platform 
> >> > > > > needs
> >> > > > > more time, only this one? And which command, specifically, causes
> >> > > > > problem?
> >> > >
> >> > > Sorry for my back to this so late.
> >> > >
> >> > > This change is required on my dwc3 based HW too, I gave a check
> >> > > and the reason is suspend_clk is used in case the PIPE phy is at P3,
> >> > > this slow clock makes my EP command below timeout.
> >> > >
> >> > > dwc3_gadget_ep_cmd: ep0out: cmd 'Set Endpoint Configuration' [401]
> >> > > params 1000 0500  --> status: Timed Out
> >> > >
> >> > > Success case takes about 400us to complete, see below trace(44.286278
> >> > > - 44.285897 = 0.000381):
> >> > >
> >> > > configfs_acm.sh-822   [000] d..144.285896: dwc3_writel: addr
> >> > > 6d59aae1 value 0401
> >> > > configfs_acm.sh-822   [000] d..144.285897: dwc3_readl: addr
> >> > > 6d59aae1 value 0401
> >> > > ... ...
> >> > > configfs_acm.sh-822   [000] d..144.286278: dwc3_readl: addr
> >> > > 6d59aae1 value 0001
> >> > > configfs_acm.sh-822   [000] d..144.286279: dwc3_gadget_ep_cmd:
> >> > > ep0out: cmd 'Set Endpoint Configuration' [401] params 1000
> >> > > 0500  --> status: Successful
> >> > >
> >> > > Hi John,
> >> > >
> >> > > Do you still have this problem? if yes, What's the value of
> >> > > USBLNKST[21:18] when the timeout happens?
> >> >
> >> > Sorry. As I mentioned, I was working to upstream a patchset that I
> >> > hadn't created, so the context I had was limited. As I couldn't
> >> > reproduce an issue without the change on the device I had, I figured
> >> > it would be best to drop it.
> >>
> >> That was fine.
> >> >
> >> > However, as you have some analysis and rational for why such a change
> >> > would be needed, I don't have an objection to it. Do you want to
> >> > resubmit the patch with your explanation and detailed log above in the
> >> > commit message?
> >>
> >> Sure, I will resubmit the patch with my explanation added in commit 
> >> message.
> >
> > Hi John
> >
> > A second think of this, I feel use readl_poll_timeout_atomic() to wait by 
> > time
> > is more proper here, so I create a new patch to address this also other
> > registers polling, see below patch with you CCed:
> >
> > https://patchwork.kernel.org/patch/11536081/
>
> Fixing a bug has nothing to do with using
> readl_poll_timeout_atomic(). Please don't mix things as it just makes
> review time consuming.
>
> Let's find out what the bug is all about, only then should we consider
> moving over to readl_poll_timeout_atomic().

Agreed, sorry about that, I will hold on my readl_poll_timeout_atomic() changes
until we have a conclusion on this issue fix.

thanks
Li Jun
>
> --
> balbi


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-09 Thread Jun Li
Hi,

Felipe Balbi  于2020年5月8日周五 下午8:33写道:
>
>
> Hi,
>
> Jun Li  writes:
> > John Stultz  于2019年10月30日周三 上午5:18写道:
> >>
> >> On Tue, Oct 29, 2019 at 2:11 AM Felipe Balbi  wrote:
> >> > John Stultz  writes:
> >> > > From: Yu Chen 
> >> > >
> >> > > It needs more time for the device controller to clear the CmdAct of
> >> > > DEPCMD on Hisilicon Kirin Soc.
> >> >
> >> > Why does it need more time? Why is it so that no other platform needs
> >> > more time, only this one? And which command, specifically, causes
> >> > problem?
> >
> > Sorry for my back to this so late.
> >
> > This change is required on my dwc3 based HW too, I gave a check
> > and the reason is suspend_clk is used in case the PIPE phy is at P3,
> > this slow clock makes my EP command below timeout.
>
> The phy needs to woken up before the command is triggered. Currently we
> only wake up the HS PHY. Does it help you if we wake up the SS phy as
> well?
>
> Something like below ought to do it:
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index a0555252dee0..ee46c2dacaeb 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -274,7 +274,8 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned 
> cmd,
> const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
> struct dwc3 *dwc = dep->dwc;
> u32 timeout = 1000;
> -   u32 saved_config = 0;
> +   u32 saved_hs_config = 0;
> +   u32 saved_ss_config = 0;
> u32 reg;
>
> int cmd_status = 0;
> @@ -293,19 +294,28 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, 
> unsigned cmd,
> if (dwc->gadget.speed <= USB_SPEED_HIGH) {
> reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
> if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) {
> -   saved_config |= DWC3_GUSB2PHYCFG_SUSPHY;
> +   saved_hs_config |= DWC3_GUSB2PHYCFG_SUSPHY;
> reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
> }
>
> if (reg & DWC3_GUSB2PHYCFG_ENBLSLPM) {
> -   saved_config |= DWC3_GUSB2PHYCFG_ENBLSLPM;
> +   saved_hs_config |= DWC3_GUSB2PHYCFG_ENBLSLPM;
> reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
> }
>
> -   if (saved_config)
> +   if (saved_hs_config)
> dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
> }
>
> +   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
> +   if (unlikely(reg & DWC3_GUSB3PIPECTL_SUSPHY)) {
> +   saved_ss_config |= DWC3_GUSB3PIPECTL_SUSPHY;
> +   reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
> +   }
> +
> +   if (saved_ss_config)
> +   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
> +
> if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
> int needs_wakeup;
>
> @@ -397,12 +407,18 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, 
> unsigned cmd,
> dwc3_gadget_ep_get_transfer_index(dep);
> }
>
> -   if (saved_config) {
> +   if (saved_hs_config) {
> reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
> -   reg |= saved_config;
> +   reg |= saved_hs_config;
> dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
> }
>
> +   if (saved_ss_config) {
> +   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
> +   reg |= saved_ss_config;
> +   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
> +   }
> +
> return ret;
>  }

Unfortunately this way can't work, once the SS PHY enters P3, disable
suspend_en can't force SS PHY exit P3, unless do this at the very beginning
to prevent SS PHY entering P3(e.g. add "snps,dis_u3_susphy_quirk" for test).

thanks
Li Jun
>
> --
> balbi


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-08 Thread Felipe Balbi

Hi,

Jun Li  writes:
> Jun Li  于2020年5月7日周四 上午11:08写道:
>>
>> John Stultz  于2020年5月7日周四 上午6:27写道:
>> >
>> > On Wed, May 6, 2020 at 2:00 AM Jun Li  wrote:
>> > > John Stultz  于2019年10月30日周三 上午5:18写道:
>> > > > On Tue, Oct 29, 2019 at 2:11 AM Felipe Balbi  wrote:
>> > > > > John Stultz  writes:
>> > > > > > From: Yu Chen 
>> > > > > >
>> > > > > > It needs more time for the device controller to clear the CmdAct of
>> > > > > > DEPCMD on Hisilicon Kirin Soc.
>> > > > >
>> > > > > Why does it need more time? Why is it so that no other platform needs
>> > > > > more time, only this one? And which command, specifically, causes
>> > > > > problem?
>> > >
>> > > Sorry for my back to this so late.
>> > >
>> > > This change is required on my dwc3 based HW too, I gave a check
>> > > and the reason is suspend_clk is used in case the PIPE phy is at P3,
>> > > this slow clock makes my EP command below timeout.
>> > >
>> > > dwc3_gadget_ep_cmd: ep0out: cmd 'Set Endpoint Configuration' [401]
>> > > params 1000 0500  --> status: Timed Out
>> > >
>> > > Success case takes about 400us to complete, see below trace(44.286278
>> > > - 44.285897 = 0.000381):
>> > >
>> > > configfs_acm.sh-822   [000] d..144.285896: dwc3_writel: addr
>> > > 6d59aae1 value 0401
>> > > configfs_acm.sh-822   [000] d..144.285897: dwc3_readl: addr
>> > > 6d59aae1 value 0401
>> > > ... ...
>> > > configfs_acm.sh-822   [000] d..144.286278: dwc3_readl: addr
>> > > 6d59aae1 value 0001
>> > > configfs_acm.sh-822   [000] d..144.286279: dwc3_gadget_ep_cmd:
>> > > ep0out: cmd 'Set Endpoint Configuration' [401] params 1000
>> > > 0500  --> status: Successful
>> > >
>> > > Hi John,
>> > >
>> > > Do you still have this problem? if yes, What's the value of
>> > > USBLNKST[21:18] when the timeout happens?
>> >
>> > Sorry. As I mentioned, I was working to upstream a patchset that I
>> > hadn't created, so the context I had was limited. As I couldn't
>> > reproduce an issue without the change on the device I had, I figured
>> > it would be best to drop it.
>>
>> That was fine.
>> >
>> > However, as you have some analysis and rational for why such a change
>> > would be needed, I don't have an objection to it. Do you want to
>> > resubmit the patch with your explanation and detailed log above in the
>> > commit message?
>>
>> Sure, I will resubmit the patch with my explanation added in commit message.
>
> Hi John
>
> A second think of this, I feel use readl_poll_timeout_atomic() to wait by time
> is more proper here, so I create a new patch to address this also other
> registers polling, see below patch with you CCed:
>
> https://patchwork.kernel.org/patch/11536081/

Fixing a bug has nothing to do with using
readl_poll_timeout_atomic(). Please don't mix things as it just makes
review time consuming.

Let's find out what the bug is all about, only then should we consider
moving over to readl_poll_timeout_atomic().

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-08 Thread Felipe Balbi

Hi,

Jun Li  writes:
> John Stultz  于2019年10月30日周三 上午5:18写道:
>>
>> On Tue, Oct 29, 2019 at 2:11 AM Felipe Balbi  wrote:
>> > John Stultz  writes:
>> > > From: Yu Chen 
>> > >
>> > > It needs more time for the device controller to clear the CmdAct of
>> > > DEPCMD on Hisilicon Kirin Soc.
>> >
>> > Why does it need more time? Why is it so that no other platform needs
>> > more time, only this one? And which command, specifically, causes
>> > problem?
>
> Sorry for my back to this so late.
>
> This change is required on my dwc3 based HW too, I gave a check
> and the reason is suspend_clk is used in case the PIPE phy is at P3,
> this slow clock makes my EP command below timeout.

The phy needs to woken up before the command is triggered. Currently we
only wake up the HS PHY. Does it help you if we wake up the SS phy as
well?

Something like below ought to do it:

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index a0555252dee0..ee46c2dacaeb 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -274,7 +274,8 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned 
cmd,
const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
struct dwc3 *dwc = dep->dwc;
u32 timeout = 1000;
-   u32 saved_config = 0;
+   u32 saved_hs_config = 0;
+   u32 saved_ss_config = 0;
u32 reg;
 
int cmd_status = 0;
@@ -293,19 +294,28 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned 
cmd,
if (dwc->gadget.speed <= USB_SPEED_HIGH) {
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) {
-   saved_config |= DWC3_GUSB2PHYCFG_SUSPHY;
+   saved_hs_config |= DWC3_GUSB2PHYCFG_SUSPHY;
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
}
 
if (reg & DWC3_GUSB2PHYCFG_ENBLSLPM) {
-   saved_config |= DWC3_GUSB2PHYCFG_ENBLSLPM;
+   saved_hs_config |= DWC3_GUSB2PHYCFG_ENBLSLPM;
reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
}
 
-   if (saved_config)
+   if (saved_hs_config)
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
}
 
+   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
+   if (unlikely(reg & DWC3_GUSB3PIPECTL_SUSPHY)) {
+   saved_ss_config |= DWC3_GUSB3PIPECTL_SUSPHY;
+   reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
+   }
+
+   if (saved_ss_config)
+   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
+
if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
int needs_wakeup;
 
@@ -397,12 +407,18 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned 
cmd,
dwc3_gadget_ep_get_transfer_index(dep);
}
 
-   if (saved_config) {
+   if (saved_hs_config) {
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
-   reg |= saved_config;
+   reg |= saved_hs_config;
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
}
 
+   if (saved_ss_config) {
+   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
+   reg |= saved_ss_config;
+   dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
+   }
+
return ret;
 }
 
-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-08 Thread Jun Li
Jun Li  于2020年5月7日周四 上午11:08写道:
>
> John Stultz  于2020年5月7日周四 上午6:27写道:
> >
> > On Wed, May 6, 2020 at 2:00 AM Jun Li  wrote:
> > > John Stultz  于2019年10月30日周三 上午5:18写道:
> > > > On Tue, Oct 29, 2019 at 2:11 AM Felipe Balbi  wrote:
> > > > > John Stultz  writes:
> > > > > > From: Yu Chen 
> > > > > >
> > > > > > It needs more time for the device controller to clear the CmdAct of
> > > > > > DEPCMD on Hisilicon Kirin Soc.
> > > > >
> > > > > Why does it need more time? Why is it so that no other platform needs
> > > > > more time, only this one? And which command, specifically, causes
> > > > > problem?
> > >
> > > Sorry for my back to this so late.
> > >
> > > This change is required on my dwc3 based HW too, I gave a check
> > > and the reason is suspend_clk is used in case the PIPE phy is at P3,
> > > this slow clock makes my EP command below timeout.
> > >
> > > dwc3_gadget_ep_cmd: ep0out: cmd 'Set Endpoint Configuration' [401]
> > > params 1000 0500  --> status: Timed Out
> > >
> > > Success case takes about 400us to complete, see below trace(44.286278
> > > - 44.285897 = 0.000381):
> > >
> > > configfs_acm.sh-822   [000] d..144.285896: dwc3_writel: addr
> > > 6d59aae1 value 0401
> > > configfs_acm.sh-822   [000] d..144.285897: dwc3_readl: addr
> > > 6d59aae1 value 0401
> > > ... ...
> > > configfs_acm.sh-822   [000] d..144.286278: dwc3_readl: addr
> > > 6d59aae1 value 0001
> > > configfs_acm.sh-822   [000] d..144.286279: dwc3_gadget_ep_cmd:
> > > ep0out: cmd 'Set Endpoint Configuration' [401] params 1000
> > > 0500  --> status: Successful
> > >
> > > Hi John,
> > >
> > > Do you still have this problem? if yes, What's the value of
> > > USBLNKST[21:18] when the timeout happens?
> >
> > Sorry. As I mentioned, I was working to upstream a patchset that I
> > hadn't created, so the context I had was limited. As I couldn't
> > reproduce an issue without the change on the device I had, I figured
> > it would be best to drop it.
>
> That was fine.
> >
> > However, as you have some analysis and rational for why such a change
> > would be needed, I don't have an objection to it. Do you want to
> > resubmit the patch with your explanation and detailed log above in the
> > commit message?
>
> Sure, I will resubmit the patch with my explanation added in commit message.

Hi John

A second think of this, I feel use readl_poll_timeout_atomic() to wait by time
is more proper here, so I create a new patch to address this also other
registers polling, see below patch with you CCed:

https://patchwork.kernel.org/patch/11536081/

thanks
Li Jun
>
> thanks
> Li Jun
> >
> > thanks
> > -john


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-06 Thread Jun Li
John Stultz  于2020年5月7日周四 上午6:27写道:
>
> On Wed, May 6, 2020 at 2:00 AM Jun Li  wrote:
> > John Stultz  于2019年10月30日周三 上午5:18写道:
> > > On Tue, Oct 29, 2019 at 2:11 AM Felipe Balbi  wrote:
> > > > John Stultz  writes:
> > > > > From: Yu Chen 
> > > > >
> > > > > It needs more time for the device controller to clear the CmdAct of
> > > > > DEPCMD on Hisilicon Kirin Soc.
> > > >
> > > > Why does it need more time? Why is it so that no other platform needs
> > > > more time, only this one? And which command, specifically, causes
> > > > problem?
> >
> > Sorry for my back to this so late.
> >
> > This change is required on my dwc3 based HW too, I gave a check
> > and the reason is suspend_clk is used in case the PIPE phy is at P3,
> > this slow clock makes my EP command below timeout.
> >
> > dwc3_gadget_ep_cmd: ep0out: cmd 'Set Endpoint Configuration' [401]
> > params 1000 0500  --> status: Timed Out
> >
> > Success case takes about 400us to complete, see below trace(44.286278
> > - 44.285897 = 0.000381):
> >
> > configfs_acm.sh-822   [000] d..144.285896: dwc3_writel: addr
> > 6d59aae1 value 0401
> > configfs_acm.sh-822   [000] d..144.285897: dwc3_readl: addr
> > 6d59aae1 value 0401
> > ... ...
> > configfs_acm.sh-822   [000] d..144.286278: dwc3_readl: addr
> > 6d59aae1 value 0001
> > configfs_acm.sh-822   [000] d..144.286279: dwc3_gadget_ep_cmd:
> > ep0out: cmd 'Set Endpoint Configuration' [401] params 1000
> > 0500  --> status: Successful
> >
> > Hi John,
> >
> > Do you still have this problem? if yes, What's the value of
> > USBLNKST[21:18] when the timeout happens?
>
> Sorry. As I mentioned, I was working to upstream a patchset that I
> hadn't created, so the context I had was limited. As I couldn't
> reproduce an issue without the change on the device I had, I figured
> it would be best to drop it.

That was fine.
>
> However, as you have some analysis and rational for why such a change
> would be needed, I don't have an objection to it. Do you want to
> resubmit the patch with your explanation and detailed log above in the
> commit message?

Sure, I will resubmit the patch with my explanation added in commit message.

thanks
Li Jun
>
> thanks
> -john


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-06 Thread John Stultz
On Wed, May 6, 2020 at 2:00 AM Jun Li  wrote:
> John Stultz  于2019年10月30日周三 上午5:18写道:
> > On Tue, Oct 29, 2019 at 2:11 AM Felipe Balbi  wrote:
> > > John Stultz  writes:
> > > > From: Yu Chen 
> > > >
> > > > It needs more time for the device controller to clear the CmdAct of
> > > > DEPCMD on Hisilicon Kirin Soc.
> > >
> > > Why does it need more time? Why is it so that no other platform needs
> > > more time, only this one? And which command, specifically, causes
> > > problem?
>
> Sorry for my back to this so late.
>
> This change is required on my dwc3 based HW too, I gave a check
> and the reason is suspend_clk is used in case the PIPE phy is at P3,
> this slow clock makes my EP command below timeout.
>
> dwc3_gadget_ep_cmd: ep0out: cmd 'Set Endpoint Configuration' [401]
> params 1000 0500  --> status: Timed Out
>
> Success case takes about 400us to complete, see below trace(44.286278
> - 44.285897 = 0.000381):
>
> configfs_acm.sh-822   [000] d..144.285896: dwc3_writel: addr
> 6d59aae1 value 0401
> configfs_acm.sh-822   [000] d..144.285897: dwc3_readl: addr
> 6d59aae1 value 0401
> ... ...
> configfs_acm.sh-822   [000] d..144.286278: dwc3_readl: addr
> 6d59aae1 value 0001
> configfs_acm.sh-822   [000] d..144.286279: dwc3_gadget_ep_cmd:
> ep0out: cmd 'Set Endpoint Configuration' [401] params 1000
> 0500  --> status: Successful
>
> Hi John,
>
> Do you still have this problem? if yes, What's the value of
> USBLNKST[21:18] when the timeout happens?

Sorry. As I mentioned, I was working to upstream a patchset that I
hadn't created, so the context I had was limited. As I couldn't
reproduce an issue without the change on the device I had, I figured
it would be best to drop it.

However, as you have some analysis and rational for why such a change
would be needed, I don't have an objection to it. Do you want to
resubmit the patch with your explanation and detailed log above in the
commit message?

thanks
-john


Re: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller

2020-05-06 Thread Jun Li
John Stultz  于2019年10月30日周三 上午5:18写道:
>
> On Tue, Oct 29, 2019 at 2:11 AM Felipe Balbi  wrote:
> > John Stultz  writes:
> > > From: Yu Chen 
> > >
> > > It needs more time for the device controller to clear the CmdAct of
> > > DEPCMD on Hisilicon Kirin Soc.
> >
> > Why does it need more time? Why is it so that no other platform needs
> > more time, only this one? And which command, specifically, causes
> > problem?

Sorry for my back to this so late.

This change is required on my dwc3 based HW too, I gave a check
and the reason is suspend_clk is used in case the PIPE phy is at P3,
this slow clock makes my EP command below timeout.

dwc3_gadget_ep_cmd: ep0out: cmd 'Set Endpoint Configuration' [401]
params 1000 0500  --> status: Timed Out

Success case takes about 400us to complete, see below trace(44.286278
- 44.285897 = 0.000381):

configfs_acm.sh-822   [000] d..144.285896: dwc3_writel: addr
6d59aae1 value 0401
configfs_acm.sh-822   [000] d..144.285897: dwc3_readl: addr
6d59aae1 value 0401
... ...
configfs_acm.sh-822   [000] d..144.286278: dwc3_readl: addr
6d59aae1 value 0001
configfs_acm.sh-822   [000] d..144.286279: dwc3_gadget_ep_cmd:
ep0out: cmd 'Set Endpoint Configuration' [401] params 1000
0500  --> status: Successful

Hi John,

Do you still have this problem? if yes, What's the value of
USBLNKST[21:18] when the timeout happens?

thanks
Li Jun
>
> Hrm. Sadly I don't have that context (again I'm picking up a
> semi-abandoned patchset here), which is unfortunate, as I'm sure
> someone spent a number of hours debugging things to come up with this.
> :)
>
> But alas, I've dropped this for now in my stack, and things seem to be
> working ok so far. I suspect there's some edge case I'll run into, but
> hopefully I'll be able to debug and get more details when that
> happens.
>
> I do appreciate the review and pushback here!
>
> thanks
> -john