]> git.itanic.dy.fi Git - linux-stable/commitdiff
platform/x86: dell-smbios: Link all dell-smbios-* modules together
authorMario Limonciello <mario.limonciello@dell.com>
Tue, 27 Feb 2018 18:23:04 +0000 (12:23 -0600)
committerDarren Hart (VMware) <dvhart@infradead.org>
Fri, 9 Mar 2018 17:35:42 +0000 (09:35 -0800)
Some race conditions were raised due to dell-smbios and its backends
not being ready by the time that a consumer would call one of the
exported methods.

To avoid this problem, guarantee that all initialization has been
done by linking them all together and running init for them all.

As part of this change the Kconfig needs to be adjusted so that
CONFIG_DELL_SMBIOS_SMM and CONFIG_DELL_SMBIOS_WMI are boolean
rather than modules.

CONFIG_DELL_SMBIOS is a visually selectable option again and both
CONFIG_DELL_SMBIOS_WMI and CONFIG_DELL_SMBIOS_SMM are optional.

Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
[dvhart: Update prompt and help text for DELL_SMBIOS_* backends]
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
drivers/platform/x86/Kconfig
drivers/platform/x86/Makefile
drivers/platform/x86/dell-smbios-base.c
drivers/platform/x86/dell-smbios-smm.c
drivers/platform/x86/dell-smbios-wmi.c
drivers/platform/x86/dell-smbios.h

index 9a8f96465cdc3c04783f6296dcc778128c231df5..3abd0de7d406977a06c395611b063ff09e5e4563 100644 (file)
@@ -106,10 +106,15 @@ config ASUS_LAPTOP
          If you have an ACPI-compatible ASUS laptop, say Y or M here.
 
 config DELL_SMBIOS
-       tristate
+       tristate "Dell SMBIOS driver"
+       ---help---
+       This provides support for the Dell SMBIOS calling interface.
+       If you have a Dell computer you should enable this option.
+
+       Be sure to select at least one backend for it to work properly.
 
 config DELL_SMBIOS_WMI
-       tristate "Dell SMBIOS calling interface (WMI implementation)"
+       bool "Dell SMBIOS driver WMI backend"
        depends on ACPI_WMI
        select DELL_WMI_DESCRIPTOR
        select DELL_SMBIOS
@@ -117,19 +122,19 @@ config DELL_SMBIOS_WMI
        This provides an implementation for the Dell SMBIOS calling interface
        communicated over ACPI-WMI.
 
-       If you have a Dell computer from >2007 you should say Y or M here.
+       If you have a Dell computer from >2007 you should say Y here.
        If you aren't sure and this module doesn't work for your computer
        it just won't load.
 
 config DELL_SMBIOS_SMM
-       tristate "Dell SMBIOS calling interface (SMM implementation)"
+       bool "Dell SMBIOS driver SMM backend"
        depends on DCDBAS
        select DELL_SMBIOS
        ---help---
        This provides an implementation for the Dell SMBIOS calling interface
        communicated over SMI/SMM.
 
-       If you have a Dell computer from <=2017 you should say Y or M here.
+       If you have a Dell computer from <=2017 you should say Y here.
        If you aren't sure and this module doesn't work for your computer
        it just won't load.
 
index 940b1180fbff981840fed1b4c110942cfdb261cf..2ba6cb7953384e8af9b150adca7775c3bea6ec29 100644 (file)
@@ -14,8 +14,8 @@ obj-$(CONFIG_ACPI_CMPC)               += classmate-laptop.o
 obj-$(CONFIG_COMPAL_LAPTOP)    += compal-laptop.o
 obj-$(CONFIG_DELL_SMBIOS)      += dell-smbios.o
 dell-smbios-objs               := dell-smbios-base.o
