LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alan Stern <stern@rowland.harvard.edu>
Subject: Re: [PATCH] USB: Don't enable LPM if it's already enabled
Date: Tue, 30 Oct 2018 16:24:08 +0200	[thread overview]
Message-ID: <c5d72c60-c13c-8801-26d5-2fe8ab48d98c@linux.intel.com> (raw)
In-Reply-To: <20181030055452.25969-1-kai.heng.feng@canonical.com>

On 30.10.2018 07:54, 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>
> ---
>   drivers/usb/core/driver.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index 53564386ed57..e11d2eac76b6 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -1901,7 +1901,8 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
>   	struct usb_hcd *hcd = bus_to_hcd(udev->bus);
>   	int ret = -EPERM;
>   
> -	if (enable && !udev->usb2_hw_lpm_allowed)
> +	if (enable && !udev->usb2_hw_lpm_allowed ||
> +	    udev->usb2_hw_lpm_enabled == enable)
>   		return 0;
>   
>   	if (hcd->driver->set_usb2_hw_lpm) {
> 

Something like that would probably work.

Would it make sense to skip USB2 hw LPM enabling in usb_port_resume() if
port was just reset (and thus LPM enabled)?

something like this:

--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3520,7 +3520,7 @@ 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->reset_resume)
                         usb_set_usb2_hardware_lpm(udev, 1);
  
                 /* Try to enable USB3 LTM */

-Mathias

  parent reply	other threads:[~2018-10-30 14:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30  5:54 Kai-Heng Feng
2018-10-30  6:16 ` kbuild test robot
2018-10-30  6:30 ` kbuild test robot
2018-10-30 14:24 ` Mathias Nyman [this message]
2018-10-30 15:00   ` Alan Stern
2018-10-30 15:07     ` Kai Heng Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c5d72c60-c13c-8801-26d5-2fe8ab48d98c@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --subject='Re: [PATCH] USB: Don'\''t enable LPM if it'\''s already enabled' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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