From patchwork Fri Sep 4 22:06:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 45802 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n84M5Nbg010339 for ; Fri, 4 Sep 2009 22:05:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934349AbZIDWFU (ORCPT ); Fri, 4 Sep 2009 18:05:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S934340AbZIDWFU (ORCPT ); Fri, 4 Sep 2009 18:05:20 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:43972 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934321AbZIDWFS (ORCPT ); Fri, 4 Sep 2009 18:05:18 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id BA4CE155C21; Fri, 4 Sep 2009 21:03:39 +0200 (CEST) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 10932-04; Fri, 4 Sep 2009 21:03:23 +0200 (CEST) Received: from tosh.localnet (220-bem-13.acn.waw.pl [82.210.184.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 5A2AE155EB7; Fri, 4 Sep 2009 21:03:23 +0200 (CEST) From: "Rafael J. Wysocki" To: linux-pm@lists.linux-foundation.org Subject: [RFC][PATCH 5] PCI/ACPI PM: Propagate wake-up enable for devices w/o ACPI support Date: Sat, 5 Sep 2009 00:06:15 +0200 User-Agent: KMail/1.12.1 (Linux/2.6.31-rc8-rjw; KDE/4.3.1; x86_64; ; ) Cc: ACPI Devel Maling List , Jesse Barnes , Henrique de Moraes Holschuh , Linux PCI , ykzhao References: <200908300041.14541.rjw@sisk.pl> <200909040007.09926.rjw@sisk.pl> <200909050003.46520.rjw@sisk.pl> In-Reply-To: <200909050003.46520.rjw@sisk.pl> MIME-Version: 1.0 Message-Id: <200909050006.15506.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Rafael J. Wysocki Some PCI devices (not PCI Express), like PCI add-on cards, can generate PME#, but they don't have any special platform wake-up support. For this reason, even if they generate PME# to wake up the system from a sleep state, wake-up events are not generated by the platform. It turns out that, at least on some systems, PCI bridges and the PCI host bridge have ACPI GPEs associated with them that, if enabled to generate wake-up events, allow the system to wake up if one of the add-on devices asserts PME# while the system is in a sleep state. Following this observation, if a PCI device without direct ACPI wake-up support is prepared to wake up the system during a transition into a sleep state (eg. suspend to RAM), try to configure the bridges on the path from the device to the root bridge to wake-up the system. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/sleep.c | 2 +- drivers/pci/pci-acpi.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/pci/pci-acpi.c =================================================================== --- linux-2.6.orig/drivers/pci/pci-acpi.c +++ linux-2.6/drivers/pci/pci-acpi.c @@ -109,10 +109,32 @@ static bool acpi_pci_can_wakeup(struct p return handle ? acpi_bus_can_wakeup(handle) : false; } +static void acpi_pci_propagate_wakeup_enable(struct pci_bus *bus, bool enable) +{ + while (bus->parent) { + struct pci_dev *bridge = bus->self; + int ret; + + ret = acpi_pm_device_sleep_wake(&bridge->dev, enable); + if (!ret || bridge->is_pcie) + return; + bus = bus->parent; + } + + /* We have reached the root bus. */ + if (bus->bridge) + acpi_pm_device_sleep_wake(bus->bridge, enable); +} + static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable) { - return acpi_pci_can_wakeup(dev) ? - acpi_pm_device_sleep_wake(&dev->dev, enable) : 0; + if (acpi_pci_can_wakeup(dev)) + return acpi_pm_device_sleep_wake(&dev->dev, enable); + + if (!dev->is_pcie) + acpi_pci_propagate_wakeup_enable(dev->bus, enable); + + return 0; } static struct pci_platform_pm_ops acpi_pci_platform_pm = { Index: linux-2.6/drivers/acpi/sleep.c =================================================================== --- linux-2.6.orig/drivers/acpi/sleep.c +++ linux-2.6/drivers/acpi/sleep.c @@ -691,7 +691,7 @@ int acpi_pm_device_sleep_wake(struct dev struct acpi_device *adev; int error; - if (!device_may_wakeup(dev)) + if (!device_can_wakeup(dev)) return -EINVAL; handle = DEVICE_ACPI_HANDLE(dev);