-obj-$(CONFIG_DELL_SMBIOS_WMI)  += dell-smbios-wmi.o
-obj-$(CONFIG_DELL_SMBIOS_SMM)  += dell-smbios-smm.o
+dell-smbios-$(CONFIG_DELL_SMBIOS_WMI)  += dell-smbios-wmi.o
+dell-smbios-$(CONFIG_DELL_SMBIOS_SMM)  += dell-smbios-smm.o
 obj-$(CONFIG_DELL_LAPTOP)      += dell-laptop.o
 obj-$(CONFIG_DELL_WMI)         += dell-wmi.o
 obj-$(CONFIG_DELL_WMI_DESCRIPTOR)      += dell-wmi-descriptor.o
index 76b9d754544728a3d1e2f985763574cbd21a69a9..5bcf8a18f78595eedc5ef33b67836ebcf35a6d9b 100644 (file)
@@ -556,7 +556,7 @@ static void free_group(struct platform_device *pdev)
 static int __init dell_smbios_init(void)
 {
        const struct dmi_device *valid;
-       int ret;
+       int ret, wmi, smm;
 
        valid = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, "Dell System", NULL);
        if (!valid) {
@@ -591,8 +591,24 @@ static int __init dell_smbios_init(void)
        if (ret)
                goto fail_create_group;
 
+       /* register backends */
+       wmi = init_dell_smbios_wmi();
+       if (wmi)
+               pr_debug("Failed to initialize WMI backend: %d\n", wmi);
+       smm = init_dell_smbios_smm();
+       if (smm)
+               pr_debug("Failed to initialize SMM backend: %d\n", smm);
+       if (wmi && smm) {
+               pr_err("No SMBIOS backends available (wmi: %d, smm: %d)\n",
+                       wmi, smm);
+               goto fail_sysfs;
+       }
+
        return 0;
 
+fail_sysfs:
+       free_group(platform_device);
+
 fail_create_group:
        platform_device_del(platform_device);
 
@@ -609,6 +625,8 @@ static int __init dell_smbios_init(void)
 
 static void __exit dell_smbios_exit(void)
 {
+       exit_dell_smbios_wmi();
+       exit_dell_smbios_smm();
        mutex_lock(&smbios_mutex);
        if (platform_device) {
                free_group(platform_device);
@@ -625,5 +643,6 @@ module_exit(dell_smbios_exit);
 MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
 MODULE_AUTHOR("Gabriele Mazzotta <gabriele.mzt@gmail.com>");
 MODULE_AUTHOR("Pali Rohár <pali.rohar@gmail.com>");
+MODULE_AUTHOR("Mario Limonciello <mario.limonciello@dell.com>");
 MODULE_DESCRIPTION("Common functions for kernel modules using Dell SMBIOS");
 MODULE_LICENSE("GPL");
index 89f65c4651a04151aa1002afd65f8a0736f7a776..e9e9da556318703275ac6cb9eef59ae7426d4776 100644 (file)
@@ -58,7 +58,7 @@ static const struct dmi_system_id dell_device_table[] __initconst = {
 };
 MODULE_DEVICE_TABLE(dmi, dell_device_table);
 
-static void __init parse_da_table(const struct dmi_header *dm)
+static void parse_da_table(const struct dmi_header *dm)
 {
        struct calling_interface_structure *table =
                container_of(dm, struct calling_interface_structure, header);
@@ -73,7 +73,7 @@ static void __init parse_da_table(const struct dmi_header *dm)
        da_command_code = table->cmdIOCode;
 }
 
-static void __init find_cmd_address(const struct dmi_header *dm, void *dummy)
+static void find_cmd_address(const struct dmi_header *dm, void *dummy)
 {
        switch (dm->type) {
        case 0xda: /* Calling interface */
@@ -128,7 +128,7 @@ static bool test_wsmt_enabled(void)
        return false;
 }
 
-static int __init dell_smbios_smm_init(void)
+int init_dell_smbios_smm(void)
 {
        int ret;
        /*
@@ -176,7 +176,7 @@ static int __init dell_smbios_smm_init(void)
        return ret;
 }
 
-static void __exit dell_smbios_smm_exit(void)
+void exit_dell_smbios_smm(void)
 {
        if (platform_device) {
                dell_smbios_unregister_device(&platform_device->dev);
@@ -184,13 +184,3 @@ static void __exit dell_smbios_smm_exit(void)
                free_page((unsigned long)buffer);
        }
 }
-
-subsys_initcall(dell_smbios_smm_init);
-module_exit(dell_smbios_smm_exit);
-
-MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
-MODULE_AUTHOR("Gabriele Mazzotta <gabriele.mzt@gmail.com>");
-MODULE_AUTHOR("Pali Rohár <pali.rohar@gmail.com>");
-MODULE_AUTHOR("Mario Limonciello <mario.limonciello@dell.com>");
-MODULE_DESCRIPTION("Dell SMBIOS communications over SMI");
-MODULE_LICENSE("GPL");
index 609557aa58684375b7534a39e21f9fe9eadd97e6..fbefedb1c17237c5a926446bb9162ef2a8fcb993 100644 (file)
@@ -228,7 +228,7 @@ static const struct wmi_device_id dell_smbios_wmi_id_table[] = {
        { },
 };
 
-static void __init parse_b1_table(const struct dmi_header *dm)
+static void parse_b1_table(const struct dmi_header *dm)
 {
        struct misc_bios_flags_structure *flags =
        container_of(dm, struct misc_bios_flags_structure, header);
@@ -242,7 +242,7 @@ static void __init parse_b1_table(const struct dmi_header *dm)
                wmi_supported = 1;
 }
 
-static void __init find_b1(const struct dmi_header *dm, void *dummy)
+static void find_b1(const struct dmi_header *dm, void *dummy)
 {
        switch (dm->type) {
        case 0xb1: /* misc bios flags */
@@ -261,7 +261,7 @@ static struct wmi_driver dell_smbios_wmi_driver = {
        .filter_callback = dell_smbios_wmi_filter,
 };
 
-static int __init init_dell_smbios_wmi(void)
+int init_dell_smbios_wmi(void)
 {
        dmi_walk(find_b1, NULL);
 
@@ -271,15 +271,9 @@ static int __init init_dell_smbios_wmi(void)
        return wmi_driver_register(&dell_smbios_wmi_driver);
 }
 
-static void __exit exit_dell_smbios_wmi(void)
+void exit_dell_smbios_wmi(void)
 {
        wmi_driver_unregister(&dell_smbios_wmi_driver);
 }
 
-module_init(init_dell_smbios_wmi);
-module_exit(exit_dell_smbios_wmi);
-
 MODULE_ALIAS("wmi:" DELL_WMI_SMBIOS_GUID);
-MODULE_AUTHOR("Mario Limonciello <mario.limonciello@dell.com>");
-MODULE_DESCRIPTION("Dell SMBIOS communications over WMI");
-MODULE_LICENSE("GPL");
index 138d478d9adc91bdceee7194567cbe40718ec1f7..d8adaf9597409e1ee4ebf9cc6043e6e1f7095cb4 100644 (file)
@@ -75,4 +75,29 @@ int dell_laptop_register_notifier(struct notifier_block *nb);
 int dell_laptop_unregister_notifier(struct notifier_block *nb);
 void dell_laptop_call_notifier(unsigned long action, void *data);
 
-#endif
+/* for the supported backends */
+#ifdef CONFIG_DELL_SMBIOS_WMI
+int init_dell_smbios_wmi(void);
+void exit_dell_smbios_wmi(void);
+#else /* CONFIG_DELL_SMBIOS_WMI */
+static inline int init_dell_smbios_wmi(void)
+{
+       return -ENODEV;
+}
+static inline void exit_dell_smbios_wmi(void)
+{}
+#endif /* CONFIG_DELL_SMBIOS_WMI */
+
+#ifdef CONFIG_DELL_SMBIOS_SMM
+int init_dell_smbios_smm(void);
+void exit_dell_smbios_smm(void);
+#else /* CONFIG_DELL_SMBIOS_SMM */
+static inline int init_dell_smbios_smm(void)
+{
+       return -ENODEV;
+}
+static inline void exit_dell_smbios_smm(void)
+{}
+#endif /* CONFIG_DELL_SMBIOS_SMM */
+
+#endif /* _DELL_SMBIOS_H_ */