X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events
@ 2010-05-03  9:10 Thomas Renninger
  2010-05-03  9:10 ` [PATCH 2/2] X86 platform wmi: Also log GUID string when an event happens and debug is set Thomas Renninger
  2010-05-03 12:07 ` [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events Corentin Chary
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Renninger @ 2010-05-03  9:10 UTC (permalink / raw)
  To: mjg59; +Cc: platform-driver-x86, corentin.chary, Thomas Renninger

To give people easily an idea what could be WMI driven on their system.
Introduces:
wmi.debug=[01]

Tested on an acer:
ACPI: WMI: DEBUG Event INTEGER_TYPE - 65535

Situation where a driver registers for specific event and debug
handler gets overridden and set again if the registering driver gets
unloaded again is untested, but should work.

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: platform-driver-x86@vger.kernel.org
CC: mjg59@srcf.ucam.org
CC: corentin.chary@gmail.com
---
 drivers/platform/x86/wmi.c |   58 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 39ec5b6..dbd7281 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -81,6 +81,11 @@ static struct wmi_block wmi_blocks;
 #define ACPI_WMI_STRING      0x4	/* GUID takes & returns a string */
 #define ACPI_WMI_EVENT       0x8	/* GUID is an event */
 
+static int debug;
+module_param(debug, bool, 0444);
+MODULE_PARM_DESC(debug,
+		 "Debug facility to log WMI Events [0/1]");
+
 static int acpi_wmi_remove(struct acpi_device *device, int type);
 static int acpi_wmi_add(struct acpi_device *device);
 static void acpi_wmi_notify(struct acpi_device *device, u32 event);
@@ -477,6 +482,37 @@ const struct acpi_buffer *in)
 }
 EXPORT_SYMBOL_GPL(wmi_set_block);
 
