From patchwork Thu Sep 3 22:05:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 45441 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 n83M7PH3016057 for ; Thu, 3 Sep 2009 22:07:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932402AbZICWGm (ORCPT ); Thu, 3 Sep 2009 18:06:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932406AbZICWGm (ORCPT ); Thu, 3 Sep 2009 18:06:42 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:39278 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932402AbZICWGi (ORCPT ); Thu, 3 Sep 2009 18:06:38 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 3040F1561A8; Thu, 3 Sep 2009 21:05:11 +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 32670-06; Thu, 3 Sep 2009 21:04:40 +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 AD217156220; Thu, 3 Sep 2009 21:04:40 +0200 (CEST) From: "Rafael J. Wysocki" To: linux-pm@lists.linux-foundation.org Subject: [RFC][PATCH 3/4] PCI PM: Introduce device flag wakeup_prepared Date: Fri, 4 Sep 2009 00:05:26 +0200 User-Agent: KMail/1.12.0 (Linux/2.6.31-rc8-rjw; KDE/4.3.0; x86_64; ; ) Cc: ACPI Devel Maling List , Henrique de Moraes Holschuh , Jesse Barnes , Linux PCI References: <200908300041.14541.rjw@sisk.pl> <200909020041.57754.rjw@sisk.pl> <200909040002.02562.rjw@sisk.pl> In-Reply-To: <200909040002.02562.rjw@sisk.pl> MIME-Version: 1.0 Message-Id: <200909040005.26979.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 Introduce a new PCI device flag, wakeup_prepared, to prevent PCI wake-up preparation code from being executed twice in a row for the same device and for the same purpose. Signed-off-by: Rafael J. Wysocki --- drivers/pci/pci.c | 8 ++++++++ include/linux/pci.h | 1 + 2 files changed, 9 insertions(+) -- 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.c =================================================================== --- linux-2.6.orig/drivers/pci/pci.c +++ linux-2.6/drivers/pci/pci.c @@ -1223,6 +1223,10 @@ int pci_enable_wake(struct pci_dev *dev, if (enable && !device_may_wakeup(&dev->dev)) return -EINVAL; + /* Don't do the same thing twice in a row for one device. */ + if (!!enable == !!dev->wakeup_prepared) + return 0; + /* * According to "PCI System Architecture" 4th ed. by Tom Shanley & Don * Anderson we should be doing PME# wake enable followed by ACPI wake @@ -1239,9 +1243,12 @@ int pci_enable_wake(struct pci_dev *dev, error = platform_pci_sleep_wake(dev, true); if (ret) ret = error; + if (!ret) + dev->wakeup_prepared = true; } else { platform_pci_sleep_wake(dev, false); pci_pme_active(dev, false); + dev->wakeup_prepared = false; } return ret; @@ -1364,6 +1371,7 @@ void pci_pm_init(struct pci_dev *dev) u16 pmc; device_enable_async_suspend(&dev->dev, true); + dev->wakeup_prepared = false; dev->pm_cap = 0; /* find PCI PM capability in list */ Index: linux-2.6/include/linux/pci.h =================================================================== --- linux-2.6.orig/include/linux/pci.h +++ linux-2.6/include/linux/pci.h @@ -241,6 +241,7 @@ struct pci_dev { unsigned int d1_support:1; /* Low power state D1 is supported */ unsigned int d2_support:1; /* Low power state D2 is supported */ unsigned int no_d1d2:1; /* Only allow D0 and D3 */ + unsigned int wakeup_prepared:1; #ifdef CONFIG_PCIEASPM struct pcie_link_state *link_state; /* ASPM link state. */