From patchwork Thu Nov 9 17:49:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10051609 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 650D4601EA for ; Thu, 9 Nov 2017 17:49:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50E2329A55 for ; Thu, 9 Nov 2017 17:49:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 430B829A6B; Thu, 9 Nov 2017 17:49:48 +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 BA8CC29A55 for ; Thu, 9 Nov 2017 17:49:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752739AbdKIRtr (ORCPT ); Thu, 9 Nov 2017 12:49:47 -0500 Received: from esa5.dell-outbound.iphmx.com ([68.232.153.95]:52654 "EHLO esa5.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751219AbdKIRtU (ORCPT ); Thu, 9 Nov 2017 12:49:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1510249514; x=1541785514; h=from:to:cc:subject:date:message-id; bh=VaEHsD2/1+J4AYkmBEzxJC79UbQUNdDlmZzq0MfI5IA=; b=oSjBr5ddi6ozio22AhIAblVXb2eoFI2Qvs8OhicOrTIzCW1wr/8y/Nqh KBSUK+HBue7K0ICsgCnCHKQYk3jlVvKE2RQ9WLKsTUjgo5ZzBh6GqmPPU VTQn+p8hh++/kxS70wusZAX+fqZ/LL/1KFImfoex3ErlTaq9XddljzJ/c A=; IronPort-PHdr: =?us-ascii?q?9a23=3AMabj1RXK0tRygwHfokRebWH3qk/V8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYZRSOuadThVPEFb/W9+hDw7KP9fuxCSpYud6oizMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVr?= =?us-ascii?q?O+/7BpDdj9it1+C15pbffxhEiCCzbL52Lxi6txndutULioZ+N6g9zQfErGFVcO?= =?us-ascii?q?pM32NoIlyTnxf45siu+ZNo7jpdtfE8+cNeSKv2Z6s3Q6BWAzQgKGA1+dbktQLf?= =?us-ascii?q?QguV53sTSXsZnxxVCAXY9h76X5Pxsizntuph3SSRIMP7QawoVTmk8qxmUwHjhj?= =?us-ascii?q?sZODEl8WHXks1wg7xdoBK9vBx03orYbJiIOPZiYq/ReNUXSm1dUMhRSSFNG5qw?= =?us-ascii?q?YYkSAOobJOpWspT9p0AWrRSgGQasGPrjyjtPhn74wKY21+QsHQTA0QMnA9wAsG?= =?us-ascii?q?rZoMzsOKkQTO+11rDEwyjeb/NNwTfy9pTHcgw8qv2IQ758bc/dxE8yHA3Hk1qQ?= =?us-ascii?q?s5ToMTOL2OoQvWaV7O1uWuChi2ElpQF8uSSjyts2h4XVnI8Z1kzI+CNky4g1P9?= =?us-ascii?q?24T0t7bMajHpRKrSGaNox2Sd4kTWFpvSY6zbsGtoK6fCcUzJQnwxnfYOGAfoiN?= =?us-ascii?q?+B3jTueRITBiiHJhebK/ghGy8U68xe39SMa01FJKri1en9bRqH8N0xjT5tKbRf?= =?us-ascii?q?t6+0eswDCC3B3Q5OFcOU05lKnWJ4Q/zrM+iJYfq1nPEy/4lUnskqOaaksp9vC1?= =?us-ascii?q?5+nobLjqvIKQOo51hw3kMakjmtazDfk4PwUPWWWQ5P6y26f5/ULjRbVHlvg2kq?= =?us-ascii?q?7Ev5/EPckbvau5AxNN0oYk9ha/Ey+q0NQGknkDK1JIYAyIj5PzNFzOOvz3EOmw?= =?us-ascii?q?g1CokDtywPDGI6HhDY7KLnjelrfuYKhx51RdyAorzdBf4p1VBqsdL/L0X0/9rN?= =?us-ascii?q?3YDhknPAyo2+vqCdZw2pkAVW+BHKOVKr7evF+G6+41PeWAeIEYtC74K/c/5v7u?= =?us-ascii?q?iXE5mUUafamsxZYXbWq3Hu5nI0Wee3bshtYBEWINvgo4UOPqiUONUTpXZ3a1RK?= =?us-ascii?q?8z+y80CIaiDYvZWo+th7mB0D+hHpJKfmBGFkyMEXDweoWAWvcMbj+SI8B4njwH?= =?us-ascii?q?S7ehUYkh2g+qtALh1bpnIfTb+jcCuZLgytd1/evTmg829TBuCMSdyW6NRXlunm?= =?us-ascii?q?wUXz82wLx/oUtlx1eb1ah3meBYFdJU5/NTVwc2LIPTz/Z7C9DsRA3BZM6FSVml?= =?us-ascii?q?T9inGjwxUN0xzMEUY0pnGNWtkArD3yy0DL8RjbCLA4Y08q2Pl0T2cspjy3/cyI?= =?us-ascii?q?EgiVc8S8dCPGHggbRws0D6AYLY236Zmrihdaka3ymFoG6FwXvIp0FVTgVwXKPG?= =?us-ascii?q?WlgQY0LXqZLy4UaUHJG0DrFyFwJbyMnKDqpPbdvijFhCQPCrbNHXeWO23WOxAB?= =?us-ascii?q?GOzbKBaI7tU2kQ2CGbA08BxVNAtU2aPBQzU3/y61nVCyZjQBewPk4=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2E5AABblARah8uZ6ERcGQEBAQEBAQEBA?= =?us-ascii?q?QEBAQcBAQEBAYUGJ44cjyeBVpZ0ghEKhTsChDc/GAEBAQEBAQEBAQECEAEBAQo?= =?us-ascii?q?LCQgoL4I4JIJDBidSED8SVwYBEoojq186ixcBAQEBBiiDMIIHgVSBaTSOBQWKI?= =?us-ascii?q?ohSW45MgjGSTZM7liKBOR+CKnpegmSCXBAMGYFtWIwKAQEB?= X-IPAS-Result: =?us-ascii?q?A2E5AABblARah8uZ6ERcGQEBAQEBAQEBAQEBAQcBAQEBAYU?= =?us-ascii?q?GJ44cjyeBVpZ0ghEKhTsChDc/GAEBAQEBAQEBAQECEAEBAQoLCQgoL4I4JIJDB?= =?us-ascii?q?idSED8SVwYBEoojq186ixcBAQEBBiiDMIIHgVSBaTSOBQWKIohSW45MgjGSTZM?= =?us-ascii?q?7liKBOR+CKnpegmSCXBAMGYFtWIwKAQEB?= Received: from esa5.dell-outbound2.iphmx.com ([68.232.153.203]) by esa5.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2017 11:45:13 -0600 Received: from ausxippc106.us.dell.com ([143.166.85.156]) by esa5.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2017 23:45:05 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.44,370,1505797200"; d="scan'208";a="171994797" X-DLP: DLP_GlobalPCIDSS From: Mario Limonciello To: dvhart@infradead.org, Andy Shevchenko Cc: LKML , platform-driver-x86@vger.kernel.org, pali.rohar@gmail.com, Mario Limonciello Subject: [PATCH v2 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers Date: Thu, 9 Nov 2017 11:49:10 -0600 Message-Id: <2080bee9a4c98164498aa32c4f10b12bc50b183d.1510246939.git.mario.limonciello@dell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: 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 dell-wmi and dell-smbios-wmi are dependent upon dell-wmi-descriptor finishing probe successfully to probe themselves. Currently if dell-wmi-descriptor fails probing in a non-recoverable way (such as invalid header) dell-wmi and dell-smbios-wmi will continue to try to redo probing due to deferred probing. To solve this have the dependent drivers query the dell-wmi-descriptor driver whether the descriptor has been determined valid. The possible results are: -ENODEV: Descriptor GUID missing from WMI bus -EPROBE_DEFER: Descriptor not yet probed, dependent driver should wait and use deferred probing < 0: Descriptor probed, invalid. Dependent driver should return an error. 0: Successful descriptor probe, dependent driver can continue Successful descriptor probe still doesn't mean that the descriptor driver is necessarily bound at the time of initialization of dependent driver. Userspace can unbind the driver, so all methods used from driver should still be verified to return success values otherwise deferred probing be used. Signed-off-by: Mario Limonciello Reviewed-by: Pali Rohár --- drivers/platform/x86/dell-smbios-wmi.c | 5 +++-- drivers/platform/x86/dell-wmi-descriptor.c | 16 ++++++++++++++++ drivers/platform/x86/dell-wmi-descriptor.h | 8 +++++++- drivers/platform/x86/dell-wmi.c | 6 ++++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/dell-smbios-wmi.c b/drivers/platform/x86/dell-smbios-wmi.c index 35c13815b24c..ca556803c8c9 100644 --- a/drivers/platform/x86/dell-smbios-wmi.c +++ b/drivers/platform/x86/dell-smbios-wmi.c @@ -148,8 +148,9 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev) int count; int ret; - if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID)) - return -ENODEV; + ret = dell_wmi_get_descriptor_valid(); + if (ret) + return ret; priv = devm_kzalloc(&wdev->dev, sizeof(struct wmi_smbios_priv), GFP_KERNEL); diff --git a/drivers/platform/x86/dell-wmi-descriptor.c b/drivers/platform/x86/dell-wmi-descriptor.c index 28ef5f37cfbf..4dfef1f53481 100644 --- a/drivers/platform/x86/dell-wmi-descriptor.c +++ b/drivers/platform/x86/dell-wmi-descriptor.c @@ -21,14 +21,26 @@ #include #include "dell-wmi-descriptor.h" +#define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-B622A1EF5492" + struct descriptor_priv { struct list_head list; u32 interface_version; u32 size; }; +static int descriptor_valid = -EPROBE_DEFER; static LIST_HEAD(wmi_list); static DEFINE_MUTEX(list_mutex); +int dell_wmi_get_descriptor_valid(void) +{ + if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID)) + return -ENODEV; + + return descriptor_valid; +} +EXPORT_SYMBOL_GPL(dell_wmi_get_descriptor_valid); + bool dell_wmi_get_interface_version(u32 *version) { struct descriptor_priv *priv; @@ -91,6 +103,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev) if (obj->type != ACPI_TYPE_BUFFER) { dev_err(&wdev->dev, "Dell descriptor has wrong type\n"); ret = -EINVAL; + descriptor_valid = ret; goto out; } @@ -102,6 +115,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev) "Dell descriptor buffer has unexpected length (%d)\n", obj->buffer.length); ret = -EINVAL; + descriptor_valid = ret; goto out; } @@ -111,8 +125,10 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev) dev_err(&wdev->dev, "Dell descriptor buffer has invalid signature (%8ph)\n", buffer); ret = -EINVAL; + descriptor_valid = ret; goto out; } + descriptor_valid = 0; if (buffer[2] != 0 && buffer[2] != 1) dev_warn(&wdev->dev, "Dell descriptor buffer has unknown version (%lu)\n", diff --git a/drivers/platform/x86/dell-wmi-descriptor.h b/drivers/platform/x86/dell-wmi-descriptor.h index 5f7b69c2c83a..1e8cb96ffd78 100644 --- a/drivers/platform/x86/dell-wmi-descriptor.h +++ b/drivers/platform/x86/dell-wmi-descriptor.h @@ -13,7 +13,13 @@ #include -#define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-B622A1EF5492" +/* possible return values: + * -ENODEV: Descriptor GUID missing from WMI bus + * -EPROBE_DEFER: probing for dell-wmi-descriptor not yet run + * 0: valid descriptor, successfully probed + * < 0: invalid descriptor, don't probe dependent devices + */ +int dell_wmi_get_descriptor_valid(void); bool dell_wmi_get_interface_version(u32 *version); bool dell_wmi_get_size(u32 *size); diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c index 54321080a30d..39d2f4518483 100644 --- a/drivers/platform/x86/dell-wmi.c +++ b/drivers/platform/x86/dell-wmi.c @@ -655,9 +655,11 @@ static int dell_wmi_events_set_enabled(bool enable) static int dell_wmi_probe(struct wmi_device *wdev) { struct dell_wmi_priv *priv; + int ret; - if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID)) - return -ENODEV; + ret = dell_wmi_get_descriptor_valid(); + if (ret) + return ret; priv = devm_kzalloc( &wdev->dev, sizeof(struct dell_wmi_priv), GFP_KERNEL);