mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: "Moore, Robert" <robert.moore@intel.com>,
	Matthew Garrett <mjg@redhat.com>, Len Brown <lenb@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	pm list <linux-pm@lists.linux-foundation.org>,
	Linux PCI <linux-pci@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Oliver Neukum <oliver@neukum.org>,
	Bjorn Helgaas <bjorn.helgaas@hp.com>,
	Shaohua Li <shaohua.li@intel.com>
Subject: [PATCH 7/9] ACPI / PM: Add more run-time wake-up fields (rev. 2)
Date: Sun, 10 Jan 2010 14:48:39 +0100	[thread overview]
Message-ID: <201001101448.39486.rjw@sisk.pl> (raw)
In-Reply-To: <201001101431.38630.rjw@sisk.pl>

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

Use the run_wake flag to mark all devices for which run-time wake-up
events may be generated by the platform.  Introduce a new wake-up
flag, always_enabled, for marking devices that should be permanently
enabled to generate run-time events.  Also, introduce a reference
counter for run-wake devices and a function that will initialize all
of the run-time wake-up fields for given device.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Len Brown <len.brown@intel.com>
---
 drivers/acpi/button.c   |    2 ++
 drivers/acpi/scan.c     |   37 +++++++++++++++++++++++++++----------
 drivers/acpi/wakeup.c   |    3 ++-
 include/acpi/acpi_bus.h |    2 ++
 4 files changed, 33 insertions(+), 11 deletions(-)

Index: linux-2.6/drivers/acpi/wakeup.c
===================================================================
--- linux-2.6.orig/drivers/acpi/wakeup.c
+++ linux-2.6/drivers/acpi/wakeup.c
@@ -106,7 +106,8 @@ int __init acpi_wakeup_device_init(void)
 						       struct acpi_device,
 						       wakeup_list);
 		/* In case user doesn't load button driver */
-		if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled)
+		if (!dev->wakeup.flags.always_enabled ||
+		    dev->wakeup.state.enabled)
 			continue;
 		acpi_ref_wakeup_gpe(dev->wakeup.gpe_device,
 				    dev->wakeup.gpe_number);
Index: linux-2.6/include/acpi/acpi_bus.h
===================================================================
--- linux-2.6.orig/include/acpi/acpi_bus.h
+++ linux-2.6/include/acpi/acpi_bus.h
@@ -242,6 +242,7 @@ struct acpi_device_perf {
 struct acpi_device_wakeup_flags {
 	u8 valid:1;		/* Can successfully enable wakeup? */
 	u8 run_wake:1;		/* Run-Wake GPE devices */
+	u8 always_enabled:1;	/* Run-wake devices that are always enabled */
 };
 
 struct acpi_device_wakeup_state {
@@ -256,6 +257,7 @@ struct acpi_device_wakeup {
 	struct acpi_device_wakeup_state state;
 	struct acpi_device_wakeup_flags flags;
 	int prepare_count;
+	int run_wake_count;
 };
 
 /* Device */
Index: linux-2.6/drivers/acpi/button.c
===================================================================
--- linux-2.6.orig/drivers/acpi/button.c
+++ linux-2.6/drivers/acpi/button.c
@@ -426,6 +426,7 @@ static int acpi_button_add(struct acpi_d
 				     device->wakeup.gpe_number);
 		acpi_ref_wakeup_gpe(device->wakeup.gpe_device,
 				    device->wakeup.gpe_number);
+		device->wakeup.run_wake_count++;
 		device->wakeup.state.enabled = 1;
 	}
 
@@ -450,6 +451,7 @@ static int acpi_button_remove(struct acp
 			     device->wakeup.gpe_number);
 		acpi_unref_wakeup_gpe(device->wakeup.gpe_device,
 				      device->wakeup.gpe_number);
+		device->wakeup.run_wake_count--;
 		device->wakeup.state.enabled = 0;
 	}
 
Index: linux-2.6/drivers/acpi/scan.c
===================================================================
--- linux-2.6.orig/drivers/acpi/scan.c
+++ linux-2.6/drivers/acpi/scan.c
@@ -741,19 +741,39 @@ acpi_bus_extract_wakeup_device_power_pac
 	return AE_OK;
 }
 
