From 4255c30fe88ee3cc99bbeac7974db27e4217a497 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Thu, 16 Nov 2017 22:13:12 -0600 Subject: platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix The Dell SMBIOS WMI interface will fail for some more complex calls unless a WMI hotfix has been included. Most platforms have this fix available in a maintenance BIOS release. In the case the driver is loaded on a platform without this fix, disable the userspace interface. A hotfix indicator is present in the dell-wmi-descriptor that represents whether or not more complex calls will work properly. "Simple" calls such as those used by dell-laptop and dell-wmi will continue to work properly so dell-smbios-wmi should not be blocked from binding and being used as the dell-smbios dispatcher. Suggested-by: Girish Prakash Signed-off-by: Mario Limonciello Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/dell-smbios-wmi.c | 13 +++++++++++++ drivers/platform/x86/dell-wmi-descriptor.c | 26 ++++++++++++++++++++++++-- drivers/platform/x86/dell-wmi-descriptor.h | 1 + 3 files changed, 38 insertions(+), 2 deletions(-) (limited to 'drivers/platform') diff --git a/drivers/platform/x86/dell-smbios-wmi.c b/drivers/platform/x86/dell-smbios-wmi.c index 0cab1f9c35af..609557aa5868 100644 --- a/drivers/platform/x86/dell-smbios-wmi.c +++ b/drivers/platform/x86/dell-smbios-wmi.c @@ -147,7 +147,10 @@ fail_smbios_cmd: static int dell_smbios_wmi_probe(struct wmi_device *wdev) { + struct wmi_driver *wdriver = + container_of(wdev->dev.driver, struct wmi_driver, driver); struct wmi_smbios_priv *priv; + u32 hotfix; int count; int ret; @@ -164,6 +167,16 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev) if (!dell_wmi_get_size(&priv->req_buf_size)) return -EPROBE_DEFER; + /* some SMBIOS calls fail unless BIOS contains hotfix */ + if (!dell_wmi_get_hotfix(&hotfix)) + return -EPROBE_DEFER; + if (!hotfix) { + dev_warn(&wdev->dev, + "WMI SMBIOS userspace interface not supported(%u), try upgrading to a newer BIOS\n", + hotfix); + wdriver->filter_callback = NULL; + } + /* add in the length object we will use internally with ioctl */ priv->req_buf_size += sizeof(u64); ret = set_required_buffer_size(wdev, priv->req_buf_size); diff --git a/drivers/platform/x86/dell-wmi-descriptor.c b/drivers/platform/x86/dell-wmi-descriptor.c index 4dfef1f53481..072821aa47fc 100644 --- a/drivers/platform/x86/dell-wmi-descriptor.c +++ b/drivers/platform/x86/dell-wmi-descriptor.c @@ -27,6 +27,7 @@ struct descriptor_priv { struct list_head list; u32 interface_version; u32 size; + u32 hotfix; }; static int descriptor_valid = -EPROBE_DEFER; static LIST_HEAD(wmi_list); @@ -77,6 +78,24 @@ bool dell_wmi_get_size(u32 *size) } EXPORT_SYMBOL_GPL(dell_wmi_get_size); +bool dell_wmi_get_hotfix(u32 *hotfix) +{ + struct descriptor_priv *priv; + bool ret = false; + + mutex_lock(&list_mutex); + priv = list_first_entry_or_null(&wmi_list, + struct descriptor_priv, + list); + if (priv) { + *hotfix = priv->hotfix; + ret = true; + } + mutex_unlock(&list_mutex); + return ret; +} +EXPORT_SYMBOL_GPL(dell_wmi_get_hotfix); + /* * Descriptor buffer is 128 byte long and contains: * @@ -85,6 +104,7 @@ EXPORT_SYMBOL_GPL(dell_wmi_get_size); * Object Signature 4 4 " WMI" * WMI Interface Version 8 4 * WMI buffer length 12 4 + * WMI hotfix number 16 4 */ static int dell_wmi_descriptor_probe(struct wmi_device *wdev) { @@ -144,15 +164,17 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev) priv->interface_version = buffer[2]; priv->size = buffer[3]; + priv->hotfix = buffer[4]; ret = 0; dev_set_drvdata(&wdev->dev, priv); mutex_lock(&list_mutex); list_add_tail(&priv->list, &wmi_list); mutex_unlock(&list_mutex); - dev_dbg(&wdev->dev, "Detected Dell WMI interface version %lu and buffer size %lu\n", + dev_dbg(&wdev->dev, "Detected Dell WMI interface version %lu, buffer size %lu, hotfix %lu\n", (unsigned long) priv->interface_version, - (unsigned long) priv->size); + (unsigned long) priv->size, + (unsigned long) priv->hotfix); out: kfree(obj); diff --git a/drivers/platform/x86/dell-wmi-descriptor.h b/drivers/platform/x86/dell-wmi-descriptor.h index 1e8cb96ffd78..a6123a4d06a7 100644 --- a/drivers/platform/x86/dell-wmi-descriptor.h +++ b/drivers/platform/x86/dell-wmi-descriptor.h @@ -23,5 +23,6 @@ int dell_wmi_get_descriptor_valid(void); bool dell_wmi_get_interface_version(u32 *version); bool dell_wmi_get_size(u32 *size); +bool dell_wmi_get_hotfix(u32 *hotfix); #endif -- cgit v1.2.3 From c6f9288ee460565b94994aaf3261318199c2a674 Mon Sep 17 00:00:00 2001 From: weiyongjun (A) Date: Tue, 14 Nov 2017 13:40:13 +0000 Subject: platform/x86: dell-laptop: fix error return code in dell_init() Fix to return error code -ENOMEM from the kzalloc() error handling case instead of 0, as done elsewhere in this function. Fixes: 549b4930f057 ("platform/x86: dell-smbios: Introduce dispatcher for SMM calls") Signed-off-by: Wei Yongjun Acked-by: Mario Limonciello Signed-off-by: Andy Shevchenko --- drivers/platform/x86/dell-laptop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/platform') diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 2d704361f672..bf897b1832b1 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -2074,8 +2074,10 @@ static int __init dell_init(void) goto fail_platform_device2; buffer = kzalloc(sizeof(struct calling_interface_buffer), GFP_KERNEL); - if (!buffer) + if (!buffer) { + ret = -ENOMEM; goto fail_buffer; + } ret = dell_setup_rfkill(); -- cgit v1.2.3