From patchwork Thu Nov 16 20:48:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10062095 X-Patchwork-Delegate: dvhart@infradead.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C64D60230 for ; Thu, 16 Nov 2017 20:50:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C75F2AAF0 for ; Thu, 16 Nov 2017 20:50:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E26D2AB17; Thu, 16 Nov 2017 20:50:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F8C22AAF0 for ; Thu, 16 Nov 2017 20:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934486AbdKPUuK (ORCPT ); Thu, 16 Nov 2017 15:50:10 -0500 Received: from esa7.dell-outbound.iphmx.com ([68.232.153.96]:63060 "EHLO esa7.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934239AbdKPUuJ (ORCPT ); Thu, 16 Nov 2017 15:50:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1510865164; x=1542401164; h=from:to:cc:subject:date:message-id; bh=RifE7XFwczAyQ8jUc8LLOR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TzxHT8c2HSu?= =?us-ascii?q?dl/kemxDaPyxjf6uFaLkAwkqrWM4AuwqUqmZYNq0jMAzH5mEHyjKOPcUUk5/So?= =?us-ascii?q?5P/gYrX7oJ+TKpF4hhv/MqQ2msy/BOs5PhISUGic/OSwzLzj/UvnT7VWlvA7k6?= =?us-ascii?q?rUvIrEKckVuKK1GRJZ34Yt5hqlETuqzMoUkWECLF1feRKHi4bpO0vJIPD9Ffq/?= =?us-ascii?q?hk6jkC1qx/DBJLHhBpTNLn3EkLfnYbl96lBTyA43zdBY/J9bF68OIPb3WkPrqN?= =?us-ascii?q?PYCRo5PxSuw+n7ENV9yp8eWWWXD6+dMaPSt0KI5+02L+mPeoAVojD9JOYh5/P1?= =?us-ascii?q?k385lkESfbOz0ZsUdn+4BPJmLFudYXb2hdcBC2gKtBIkTOP2kF2CTSJTZ3GqUq?= =?us-ascii?q?Ik4jE0Ep6mDYnERoC3hbyNxTq0HodXZmBYFF+MC27kdoqHVvoNcy+SPMBhnSIe?= =?us-ascii?q?VbS7SI8uywuutAnkxLpjNObU/TcYtZ2wnORysuHNlRgo6RR1CcqH2m2ARm0ymX?= =?us-ascii?q?kHA3cf2qxu6Xd9x0mI0aV+gPsQQdVV6+IPSQc3K5Xcwup5DPj9XwvAepGCT1Pw?= =?us-ascii?q?Efu8BjRka9srwthGR0d4HNOpjx3H2y3iV7ocjb2MQpg196Xa1Hn8I8J643rL0K?= =?us-ascii?q?1nhF4jFJgcfVa6j7JyolCAT7XClF+UwuPzLfwR?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2FyAAAT+Q1ah8qZ6ERdGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYMIggAnjh6PJphcghEKhTuEYT8YAQEBAQEBAQEBAQIQAQEBCgsJCCg?= =?us-ascii?q?vgjgkAYJwUk9vARKKJKsmOotDgzSCB4FVgWmOOwWTB480gjeSUwKTRAKWMIE5H?= =?us-ascii?q?4Iuel6CZIIMAU8QDBmBbViMAgEBAQ?= X-IPAS-Result: =?us-ascii?q?A2FyAAAT+Q1ah8qZ6ERdGgEBAQEBAgEBAQEIAQEBAYMIggA?= =?us-ascii?q?njh6PJphcghEKhTuEYT8YAQEBAQEBAQEBAQIQAQEBCgsJCCgvgjgkAYJwUk9vA?= =?us-ascii?q?RKKJKsmOotDgzSCB4FVgWmOOwWTB480gjeSUwKTRAKWMIE5H4Iuel6CZIIMAU8?= =?us-ascii?q?QDBmBbViMAgEBAQ?= Received: from esa2.dell-outbound2.iphmx.com ([68.232.153.202]) by esa7.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2017 14:46:04 -0600 Received: from ausxipps306.us.dell.com ([143.166.148.156]) by esa2.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2017 02:41:36 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.44,405,1505797200"; d="scan'208";a="174648794" X-DLP: DLP_GlobalPCIDSS From: Mario Limonciello To: dvhart@infradead.org, Andy Shevchenko Cc: LKML , platform-driver-x86@vger.kernel.org, Mario Limonciello Subject: [PATCH] platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix Date: Thu, 16 Nov 2017 14:48:30 -0600 Message-Id: <1510865310-19893-1-git-send-email-mario.limonciello@dell.com> X-Mailer: git-send-email 2.7.4 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/platform/x86/dell-smbios-wmi.c | 14 ++++++++++++++ drivers/platform/x86/dell-wmi-descriptor.c | 26 ++++++++++++++++++++++++-- drivers/platform/x86/dell-wmi-descriptor.h | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/dell-smbios-wmi.c b/drivers/platform/x86/dell-smbios-wmi.c index 8ad11ef..a296551 100644 --- a/drivers/platform/x86/dell-smbios-wmi.c +++ b/drivers/platform/x86/dell-smbios-wmi.c @@ -147,9 +147,12 @@ static long dell_smbios_wmi_filter(struct wmi_device *wdev, unsigned int 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; int count; int ret; + u32 hotfix; if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID)) return -ENODEV; @@ -167,6 +170,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)\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); @@ -184,6 +197,7 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev) if (ret) goto fail_register; + priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); mutex_lock(&list_mutex); diff --git a/drivers/platform/x86/dell-wmi-descriptor.c b/drivers/platform/x86/dell-wmi-descriptor.c index e7f4c3a..5083ce0 100644 --- a/drivers/platform/x86/dell-wmi-descriptor.c +++ b/drivers/platform/x86/dell-wmi-descriptor.c @@ -25,6 +25,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); @@ -72,6 +73,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: * @@ -80,6 +99,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) { @@ -139,15 +159,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 776cddd..217b833 100644 --- a/drivers/platform/x86/dell-wmi-descriptor.h +++ b/drivers/platform/x86/dell-wmi-descriptor.h @@ -24,5 +24,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