Skip to contentSkip to conversation

ACPICA: Global event handler

PATCH Superseded Lin Ming 3 participants 4 messages Dec 6, 2010 – Dec 9, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lin Ming

author
#0 lore raw

PATCH 5/6 ACPICA: Global event handler

The global event handler is called whenever a general purpose or fixed ACPI event occurs.

---
drivers/acpi/acpica/acglobal.h | 5 ++++

 drivers/acpi/acpica/evevent.c  |   12 ++++++++-
 drivers/acpi/acpica/evgpe.c    |    9 ++++++-
 drivers/acpi/acpica/evxface.c  |   51 ++++++++++++++++++++++++++++++++++++++++
 drivers/acpi/acpica/utglobal.c |    1 +
 drivers/acpi/sysfs.c           |   19 +++++++++++++-
 include/acpi/acpixf.h          |    4 +++
 include/acpi/actypes.h         |    8 ++++++
 8 files changed, 104 insertions(+), 5 deletions(-)
drivers/acpi/acpica/acglobal.h +5 -0
index fc69464..9bb69c5 100644
@@ -146,6 +146,9 @@ u8 acpi_gbl_system_awake_and_running;
 
 extern u32 acpi_gbl_nesting_level;
 
+ACPI_EXTERN u32 acpi_gpe_count;
+ACPI_EXTERN u32 acpi_fixed_event_count[ACPI_NUM_FIXED_EVENTS];
+
 /* Support for dynamic control method tracing mechanism */
 
 ACPI_EXTERN u32 acpi_gbl_original_dbg_level;
@@ -371,6 +374,8 @@ ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
 ACPI_EXTERN struct acpi_gpe_block_info
 *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
 ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized;
+ACPI_EXTERN ACPI_GBL_EVENT_HANDLER acpi_gbl_global_event_handler;
+ACPI_EXTERN void *acpi_gbl_global_event_handler_context;
 
 /*****************************************************************************
  *
drivers/acpi/acpica/evevent.c +10 -2
index c61c303..e5e313c 100644
@@ -217,9 +217,17 @@ u32 acpi_ev_fixed_event_detect(void)
 		     status_bit_mask)
 		    && (fixed_enable & acpi_gbl_fixed_event_info[i].
 			enable_bit_mask)) {
+			/*
+			 * Found an active (signalled) event. Invoke global event
+			 * handler if present.
+			 */
+			acpi_fixed_event_count[i]++;
+			if (acpi_gbl_global_event_handler) {
+				acpi_gbl_global_event_handler
+				    (ACPI_EVENT_TYPE_FIXED, NULL, i,
+				     acpi_gbl_global_event_handler_context);
+			}
 
-			/* Found an active (signalled) event */
-			acpi_os_fixed_event_count(i);
 			int_status |= acpi_ev_fixed_event_dispatch(i);
 		}
 	}
drivers/acpi/acpica/evgpe.c +8 -1
index 56a7805..c9d9ecf 100644
@@ -641,7 +641,14 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
 
 	ACPI_FUNCTION_TRACE(ev_gpe_dispatch);
 
-	acpi_os_gpe_count(gpe_number);
+	/* Invoke global event handler if present */
+
+	acpi_gpe_count++;
+	if (acpi_gbl_global_event_handler) {
+		acpi_gbl_global_event_handler(ACPI_EVENT_TYPE_GPE, gpe_device,
+					      gpe_number,
+					      acpi_gbl_global_event_handler_context);
+	}
 
 	/*
 	 * If edge-triggered, clear the GPE status bit now. Note that
drivers/acpi/acpica/evxface.c +51 -0

57 lines not on this page · raw message

drivers/acpi/acpica/utglobal.c +1 -0
index a99c32a..508537f 100644
@@ -778,6 +778,7 @@ acpi_status acpi_ut_init_globals(void)
 	acpi_gbl_init_handler = NULL;
 	acpi_gbl_table_handler = NULL;
 	acpi_gbl_interface_handler = NULL;
+	acpi_gbl_global_event_handler = NULL;
 
 	/* Global Lock support */
 
