Skip to contentSkip to conversation

X86 platform wmi: Introduce debug param to log all WMI events

PATCH Applied Thomas Renninger 4 participants 14 messages May 3, 2010 – May 20, 2010 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 X86 platform wmi: Introduce debug param to log all WMI events

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.

---
 drivers/platform/x86/wmi.c |   58 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 8 deletions(-)
drivers/platform/x86/wmi.c +50 -8
index 39ec5b6..e4e4a48 100644
@@ -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_event;
+module_param(debug_event, bool, 0444);
+MODULE_PARM_DESC(debug_event,
+		 "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_event) {
+		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_event) {
+			wblock->handler = wmi_notify_debug;
+			status = wmi_method_enable(wblock, 1);
+		}
 		list_add_tail(&wblock->list, &wmi_blocks.list);
 	}
 
Signature · 1 line
1.6.3
#1 lore raw

PATCH 2/3 X86 platform wmi: Also log GUID string when an event happens and debug is set

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

---
 drivers/platform/x86/wmi.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/platform/x86/wmi.c +6 -0
index e4e4a48..d48bcdb 100644
@@ -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_event) {
+				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),
Signature · 1 line
1.6.3
#2 lore raw

Re: [PATCH 2/3] X86 platform wmi: Also log GUID string when an event happens and debug is set

Quoted 5 lines · On Monday 03 May 2010 14:30:16 Thomas Renninger wrote:

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

Quoted 3 lines
Signature · 3 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
#3 lore raw

PATCH 3/3 X86 platfrom wmi: Add debug facility to dump WMI data in a readable way

In reply to Thomas Renninger
---
 drivers/platform/x86/wmi.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
drivers/platform/x86/wmi.c +35 -0
index d48bcdb..c1fa40d 100644
@@ -86,6 +86,11 @@ module_param(debug_event, bool, 0444);
 MODULE_PARM_DESC(debug_event,
 		 "Log WMI Events [0/1]");
 
+static int debug_dump_wdg;
+module_param(debug_dump_wdg, bool, 0444);
+MODULE_PARM_DESC(debug_dump_wdg,
+		 "Dump available WMI interfaces [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);
@@ -482,6 +487,33 @@ const struct acpi_buffer *in)
 }
 EXPORT_SYMBOL_GPL(wmi_set_block);
 
+static void wmi_dump_wdg(struct guid_block *g)
+{
+	char guid_string[37];
+
+	wmi_gtoa(g->guid, guid_string);
+	printk(KERN_INFO PREFIX "%s:\n", guid_string);
+	printk(KERN_INFO PREFIX "\tobject_id: %c%c\n",
+	       g->object_id[0], g->object_id[1]);
+	printk(KERN_INFO PREFIX "\tnotify_id: %02X\n", g->notify_id);
+	printk(KERN_INFO PREFIX "\treserved: %02X\n", g->reserved);
+	printk(KERN_INFO PREFIX "\tinstance_count: %d\n", g->instance_count);
+	printk(KERN_INFO PREFIX "\tflags: %#x", g->flags);
+	if (g->flags) {
+		printk(" ");
+		if (g->flags & ACPI_WMI_EXPENSIVE)
+			printk("ACPI_WMI_EXPENSIVE ");
+		if (g->flags & ACPI_WMI_METHOD)
+			printk("ACPI_WMI_METHOD ");
+		if (g->flags & ACPI_WMI_STRING)
+			printk("ACPI_WMI_STRING ");
+		if (g->flags & ACPI_WMI_EVENT)
+			printk("ACPI_WMI_EVENT ");
+	}
+	printk("\n");
+
+}
+
 static void wmi_notify_debug(u32 value, void *context)
 {
 	struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -814,6 +846,9 @@ static __init acpi_status parse_wdg(acpi_handle handle)
 				guid_string);
 			continue;
 		}
+		if (debug_dump_wdg)
+			wmi_dump_wdg(&gblock[i]);
+
 		wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
 		if (!wblock)
 			return AE_NO_MEMORY;
