From patchwork Tue Oct 11 15:18:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 9371275 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45BB160487 for ; Tue, 11 Oct 2016 15:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C0331FE82 for ; Tue, 11 Oct 2016 15:20:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E91629CD8; Tue, 11 Oct 2016 15:20:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBCBF29CD3 for ; Tue, 11 Oct 2016 15:20:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752826AbcJKPUB (ORCPT ); Tue, 11 Oct 2016 11:20:01 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:43232 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752669AbcJKPUA (ORCPT ); Tue, 11 Oct 2016 11:20:00 -0400 Received: (qmail 7056 invoked by uid 2102); 11 Oct 2016 11:18:28 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 11 Oct 2016 11:18:28 -0400 Date: Tue, 11 Oct 2016 11:18:28 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Lukas Wunner cc: Bjorn Helgaas , Mathias Nyman , Pierre de Villemereuil , Oliver Neukum , USB list , , "Rafael J. Wysocki" Subject: Re: USB hot-plug not working (ASUS TP301UA-C4028T) In-Reply-To: <20161008103140.GA7725@wunner.de> Message-ID: MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sat, 8 Oct 2016, Lukas Wunner wrote: > The PCI core already calls pm_runtime_get_sync() before invoking the > ->probe hook of a driver (see local_pci_probe()). Drivers need to > explicitly release a runtime ref to allow their device to suspend. > For xhci-pci, this seems to happen in usb_hcd_pci_probe(): > > if (pci_dev_run_wake(dev)) > pm_runtime_put_noidle(&dev->dev); > > So you could either modify the if-condition if you want to change the > behaviour for XHCI devices only, or if you want to change it in general, > add something like this to pci_dev_run_wake(): > > /* PME capable in principle, but not from the intended sleep state */ > if (dev->pme_support && !pci_pme_capable(dev, pci_target_state(dev))) > return false; > > I've briefly looked over the callers of pci_dev_run_wake() and the above > seems safe but you should double-check them. That seems like a good suggestion. The patch is below; Pierre, can you test it? This should remove the need to set the USB autosuspend module parameter to -1. Alan Stern --- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: usb-4.x/drivers/pci/pci.c =================================================================== --- usb-4.x.orig/drivers/pci/pci.c +++ usb-4.x/drivers/pci/pci.c @@ -2064,6 +2064,10 @@ bool pci_dev_run_wake(struct pci_dev *de if (!dev->pme_support) return false; + /* PME-capable in principle, but not from the intended sleep state */ + if (!pci_pme_capable(dev, pci_target_state(dev))) + return false; + while (bus->parent) { struct pci_dev *bridge = bus->self;