Jesse Keating 2f82dda
From: Carlos Corbacho <carlos@strangeworlds.co.uk>
Jesse Keating 2f82dda
Date: Sat, 26 Dec 2009 19:14:59 +0000 (+0000)
Jesse Keating 2f82dda
Subject: ACPI: WMI: Survive BIOS with duplicate GUIDs
Jesse Keating 2f82dda
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=d1f9e4970742bb1e22d07b01bd44f9c357d25c42
Jesse Keating 2f82dda
Jesse Keating 2f82dda
ACPI: WMI: Survive BIOS with duplicate GUIDs
Jesse Keating 2f82dda
Jesse Keating 2f82dda
It would appear that in BIOS's with nVidia hooks, the GUID
Jesse Keating 2f82dda
05901221-D566-11D1-B2F0-00A0C9062910 is duplicated. For now, the simplest
Jesse Keating 2f82dda
solution is to just ignore any duplicate GUIDs. These particular hooks are not
Jesse Keating 2f82dda
currently supported/ used in the kernel, so whoever does that can figure out
Jesse Keating 2f82dda
what the 'right' solution should be (if there's a better one).
Jesse Keating 2f82dda
Jesse Keating 2f82dda
http://bugzilla.kernel.org/show_bug.cgi?id=14846
Jesse Keating 2f82dda
Jesse Keating 2f82dda
Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk>
Jesse Keating 2f82dda
Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
Jesse Keating 2f82dda
Reported-by: Oldřich Jedlička <oldium.pro@seznam.cz>
Jesse Keating 2f82dda
Signed-off-by: Len Brown <len.brown@intel.com>
Jesse Keating 2f82dda
---
Jesse Keating 2f82dda
Jesse Keating 2f82dda
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
Jesse Keating 2f82dda
index cc9ad74..b104302 100644
Jesse Keating 2f82dda
--- a/drivers/platform/x86/wmi.c
Jesse Keating 2f82dda
+++ b/drivers/platform/x86/wmi.c
Jesse Keating 2f82dda
@@ -714,6 +714,22 @@ static int wmi_class_init(void)
Jesse Keating 2f82dda
 	return ret;
Jesse Keating 2f82dda
 }
Jesse Keating 2f82dda
 
Jesse Keating 2f82dda
+static bool guid_already_parsed(const char *guid_string)
Jesse Keating 2f82dda
+{
Jesse Keating 2f82dda
+	struct guid_block *gblock;
Jesse Keating 2f82dda
+	struct wmi_block *wblock;
Jesse Keating 2f82dda
+	struct list_head *p;
Jesse Keating 2f82dda
+
Jesse Keating 2f82dda
+	list_for_each(p, &wmi_blocks.list) {
Jesse Keating 2f82dda
+		wblock = list_entry(p, struct wmi_block, list);
Jesse Keating 2f82dda
+		gblock = &wblock->gblock;
Jesse Keating 2f82dda
+
Jesse Keating 2f82dda
+		if (strncmp(gblock->guid, guid_string, 16) == 0)
Jesse Keating 2f82dda
+			return true;
Jesse Keating 2f82dda
+	}
Jesse Keating 2f82dda
+	return false;
Jesse Keating 2f82dda
+}
Jesse Keating 2f82dda
+
Jesse Keating 2f82dda
 /*
Jesse Keating 2f82dda
  * Parse the _WDG method for the GUID data blocks
Jesse Keating 2f82dda
  */
Jesse Keating 2f82dda
@@ -723,6 +739,7 @@ static __init acpi_status parse_wdg(acpi_handle handle)
Jesse Keating 2f82dda
 	union acpi_object *obj;
Jesse Keating 2f82dda
 	struct guid_block *gblock;
Jesse Keating 2f82dda
 	struct wmi_block *wblock;
Jesse Keating 2f82dda
+	char guid_string[37];
Jesse Keating 2f82dda
 	acpi_status status;
Jesse Keating 2f82dda
 	u32 i, total;
Jesse Keating 2f82dda
 
Jesse Keating 2f82dda
@@ -745,6 +762,19 @@ static __init acpi_status parse_wdg(acpi_handle handle)
Jesse Keating 2f82dda
 	memcpy(gblock, obj->buffer.pointer, obj->buffer.length);
Jesse Keating 2f82dda
 
Jesse Keating 2f82dda
 	for (i = 0; i < total; i++) {
Jesse Keating 2f82dda
+		/*
Jesse Keating 2f82dda
+		  Some WMI devices, like those for nVidia hooks, have a
Jesse Keating 2f82dda
+		  duplicate GUID. It's not clear what we should do in this
Jesse Keating 2f82dda
+		  case yet, so for now, we'll just ignore the duplicate.
Jesse Keating 2f82dda
+		  Anyone who wants to add support for that device can come
Jesse Keating 2f82dda
+		  up with a better workaround for the mess then.
Jesse Keating 2f82dda
+		*/
Jesse Keating 2f82dda
+		if (guid_already_parsed(gblock[i].guid) == true) {
Jesse Keating 2f82dda
+			wmi_gtoa(gblock[i].guid, guid_string);
Jesse Keating 2f82dda
+			printk(KERN_INFO PREFIX "Skipping duplicate GUID %s\n",
Jesse Keating 2f82dda
+				guid_string);
Jesse Keating 2f82dda
+			continue;
Jesse Keating 2f82dda
+		}
Jesse Keating 2f82dda
 		wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
Jesse Keating 2f82dda
 		if (!wblock)
Jesse Keating 2f82dda
 			return AE_NO_MEMORY;