From patchwork Fri Nov 17 04:13:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10062265 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 9F1206023A for ; Fri, 17 Nov 2017 04:13:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86C382AA51 for ; Fri, 17 Nov 2017 04:13:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78C6F2AA4D; Fri, 17 Nov 2017 04:13:22 +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 448A12AA4D for ; Fri, 17 Nov 2017 04:13:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932658AbdKQENU (ORCPT ); Thu, 16 Nov 2017 23:13:20 -0500 Received: from esa5.dell-outbound.iphmx.com ([68.232.153.95]:22436 "EHLO esa5.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932489AbdKQENT (ORCPT ); Thu, 16 Nov 2017 23:13:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1510891574; x=1542427574; h=from:to:cc:subject:date:message-id; bh=D7aeD4Rwuubf5vcU2TMhBJBNlBuuse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7dWHSu?= =?us-ascii?q?dl8kehxzmP0wfT5/laLkAvj6XXNoQtzaMumZoXtUTPByj2mFjqjKCNcUUk5+6o?= =?us-ascii?q?5Pn5brn8p5+cL490igTxM6g0hsO/BuE4PhAPX2id5+u8yKXu8Ez6TblQkPE7nL?= =?us-ascii?q?fVvIrHKckbqKO1GRFZ3po+5xqnCjepytUYnX0JLFJffxKHipDkO1TUL/DiDPe/?= =?us-ascii?q?hE6gkDNqx/DDOb3hBInCLnndn7flebZ97FVRxxctwtBb45JYEK0OIPX2WkPprt?= =?us-ascii?q?zXEgc5MxCow+bgENh90oIeWWSSAq6WKa/SskGH5vgpI+aSYI8Yoyj9K/c76P70?= =?us-ascii?q?l3M5mkESfbOv3ZQJbHC0BPNmI1+WYXD0mNcODX8KvhYiTOztkFCCSTpTaGyuX6?= =?us-ascii?q?Iy4TE7EoemAZ7eSYC3gbyBwjm0HodPamFJCV2BEGzld5uLW/gSciKeOMxhnSIe?= =?us-ascii?q?VbinVYAh0QuitAjgy7pofaLo/XgUq5LqzsRd5uvdjxg++DV4ScOH3CXFZmd4jy?= =?us-ascii?q?szRzIo16Byp096ggOK16RpxedYGMJY5/5PUQASOpvVzug8ANf3DFHvZNCMHXOv?= =?us-ascii?q?WNShSRUwS9U3yN4DZ0J6U4GnhwrC2GyuAroSkbeKCZgw9YrQ0nz1Yc16ziCVh+?= =?us-ascii?q?Eak1A6T54XZiWdjall+l2WXtaRng=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2F4AAChYA5ah8mZ6ERcGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYMOggAnjh6PJZhfghEKhTuEYT8YAQEBAQEBAQEBAQIQAQEBCA0JCCg?= =?us-ascii?q?vgjgkAYJwUk9vARKKJKsOOos0gzSCB4FVgWmINoYFBZMHjzSCN5JTApNGljCBO?= =?us-ascii?q?R+CLnpegmSCDAFPEAwZgW1YiA+CQgEBAQ?= X-IPAS-Result: =?us-ascii?q?A2F4AAChYA5ah8mZ6ERcGgEBAQEBAgEBAQEIAQEBAYMOggA?= =?us-ascii?q?njh6PJZhfghEKhTuEYT8YAQEBAQEBAQEBAQIQAQEBCA0JCCgvgjgkAYJwUk9vA?= =?us-ascii?q?RKKJKsOOos0gzSCB4FVgWmINoYFBZMHjzSCN5JTApNGljCBOR+CLnpegmSCDAF?= =?us-ascii?q?PEAwZgW1YiA+CQgEBAQ?= Received: from esa1.dell-outbound2.iphmx.com ([68.232.153.201]) by esa5.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2017 22:06:13 -0600 Received: from ausxipps306.us.dell.com ([143.166.148.156]) by esa1.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2017 10:12:35 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.44,407,1505797200"; d="scan'208";a="174770655" 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 v2] platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix Date: Thu, 16 Nov 2017 22:13:12 -0600 Message-Id: <1510891992-31659-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 | 13 +++++++++++++ drivers/platform/x86/dell-wmi-descriptor.c | 26 ++++++++++++++++++++++++-- drivers/platform/x86/dell-wmi-descriptor.h | 1 + 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/dell-smbios-wmi.c b/drivers/platform/x86/dell-smbios-wmi.c index 8ad11ef..044a104 100644 --- a/drivers/platform/x86/dell-smbios-wmi.c +++ b/drivers/platform/x86/dell-smbios-wmi.c @@ -147,7 +147,10 @@ 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; + u32 hotfix; int count; int ret; @@ -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), 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 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