linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: xhci: Increase timeout for HC halt
@ 2021-05-11  0:29 Maximilian Luz
  2021-05-11  6:26 ` Greg Kroah-Hartman
  2021-05-11  7:19 ` Mathias Nyman
  0 siblings, 2 replies; 5+ messages in thread
From: Maximilian Luz @ 2021-05-11  0:29 UTC (permalink / raw)
  To: Mathias Nyman; +Cc: Maximilian Luz, Greg Kroah-Hartman, linux-usb, linux-kernel

On some devices (specifically the SC8180x based Surface Pro X with
QCOM04A6) HC halt / xhci_halt() times out during boot. Manually binding
the xhci-hcd driver at some point later does not exhibit this behavior.
To work around this, double XHCI_MAX_HALT_USEC, which also resolves this
issue.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
---
 drivers/usb/host/xhci-ext-caps.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
index fa59b242cd51..fb591e41cd50 100644
--- a/drivers/usb/host/xhci-ext-caps.h
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -7,8 +7,8 @@
  * Author: Sarah Sharp
  * Some code borrowed from the Linux EHCI driver.
  */
-/* Up to 16 ms to halt an HC */
-#define XHCI_MAX_HALT_USEC	(16*1000)
+/* Up to 32 ms to halt an HC */
+#define XHCI_MAX_HALT_USEC	(32 * 1000)
 /* HC not running - set to 1 when run/stop bit is cleared. */
 #define XHCI_STS_HALT		(1<<0)
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: xhci: Increase timeout for HC halt
  2021-05-11  0:29 [PATCH] usb: xhci: Increase timeout for HC halt Maximilian Luz
@ 2021-05-11  6:26 ` Greg Kroah-Hartman
  2021-05-11  8:40   ` Maximilian Luz
  2021-05-11  7:19 ` Mathias Nyman
  1 sibling, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2021-05-11  6:26 UTC (permalink / raw)
  To: Maximilian Luz; +Cc: Mathias Nyman, linux-usb, linux-kernel

On Tue, May 11, 2021 at 02:29:33AM +0200, Maximilian Luz wrote:
> On some devices (specifically the SC8180x based Surface Pro X with
> QCOM04A6) HC halt / xhci_halt() times out during boot. Manually binding
> the xhci-hcd driver at some point later does not exhibit this behavior.
> To work around this, double XHCI_MAX_HALT_USEC, which also resolves this
> issue.
> 
> Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
> ---
>  drivers/usb/host/xhci-ext-caps.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Should this go to stable kernels as well?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: xhci: Increase timeout for HC halt
  2021-05-11  0:29 [PATCH] usb: xhci: Increase timeout for HC halt Maximilian Luz
  2021-05-11  6:26 ` Greg Kroah-Hartman
@ 2021-05-11  7:19 ` Mathias Nyman
  2021-05-11  8:42   ` Maximilian Luz
  1 sibling, 1 reply; 5+ messages in thread
From: Mathias Nyman @ 2021-05-11  7:19 UTC (permalink / raw)
  To: Maximilian Luz, Mathias Nyman; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On 11.5.2021 3.29, Maximilian Luz wrote:
> On some devices (specifically the SC8180x based Surface Pro X with
> QCOM04A6) HC halt / xhci_halt() times out during boot. Manually binding
> the xhci-hcd driver at some point later does not exhibit this behavior.
> To work around this, double XHCI_MAX_HALT_USEC, which also resolves this
> issue.
> 
> Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
> ---
>  drivers/usb/host/xhci-ext-caps.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
> index fa59b242cd51..fb591e41cd50 100644
> --- a/drivers/usb/host/xhci-ext-caps.h
> +++ b/drivers/usb/host/xhci-ext-caps.h
> @@ -7,8 +7,8 @@
>   * Author: Sarah Sharp
>   * Some code borrowed from the Linux EHCI driver.
>   */
> -/* Up to 16 ms to halt an HC */
> -#define XHCI_MAX_HALT_USEC	(16*1000)
> +/* Up to 32 ms to halt an HC */
> +#define XHCI_MAX_HALT_USEC	(32 * 1000)

