Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4832638imd; Tue, 30 Oct 2018 08:04:52 -0700 (PDT) X-Google-Smtp-Source: AJdET5cKIxLLPnJRueXdrGMpONwYCskV6ikxOHpLUealnCrkT14LhoSVKqqo/kFdGa4GKXyvWxoE X-Received: by 2002:a65:4683:: with SMTP id h3mr17559334pgr.225.1540911892556; Tue, 30 Oct 2018 08:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540911892; cv=none; d=google.com; s=arc-20160816; b=cFurnibzXQP04aiSb5cczxKjRQ3+YMKJ+o0vWizhBHd5Zp9x/+Fs+XMVj5aFOpCXVf vzkbKgGcbr0y/D8in6FV6Xd2kuXbWg4+RRoJtilp8PjH0My57SN5Y1CetlIIlHx3Pk3a v2C6/TjjU3SEJmz0C/DgvN3vnpodU4VQUFxJLPhBK94HAQxdJZUXyjgfFA7NKUdnTS4N GtCGbaaQLVmIe/v7W/I+PsmIJmpaAP1/dPBMeROBX1veSLSRZB9JhMwN5InYrkB5Htw8 1tmuU3FS4kEbiSqyZwjEY9ZjvQpaWc9WUfvR3M8srw3bKRjfF+PYVQj9lbxpo6F1yAb9 vhFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=MWOOjHWieYcTun/N7ozqEnLhbn9rn0/XyKpnmNNhLTY=; b=SbYUtVy3dCMF4+8W7jhqW4sy6BY0c5CDxcO5Y/MwmlPXjHk27F43vzK/wIirprUvhd 4At7BNkrA/eU7vSin2QRmuzTtDl7dESQIpQJlK95QLlq55iXMK7dGo9jGdqQbREbYe7V edsQFv7OqKanepqtVlQc7G1gqr0XxCaSGOuxkMvOwd0Eo8x2t4vQKBXg3YDelTdI5nSp +sojCi/qtaEf164m/62QFz9h6J+t8Bv2SsBJKtnkLw+fQMWG+VfV6FJy+tdcvuP1xEPs 6MJl52wr0+5+VwU6UqyDbxA8bLmmNq2BOofZjEDI7v9YkAC71eL8Z6dH12336JG4kPBi dAzg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6-v6si24386815pgf.303.2018.10.30.08.04.18; Tue, 30 Oct 2018 08:04:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727573AbeJ3Xyf (ORCPT + 99 others); Tue, 30 Oct 2018 19:54:35 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:51706 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727545AbeJ3Xyf (ORCPT ); Tue, 30 Oct 2018 19:54:35 -0400 Received: (qmail 4836 invoked by uid 2102); 30 Oct 2018 11:00:46 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 30 Oct 2018 11:00:46 -0400 Date: Tue, 30 Oct 2018 11:00:46 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Mathias Nyman cc: Kai-Heng Feng , , , Subject: Re: [PATCH] USB: Don't enable LPM if it's already enabled In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 30 Oct 2018, Mathias Nyman wrote: > 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 */ Why not simply test whether udev->usb2_hw_lpm_enabled is already true? if (udev->usb2_hw_lpm_capable == 1 && !udev->usb2_hw_lpm_enabled) Or even put this extra test into usb_set_usb2_hardware_lpm(). Alan Stern