Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8137655ybi; Thu, 6 Jun 2019 07:19:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqC2tBhM2LBcqN1jFGMYpjrzjal2KXH+b16qhWkb/n3/mLs/JLEuIhDi3RGkNKlVU+i/55 X-Received: by 2002:a62:f20b:: with SMTP id m11mr930034pfh.125.1559830788515; Thu, 06 Jun 2019 07:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559830788; cv=none; d=google.com; s=arc-20160816; b=L2N2UvGDGnjizJe+C5TlNCC4Cg9nVVr2/zKKKmNmMaeyPb5nw2e5A8Pa6A940PTZj9 14XUDR1Hkx+9NXoEUBUdmHm2Hq85lO3yqVHjGr82SiC8KCnYFzfyPL/E5O+6Hs0dNtUH 9P/HRlxIB/sCp78LgN3Fs5j/AisYXpzqFYFYJJy2PqG9pGV9MvqDtTjx5VYew9dKEh8n Md+BSjj689p0PxaMofTlfNumUVSkaeqW9JHGwba65AfpuF+1lV+DSKhWqObTXkzFXL5h dkBNro1Yt+AKq8uiB1pxFUdLObVgN03UtzHcIsaMibH8RDLozi6wIY3AGkpoGa+0dhu6 /Q6A== 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:mime-version :message-id:in-reply-to:subject:cc:to:from:date; bh=wp70zf4e0iJWQBa3zSMKyWlnzpxd9t5JrsN01KJiqsQ=; b=JkDKV+3RP0Q3mp+8HZwZ9vhFL8MjrmFg7nrtVab4XFqLMVZdgIG9d0ZyCPXO0XHg8i 91UIn9XcfFg4E+De1YYZu5rYS0lSYWMBjHXc5zYMvbEWht2Zy2YNm25Jw5YxOkJpZwip CIsqbAeqclDE4f917YfzYPkmHSe28Z2RBpaWf3kvFTtm5MAYvq09pdsa5RKM9NnVuIr3 L+rMa2PdkVnx2W418ZQRMxu5YVJ5J48Od+yIrl6A1dQGP5UBp0aaYoLEaBHSa7GfjBH6 BIb7axoTaMKe0B5AvJxUs5rW9gFWIPqzessGdz4Zx/4bkSXsBJKOkh4oHRjqc3ETZ5Dq Kwfg== 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 y8si1922977pjp.65.2019.06.06.07.19.30; Thu, 06 Jun 2019 07:19:48 -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 S1728795AbfFFORJ (ORCPT + 99 others); Thu, 6 Jun 2019 10:17:09 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:51784 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727168AbfFFORJ (ORCPT ); Thu, 6 Jun 2019 10:17:09 -0400 Received: (qmail 2998 invoked by uid 2102); 6 Jun 2019 10:17:08 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 6 Jun 2019 10:17:08 -0400 Date: Thu, 6 Jun 2019 10:17:08 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Kai-Heng Feng cc: Mathias Nyman , Greg KH , Linux USB List , lkml Subject: Re: [PATCH v2] USB: Disable USB2 LPM at shutdown In-Reply-To: <1C63D05A-1AEF-40F6-8127-4958A4112676@canonical.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 Jun 2019, Kai-Heng Feng wrote: > at 15:55, Kai-Heng Feng wrote: > > > at 18:22, Kai-Heng Feng wrote: > > > >> at 00:01, Kai-Heng Feng wrote: > >> > >>>> On Jan 30, 2019, at 16:21, Greg KH wrote: > >>>> > >>>> On Thu, Jan 24, 2019 at 02:16:43PM +0800, Kai-Heng Feng wrote: > >>>>> The QCA Rome USB Bluetooth controller has several issues once LPM gets > >>>>> enabled: > >>>>> - Fails to get enumerated in coldboot. [1] > >>>>> - Drains more power (~ 0.2W) when the system is in S5. [2] > >>>>> - Disappears after a warmboot. [2] > >>>>> > >>>>> The issue happens because the device lingers at LPM L1 in S5, so device > >>>>> can't get enumerated even after a reboot. > >>>>> > >>>>> Disable LPM at shutdown to solve the issue. > >>>>> > >>>>> [1] https://bugs.launchpad.net/bugs/1757218 > >>>>> [2] https://patchwork.kernel.org/patch/10607097/ > >>>>> > >>>>> Signed-off-by: Kai-Heng Feng > >>>>> --- > >>>>> v2: Use new LPM helpers. > >>>>> > >>>>> drivers/usb/core/port.c | 9 +++++++++ > >>>>> 1 file changed, 9 insertions(+) > >>>>> > >>>>> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c > >>>>> index 1a06a4b5fbb1..bbbb35fa639f 100644 > >>>>> --- a/drivers/usb/core/port.c > >>>>> +++ b/drivers/usb/core/port.c > >>>>> @@ -285,6 +285,14 @@ static int usb_port_runtime_suspend(struct > >>>>> device *dev) > >>>>> } > >>>>> #endif > >>>>> > >>>>> +static void usb_port_shutdown(struct device *dev) > >>>>> +{ > >>>>> + struct usb_port *port_dev = to_usb_port(dev); > >>>>> + > >>>>> + if (port_dev->child) > >>>>> + usb_disable_usb2_hardware_lpm(port_dev->child); > >>>>> +} > >>>>> + > >>>>> static const struct dev_pm_ops usb_port_pm_ops = { > >>>>> #ifdef CONFIG_PM > >>>>> .runtime_suspend = usb_port_runtime_suspend, > >>>>> @@ -301,6 +309,7 @@ struct device_type usb_port_device_type = { > >>>>> static struct device_driver usb_port_driver = { > >>>>> .name = "usb", > >>>>> .owner = THIS_MODULE, > >>>>> + .shutdown = usb_port_shutdown, > >>>>> }; > >>>> > >>>> So you now do this for all ports in the system, no matter what is > >>>> plugged in or not. Are you _SURE_ you want to do that? It seems like a > >>>> big hammer to solve just one single device's problems. > >>> > >>> Yes I think this should be universally applied. > >>> > >>> I don’t think the bug only happens to one device. Users won’t find this > >>> unless they connect their laptop to a power meter. > >>> > >>> Platform may not completely cut off USB bus power during shutdown, > >>> so the device transits to L1 after system shutdown. Now xHC is disabled > >>> so nothing can bring it back to L0 or L2. > >> > >> It would be great if someone can come up with better ideas. > >> > >> We can also use other approaches, but currently this is the only way I > >> can think of. > > > > Alan and Mathias, > > > > It would be great if you can review this patch, or give me some suggestion. > > Can I get some advice here? > I really think disabling LPM should be universally applied. > > Kai-Heng I agree with Kai-Heng, this seems like a fairly light-weight solution to a reasonable problem. As to the issue of how much it will slow down system shutdowns, I have no idea. Probably not very much, unless somebody has an unusually large number of USB devices plugged in, but only testing can give a real answer. I suppose we could add an HCD flag for host controllers which require this workaround. Either way, it's probably not a very big deal. Alan Stern