drivers/acpi/sysfs.c +17 -2
index f8588f8..61891e7 100644
@@ -438,7 +438,7 @@ static void delete_gpe_attr_array(void)
 	return;
 }
 
-void acpi_os_gpe_count(u32 gpe_number)
+static void gpe_count(u32 gpe_number)
 {
 	acpi_gpe_count++;
 
@@ -454,7 +454,7 @@ void acpi_os_gpe_count(u32 gpe_number)
 	return;
 }
 
-void acpi_os_fixed_event_count(u32 event_number)
+static void fixed_event_count(u32 event_number)
 {
 	if (!all_counters)
 		return;
@@ -468,6 +468,16 @@ void acpi_os_fixed_event_count(u32 event_number)
 	return;
 }
 
+static void acpi_gbl_event_handler(u32 event_type, acpi_handle device,
+	u32 event_number, void *context)
+{
+	if (event_type == ACPI_EVENT_TYPE_GPE)
+		gpe_count(event_number);
+
+	if (event_type == ACPI_EVENT_TYPE_FIXED)
+		fixed_event_count(event_number);
+}
+
 static int get_status(u32 index, acpi_event_status *status,
 		      acpi_handle *handle)
 {
@@ -601,6 +611,7 @@ end:
 
 void acpi_irq_stats_init(void)
 {
+	acpi_status status;
 	int i;
 
 	if (all_counters)
@@ -619,6 +630,10 @@ void acpi_irq_stats_init(void)
 	if (all_counters == NULL)
 		goto fail;
 
+	status = acpi_install_global_event_handler(acpi_gbl_event_handler, NULL);
+	if (ACPI_FAILURE(status))
+		goto fail;
+
 	counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters),
 				GFP_KERNEL);
 	if (counter_attrs == NULL)
include/acpi/acpixf.h +4 -0
index 9de6a17..e8142d5 100644
@@ -229,6 +229,10 @@ acpi_status
 acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
 
 acpi_status
+acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler,
+				 void *context);
+
+acpi_status
 acpi_install_fixed_event_handler(u32 acpi_event,
 				 acpi_event_handler handler, void *context);
 
include/acpi/actypes.h +8 -0
index d7274ee..939a431 100644
@@ -895,6 +895,14 @@ typedef void
 /*
  * Various handlers and callback procedures
  */
+typedef
+void (*ACPI_GBL_EVENT_HANDLER) (u32 event_type,
+			       acpi_handle device,
+			       u32 event_number, void *context);
+
+#define ACPI_EVENT_TYPE_GPE         0
+#define ACPI_EVENT_TYPE_FIXED       1
+
 typedef u32(*acpi_event_handler) (void *context);
 
 typedef
Signature · 1 line
1.5.3
#1 lore raw
Quoted 2 lines · Lin Ming

The global event handler is called whenever a general purpose or fixed ACPI event occurs.

Well, you know my opinion about this one ...

Thanks,
Rafael

#2 lore raw

It's part of ACPICA until I get feedback from:

Apple
FreeBSD
HPUX
Solaris

-----Original Message-----
From: Rafael J. Wysocki [mailto:[email protected]]
Sent: Thursday, December 09, 2010 2:32 PM
To: Lin, Ming M
Cc: Moore, Robert; [email protected]
Subject: Re: [PATCH 5/6] ACPICA: Global event handler

Quoted 2 lines · Lin Ming

The global event handler is called whenever a general purpose or fixed ACPI event occurs.

Well, you know my opinion about this one ...

Thanks,
Rafael

#3 lore raw
Quoted 6 lines · Robert

It's part of ACPICA until I get feedback from:

Apple
FreeBSD
HPUX
Solaris

I know, but that doesn't mean I have to like it. :-)

Quoted 15 lines

-----Original Message-----
From: Rafael J. Wysocki [mailto:[email protected]]
Sent: Thursday, December 09, 2010 2:32 PM
To: Lin, Ming M
Cc: Moore, Robert; [email protected]
Subject: Re: [PATCH 5/6] ACPICA: Global event handler

Quoted 2 lines · Lin Ming

The global event handler is called whenever a general purpose or fixed ACPI event occurs.

Well, you know my opinion about this one ...

Thanks,
Rafael