All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Andi Kleen <andi@firstfloor.org>,
	pm list <linux-pm@lists.linux-foundation.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Zhao Yakui <yakui.zhao@intel.com>, Pavel Machek <pavel@suse.cz>
Subject: [PATCH 5/8] ACPI: Introduce new device wakeup flag 'prepared'
Date: Mon, 7 Jul 2008 03:34:11 +0200	[thread overview]
Message-ID: <200807070334.12948.rjw@sisk.pl> (raw)
In-Reply-To: <200807070330.02849.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

ACPI: Introduce new device wakeup flag 'prepared'

Introduce additional flag 'prepared' in
struct acpi_device_wakeup_flags and use it to prevent devices from
being enable/disabled do wake up the system multiple times in a row
(this does not happen currently, but will be possible after some of
the following patches).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/acpi/power.c    |   24 ++++++++++++++++++++++--
 include/acpi/acpi_bus.h |    1 +
 2 files changed, 23 insertions(+), 2 deletions(-)

Index: linux-next/drivers/acpi/power.c
===================================================================
--- linux-next.orig/drivers/acpi/power.c
+++ linux-next/drivers/acpi/power.c
@@ -363,11 +363,18 @@ int acpi_device_sleep_wake(struct acpi_d
  */
 int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
 {
-	int i;
+	int i, err;
 
 	if (!dev || !dev->wakeup.flags.valid)
 		return -EINVAL;
 
+	/*
+	 * Do not execute the code below twice in a row without calling
+	 * acpi_disable_wakeup_device_power() in between for the same device
+	 */
+	if (dev->wakeup.flags.prepared)
+		return 0;
+
 	/* Open power resource */
 	for (i = 0; i < dev->wakeup.resources.count; i++) {
 		int ret = acpi_power_on(dev->wakeup.resources.handles[i], dev);
@@ -382,7 +389,11 @@ int acpi_enable_wakeup_device_power(stru
 	 * Passing 3 as the third argument below means the device may be placed
 	 * in arbitrary power state afterwards.
 	 */
-	return acpi_device_sleep_wake(dev, 1, sleep_state, 3);
+	err = acpi_device_sleep_wake(dev, 1, sleep_state, 3);
+	if (!err)
+		dev->wakeup.flags.prepared = 1;
+
+	return err;
 }
 
 /*
@@ -398,6 +409,15 @@ int acpi_disable_wakeup_device_power(str
 	if (!dev || !dev->wakeup.flags.valid)
 		return -EINVAL;
 
+	/*
+	 * Do not execute the code below twice in a row without calling
+	 * acpi_enable_wakeup_device_power() in between for the same device
+	 */
+	if (!dev->wakeup.flags.prepared)
+		return 0;
+
+	dev->wakeup.flags.prepared = 0;
+
 	ret = acpi_device_sleep_wake(dev, 0, 0, 0);
 	if (ret)
 		return ret;
Index: linux-next/include/acpi/acpi_bus.h
===================================================================
--- linux-next.orig/include/acpi/acpi_bus.h
+++ linux-next/include/acpi/acpi_bus.h
@@ -259,6 +259,7 @@ struct acpi_device_perf {
 /* Wakeup Management */
 struct acpi_device_wakeup_flags {
 	u8 valid:1;		/* Can successfully enable wakeup? */
+	u8 prepared:1;		/* Has the wake-up capability been enabled? */
 	u8 run_wake:1;		/* Run-Wake GPE devices */
 };
 


  parent reply	other threads:[~2008-07-07  1:34 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-01 21:56 [PATCH 0/9] PCI PM: Handling of PCI devices wake-up functionality (rev. 3) Rafael J. Wysocki
2008-07-01 22:00 ` [PATCH 1/9] PCI ACPI: Remove acpi_platform_enable_wakeup Rafael J. Wysocki
2008-07-01 22:00 ` Rafael J. Wysocki
2008-07-01 22:03 ` [PATCH 2/9] ACPI: Introduce acpi_bus_power_manageable function Rafael J. Wysocki
2008-07-01 22:03 ` Rafael J. Wysocki
2008-07-01 22:04 ` [PATCH 3/9] PCI: Introduce platform_pci_power_manageable function Rafael J. Wysocki
2008-07-01 22:04 ` Rafael J. Wysocki
2008-07-01 22:05 ` [PATCH 4/9] PCI: Rework pci_set_power_state function (rev. 3) Rafael J. Wysocki
2008-07-01 22:05 ` Rafael J. Wysocki
2008-07-01 22:06 ` [PATCH 5/9] ACPI: Introduce acpi_device_sleep_wake function Rafael J. Wysocki
2008-07-01 22:06 ` Rafael J. Wysocki
2008-07-01 22:07 ` [PATCH 6/9] ACPI: Introduce new device wakeup flag 'prepared' Rafael J. Wysocki
2008-07-01 22:07 ` Rafael J. Wysocki
2008-07-01 22:08 ` [PATCH 7/9] PCI ACPI: Rework PCI handling of wake-up (rev. 4) Rafael J. Wysocki
2008-07-01 22:08 ` Rafael J. Wysocki
2008-07-02  7:30   ` Zhao Yakui
2008-07-02  7:30   ` Zhao Yakui
2008-07-02 10:16     ` Rafael J. Wysocki
2008-07-02 10:16     ` Rafael J. Wysocki
2008-07-01 22:09 ` [PATCH 8/9] PCI PM: Introduce pci_prepare_to_sleep and pci_back_from_sleep Rafael J. Wysocki
2008-07-01 22:09 ` Rafael J. Wysocki
2008-07-01 22:10 ` [PATCH 9/9] PCI: Simplify PCI device PM code (rev. 4) Rafael J. Wysocki
2008-07-01 22:10 ` Rafael J. Wysocki
2008-07-03 12:04 ` [PATCH 0/9] PCI PM: Handling of PCI devices wake-up functionality (rev. 3) Rafael J. Wysocki
2008-07-07  1:30 ` [PATCH 0/8] PCI PM: Handling of PCI devices wake-up functionality (rev. 4) Rafael J. Wysocki
2008-07-07  1:30 ` Rafael J. Wysocki
2008-07-07  1:30   ` [PATCH 1/8] ACPI: Introduce acpi_bus_power_manageable function Rafael J. Wysocki
2008-07-07  1:30   ` Rafael J. Wysocki
2008-07-07  1:32   ` [PATCH 2/8] PCI: Introduce platform_pci_power_manageable function Rafael J. Wysocki
2008-07-07  1:32   ` Rafael J. Wysocki
2008-07-07  1:32   ` [PATCH 3/8] PCI: Rework pci_set_power_state function (rev. 4) Rafael J. Wysocki
2008-07-07  1:32   ` Rafael J. Wysocki
2008-07-07  1:33   ` [PATCH 4/8] ACPI: Introduce acpi_device_sleep_wake function Rafael J. Wysocki
2008-07-07  1:33   ` Rafael J. Wysocki
2008-07-07  1:34   ` Rafael J. Wysocki [this message]
2008-07-07 14:08     ` [PATCH 5/8] ACPI: Introduce new device wakeup flag 'prepared' Pavel Machek
2008-07-07 14:08     ` Pavel Machek
2008-07-07  1:34   ` Rafael J. Wysocki
2008-07-07  1:34   ` [PATCH 6/8] PCI ACPI: Rework PCI handling of wake-up (rev. 5) Rafael J. Wysocki
2008-07-07  1:34   ` Rafael J. Wysocki
2008-07-11 20:30     ` Pavel Machek
2008-07-11 20:30     ` Pavel Machek
2008-07-07  1:35   ` [PATCH 7/8] PCI PM: Introduce pci_prepare_to_sleep and pci_back_from_sleep Rafael J. Wysocki
2008-07-11 20:31     ` Pavel Machek
2008-07-11 20:31     ` Pavel Machek
2008-07-07  1:35   ` Rafael J. Wysocki
2008-07-07  1:36   ` [PATCH 8/8] PCI: Simplify PCI device PM code (rev. 4) Rafael J. Wysocki
2008-07-07  1:36   ` Rafael J. Wysocki
2008-07-11 20:37     ` Pavel Machek
2008-07-11 20:45       ` Rafael J. Wysocki
2008-07-11 20:45       ` Rafael J. Wysocki
2008-07-11 20:49         ` Pavel Machek
2008-07-11 20:49         ` Pavel Machek
2008-07-11 20:37     ` Pavel Machek
2008-07-08  0:49   ` [PATCH 0/8] PCI PM: Handling of PCI devices wake-up functionality " Jesse Barnes
2008-07-08 14:42     ` Rafael J. Wysocki
2008-07-08 14:42     ` Rafael J. Wysocki
2008-07-13 20:45   ` PCI PM: Fix pci_prepare_to_sleep Rafael J. Wysocki
2008-07-13 20:45   ` Rafael J. Wysocki
2008-07-14 21:27     ` Jesse Barnes
2008-07-14 21:40       ` Rafael J. Wysocki
2008-07-14 21:40       ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2008-06-26 22:22 [PATCH 0/8] PCI PM: Handling of PCI devices wake-up functionality (rev. 2) Rafael J. Wysocki
2008-06-26 22:27 ` [PATCH 5/8] ACPI: Introduce new device wakeup flag 'prepared' Rafael J. Wysocki
2008-06-26 22:27 ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200807070334.12948.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=andi@firstfloor.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=pavel@suse.cz \
    --cc=rui.zhang@intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=yakui.zhao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.