-static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
+static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
 {
-	acpi_status status = 0;
-	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object *package = NULL;
-	int psw_error;
-
 	struct acpi_device_id button_device_ids[] = {
 		{"PNP0C0D", 0},
 		{"PNP0C0C", 0},
 		{"PNP0C0E", 0},
 		{"", 0},
 	};
+	acpi_status status;
+	acpi_event_status event_status;
+
+	device->wakeup.run_wake_count = 0;
+
+	/* Power button, Lid switch always enable wakeup */
+	if (!acpi_match_device_ids(device, button_device_ids)) {
+		device->wakeup.flags.run_wake = 1;
+		device->wakeup.flags.always_enabled = 1;
+		return;
+	}
+
+	status = acpi_get_gpe_status(NULL, device->wakeup.gpe_number,
+					ACPI_NOT_ISR, &event_status);
+	if (status == AE_OK)
+		device->wakeup.flags.run_wake =
+				!!(event_status & ACPI_EVENT_FLAG_HANDLE);
+}
+
+static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
+{
+	acpi_status status = 0;
+	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+	union acpi_object *package = NULL;
+	int psw_error;
 
 	/* _PRW */
 	status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
@@ -773,6 +793,7 @@ static int acpi_bus_get_wakeup_device_fl
 
 	device->wakeup.flags.valid = 1;
 	device->wakeup.prepare_count = 0;
+	acpi_bus_set_run_wake_flags(device);
 	/* Call _PSW/_DSW object to disable its ability to wake the sleeping
 	 * system for the ACPI device with the _PRW object.
 	 * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
@@ -784,10 +805,6 @@ static int acpi_bus_get_wakeup_device_fl
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 				"error in _DSW or _PSW evaluation\n"));
 
-	/* Power button, Lid switch always enable wakeup */
-	if (!acpi_match_device_ids(device, button_device_ids))
-		device->wakeup.flags.run_wake = 1;
-
 end:
 	if (ACPI_FAILURE(status))
 		device->flags.wake_capable = 0;


  parent reply	other threads:[~2010-01-10 14:06 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-10 13:31 [PATCH 0/9] PCI run-time PM support (rev. 3) Rafael J. Wysocki
2010-01-10 13:35 ` [PATCH 1/9] PCI PM: Add function for checking PME status of devices Rafael J. Wysocki
2010-01-15 17:55   ` Jesse Barnes
2010-01-10 13:36 ` [PATCH 2/9] PCI PM: PCIe PME root port service driver (rev. 5) Rafael J. Wysocki
2010-01-10 13:37 ` [PATCH 3/9] PCI PM: Make it possible to force using INTx for PCIe PME signaling Rafael J. Wysocki
2010-01-10 13:38 ` [PATCH 4/9] ACPI: Add infrastructure for refcounting GPE consumers Rafael J. Wysocki
2010-01-10 13:39 ` [PATCH 5/9] ACPI: Add support for new refcounted GPE API to drivers Rafael J. Wysocki
2010-01-10 13:40 ` [PATCH 6/9] ACPI: Remove old GPE API and transition code entirely to new one Rafael J. Wysocki
2010-01-10 13:48 ` Rafael J. Wysocki [this message]
2010-01-10 14:01 ` [PATCH 8/9] PCI / ACPI / PM: Platform support for PCI PME wake-up (rev. 7) Rafael J. Wysocki
2010-02-05 23:57   ` Bjorn Helgaas
2010-02-06  0:20     ` Rafael J. Wysocki
2010-02-06 20:11     ` Rafael J. Wysocki
2010-02-08 17:53       ` Gary Hade
2010-02-08 19:17         ` Rafael J. Wysocki
2010-02-08 21:12           ` Gary Hade
2010-02-08 21:30           ` [linux-pm] " Rafael J. Wysocki
2010-02-08 23:37             ` Gary Hade
2010-02-09  0:53               ` Gary Hade
2010-02-09 12:48                 ` Rafael J. Wysocki
2010-02-09 13:34                   ` Rafael J. Wysocki
2010-02-09 16:41                   ` Gary Hade
2010-02-09 17:35                     ` Gary Hade
2010-02-09 20:19                       ` Rafael J. Wysocki
2010-02-09 20:58                         ` Gary Hade
2010-02-09 23:31                           ` Gary Hade
2010-02-10  1:07                             ` Rafael J. Wysocki
2010-02-10  1:12                               ` Rafael J. Wysocki
2010-02-10 17:48                                 ` Gary Hade
2010-02-10 18:00                                   ` Rafael J. Wysocki
2010-02-10 20:38                                     ` Gary Hade
2010-02-10 21:42                                       ` Rafael J. Wysocki
2010-02-10 22:13                                         ` Gary Hade
2010-02-10 22:58                                           ` Rafael J. Wysocki
2010-02-10 23:04                                             ` Gary Hade
2010-02-10 23:25                                               ` Rafael J. Wysocki
2010-02-11  0:56                                                 ` Rafael J. Wysocki
2010-02-11  2:07                                                   ` Gary Hade
2010-02-11 13:27                                                     ` Rafael J. Wysocki
2010-02-11 18:29                                                       ` Gary Hade
2010-02-11 18:33                                                         ` Bjorn Helgaas
2010-02-11 20:32                                                         ` Rafael J. Wysocki
2010-02-11 20:40                                                           ` Rafael J. Wysocki
2010-02-11 21:56                                                           ` Gary Hade
2010-02-11 22:21                                                             ` Rafael J. Wysocki
2010-02-12  1:55                                                               ` Gary Hade
2010-02-12 11:19                                                                 ` Rafael J. Wysocki
2010-02-13  0:20                                                                   ` Rafael J. Wysocki
2010-02-13  1:27                                                                     ` Gary Hade
2010-02-14 13:51                                                                       ` Rafael J. Wysocki
2010-02-15 19:22                                                                         ` Gary Hade
2010-02-15 21:42                                                                           ` Rafael J. Wysocki
2010-01-10 14:02 ` [PATCH 9/9] PCI PM: Run-time callbacks for PCI bus type (rev. 2) 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=201001101448.39486.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=bjorn.helgaas@hp.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mjg@redhat.com \
    --cc=oliver@neukum.org \
    --cc=robert.moore@intel.com \
    --cc=shaohua.li@intel.com \
    --cc=stern@rowland.harvard.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome