public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [RFT][PATCH] ACPI / ACPICA: Implicit notify for multiple devices
@ 2011-02-23 22:05 Rafael J. Wysocki
  2011-02-24 15:41 ` Matthew Garrett
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2011-02-23 22:05 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Linux PM mailing list, ACPI Devel Mailing List, Moore, Robert,
	Len Brown, Lin Ming

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

Commit bba63a2 (ACPICA: Implicit notify support) introduced a
mechanism that causes a notify request of type
ACPI_NOTIFY_DEVICE_WAKE to be queued automatically by
acpi_ev_asynch_execute_gpe_method() for the device whose _PRW points
to the GPE being handled if that GPE is not associated with an
_Lxx/_Exx method.  However, it turns out that on some systems there
are multiple devices with _PRW pointing to the same GPE without
_Lxx/_Exx and the mechanism introduced by commit bba63a2 needs to be
extended so that "implicit" notify requests of type
ACPI_NOTIFY_DEVICE_WAKE can be queued automatically for all those
devices at the same time.

Reported-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---

Hi Matthew,

The patch below doesn't blow up my Toshiba test box, which is a good sign,
but please test it on the boxes where you see the problem.

Thanks,
Rafael

---
 drivers/acpi/acpica/aclocal.h |    7 ++++++-
 drivers/acpi/acpica/evgpe.c   |   17 +++++++++++++----
 drivers/acpi/acpica/evxfgpe.c |   42 +++++++++++++++++++++++++++++++++---------
 3 files changed, 52 insertions(+), 14 deletions(-)

Index: linux-2.6/drivers/acpi/acpica/aclocal.h
===================================================================
--- linux-2.6.orig/drivers/acpi/acpica/aclocal.h
+++ linux-2.6/drivers/acpi/acpica/aclocal.h
@@ -416,10 +416,15 @@ struct acpi_gpe_handler_info {
 	u8 originally_enabled;  /* True if GPE was originally enabled */
 };
 
+struct acpi_gpe_notify_object {
+	struct acpi_namespace_node *node;
+	struct acpi_gpe_notify_object *next;
+};
+
 union acpi_gpe_dispatch_info {
 	struct acpi_namespace_node *method_node;	/* Method node for this GPE level */
 	struct acpi_gpe_handler_info *handler;  /* Installed GPE handler */
-	struct acpi_namespace_node *device_node;        /* Parent _PRW device for implicit notify */
+	struct acpi_gpe_notify_object device;   /* List of _PRW devices for implicit notify */
 };
 
 /*
Index: linux-2.6/drivers/acpi/acpica/evxfgpe.c
===================================================================
--- linux-2.6.orig/drivers/acpi/acpica/evxfgpe.c
+++ linux-2.6/drivers/acpi/acpica/evxfgpe.c
@@ -198,7 +198,9 @@ acpi_setup_gpe_for_wake(acpi_handle wake
 	acpi_status status = AE_BAD_PARAMETER;
 	struct acpi_gpe_event_info *gpe_event_info;
 	struct acpi_namespace_node *device_node;
+	struct acpi_gpe_notify_object *notify_object;
 	acpi_cpu_flags flags;
+	u8 gpe_dispatch_mask;
 
 	ACPI_FUNCTION_TRACE(acpi_setup_gpe_for_wake);
 
@@ -221,27 +223,49 @@ acpi_setup_gpe_for_wake(acpi_handle wake
 		goto unlock_and_exit;
 	}
 
+	if (wake_device == ACPI_ROOT_OBJECT) {
+		goto out;
+	}
+
 	/*
 	 * If there is no method or handler for this GPE, then the
 	 * wake_device will be notified whenever this GPE fires (aka
 	 * "implicit notify") Note: The GPE is assumed to be
 	 * level-triggered (for windows compatibility).
 	 */
-	if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
-	      ACPI_GPE_DISPATCH_NONE) && (wake_device != ACPI_ROOT_OBJECT)) {
+	gpe_dispatch_mask = gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK;
+	if (gpe_dispatch_mask != ACPI_GPE_DISPATCH_NONE
+	    && gpe_dispatch_mask != ACPI_GPE_DISPATCH_NOTIFY) {
+		goto out;
+	}
 
-		/* Validate wake_device is of type Device */
+	/* Validate wake_device is of type Device */
 
-		device_node = ACPI_CAST_PTR(struct acpi_namespace_node,
-					    wake_device);
-		if (device_node->type != ACPI_TYPE_DEVICE) {
-			goto unlock_and_exit;
-		}
+	device_node = ACPI_CAST_PTR(struct acpi_namespace_node, wake_device);
+	if (device_node->type != ACPI_TYPE_DEVICE) {
+		goto unlock_and_exit;
+	}
+
+	if (gpe_dispatch_mask == ACPI_GPE_DISPATCH_NONE) {
 		gpe_event_info->flags = (ACPI_GPE_DISPATCH_NOTIFY |
 					 ACPI_GPE_LEVEL_TRIGGERED);
-		gpe_event_info->dispatch.device_node = device_node;
+		gpe_event_info->dispatch.device.node = device_node;
+		gpe_event_info->dispatch.device.next = NULL;
+	} else {
+		/* There are multiple devices to notify implicitly. */
+
+		notify_object = ACPI_ALLOCATE_ZEROED(sizeof(*notify_object));
+		if (!notify_object) {
+			status = AE_NO_MEMORY;
+			goto unlock_and_exit;
+		}
+
+		notify_object->node = device_node;
+		notify_object->next = gpe_event_info->dispatch.device.next;
+		gpe_event_info->dispatch.device.next = notify_object;
 	}
 
+ out:
 	gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
 	status = AE_OK;
 
Index: linux-2.6/drivers/acpi/acpica/evgpe.c
===================================================================
--- linux-2.6.orig/drivers/acpi/acpica/evgpe.c
+++ linux-2.6/drivers/acpi/acpica/evgpe.c
@@ -457,6 +457,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_as
 	acpi_status status;
 	struct acpi_gpe_event_info *local_gpe_event_info;
 	struct acpi_evaluate_info *info;
+	struct acpi_gpe_notify_object *notify_object;
 
 	ACPI_FUNCTION_TRACE(ev_asynch_execute_gpe_method);
 
@@ -508,10 +509,18 @@ static void ACPI_SYSTEM_XFACE acpi_ev_as
 		 * from this thread -- because handlers may in turn run other
 		 * control methods.
 		 */
-		status =
-		    acpi_ev_queue_notify_request(local_gpe_event_info->dispatch.
-						 device_node,
-						 ACPI_NOTIFY_DEVICE_WAKE);
+		status = acpi_ev_queue_notify_request(
+				local_gpe_event_info->dispatch.device.node,
+				ACPI_NOTIFY_DEVICE_WAKE);
+
+		notify_object = local_gpe_event_info->dispatch.device.next;
+		while (ACPI_SUCCESS(status) && notify_object) {
+			status = acpi_ev_queue_notify_request(
+					notify_object->node,
+					ACPI_NOTIFY_DEVICE_WAKE);
+			notify_object = notify_object->next;
+		}
+
 		break;
 
 	case ACPI_GPE_DISPATCH_METHOD:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFT][PATCH] ACPI / ACPICA: Implicit notify for multiple devices
  2011-02-23 22:05 [RFT][PATCH] ACPI / ACPICA: Implicit notify for multiple devices Rafael J. Wysocki
@ 2011-02-24 15:41 ` Matthew Garrett
  2011-02-24 18:38   ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Garrett @ 2011-02-24 15:41 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PM mailing list, ACPI Devel Mailing List, Moore, Robert,
	Len Brown, Lin Ming

