Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: wmi: Allow duplicate GUIDs for drivers that use struct wmi_driver

The WMI subsystem in the kernel currently tracks WMI devices by
a GUID string not by ACPI device. The GUID used by the `wmi-bmof`
module however is available from many devices on nearly every machine.

This originally was thought to be a bug, but as it happens on most
machines it is a design mistake. It has been fixed by tying an ACPI
device to the driver with struct wmi_driver. So drivers that have
moved over to struct wmi_driver can actually support multiple
instantiations of a GUID without any problem.

Add an allow list into wmi.c for GUIDs that the drivers that are known
to use struct wmi_driver. The list is populated with `wmi-bmof` right
now. The additional instances of that in sysfs with be suffixed with -%d

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20220829201500.6341-1-mario.limonciello@amd.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Mario Limonciello and committed by
Hans de Goede
134038b0 a2bdf10c

+40 -9
+40 -9
drivers/platform/x86/wmi.c
··· 105 105 }; 106 106 MODULE_DEVICE_TABLE(acpi, wmi_device_ids); 107 107 108 + /* allow duplicate GUIDs as these device drivers use struct wmi_driver */ 109 + static const char * const allow_duplicates[] = { 110 + "05901221-D566-11D1-B2F0-00A0C9062910", /* wmi-bmof */ 111 + NULL 112 + }; 113 + 108 114 static struct platform_driver acpi_wmi_driver = { 109 115 .driver = { 110 116 .name = "acpi-wmi", ··· 1079 1073 .release = wmi_dev_release, 1080 1074 }; 1081 1075 1076 + /* 1077 + * _WDG is a static list that is only parsed at startup, 1078 + * so it's safe to count entries without extra protection. 1079 + */ 1080 + static int guid_count(const guid_t *guid) 1081 + { 1082 + struct wmi_block *wblock; 1083 + int count = 0; 1084 + 1085 + list_for_each_entry(wblock, &wmi_block_list, list) { 1086 + if (guid_equal(&wblock->gblock.guid, guid)) 1087 + count++; 1088 + } 1089 + 1090 + return count; 1091 + } 1092 + 1082 1093 static int wmi_create_device(struct device *wmi_bus_dev, 1083 1094 struct wmi_block *wblock, 1084 1095 struct acpi_device *device) ··· 1103 1080 struct acpi_device_info *info; 1104 1081 char method[WMI_ACPI_METHOD_NAME_SIZE]; 1105 1082 int result; 1083 + uint count; 1106 1084 1107 1085 if (wblock->gblock.flags & ACPI_WMI_EVENT) { 1108 1086 wblock->dev.dev.type = &wmi_type_event; ··· 1158 1134 wblock->dev.dev.bus = &wmi_bus_type; 1159 1135 wblock->dev.dev.parent = wmi_bus_dev; 1160 1136 1161 - dev_set_name(&wblock->dev.dev, "%pUL", &wblock->gblock.guid); 1137 + count = guid_count(&wblock->gblock.guid); 1138 + if (count) 1139 + dev_set_name(&wblock->dev.dev, "%pUL-%d", &wblock->gblock.guid, count); 1140 + else 1141 + dev_set_name(&wblock->dev.dev, "%pUL", &wblock->gblock.guid); 1162 1142 1163 1143 device_initialize(&wblock->dev.dev); 1164 1144 ··· 1182 1154 } 1183 1155 } 1184 1156 1185 - static bool guid_already_parsed(struct acpi_device *device, const guid_t *guid) 1157 + static bool guid_already_parsed_for_legacy(struct acpi_device *device, const guid_t *guid) 1186 1158 { 1187 1159 struct wmi_block *wblock; 1188 1160 1189 1161 list_for_each_entry(wblock, &wmi_block_list, list) { 1162 + /* skip warning and register if we know the driver will use struct wmi_driver */ 1163 + for (int i = 0; allow_duplicates[i] != NULL; i++) { 1164 + guid_t tmp; 1165 + 1166 + if (guid_parse(allow_duplicates[i], &tmp)) 1167 + continue; 1168 + if (guid_equal(&tmp, guid)) 1169 + return false; 1170 + } 1190 1171 if (guid_equal(&wblock->gblock.guid, guid)) { 1191 1172 /* 1192 1173 * Because we historically didn't track the relationship ··· 1245 1208 if (debug_dump_wdg) 1246 1209 wmi_dump_wdg(&gblock[i]); 1247 1210 1248 - /* 1249 - * Some WMI devices, like those for nVidia hooks, have a 1250 - * duplicate GUID. It's not clear what we should do in this 1251 - * case yet, so for now, we'll just ignore the duplicate 1252 - * for device creation. 1253 - */ 1254 - if (guid_already_parsed(device, &gblock[i].guid)) 1211 + if (guid_already_parsed_for_legacy(device, &gblock[i].guid)) 1255 1212 continue; 1256 1213 1257 1214 wblock = kzalloc(sizeof(*wblock), GFP_KERNEL);