xHCI spec has a 16ms limit stated in several places, for example section 5.4.1
"xHC is forced to halt within 16 ms. of software clearing the R/S bit to ‘0’,
irrespective of any queued Transfer or Command Ring activity"

To make sure hosts work we could increase it to 32, but comment could be
changed to make sure it doean't get optimized back to 16 ms later.

How about:
/* HC should halt within 16 ms, but use 32 ms as some in reality take longer */

If that's ok I can take this and modify the comment

-Mathias

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: xhci: Increase timeout for HC halt
  2021-05-11  6:26 ` Greg Kroah-Hartman
@ 2021-05-11  8:40   ` Maximilian Luz
  0 siblings, 0 replies; 5+ messages in thread
From: Maximilian Luz @ 2021-05-11  8:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Mathias Nyman, linux-usb, linux-kernel

On 5/11/21 8:26 AM, Greg Kroah-Hartman wrote:
> On Tue, May 11, 2021 at 02:29:33AM +0200, Maximilian Luz wrote:
>> On some devices (specifically the SC8180x based Surface Pro X with
>> QCOM04A6) HC halt / xhci_halt() times out during boot. Manually binding
>> the xhci-hcd driver at some point later does not exhibit this behavior.
>> To work around this, double XHCI_MAX_HALT_USEC, which also resolves this
>> issue.
>>
>> Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
>> ---
>>   drivers/usb/host/xhci-ext-caps.h | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Should this go to stable kernels as well?

Ah sorry, didn't think about that since the device in question currently
requires a couple of other fixes to be usable. But I guess it would be good
to have this in stable.

Regards,
Max


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: xhci: Increase timeout for HC halt
  2021-05-11  7:19 ` Mathias Nyman
@ 2021-05-11  8:42   ` Maximilian Luz
  0 siblings, 0 replies; 5+ messages in thread
From: Maximilian Luz @ 2021-05-11  8:42 UTC (permalink / raw)
  To: Mathias Nyman, Mathias Nyman; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On 5/11/21 9:19 AM, Mathias Nyman wrote:
> On 11.5.2021 3.29, Maximilian Luz wrote:
>> On some devices (specifically the SC8180x based Surface Pro X with
>> QCOM04A6) HC halt / xhci_halt() times out during boot. Manually binding
>> the xhci-hcd driver at some point later does not exhibit this behavior.
>> To work around this, double XHCI_MAX_HALT_USEC, which also resolves this
>> issue.
>>
>> Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
>> ---
>>   drivers/usb/host/xhci-ext-caps.h | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
>> index fa59b242cd51..fb591e41cd50 100644
>> --- a/drivers/usb/host/xhci-ext-caps.h
>> +++ b/drivers/usb/host/xhci-ext-caps.h
>> @@ -7,8 +7,8 @@
>>    * Author: Sarah Sharp
>>    * Some code borrowed from the Linux EHCI driver.
>>    */
>> -/* Up to 16 ms to halt an HC */
>> -#define XHCI_MAX_HALT_USEC	(16*1000)
>> +/* Up to 32 ms to halt an HC */
>> +#define XHCI_MAX_HALT_USEC	(32 * 1000)
> 
> xHCI spec has a 16ms limit stated in several places, for example section 5.4.1
> "xHC is forced to halt within 16 ms. of software clearing the R/S bit to ‘0’,
> irrespective of any queued Transfer or Command Ring activity"

Right, thanks, I wasn't aware of this.

> To make sure hosts work we could increase it to 32, but comment could be
> changed to make sure it doean't get optimized back to 16 ms later.
> 
> How about:
> /* HC should halt within 16 ms, but use 32 ms as some in reality take longer */
> 
> If that's ok I can take this and modify the comment

That makes sense, yes. Please feel free to change that comment as you wish.

Regards,
Max

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-11  8:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11  0:29 [PATCH] usb: xhci: Increase timeout for HC halt Maximilian Luz
2021-05-11  6:26 ` Greg Kroah-Hartman
2021-05-11  8:40   ` Maximilian Luz
2021-05-11  7:19 ` Mathias Nyman
2021-05-11  8:42   ` Maximilian Luz

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).