Works on my test Thinkpad - notifies get sent to both EHCI controllers 
and the HDA hardware now.

Tested-by: Matthew Garrett <mjg@redhat.com>

-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFT][PATCH] ACPI / ACPICA: Implicit notify for multiple devices
  2011-02-24 15:41 ` Matthew Garrett
@ 2011-02-24 18:38   ` Rafael J. Wysocki
  2011-02-24 18:41     ` Matthew Garrett
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2011-02-24 18:38 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Linux PM mailing list, ACPI Devel Mailing List, Moore, Robert,
	Len Brown, Lin Ming

On Thursday, February 24, 2011, Matthew Garrett wrote:
> Works on my test Thinkpad - notifies get sent to both EHCI controllers 
> and the HDA hardware now.
> 
> Tested-by: Matthew Garrett <mjg@redhat.com>

Cool, thanks!

How urgent is this issue?

Rafael

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFT][PATCH] ACPI / ACPICA: Implicit notify for multiple devices
  2011-02-24 18:38   ` Rafael J. Wysocki
@ 2011-02-24 18:41     ` Matthew Garrett
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Garrett @ 2011-02-24 18:41 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PM mailing list, ACPI Devel Mailing List, Moore, Robert,
	Len Brown, Lin Ming

On Thu, Feb 24, 2011 at 07:38:36PM +0100, Rafael J. Wysocki wrote:
> On Thursday, February 24, 2011, Matthew Garrett wrote:
> > Works on my test Thinkpad - notifies get sent to both EHCI controllers 
> > and the HDA hardware now.
> > 
> > Tested-by: Matthew Garrett <mjg@redhat.com>
> 
> Cool, thanks!
> 
> How urgent is this issue?

Enabling PCI runtime PM on these machines could cause GPE storms without 
waking the device.

-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-24 18:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-23 22:05 [RFT][PATCH] ACPI / ACPICA: Implicit notify for multiple devices Rafael J. Wysocki
2011-02-24 15:41 ` Matthew Garrett
2011-02-24 18:38   ` Rafael J. Wysocki
2011-02-24 18:41     ` Matthew Garrett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox