Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4784013imd; Tue, 30 Oct 2018 07:23:12 -0700 (PDT) X-Google-Smtp-Source: AJdET5eIIRNLw+riFp6ag2kXNSIqP/0GW103QAk36+PAM2LttwYmBpcV6nvOpEcrj68LeYPj5Q67 X-Received: by 2002:a62:b90f:: with SMTP id z15-v6mr3200736pfe.171.1540909392824; Tue, 30 Oct 2018 07:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540909392; cv=none; d=google.com; s=arc-20160816; b=gcx+J+IaA3r3UaMFw4lSrd3bGlY31rSNgIpPt6qYY2cTsJRp0q7wnM36bnbDb8zqXY 049Fs4AqWJyTFrQxWDg7BDU8qUAzaLsCxZzDlikRBxt8HrT9DRLfjk7yI63Jvb0mXe+m K662/dE6+k06hpBRTWSccKIQaGQgB0mtsKVKtQyyO1TONzL5RQtTNKPBBwgXLHBEtWCo xkSwI0BP9GYn2ED4bwoSONMcla/7cJKuK4hDupisRATuOCfTveluAfxFHnjOpzbLc2wW URQGFGBI2Njk/dKfZ/SGdnfyDYIwJ8yFy5QMFSxS0QF3UNDFsvvFeC8ZW6FhVIr49Fpr CojQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Q2epQW83/Vfquv6it5ePOv+QCXAWKypzm4IOZbwvxLQ=; b=py/g4nZVCpTezCA2O6vVlPucJI/7gWBb3jaqT7XZXl2ndKcII4yyVghOPpCWB/q9CD j/QojnmNBhDGrAyK69n5FZW4661gJIQfTam0vWxNLTPVH8D023Jx9QOghxh+N0t5Lnk1 Gj/GlMqaIQKnYfzbvsWjasuZVSRcAQdI/sYPPgjDOAJfpOPbYRSS9mKKFHtc7jnXzFfC WylRioT1d4zoIFWw+Zdh9lGtoljAwqdrsFb/O1BwAoHxynPACHdPE1TSg7+pCjWzEUYf NfqTLAa4wlgVeJ0C135o6YMseEQPG5ErRQCmRMkErN9OKJJxRc78OGZ5kPRUOSjjJCNx /C/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7-v6si8137843pfg.205.2018.10.30.07.22.56; Tue, 30 Oct 2018 07:23:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728288AbeJ3XOP (ORCPT + 99 others); Tue, 30 Oct 2018 19:14:15 -0400 Received: from mga01.intel.com ([192.55.52.88]:31308 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbeJ3XOP (ORCPT ); Tue, 30 Oct 2018 19:14:15 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2018 07:20:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,444,1534834800"; d="scan'208";a="86882686" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.164]) ([10.237.72.164]) by orsmga006.jf.intel.com with ESMTP; 30 Oct 2018 07:20:33 -0700 Subject: Re: [PATCH] USB: Don't enable LPM if it's already enabled To: Kai-Heng Feng , gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Stern References: <20181030055452.25969-1-kai.heng.feng@canonical.com> From: Mathias Nyman Message-ID: Date: Tue, 30 Oct 2018 16:24:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181030055452.25969-1-kai.heng.feng@canonical.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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