Signature · 1 line
1.6.3
#4 lore raw

Re: [PATCH 3/3] X86 platfrom wmi: Add debug facility to dump WMI data in a readable way

Quoted 4 lines · On Monday 03 May 2010 14:30:17 Thomas Renninger wrote:

I don't really see the point of this one - this information is all obtainable from the DSDT.

If you really want it, then I don't mind, it just seems redundant...

-Carlos

Signature · 3 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
#5 lore raw

Re: [PATCH 3/3] X86 platfrom wmi: Add debug facility to dump WMI data in a readable way

Quoted 8 lines · Carlos Corbacho
Quoted 4 lines · On Monday 03 May 2010 14:30:17 Thomas Renninger wrote:

I don't really see the point of this one - this information is all obtainable from the DSDT.

Yes, but you depend on the wmidump userspace stuff and manually copying parts of the DSDT, etc.

Quoted 1 line

If you really want it, then I don't mind, it just seems redundant...

All the code of wmidump is included wmi.c now.
Only dumping this info is missing, which is really useful if you are not aware of the wmidump tool (and even then it's still convenient to have) and overhead is negligible.
Yep, I really like to see this.

Thanks,

Thomas

#6 lore raw
In reply to Thomas Renninger
Quoted 7 lines · 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

Quoted 8 lines

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.

CCing wmi.c maintainer.

Signature · 2 lines
Corentin Chary
http://xf.iksaif.net
#7 lore raw
Quoted 2 lines · Corentin Chary
Quoted 1 line · Thomas Renninger

To give people easily an idea what could be WMI driven on their system.

...

Quoted 1 line

CCing wmi.c maintainer.

Oh dear, I mixed you up. Both starting with C.. C.. :)
Corentin: Do you read [email protected]? I'll bounce you the three patches...

Thomas

#8 lore raw
Quoted 10 lines · Thomas Renninger
Quoted 2 lines · Corentin Chary
Quoted 1 line · Thomas Renninger

To give people easily an idea what could be WMI driven on their system.

...

Quoted 1 line

CCing wmi.c maintainer.

Oh dear, I mixed you up. Both starting with C.. C.. :)
Corentin: Do you read [email protected]? I'll bounce you the three patches...

   Thomas

Hum, there is some confusion here. Carlos is the maintainer, it's why I CCed him.
I received the patchs (I red platform-x86, and I was CCed), but I only maintain eeepc-laptop and asus-laptop.
Now, it's Matthews or Carlos calls :).

Signature · 6 lines
Corentin Chary
http://xf.iksaif.net
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw
In reply to Thomas Renninger
Quoted 4 lines · On Monday 03 May 2010 14:30:15 Thomas Renninger wrote:

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

Quoted 8 lines

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.

Quoted 3 lines
Signature · 3 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
#10 lore raw
In reply to Thomas Renninger

drivers/platform/x86/wmi.c static struct wmi_block wmi_blocks; · line 87

Quoted 3 lines · Thomas Renninger
drivers/platform/x86/wmi.c +3 -0
+module_param(debug_event, bool, 0444);
+MODULE_PARM_DESC(debug_event,
+		 "Log WMI Events [0/1]");

It's an insanely small nit, but it's already declared as a bool parameter so the 0/1 is kind of unnecessary.

Signature · 1 line
Matthew Garrett | [email protected]
#12 lore raw
Quoted 1 line · On Thursday 20 May 2010 15:42:11 Matthew Garrett wrote:

I've applied this patchset, thanks.

Thanks.
You could have removed the 0/1 manually.
No need to ask for such a tiny change and the patch had not needed rediffing.

Thomas

#13 lore raw
Quoted 3 lines · Thomas Renninger

You could have removed the 0/1 manually.
No need to ask for such a tiny change and the patch had not needed rediffing.

Yeah, in the end I didn't worry about it - it's entirely harmless.

Signature · 1 line
Matthew Garrett | [email protected]