+static void wmi_notify_debug(u32 value, void *context)
+{
+	struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
+	union acpi_object *obj;
+
+	wmi_get_event_data(value, &response);
+
+	obj = (union acpi_object *)response.pointer;
+
+	if (!obj)
+		return;
+
+	printk(KERN_INFO PREFIX "DEBUG Event ");
+	switch(obj->type) {
+	case ACPI_TYPE_BUFFER:
+		printk("BUFFER_TYPE - length %d\n", obj->buffer.length);
+		break;
+	case ACPI_TYPE_STRING:
+		printk("STRING_TYPE - %s\n", obj->string.pointer);
+		break;
+	case ACPI_TYPE_INTEGER:
+		printk("INTEGER_TYPE - %llu\n", obj->integer.value);
+		break;
+	case ACPI_TYPE_PACKAGE:
+		printk("PACKAGE_TYPE - %d elements\n", obj->package.count);
+		break;
+	default:
+		printk("object type 0x%X\n", obj->type);
+	}
+}
+
 /**
  * wmi_install_notify_handler - Register handler for WMI events
  * @handler: Function to handle notifications
@@ -496,7 +532,7 @@ wmi_notify_handler handler, void *data)
 	if (!find_guid(guid, &block))
 		return AE_NOT_EXIST;
 
-	if (block->handler)
+	if (block->handler && block->handler != wmi_notify_debug)
 		return AE_ALREADY_ACQUIRED;
 
 	block->handler = handler;
@@ -516,7 +552,7 @@ EXPORT_SYMBOL_GPL(wmi_install_notify_handler);
 acpi_status wmi_remove_notify_handler(const char *guid)
 {
 	struct wmi_block *block;
-	acpi_status status;
+	acpi_status status = AE_OK;
 
 	if (!guid)
 		return AE_BAD_PARAMETER;
@@ -524,14 +560,16 @@ acpi_status wmi_remove_notify_handler(const char *guid)
 	if (!find_guid(guid, &block))
 		return AE_NOT_EXIST;
 
-	if (!block->handler)
+	if (!block->handler || block->handler == wmi_notify_debug)
 		return AE_NULL_ENTRY;
 
-	status = wmi_method_enable(block, 0);
-
-	block->handler = NULL;
-	block->handler_data = NULL;
-
+	if (debug) {
+		block->handler = wmi_notify_debug;
+	} else {
+		status = wmi_method_enable(block, 0);
+		block->handler = NULL;
+		block->handler_data = NULL;
+	}
 	return status;
 }
 EXPORT_SYMBOL_GPL(wmi_remove_notify_handler);
@@ -782,6 +820,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
 
 		wblock->gblock = gblock[i];
 		wblock->handle = handle;
+		if (debug) {
+			wblock->handler = wmi_notify_debug;
+			status = wmi_method_enable(wblock, 1);
+		}
 		list_add_tail(&wblock->list, &wmi_blocks.list);
 	}
 
-- 
1.6.3


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

* [PATCH 2/2] X86 platform wmi: Also log GUID string when an event happens and debug is set
  2010-05-03  9:10 [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events Thomas Renninger
@ 2010-05-03  9:10 ` Thomas Renninger
  2010-05-03 12:07 ` [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events Corentin Chary
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Renninger @ 2010-05-03  9:10 UTC (permalink / raw)
  To: mjg59; +Cc: platform-driver-x86, corentin.chary, Thomas Renninger

Output in log with debug=1:
ACPI: WMI: DEBUG Event INTEGER_TYPE - 65535
ACPI: WMI: DEBUG Event GUID: CC1A61AC-4256-41A3-B9E0-05A445ADE2F5

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: platform-driver-x86@vger.kernel.org
CC: mjg59@srcf.ucam.org
CC: corentin.chary@gmail.com
---
 drivers/platform/x86/wmi.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index dbd7281..73ccce2 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -882,6 +882,7 @@ static void acpi_wmi_notify(struct acpi_device *device, u32 event)
 	struct guid_block *block;
 	struct wmi_block *wblock;
 	struct list_head *p;
+	char guid_string[37];
 
 	list_for_each(p, &wmi_blocks.list) {
 		wblock = list_entry(p, struct wmi_block, list);
@@ -891,6 +892,11 @@ static void acpi_wmi_notify(struct acpi_device *device, u32 event)
 			(block->notify_id == event)) {
 			if (wblock->handler)
 				wblock->handler(event, wblock->handler_data);
+			if (debug) {
+				wmi_gtoa(wblock->gblock.guid, guid_string);
+				printk(KERN_INFO PREFIX "DEBUG Event GUID:"
+				       " %s\n", guid_string);
+			}
 
 			acpi_bus_generate_netlink_event(
 				device->pnp.device_class, dev_name(&device->dev),
-- 
1.6.3


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

* Re: [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events
  2010-05-03  9:10 [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events Thomas Renninger
  2010-05-03  9:10 ` [PATCH 2/2] X86 platform wmi: Also log GUID string when an event happens and debug is set Thomas Renninger
@ 2010-05-03 12:07 ` Corentin Chary
  2010-05-03 13:22   ` Thomas Renninger
  1 sibling, 1 reply; 4+ messages in thread
From: Corentin Chary @ 2010-05-03 12:07 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: mjg59, platform-driver-x86

On Mon, May 3, 2010 at 11:10 AM, Thomas Renninger <trenn@suse.de> wrote:
> To give people easily an idea what could be WMI driven on their system.
> Introduces:
> wmi.debug=[01]
> ...
> +MODULE_PARM_DESC(debug,
> +                "Debug facility to log WMI Events [0/1]");
> +

I'm ok with the base idea, but as this debug option is event specific,
maybe it should be called debug_events ?

Or we can call it debug, change the param description ("add
verbosity/debug messages to the wmi driver" for example)
and also dump all guids (like I do in wmidump).


-- 
Corentin Chary
http://xf.iksaif.net

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

* Re: [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events
  2010-05-03 12:07 ` [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events Corentin Chary
@ 2010-05-03 13:22   ` Thomas Renninger
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Renninger @ 2010-05-03 13:22 UTC (permalink / raw)
  To: Corentin Chary; +Cc: mjg59, platform-driver-x86

On Monday 03 May 2010 14:07:56 Corentin Chary wrote:
> On Mon, May 3, 2010 at 11:10 AM, Thomas Renninger <trenn@suse.de> 
wrote:
> > To give people easily an idea what could be WMI driven on their 
system.
> > Introduces:
> > wmi.debug=[01]
> > ...
> > +MODULE_PARM_DESC(debug,
> > +                "Debug facility to log WMI Events [0/1]");
> > +
> 
> I'm ok with the base idea, but as this debug option is event specific,
> maybe it should be called debug_events ?
Whatabout keeping this as long as it's the only debug option.
If we get more, we can pass a mask:
  0x1 Debug events
  0x2 Debug methods
  0x4 Be more verbose
  0x8 ...
and then also adjust the description appropriately.

Hmm, drawback I just realized: You can't properly document this
with the MODULE_PARM_DESC macro.

> Or we can call it debug, change the param description ("add
> verbosity/debug messages to the wmi driver" for example)
> and also dump all guids (like I do in wmidump).
I also thought about this already.

I'll repost with a third patch adding the same prints as
done in wmidump, just replacing printf to printk.

Would be great to see this merged.

Thanks,

    Thomas

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

end of thread, other threads:[~2010-05-03 13:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-03  9:10 [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events Thomas Renninger
2010-05-03  9:10 ` [PATCH 2/2] X86 platform wmi: Also log GUID string when an event happens and debug is set Thomas Renninger
2010-05-03 12:07 ` [PATCH 1/2] X86 platform wmi: Introduce debug param to log all WMI events Corentin Chary
2010-05-03 13:22   ` Thomas Renninger

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