LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] USB: Don't enable LPM if it's already enabled
@ 2018-10-31  5:52 Kai-Heng Feng
  2018-11-23  6:03 ` Kai Heng Feng
  2018-11-23 15:08 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Kai-Heng Feng @ 2018-10-31  5:52 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-kernel, Kai-Heng Feng

USB Bluetooth controller QCA ROME (0cf3:e007) sometimes stops working
after S3:
[ 165.110742] Bluetooth: hci0: using NVM file: qca/nvm_usb_00000302.bin
[ 168.432065] Bluetooth: hci0: Failed to send body at 4 of 1953 (-110)

After some experiments, I found that disabling LPM can workaround the
issue.

On some platforms, the USB power is cut during S3, so the driver uses
reset-resume to resume the device. During port resume, LPM gets enabled
twice, by usb_reset_and_verify_device() and usb_port_resume().

So let's enable LPM for just once, as this solves the issue for the
device in question.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v2:
 -  Check udev->usb2_hw_lpm_enabled before calling usb_port_resume().

 drivers/usb/core/hub.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index c6077d582d29..02fa574e98ce 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3523,7 +3523,8 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
 		hub_port_logical_disconnect(hub, port1);
 	} else  {
 		/* Try to enable USB2 hardware LPM */
-		if (udev->usb2_hw_lpm_capable == 1)
+		if (udev->usb2_hw_lpm_capable == 1 &&
+		    !udev->usb2_hw_lpm_enabled)
 			usb_set_usb2_hardware_lpm(udev, 1);
 
 		/* Try to enable USB3 LTM */
-- 
2.19.1


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

* Re: [PATCH v2] USB: Don't enable LPM if it's already enabled
  2018-10-31  5:52 [PATCH v2] USB: Don't enable LPM if it's already enabled Kai-Heng Feng
@ 2018-11-23  6:03 ` Kai Heng Feng
  2018-11-23 15:08 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Kai Heng Feng @ 2018-11-23  6:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel

Hi Greg,

> On Oct 31, 2018, at 1:52 PM, Kai-Heng Feng <kai.heng.feng@canonical.com> wrote:
> 
> USB Bluetooth controller QCA ROME (0cf3:e007) sometimes stops working
> after S3:
> [ 165.110742] Bluetooth: hci0: using NVM file: qca/nvm_usb_00000302.bin
> [ 168.432065] Bluetooth: hci0: Failed to send body at 4 of 1953 (-110)
> 
> After some experiments, I found that disabling LPM can workaround the
> issue.
> 
> On some platforms, the USB power is cut during S3, so the driver uses
> reset-resume to resume the device. During port resume, LPM gets enabled
> twice, by usb_reset_and_verify_device() and usb_port_resume().
> 
> So let's enable LPM for just once, as this solves the issue for the
> device in question.
> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

Would it be possible to merge this patch?

Kai-Heng

> ---
> v2:
> -  Check udev->usb2_hw_lpm_enabled before calling usb_port_resume().
> 
> drivers/usb/core/hub.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index c6077d582d29..02fa574e98ce 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -3523,7 +3523,8 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
> 		hub_port_logical_disconnect(hub, port1);
> 	} else  {
> 		/* Try to enable USB2 hardware LPM */
> -		if (udev->usb2_hw_lpm_capable == 1)
> +		if (udev->usb2_hw_lpm_capable == 1 &&
> +		    !udev->usb2_hw_lpm_enabled)
> 			usb_set_usb2_hardware_lpm(udev, 1);
> 
> 		/* Try to enable USB3 LTM */
> -- 
> 2.19.1
> 


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

* Re: [PATCH v2] USB: Don't enable LPM if it's already enabled
  2018-10-31  5:52 [PATCH v2] USB: Don't enable LPM if it's already enabled Kai-Heng Feng
  2018-11-23  6:03 ` Kai Heng Feng
@ 2018-11-23 15:08 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-11-23 15:08 UTC (permalink / raw)
  To: Kai-Heng Feng; +Cc: linux-usb, linux-kernel

On Wed, Oct 31, 2018 at 01:52:09PM +0800, Kai-Heng Feng wrote:
> USB Bluetooth controller QCA ROME (0cf3:e007) sometimes stops working
> after S3:
> [ 165.110742] Bluetooth: hci0: using NVM file: qca/nvm_usb_00000302.bin
> [ 168.432065] Bluetooth: hci0: Failed to send body at 4 of 1953 (-110)
> 
> After some experiments, I found that disabling LPM can workaround the
> issue.
> 
> On some platforms, the USB power is cut during S3, so the driver uses
> reset-resume to resume the device. During port resume, LPM gets enabled
> twice, by usb_reset_and_verify_device() and usb_port_resume().
> 
> So let's enable LPM for just once, as this solves the issue for the
> device in question.
> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
> v2:
>  -  Check udev->usb2_hw_lpm_enabled before calling usb_port_resume().
> 
>  drivers/usb/core/hub.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index c6077d582d29..02fa574e98ce 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -3523,7 +3523,8 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
>  		hub_port_logical_disconnect(hub, port1);
>  	} else  {
>  		/* Try to enable USB2 hardware LPM */
> -		if (udev->usb2_hw_lpm_capable == 1)
> +		if (udev->usb2_hw_lpm_capable == 1 &&
> +		    !udev->usb2_hw_lpm_enabled)
>  			usb_set_usb2_hardware_lpm(udev, 1);

It's annoying how every caller has to try to figure this out, why can't
we put this logic in the usb_set_usb2_hardware_lpm() itself?

And usb_set_usb2_hardware_lpm() is a horrid name, as it has a bool
option that you always have to look up.  We should just have
usb_usb2_hardware_lpm_enable() and usb_usb2_hardware_lpm_disable().

Care to make this a patch series to fix all of this up?

thanks,

greg k-h

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

end of thread, other threads:[~2018-11-23 15:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-31  5:52 [PATCH v2] USB: Don't enable LPM if it's already enabled Kai-Heng Feng
2018-11-23  6:03 ` Kai Heng Feng
2018-11-23 15:08 ` Greg KH

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