From patchwork Fri Oct 21 20:45:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 9390115 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 D900160762 for ; Fri, 21 Oct 2016 20:45:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBDE029FB8 for ; Fri, 21 Oct 2016 20:45:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC29C29FC1; Fri, 21 Oct 2016 20:45:43 +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 E023529FB8 for ; Fri, 21 Oct 2016 20:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755075AbcJUUpl (ORCPT ); Fri, 21 Oct 2016 16:45:41 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:35794 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755056AbcJUUpk (ORCPT ); Fri, 21 Oct 2016 16:45:40 -0400 Received: (qmail 5076 invoked by uid 2102); 21 Oct 2016 16:45:38 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 21 Oct 2016 16:45:38 -0400 Date: Fri, 21 Oct 2016 16:45:38 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Bjorn Helgaas cc: Lukas Wunner , Pierre de Villemereuil , , USB list Subject: [PATCH 1/2] PCI: check for PME in targeted sleep state 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 One some systems, the firmware does not allow certain PCI devices to be put in deep D-states. This can cause problems for wakeup signalling, if the device does not support PME# in the deepest allowed suspend state. For example, Pierre reports that on his system, ACPI does not permit his xHCI host controller to go into D3 during runtime suspend -- but D3 is the only state in which the controller can generate PME# signals. As a result, the controller goes into runtime suspend but never wakes up, so it doesn't work properly. USB devices plugged into the controller are never detected. If the device relies on PME# for wakeup signals but is not capable of generating PME# in the target state, the PCI core should accurately report that it cannot do wakeup from runtime suspend. This patch modifies the pci_dev_run_wake() routine to add this check. Signed-off-by: Alan Stern CC: Lukas Wunner Reported-by: Pierre de Villemereuil Tested-by: Pierre de Villemereuil CC: Acked-by: Rafael J. Wysocki --- [as1814] drivers/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+) -- 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;