From patchwork Thu Dec 7 22:26:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 175459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5101078vqy; Thu, 7 Dec 2023 14:27:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDDqwaXBDSmXiIOzGSHU8WaVErkQYUdcxEwDunx0G02Tt+lReFa5tW7DxB/LqH/T+jBN5e X-Received: by 2002:aa7:9a4c:0:b0:6ce:2df5:48b with SMTP id x12-20020aa79a4c000000b006ce2df5048bmr3019684pfj.32.1701988061527; Thu, 07 Dec 2023 14:27:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701988061; cv=none; d=google.com; s=arc-20160816; b=PUBajCbgWN703ud8H+o80cqMb8cn6Cg/DK3TyGZdXI0x3GyvwciuR2OPFps6OC6ddP XQmunX8/ZG4932aEJXAfGzlvPIkCcz5FSpDJUsmh8LO8HAcs1YYD7j1nGfPBvm7zPFG5 lqhORSu3Iiu75B/WqmhjQDNcLkDyz8L9B6LXVQ2Rk13dAISUBkd3cR4LD+2ocErViW9z RkpF6YUHaru1okatc7DGhsucIciFtBWh7QJkESPAPxsjPiUksQGHn/NDgpb3Rqcc/mAJ QO2nmPEEAt/hcyfJkdwb5O3MKG36i4ISqtAsyPRCbG0i62izDk/RNgkNkjMidkpchveM scKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nsYqFu5yqpmpCU/YPpW1R60GlVsvsQNsBWMP8m58DsQ=; fh=li8yxIESWfZR7lmBO8wCmgOg4WdXsWPyQvEuWPhaOvo=; b=QrXcQEk3+DQayQue6WCB52Mzf+RH2XJUWOaq7KzbWOfGR9u1NOA6oGasX1VtiCKTaP eIG8SH3Zdk5ZswJ8X9XKb4yJYhEpUQXG1RF6KCZso20yNI/TLf7qcuBLHAeldSfaKRRk zB8RMQW1mLlqZHdoMRnWp4YCPLvNSpryfMxPyR8AySmFLEZxZJsKGdJdUBAYo29oEKj1 ZSsmeWfMIkWtxZC4Z+qjMsEv0nmwb27O1YyEXVfw37Dz73z0QdR9fwKqG0J0JOYfFhb+ hRVXUef4u7sSjoDZlkPdoYjKZ9BHk1y1rVbrC9Z7Ptnc4jVGyYlao7qUKG3MuE1kQfiR lpwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=cywH9xVz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o198-20020a62cdcf000000b006ce03f8d014si362436pfg.391.2023.12.07.14.27.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 14:27:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=cywH9xVz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0F0B381679C2; Thu, 7 Dec 2023 14:27:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444090AbjLGW07 (ORCPT + 99 others); Thu, 7 Dec 2023 17:26:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjLGW0y (ORCPT ); Thu, 7 Dec 2023 17:26:54 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3BED53; Thu, 7 Dec 2023 14:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1701988001; x=1702592801; i=w_armin@gmx.de; bh=bDupiqQnoHP4fbU+fdZXLeAEnhHecT9ssUymdrsFWIY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=cywH9xVzABfLKGfaS7RhH4DEpMCsZqtFqZ0htq0RfnBgsNIL86r3kOEplRMTWJnc P79Mfl69kVAJ3ft0C9nkrN9mRO/ja8rw/D9Fpa4JvkNUFke/PR9xAvskXCd4fME6c p8RZinB+VonLKeaq540HHFJE1q9fhQ72yC66GT2Y5etCOuvF3jROlOUMuHbl56Qy4 Gce6Rqhq4TGxKTFtYUVomTYAVumwl1no4Qa9hpmxHE8SgvnvBb+obvg70B7YJClw8 bd2yPm/xoA24att2WT5OtP5Otj/t9vJONSi8LQQo+Gzck4qumW8PGGX2u5HXoDKhJ 0aT8X7qpkph8h/4Wwg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MYeMj-1qgHBK1tlz-00Vdhw; Thu, 07 Dec 2023 23:26:41 +0100 From: Armin Wolf To: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, corbet@lwn.net Cc: Dell.Client.Kernel@dell.com, linux-doc@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] platform/x86: wmi: Remove debug_dump_wdg module param Date: Thu, 7 Dec 2023 23:26:19 +0100 Message-Id: <20231207222623.232074-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231207222623.232074-1-W_Armin@gmx.de> References: <20231207222623.232074-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:HgA1KPLs62Do40wpJGBb9R8bKIzYupdTSBSuEbwuBagc/iZ7MQa 1ZNy6v8ZQHel1udc4tjXe6jV8YqVM7nQzKiO3bCoy9sjwWBL/NDHAo6rAJPAzMAy/cdeLrB gWU6HLd8d/WeGyEx3imbYobkuCpK73wMRMTaPCgWheSb77SDIMPq1uWIBjXp5lDKvctL8Sh PDbY9wvIqJtNm7XOcelZA== UI-OutboundReport: notjunk:1;M01:P0:4XzmQh0StuE=;BBrNL1c2rr3JaETdoYQlLtJQuPy j80ZoRxF2DZKy6Su3ENoBKS6mLEjJGs6iaub5DThFRiU9uU6TTTGs+03/XZHEcOsjZUH6DVJz nf8b6GjH7sT4Tut1AQ8ccZDD4DhpSXdgiOfxjh++hOFNtcfnM/tK7CCXHZqoBWekPZIiz5vZD SBR+vJn7t7dR94Jac3L528E/NY5Bql1C7GjoEx1iyyVAkC7sLYa0Di9QUvi/7aguBDmy/xawc +CkzdSwAlumnS1UlcVbXp/93sDgfUrxdo3pZjfTf7j6LEUKR593aN8YuPMNIZNqzhX0aoom7b Z9PnsU3m3SsCVA8PWF3jaT/WNBvZyVoVLyFnwzH2EipwoHy8d58H99oGAEAlPSOAv7uu0bvdz CEgyMzrfTPjjLmycUqB7CLWq8OgZGcaj+3Bmd7i+sMxN6Fgx2awXj8YSsrxDQUh5wtASPQpEp ZvvM9z6iqZhSgV4kGl903C2D9Rp2zufayffJuNje8ynJyDgNqL8Pgkx8ilfI6o8S//GtQ//pl bJT9M3yPQOLrqNPLWxWgWesHzvEMVxnCR5Mb0I1Uc4qLdfV2hqApiWADpdWsJvjlXPZmhhF+7 qAK9Nfv5qkY4x70U8nWx9ixXgJ8vdWVtuKCHWDE0osZuYdO3y9r55h6CAjpC7fL68BOrfrFe1 dxNS0huSDu9WxZx6ciEc4aXkoSV58kqgY+gmMVwRJlTRmGJ6bmt0utWUip8oh2MTvXlSzNAVB 9d8TgephWJZkJ6aNQ6KhktsJWRxx4EqrSXWFPGn20EDTvl/N4t1IbPU6f7NdzAO5CRPL8DWlU vj2ZJy6A6mDNx1Xm3MrAlLZYCs8iT6tsCueoQF2WMYjzNpITCpV5eAzhS8WoTwkwa8K6g7Jf7 K1fMFPFGBxzZALTpxGrsKOktnlZDTtvpE8cJImAeFHe29ETqD94mYeL3pZn1dcWF2G9Qm4pLJ gZ2es4/QRQMuOpFdEprX3X+RFX0= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 14:27:34 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784663833510764591 X-GMAIL-MSGID: 1784663833510764591 The functionality of dumping WDG entries is better provided by userspace tools like "fwts wmi", which also does not suffer from garbled printk output caused by pr_cont(). Signed-off-by: Armin Wolf Reviewed-by: Ilpo Järvinen --- drivers/platform/x86/wmi.c | 31 ------------------------------- 1 file changed, 31 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 4f94e4b117f1..e8019bc19b4f 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -90,11 +90,6 @@ module_param(debug_event, bool, 0444); MODULE_PARM_DESC(debug_event, "Log WMI Events [0/1]"); -static bool debug_dump_wdg; -module_param(debug_dump_wdg, bool, 0444); -MODULE_PARM_DESC(debug_dump_wdg, - "Dump available WMI interfaces [0/1]"); - static const struct acpi_device_id wmi_device_ids[] = { {"PNP0C14", 0}, {"pnp0c14", 0}, @@ -597,29 +592,6 @@ acpi_status wmidev_block_set(struct wmi_device *wdev, u8 instance, const struct } EXPORT_SYMBOL_GPL(wmidev_block_set); -static void wmi_dump_wdg(const struct guid_block *g) -{ - pr_info("%pUL:\n", &g->guid); - if (g->flags & ACPI_WMI_EVENT) - pr_info("\tnotify_id: 0x%02X\n", g->notify_id); - else - pr_info("\tobject_id: %2pE\n", g->object_id); - pr_info("\tinstance_count: %d\n", g->instance_count); - pr_info("\tflags: %#x", g->flags); - if (g->flags) { - if (g->flags & ACPI_WMI_EXPENSIVE) - pr_cont(" ACPI_WMI_EXPENSIVE"); - if (g->flags & ACPI_WMI_METHOD) - pr_cont(" ACPI_WMI_METHOD"); - if (g->flags & ACPI_WMI_STRING) - pr_cont(" ACPI_WMI_STRING"); - if (g->flags & ACPI_WMI_EVENT) - pr_cont(" ACPI_WMI_EVENT"); - } - pr_cont("\n"); - -} - static void wmi_notify_debug(u32 value, void *context) { struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; @@ -1343,9 +1315,6 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) total = obj->buffer.length / sizeof(struct guid_block); for (i = 0; i < total; i++) { - if (debug_dump_wdg) - wmi_dump_wdg(&gblock[i]); - if (!gblock[i].instance_count) { dev_info(wmi_bus_dev, FW_INFO "%pUL has zero instances\n", &gblock[i].guid); continue; From patchwork Thu Dec 7 22:26:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 175460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5101090vqy; Thu, 7 Dec 2023 14:27:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFnxVWqiVzoeh7CA89Mbfo54PusChsWkDtsKmeaJoWhXzvbUhIkvQ7+YbdiM22lNtBIf9Kq X-Received: by 2002:a05:6a20:7b06:b0:18f:97c:927f with SMTP id s6-20020a056a207b0600b0018f097c927fmr3327086pzh.100.1701988062480; Thu, 07 Dec 2023 14:27:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701988062; cv=none; d=google.com; s=arc-20160816; b=r6WwMBPTaEtO4lPnI2/jox9HLLhR9+3M5+ubCJtro82aC7fG0Q+Cj0v4DNTc91RBJ1 0hkxJUuafT/BhzjTr6jvwHQq7UI2zP9S/y5ktepygJsCwNfSQdgGlR/q742OjnSMMVFa rmduv8+JOLJLDkYweGG0Aoc+MoDI06Inpn/rycnwmjTJPNiJlammJdXwqJKuR93rbZ/M 84lCzRktdbpeSjh2BEf8idkVPKMlz327womPrBXw9IGMx1AIPjcP6J7VgN3aGBJnAxzl xiKxZBOoDYp+/caqXtiHjvaJUh5M4IeG7707A9VxxOPv0Xkpsighj2HVbtSmkBe095wy DYdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iGNrGoB+lzmHla6E9Xq1kfVGhiqT1vrmRWOLVbIcGsA=; fh=li8yxIESWfZR7lmBO8wCmgOg4WdXsWPyQvEuWPhaOvo=; b=GBuHeqzITcFamh5A/TvIi5Sjofv6VlV2S6Cd5vHu92yC01iKNN8cgIYRZtPF/YgpEw ezfLGYqCZERbLJbwyk3g/8Q0vmj48094JbI4gNdPBXJisNcopwZ3PRMJ81l9qtYvvZlV ZZrxNTt5Sj9KrrzO5JuELNR/mO77f+yw99llGrjz5GR6I+HlOSazAwb9GosVyOnVLeug PfIqaapGy0CsmDbHCqdifiujyKJevKuapOyLvBtkK7xDy7L6D1wzqIpv6V8KTcO1KJmZ Qe/uH6kKeAEA/CedafyQWWOa6Id/fjrlGt2MO9WxItlAvs47NpvLHPrZ2cxIHWPV+C7p nY1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=WIVYy705; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g7-20020a17090a300700b00286a56a5f67si1699095pjb.187.2023.12.07.14.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 14:27:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=WIVYy705; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 471AC8025D08; Thu, 7 Dec 2023 14:27:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444111AbjLGW1F (ORCPT + 99 others); Thu, 7 Dec 2023 17:27:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232348AbjLGW0z (ORCPT ); Thu, 7 Dec 2023 17:26:55 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B9F1709; Thu, 7 Dec 2023 14:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1701988003; x=1702592803; i=w_armin@gmx.de; bh=hRtnb6b+el/mDmpgSmqBxhwR9jcwXm8JFzOWUYTda+I=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=WIVYy705ijLpQ8zAaaIOo9myH7lzIg9YE282lJSok9+uNJLLbVq8TARUFUfHP5GN 89JUpn3GLSJ238oECqZbqBUp5XyMYMR+NTwstW0+5XvYjOp5EGRNQLwL+yE8lxvpr 4eE0LG8LqbOKkL2VUW2++6qN+D1kvbzNNf1Ktg6iMSUky0YFzs94hySgHX3pfLuhp 1PYo1NVLMdRvoGm3wnECoHOXGyhciFOZ80KYolvTJoph8tl8zap6XnmIodeeEBpqT tH5/3mrsWPwrwn9gSGBhldRO30R3daUDIPA3C8nDnPa/tzrznKhoGsGqH9yljgQAd eIt7hYBcjCnZUqVqRw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MGQnF-1r1ne225sb-00GqBo; Thu, 07 Dec 2023 23:26:43 +0100 From: Armin Wolf To: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, corbet@lwn.net Cc: Dell.Client.Kernel@dell.com, linux-doc@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] platform/x86: wmi: Remove debug_event module param Date: Thu, 7 Dec 2023 23:26:20 +0100 Message-Id: <20231207222623.232074-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231207222623.232074-1-W_Armin@gmx.de> References: <20231207222623.232074-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:V6ZKGrAqANQVKQEACBz3qEBfIRqwdnS1tGjtPZYPj5EUFpH/MxW WBhuycZ/bkrQQXjxakG9BEesEb5gOzVsu0Vv9bBYJ06MKdIZOFCG7vcedztADDBd2ODyrJY gcxz2Cn5p8HaaUdi1pR7YT3c6eAkYFmkOQSt8omDpaCfpUVpTXfhBDtBklT6JaU4D73Piku r6hn5YEAUcY99Rqh7tDDQ== UI-OutboundReport: notjunk:1;M01:P0:dybWYjf+9q0=;kipBATeSogBueG9cINoScMMyKpr ZJSjRWQwXZ08V2SBv2cd17A4yL8lVbXBWo12RTy2P+uaONdtjWxToyvf+4sysUuyi+yb3PkHN rX55RZ/4G8RJu2kwwc/NGBPBL2U+LgopOxSFisZtO9mJOFGFWvxRHYRUaRy8wvYzMHeE3VGxq r9xEvmBZ1nH8ZjI/K7FnDY4VrW2mbuEwdjnzbAGGYfk20IYrAV1xbUQr71Ae5LzIUL47sw0k6 79mds+NiVBZDjHUBDQ+756z7Y5u7z1d1NA50v/l+UaIIUsyDyvlHO9Uw8dsDJpflU270MU/QR uETUFjNQCI2Yog9fBCGQAx92lXzP+cG7SD70c7wWJuCZg4XoAi0E4pTvoQH+rVEXNqfC+pOGQ gQY85euutJmPcabhkGh14j1O98JQDmR/bfw6jdI+XXsl6Sq3YTTJwPWMhjyRZFFosVUJoD4T/ aGE9J5lmLs3dnUunUUUegjTAI4olTNCr15xVAevG6t1vhCKuqbKG9uoQw2OkvGYn863rXFEVd yLDV1wkkNuWZ5JFEviPXBstnQjA64+ZNa9gCrGkT3yukEFADzKZDptk3HlPDZnDn0BCH6AqCH c5s7OKP4kbBikpC4q1WX/RUYghvf60b/jfkOCO+Z1RnK3oxuYn6wtvV/OZP/LXrQPyDUENzsS EEruFfeqKSkXIzyZkvvF86kZ6EzkKZalbWYq3iGbaAZGCgbjbDkZH/U+ZLltCvkNOPdK1C/dK VKEmt+adIa+sjWLJ3Az8msu6XaNe/5XnpBhNpwao7JgYNpT0kGNsEYlv9/niFvFomzIe4QY1n 5BYw8k22d4SaJZ4mKnXHlpsK+u6V4kunRVSx5VefbSQvP77Pc16/W36+lKE2zoJ4oN08gbaDv 7nCEL7vHvtSnSI4ydG9ky9dX0MK6X0adWPIqXYO5NkucAzuoVeCOBtokdMCBivUUvXXN/DAqn N76nw38h1Zll5S5vdLQRCyIN3+0= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 14:27:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784663834819624197 X-GMAIL-MSGID: 1784663834819624197 Users can already listen to ACPI WMI events through the ACPI netlink interface. The old wmi_notify_debug() interface also uses the deprecated GUID-based interface. Remove it to make the event handling code more readable. Signed-off-by: Armin Wolf Reviewed-by: Ilpo Järvinen --- drivers/platform/x86/wmi.c | 74 ++++---------------------------------- 1 file changed, 7 insertions(+), 67 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index e8019bc19b4f..7df5b5ee7983 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -85,11 +85,6 @@ struct wmi_block { #define ACPI_WMI_STRING BIT(2) /* GUID takes & returns a string */ #define ACPI_WMI_EVENT BIT(3) /* GUID is an event */ -static bool debug_event; -module_param(debug_event, bool, 0444); -MODULE_PARM_DESC(debug_event, - "Log WMI Events [0/1]"); - static const struct acpi_device_id wmi_device_ids[] = { {"PNP0C14", 0}, {"pnp0c14", 0}, @@ -592,42 +587,6 @@ acpi_status wmidev_block_set(struct wmi_device *wdev, u8 instance, const struct } EXPORT_SYMBOL_GPL(wmidev_block_set); -static void wmi_notify_debug(u32 value, void *context) -{ - struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *obj; - acpi_status status; - - status = wmi_get_event_data(value, &response); - if (status != AE_OK) { - pr_info("bad event status 0x%x\n", status); - return; - } - - obj = response.pointer; - if (!obj) - return; - - pr_info("DEBUG: event 0x%02X ", value); - switch (obj->type) { - case ACPI_TYPE_BUFFER: - pr_cont("BUFFER_TYPE - length %u\n", obj->buffer.length); - break; - case ACPI_TYPE_STRING: - pr_cont("STRING_TYPE - %s\n", obj->string.pointer); - break; - case ACPI_TYPE_INTEGER: - pr_cont("INTEGER_TYPE - %llu\n", obj->integer.value); - break; - case ACPI_TYPE_PACKAGE: - pr_cont("PACKAGE_TYPE - %u elements\n", obj->package.count); - break; - default: - pr_cont("object type 0x%X\n", obj->type); - } - kfree(obj); -} - /** * wmi_install_notify_handler - Register handler for WMI events (deprecated) * @guid: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba @@ -656,8 +615,7 @@ acpi_status wmi_install_notify_handler(const char *guid, acpi_status wmi_status; if (guid_equal(&block->gblock.guid, &guid_input)) { - if (block->handler && - block->handler != wmi_notify_debug) + if (block->handler) return AE_ALREADY_ACQUIRED; block->handler = handler; @@ -698,22 +656,14 @@ acpi_status wmi_remove_notify_handler(const char *guid) acpi_status wmi_status; if (guid_equal(&block->gblock.guid, &guid_input)) { - if (!block->handler || - block->handler == wmi_notify_debug) + if (!block->handler) return AE_NULL_ENTRY; - if (debug_event) { - block->handler = wmi_notify_debug; - status = AE_OK; - } else { - wmi_status = wmi_method_enable(block, false); - block->handler = NULL; - block->handler_data = NULL; - if ((wmi_status != AE_OK) || - ((wmi_status == AE_OK) && - (status == AE_NOT_EXIST))) - status = wmi_status; - } + wmi_status = wmi_method_enable(block, false); + block->handler = NULL; + block->handler_data = NULL; + if (wmi_status != AE_OK || (wmi_status == AE_OK && status == AE_NOT_EXIST)) + status = wmi_status; } } @@ -1340,17 +1290,10 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) list_add_tail(&wblock->list, &wmi_block_list); - if (debug_event) { - wblock->handler = wmi_notify_debug; - wmi_method_enable(wblock, true); - } - retval = wmi_add_device(pdev, &wblock->dev); if (retval) { dev_err(wmi_bus_dev, "failed to register %pUL\n", &wblock->gblock.guid); - if (debug_event) - wmi_method_enable(wblock, false); list_del(&wblock->list); put_device(&wblock->dev.dev); @@ -1445,9 +1388,6 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, wblock->handler(event, wblock->handler_data); } - if (debug_event) - pr_info("DEBUG: GUID %pUL event 0x%02X\n", &wblock->gblock.guid, event); - acpi_bus_generate_netlink_event( wblock->acpi_device->pnp.device_class, dev_name(&wblock->dev.dev), From patchwork Thu Dec 7 22:26:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 175458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5101047vqy; Thu, 7 Dec 2023 14:27:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGw+chU38KHYyw5tChcbfb9oLv74tDG6WGtFgr5pBtKOO6LhyiAkddWB+aZuEjCO2drwI0p X-Received: by 2002:a05:6a20:4308:b0:18f:97c:9269 with SMTP id h8-20020a056a20430800b0018f097c9269mr3296965pzk.78.1701988056925; Thu, 07 Dec 2023 14:27:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701988056; cv=none; d=google.com; s=arc-20160816; b=GiAMLa56rJofYlCefBCtDnUzlPFHo1L2LPdLBRZARGRzLbotWrmhzktDy5k5Nm0m4b 7szl6aptY+GJ5iEmuArEfcA50OJWYcNslHGCikHvutcoAevLsDrE6Ll83LuCxaXhkwET rTtxO2v5fN50zho2BafeIr1OrhVcbXBaUnBpF6Mn6ViHwvgRRThRyUEEhyAo7t5Bkg1g jy8T7N24bTrr1/STYe203oHtgCISYWIbWWt98qSl9oT5mw843hQmEOSIx33zq6lM0EMa Uuzy41wDy1tuDtAxwXo+NQ1Y8pL5VYtlyNc3YO4BmQwuahaiFnwnrutG8JRWnh11YbjN hO/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IxEcCdhwKE0K5SWUG6FXi6xzkVCAvu2qlIJhctthqTE=; fh=li8yxIESWfZR7lmBO8wCmgOg4WdXsWPyQvEuWPhaOvo=; b=E/ruk0IqTtNGOriHwH4ENfWjz8JacFkBCyDZ3Tod29QqcLlN0WHPdj6YaCLEoHg8qm Z+PzIYxgsDFdiACs9Qpe2u/BFx4i40bUplZKN9olDttDC9miJLcXqXj98HPSkqtoYX7v n2ItGyk85FbrnZhWp+aM07ttnrIjq3cakoF9OY1/vQxhx4xi/AuvoRq0XCNSacSFu9pP UwR2vsyAmm8QuUNdc2/fIvT24JD311epEg8LnCQRfoPabE/wvdSdeRtHalz1HM9Bdjm8 6zilcQxxznuuvc0NDYZAY+OUNWJ7RvX0nnZyRMUJ5xiiJgWggX+S7ytsUgjkgMdFBQF9 cMyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=pBj4b30H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id by26-20020a056a02059a00b005c6832282f7si412590pgb.304.2023.12.07.14.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 14:27:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=pBj4b30H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id ACC8480CF547; Thu, 7 Dec 2023 14:27:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235331AbjLGW05 (ORCPT + 99 others); Thu, 7 Dec 2023 17:26:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbjLGW0y (ORCPT ); Thu, 7 Dec 2023 17:26:54 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B56D9D4A; Thu, 7 Dec 2023 14:26:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1701988006; x=1702592806; i=w_armin@gmx.de; bh=MnUO2eCpHcRNIigISNlEI4luU9Ds7WfsIdhVMY51GBw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=pBj4b30HkNOjwopaKjz/TpjTXy/Y2S+mMH4Gs0lwRbojyJrI6+AHiDqzOEjO9fv0 QRQ5ytwH1n8MOMXU6Px3+LR7ib2OUIbbblz0/I0InXw1HCGmFgwmVGgRoUkS44jbr gS2IzxApthbrFW3oKJ/nH1jVcFSA1rHLWAGPJlrVq28vpopR3or125AXFuZK01lfA A4UIZoud+v4VVVELV/mafh7Ldkq+1gkOI3mq8XsxbwT2uzukPfRm5ss1Mp10C7su7 Tj9fbM/ooFtvT+UuhfX0Rwp++nEuLNIucx7/AhJe7QqTUFwLlxybkMfGEr+Pl/y2K wKc8kY2WDAMNvOkohA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MsHns-1rUgtr4AFW-00thG4; Thu, 07 Dec 2023 23:26:46 +0100 From: Armin Wolf To: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, corbet@lwn.net Cc: Dell.Client.Kernel@dell.com, linux-doc@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] platform/x86: dell-smbios-wmi: Stop using WMI chardev Date: Thu, 7 Dec 2023 23:26:21 +0100 Message-Id: <20231207222623.232074-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231207222623.232074-1-W_Armin@gmx.de> References: <20231207222623.232074-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:uMW+ajDxQVUrTn75NdD8r7vsu6sJ0GR05zZ5AGuPswH/RdF0B64 i7Z+cedGKgj/tfuMT9D5V1imqW+EGmtN/UZmfYaYQbXPcTA9s4oflHxhSg4N1GUKNELNgo6 qnhh1imosWhOk8WTeDqJqbFxiFjOMyd3Ji8rIfwaJo8WtYo9lkONBrG6hx1xSXkfDOCyg3+ 3nE4S8F0uY9ONN9iflwzw== UI-OutboundReport: notjunk:1;M01:P0:vyVUJwqyVBQ=;o4t0zqpF4O/QIj1D1hpu8mLFA0I 5HnT/+40eWglt+OBtHXBDK6jTdfMZXoc4kF2zj/FbR4lm6cbE/6B2oiYzUB3EmH40dKc1XaFQ pNMJfFSLbNU3VIiOXxGJTEbKJ40QyIF33SsvQ+OUNzGw8uBnOkfBxarf1VFc789TvNxCt3Ry4 aB2SqhTBi6B6lN/kLERXs574aXjw64ncCu6jQj21RyFT4a8VAiFnzbUKrzYg5VzU+jpfrf8/e E+1Ev/jBZz2L6vhN3HY7VBGo0jXs+LdfFP3K3SYdUwKX4+QcIyIC9l7WxLIfK2JDgqgz3QIwN rBwZQ9MmJZQOXIMs2EgK8OQV5ZY47BwaOphwN17TSxl1YVCx8nTUovMEfkPCbVrNNMfkJVmW1 F012IMFeK2fO903f95A9mm3FbVwWac7TeZvr6aUxXy940WE0fJ4lz56gjlt38aM5xbpcPuo/j bJtIO7S0hLcuVDgE+QLFmNBC1byafbyLrbillHX1IP9xDN9FwOAJ3D6O+IorCJ6DeyREr/eFZ nWVV5rJyqNzXI/OVisHNDW28sCvGgswR6qEOLrqwxAJbwlE2KlNLswlFYiDnTUD0ujppMZFsn kHaw8phcKDebgJW2HT+uwyWqQnSNPWseaYFuudP2FIxBYBXu6Q6qMQBGdy/PNdGq7SUIGNNqr YD9F2N8JfPaFQVCluBqRrJ/9hLDbpNep+cUHwUAPGOlbNOO3mMB9mE17ez6kjhMDoy6EAMVqa 7DYMWx8fCdotoTyzb82woUBGdL0JnkdPgV+QizJzABqALi/mWdFT3+jipwCatbk4LjN0ByHxH 3taIsAVKV0Dg5EqJbhdouRTVXWty58PrL5InyC7phv1mqGvoOjBGe+k1dJK9d1qVdYLMmfks5 1J2eMZaEMOU9yIaD83Nk4n8ltGZD1VJQ2YIPAUq3+qLzI1daNSCFdSgKcePiVb3tYVZHaYrGv NPGdxKXLJc8APHUt9ACs7sVnXQ0= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 14:27:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784663828544871113 X-GMAIL-MSGID: 1784663828544871113 The WMI chardev API will be removed in the near future. Reimplement the necessary bits used by this driver so that userspace software depending on it does no break. Signed-off-by: Armin Wolf --- drivers/platform/x86/dell/dell-smbios-wmi.c | 163 ++++++++++++++------ 1 file changed, 117 insertions(+), 46 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/dell/dell-smbios-wmi.c b/drivers/platform/x86/dell/dell-smbios-wmi.c index 931cc50136de..61f40f462eca 100644 --- a/drivers/platform/x86/dell/dell-smbios-wmi.c +++ b/drivers/platform/x86/dell/dell-smbios-wmi.c @@ -7,11 +7,14 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include +#include #include #include #include #include +#include #include "dell-smbios.h" #include "dell-wmi-descriptor.h" @@ -32,7 +35,9 @@ struct wmi_smbios_priv { struct list_head list; struct wmi_device *wdev; struct device *child; - u32 req_buf_size; + u64 req_buf_size; + u32 hotfix; + struct miscdevice char_dev; }; static LIST_HEAD(wmi_list); @@ -108,48 +113,106 @@ static int dell_smbios_wmi_call(struct calling_interface_buffer *buffer) return ret; } -static long dell_smbios_wmi_filter(struct wmi_device *wdev, unsigned int cmd, - struct wmi_ioctl_buffer *arg) +static int dell_smbios_wmi_open(struct inode *inode, struct file *filp) { struct wmi_smbios_priv *priv; - int ret = 0; - - switch (cmd) { - case DELL_WMI_SMBIOS_CMD: - mutex_lock(&call_mutex); - priv = dev_get_drvdata(&wdev->dev); - if (!priv) { - ret = -ENODEV; - goto fail_smbios_cmd; - } - memcpy(priv->buf, arg, priv->req_buf_size); - if (dell_smbios_call_filter(&wdev->dev, &priv->buf->std)) { - dev_err(&wdev->dev, "Invalid call %d/%d:%8x\n", - priv->buf->std.cmd_class, - priv->buf->std.cmd_select, - priv->buf->std.input[0]); - ret = -EFAULT; - goto fail_smbios_cmd; - } - ret = run_smbios_call(priv->wdev); - if (ret) - goto fail_smbios_cmd; - memcpy(arg, priv->buf, priv->req_buf_size); -fail_smbios_cmd: - mutex_unlock(&call_mutex); - break; - default: - ret = -ENOIOCTLCMD; + + priv = container_of(filp->private_data, struct wmi_smbios_priv, char_dev); + filp->private_data = priv; + + return nonseekable_open(inode, filp); +} + +static ssize_t dell_smbios_wmi_read(struct file *filp, char __user *buffer, size_t length, + loff_t *offset) +{ + struct wmi_smbios_priv *priv = filp->private_data; + + return simple_read_from_buffer(buffer, length, offset, &priv->req_buf_size, + sizeof(priv->req_buf_size)); +} + +static long dell_smbios_wmi_do_ioctl(struct wmi_smbios_priv *priv, + struct dell_wmi_smbios_buffer __user *arg) +{ + long ret; + + if (get_user(priv->buf->length, &arg->length)) + return -EFAULT; + + if (priv->buf->length < priv->req_buf_size) + return -EINVAL; + + /* if it's too big, warn, driver will only use what is needed */ + if (priv->buf->length > priv->req_buf_size) + dev_err(&priv->wdev->dev, "Buffer %llu is bigger than required %llu\n", + priv->buf->length, priv->req_buf_size); + + if (copy_from_user(priv->buf, arg, priv->req_buf_size)) + return -EFAULT; + + if (dell_smbios_call_filter(&priv->wdev->dev, &priv->buf->std)) { + dev_err(&priv->wdev->dev, "Invalid call %d/%d:%8x\n", + priv->buf->std.cmd_class, + priv->buf->std.cmd_select, + priv->buf->std.input[0]); + + return -EINVAL; } + + ret = run_smbios_call(priv->wdev); + if (ret) + return ret; + + if (copy_to_user(arg, priv->buf, priv->req_buf_size)) + return -EFAULT; + + return 0; +} + +static long dell_smbios_wmi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + struct dell_wmi_smbios_buffer __user *input = (struct dell_wmi_smbios_buffer __user *)arg; + struct wmi_smbios_priv *priv = filp->private_data; + long ret; + + if (cmd != DELL_WMI_SMBIOS_CMD) + return -ENOIOCTLCMD; + + mutex_lock(&call_mutex); + ret = dell_smbios_wmi_do_ioctl(priv, input); + mutex_unlock(&call_mutex); + return ret; } +static const struct file_operations dell_smbios_wmi_fops = { + .owner = THIS_MODULE, + .open = dell_smbios_wmi_open, + .read = dell_smbios_wmi_read, + .unlocked_ioctl = dell_smbios_wmi_ioctl, + .compat_ioctl = compat_ptr_ioctl, +}; + +static int dell_smbios_wmi_register_chardev(struct wmi_smbios_priv *priv) +{ + priv->char_dev.minor = MISC_DYNAMIC_MINOR; + priv->char_dev.name = "wmi/dell-smbios"; + priv->char_dev.fops = &dell_smbios_wmi_fops; + priv->char_dev.mode = 0444; + + return misc_register(&priv->char_dev); +} + +static void dell_smbios_wmi_unregister_chardev(struct wmi_smbios_priv *priv) +{ + misc_deregister(&priv->char_dev); +} + static int dell_smbios_wmi_probe(struct wmi_device *wdev, const void *context) { - struct wmi_driver *wdriver = - container_of(wdev->dev.driver, struct wmi_driver, driver); struct wmi_smbios_priv *priv; - u32 hotfix; + u32 buffer_size; int count; int ret; @@ -162,39 +225,44 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev, const void *context) if (!priv) return -ENOMEM; + priv->wdev = wdev; + dev_set_drvdata(&wdev->dev, priv); + /* WMI buffer size will be either 4k or 32k depending on machine */ - if (!dell_wmi_get_size(&priv->req_buf_size)) + if (!dell_wmi_get_size(&buffer_size)) return -EPROBE_DEFER; + priv->req_buf_size = buffer_size; + /* some SMBIOS calls fail unless BIOS contains hotfix */ - if (!dell_wmi_get_hotfix(&hotfix)) + if (!dell_wmi_get_hotfix(&priv->hotfix)) return -EPROBE_DEFER; - if (!hotfix) { + + if (!priv->hotfix) dev_warn(&wdev->dev, "WMI SMBIOS userspace interface not supported(%u), try upgrading to a newer BIOS\n", - hotfix); - wdriver->filter_callback = NULL; - } + priv->hotfix); /* 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); - if (ret) - return ret; count = get_order(priv->req_buf_size); priv->buf = (void *)__get_free_pages(GFP_KERNEL, count); if (!priv->buf) return -ENOMEM; + if (priv->hotfix) { + ret = dell_smbios_wmi_register_chardev(priv); + if (ret) + goto fail_chardev; + } + /* ID is used by dell-smbios to set priority of drivers */ wdev->dev.id = 1; ret = dell_smbios_register_device(&wdev->dev, &dell_smbios_wmi_call); if (ret) goto fail_register; - priv->wdev = wdev; - dev_set_drvdata(&wdev->dev, priv); mutex_lock(&list_mutex); list_add_tail(&priv->list, &wmi_list); mutex_unlock(&list_mutex); @@ -202,6 +270,9 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev, const void *context) return 0; fail_register: + if (priv->hotfix) + dell_smbios_wmi_unregister_chardev(priv); +fail_chardev: free_pages((unsigned long)priv->buf, count); return ret; } @@ -211,6 +282,7 @@ static void dell_smbios_wmi_remove(struct wmi_device *wdev) struct wmi_smbios_priv *priv = dev_get_drvdata(&wdev->dev); int count; + dell_smbios_wmi_unregister_chardev(priv); mutex_lock(&call_mutex); mutex_lock(&list_mutex); list_del(&priv->list); @@ -256,7 +328,6 @@ static struct wmi_driver dell_smbios_wmi_driver = { .probe = dell_smbios_wmi_probe, .remove = dell_smbios_wmi_remove, .id_table = dell_smbios_wmi_id_table, - .filter_callback = dell_smbios_wmi_filter, }; int init_dell_smbios_wmi(void) From patchwork Thu Dec 7 22:26:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 175462 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5101165vqy; Thu, 7 Dec 2023 14:27:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFv7dNBGFk1Nr5L7hSeAYRSjMG3OcYPXMYtcxsLh0Y7+/Q7cptTgxbXm7y2q3zPTA82Al4B X-Received: by 2002:a17:903:26d2:b0:1cf:b14d:8939 with SMTP id jg18-20020a17090326d200b001cfb14d8939mr2674413plb.63.1701988077946; Thu, 07 Dec 2023 14:27:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701988077; cv=none; d=google.com; s=arc-20160816; b=EoVBR2Gx/uW4nQkcnRNCJkpVBdj4EJcaFWeds1mA1uIfrrU4sI2xGbTYpMmcH3TYZT qFQ/cTOkDM0mDMHUoqC0WZdLaW9VfPt87yFg6vO9P26WwDweqrlr1oohNyWfua0owsZW dMEZ2guEAGK934sm98OKAcziZUIEPrOGZqVMaZNH66cPQhSHT1O8oFNhkp4/AZsTNq+G igtNbX9sk5qukHW5cgISZKJ8i68mez84aKc8iqNUHSA3qFP1nEf1nWptfmDpqJuY5T7c hI3lppbmfEx6+S3xJkxTsAGtcVx8GSoyczvZJz5ToQqL6kX9qB1HFv8fCfZS2OtzCW8x Z3Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d+EegmElKqwqp2lATXtS/oUtHRG3isZPMw2E+pmB55I=; fh=li8yxIESWfZR7lmBO8wCmgOg4WdXsWPyQvEuWPhaOvo=; b=uG4jMbmgdg2aS8gBgqblG6nNGrysllpbp+DlsfKSJuL5Hxj+l68cEffpW9vklCZraf iHi8IE5mvzg1B05mwAzH53DJRQh2eVd8uu/xO4kdwo6NY/h/ohKHIy/tk6wcf7bUKF8Z IQtCBcnxCyq/R+L/VqX+ZNzrf1cRQyaRr6CuRzJQ2EpvKYGCzTIHN6ZA7qyxJuzEfFp5 hYyRQiM64p2L4DXMgMvJAYNIOxEMHxRnNHdTHKe0gBLjAc5pteP7XXOYIWViQUX3ImCV GTb2xfdJevXPqO/nlTdlvruj8l+WSBFIKS1/x93rfp6Gq8t0uSpKwNd7CRzoRT/Vbh1W blfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Yj+srHue; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y15-20020a17090322cf00b001d08cfd3933si427459plg.394.2023.12.07.14.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 14:27:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Yj+srHue; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 038588061CF2; Thu, 7 Dec 2023 14:27:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235331AbjLGW1K (ORCPT + 99 others); Thu, 7 Dec 2023 17:27:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232369AbjLGW04 (ORCPT ); Thu, 7 Dec 2023 17:26:56 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7C1F170C; Thu, 7 Dec 2023 14:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1701988008; x=1702592808; i=w_armin@gmx.de; bh=y2EiVsoHmyaZo5EWEuzoKsphmINyUOYwfn7EMnwuLU0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Yj+srHueQQUZbBmN77rZ2/c3CPtuEnYClCHxzkl6trWoSymWU5Mr03g3aIoUcxLB uiIqDD7+mtS36KH1x0S6Cxj3wbzLQF6kMaUJA9ZkIyAhc8QyqPKR0qHYSELS0OriS 5CScQo/lLKODJGpASISe+fiYliDcw2l1hCwB75znrZLELEZVcwiAKYMrO10njtBsx KSnGh2+cUK75JPaz4OkEQAEjhdWzQUWRicg1ftgHqccmxEIGvkFp9hpuSGMIGtWs+ plFPh7wLpdtjiM9ouRKQ4c45ducIP6ZsYo/+5anyMJLQOWTtx+O4miCn/UwlGPyFB HQih1FcinZYC1HaYAg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mg6Zw-1rj4UQ2FIM-00hgNB; Thu, 07 Dec 2023 23:26:48 +0100 From: Armin Wolf To: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, corbet@lwn.net Cc: Dell.Client.Kernel@dell.com, linux-doc@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] platform/x86: wmi: Remove chardev interface Date: Thu, 7 Dec 2023 23:26:22 +0100 Message-Id: <20231207222623.232074-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231207222623.232074-1-W_Armin@gmx.de> References: <20231207222623.232074-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:WQ9UYDFhnYuYZY2U6JeHfGozqpr2BYf08f6ZRM2dq5zgwIBVrgS 94JDOsPJlXyD22SApQEwMw/NsHWUg7hN0eJLtjUp+p599yImgw1BzNpHclSoZivB2yBFE9K RH5XA3Zx02xwZMNn+Il7u9/382ze1mD/5y5b0/T7QZE7TGxUGgFKRMCUhdZFyeXH/3ypyOx 3zTkxB1/FqmvK81nQYw+g== UI-OutboundReport: notjunk:1;M01:P0:oCtkFgIGYMc=;IWDCxZdV9V6XU83HaYvD7N4J9MV 5WUIVL1zHlmo0ofZP0/uXUhKhl5P3joTMmbKoraEttlb8DC4LFFj+r19xxejyKqWa9OQcT8Sj u+Wyyhml8y68KrNrKjMMnjjruCiMJCAT9QFwZfSBaeEGW3XZ92jhDvcXfSt1POT/ZgUr3OvBt eqzpaPbLcHkqDm1MdXfhR6j5Acd/pnpXuZE+nFnXOrDh36sMuDA/HyLgLtDf3Qde99mh2vwjv 2rAMpEvbkWwY6NarHX0kkHZlIRmViKOpL4Z0NgaFrBx/caDRd+rjrZ8L2CoTNj3Qmc7k4EGrL W2UoqvwUOUCMqkXv8It9rbkNTfDrVKJB/q3LyYnti+2+7IGUJWLjpRf/fDXTMe1btblAVoXAG fA5ZLCc2tuK1U08lBHsE6PjhmCrEGPJMDPCKkDmUiaq7DljlSYNj9y0Bw8WNuhCRiedtlffjY Al9oo4YOw/1jxJ2sCybN/PVQ+EAMZ6bgo1cqGozLrxKSCkvjXTONDILZ5xbMdejJmbLZfRh0Y qK/zLwYKB0uxLQMvHfOR9pq0hq0I4DXHxBrSbWYdthFlzL3KvbFKzW9u0sqRtqMeQKn4vdDJ+ YIw9zxoqi64+smcx1ii+UnuoRZl3diAoelA/ggP8Quk1hcE/7qWVxvuEy4zXukDWvs8IT5aRy 2RRurZ4A1dOTa3FrudayEz7jo3YbmsOhDanFx2vYcBrfTIBjyl+SCZzMy1KEQqSmf+aHxZyXg JPn5yvB3a7QRlwuKrZ5Ru9oPv451kSIhyjmRkhoEPTtrAwzbLYJzT4znB4/tO9LOpqn311z4A iGrRrbzUSRvi+m2LrQwyxlAGWxAZaSaNHPyNdM402ApcZ6SZLbdRdcfQUX0gBdtsTQ9/UdBnV vFH+oKLZ9ynf8w1CjC3NBgQxnHb433do7Te55kJETsm68ZRPT4wGD3v3LB8HiWNiKsM4+c4mD 7d2sDUbOdWLyvGx1gPNtbZCmRB8= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 14:27:55 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784663850470366978 X-GMAIL-MSGID: 1784663850470366978 The design of the WMI chardev interface is broken: - it assumes that WMI drivers are not instantiated twice - it offers next to no abstractions, the WMI driver gets a raw byte buffer - it is only used by a single driver, something which is unlikely to change Since the only user (dell-smbios-wmi) has been migrated to his own ioctl interface, remove it. Signed-off-by: Armin Wolf Reviewed-by: Ilpo Järvinen --- drivers/platform/x86/wmi.c | 180 ++----------------------------------- include/linux/wmi.h | 8 -- 2 files changed, 5 insertions(+), 183 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 7df5b5ee7983..7303702290e5 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -23,17 +23,14 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include -#include MODULE_AUTHOR("Carlos Corbacho"); MODULE_DESCRIPTION("ACPI-WMI Mapping Driver"); @@ -66,12 +63,9 @@ struct wmi_block { struct wmi_device dev; struct list_head list; struct guid_block gblock; - struct miscdevice char_dev; - struct mutex char_mutex; struct acpi_device *acpi_device; wmi_notify_handler handler; void *handler_data; - u64 req_buf_size; unsigned long flags; }; @@ -256,26 +250,6 @@ static void wmi_device_put(struct wmi_device *wdev) * Exported WMI functions */ -/** - * set_required_buffer_size - Sets the buffer size needed for performing IOCTL - * @wdev: A wmi bus device from a driver - * @length: Required buffer size - * - * Allocates memory needed for buffer, stores the buffer size in that memory. - * - * Return: 0 on success or a negative error code for failure. - */ -int set_required_buffer_size(struct wmi_device *wdev, u64 length) -{ - struct wmi_block *wblock; - - wblock = container_of(wdev, struct wmi_block, dev); - wblock->req_buf_size = length; - - return 0; -} -EXPORT_SYMBOL_GPL(set_required_buffer_size); - /** * wmi_instance_count - Get number of WMI object instances * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba @@ -884,111 +858,12 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver) return 0; } -static int wmi_char_open(struct inode *inode, struct file *filp) -{ - /* - * The miscdevice already stores a pointer to itself - * inside filp->private_data - */ - struct wmi_block *wblock = container_of(filp->private_data, struct wmi_block, char_dev); - - filp->private_data = wblock; - - return nonseekable_open(inode, filp); -} - -static ssize_t wmi_char_read(struct file *filp, char __user *buffer, - size_t length, loff_t *offset) -{ - struct wmi_block *wblock = filp->private_data; - - return simple_read_from_buffer(buffer, length, offset, - &wblock->req_buf_size, - sizeof(wblock->req_buf_size)); -} - -static long wmi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - struct wmi_ioctl_buffer __user *input = - (struct wmi_ioctl_buffer __user *) arg; - struct wmi_block *wblock = filp->private_data; - struct wmi_ioctl_buffer *buf; - struct wmi_driver *wdriver; - int ret; - - if (_IOC_TYPE(cmd) != WMI_IOC) - return -ENOTTY; - - /* make sure we're not calling a higher instance than exists*/ - if (_IOC_NR(cmd) >= wblock->gblock.instance_count) - return -EINVAL; - - mutex_lock(&wblock->char_mutex); - buf = wblock->handler_data; - if (get_user(buf->length, &input->length)) { - dev_dbg(&wblock->dev.dev, "Read length from user failed\n"); - ret = -EFAULT; - goto out_ioctl; - } - /* if it's too small, abort */ - if (buf->length < wblock->req_buf_size) { - dev_err(&wblock->dev.dev, - "Buffer %lld too small, need at least %lld\n", - buf->length, wblock->req_buf_size); - ret = -EINVAL; - goto out_ioctl; - } - /* if it's too big, warn, driver will only use what is needed */ - if (buf->length > wblock->req_buf_size) - dev_warn(&wblock->dev.dev, - "Buffer %lld is bigger than required %lld\n", - buf->length, wblock->req_buf_size); - - /* copy the structure from userspace */ - if (copy_from_user(buf, input, wblock->req_buf_size)) { - dev_dbg(&wblock->dev.dev, "Copy %llu from user failed\n", - wblock->req_buf_size); - ret = -EFAULT; - goto out_ioctl; - } - - /* let the driver do any filtering and do the call */ - wdriver = drv_to_wdrv(wblock->dev.dev.driver); - if (!try_module_get(wdriver->driver.owner)) { - ret = -EBUSY; - goto out_ioctl; - } - ret = wdriver->filter_callback(&wblock->dev, cmd, buf); - module_put(wdriver->driver.owner); - if (ret) - goto out_ioctl; - - /* return the result (only up to our internal buffer size) */ - if (copy_to_user(input, buf, wblock->req_buf_size)) { - dev_dbg(&wblock->dev.dev, "Copy %llu to user failed\n", - wblock->req_buf_size); - ret = -EFAULT; - } - -out_ioctl: - mutex_unlock(&wblock->char_mutex); - return ret; -} - -static const struct file_operations wmi_fops = { - .owner = THIS_MODULE, - .read = wmi_char_read, - .open = wmi_char_open, - .unlocked_ioctl = wmi_ioctl, - .compat_ioctl = compat_ptr_ioctl, -}; static int wmi_dev_probe(struct device *dev) { struct wmi_block *wblock = dev_to_wblock(dev); struct wmi_driver *wdriver = drv_to_wdrv(dev->driver); int ret = 0; - char *buf; if (ACPI_FAILURE(wmi_method_enable(wblock, true))) dev_warn(dev, "failed to enable device -- probing anyway\n"); @@ -996,55 +871,17 @@ static int wmi_dev_probe(struct device *dev) if (wdriver->probe) { ret = wdriver->probe(dev_to_wdev(dev), find_guid_context(wblock, wdriver)); - if (ret != 0) - goto probe_failure; - } - - /* driver wants a character device made */ - if (wdriver->filter_callback) { - /* check that required buffer size declared by driver or MOF */ - if (!wblock->req_buf_size) { - dev_err(&wblock->dev.dev, - "Required buffer size not set\n"); - ret = -EINVAL; - goto probe_failure; - } + if (!ret) { + if (ACPI_FAILURE(wmi_method_enable(wblock, false))) + dev_warn(dev, "Failed to disable device\n"); - wblock->handler_data = kmalloc(wblock->req_buf_size, - GFP_KERNEL); - if (!wblock->handler_data) { - ret = -ENOMEM; - goto probe_failure; - } - - buf = kasprintf(GFP_KERNEL, "wmi/%s", wdriver->driver.name); - if (!buf) { - ret = -ENOMEM; - goto probe_string_failure; - } - wblock->char_dev.minor = MISC_DYNAMIC_MINOR; - wblock->char_dev.name = buf; - wblock->char_dev.fops = &wmi_fops; - wblock->char_dev.mode = 0444; - ret = misc_register(&wblock->char_dev); - if (ret) { - dev_warn(dev, "failed to register char dev: %d\n", ret); - ret = -ENOMEM; - goto probe_misc_failure; + return ret; } } set_bit(WMI_PROBED, &wblock->flags); - return 0; -probe_misc_failure: - kfree(buf); -probe_string_failure: - kfree(wblock->handler_data); -probe_failure: - if (ACPI_FAILURE(wmi_method_enable(wblock, false))) - dev_warn(dev, "failed to disable device\n"); - return ret; + return 0; } static void wmi_dev_remove(struct device *dev) @@ -1054,12 +891,6 @@ static void wmi_dev_remove(struct device *dev) clear_bit(WMI_PROBED, &wblock->flags); - if (wdriver->filter_callback) { - misc_deregister(&wblock->char_dev); - kfree(wblock->char_dev.name); - kfree(wblock->handler_data); - } - if (wdriver->remove) wdriver->remove(dev_to_wdev(dev)); @@ -1131,7 +962,6 @@ static int wmi_create_device(struct device *wmi_bus_dev, if (wblock->gblock.flags & ACPI_WMI_METHOD) { wblock->dev.dev.type = &wmi_type_method; - mutex_init(&wblock->char_mutex); goto out_init; } diff --git a/include/linux/wmi.h b/include/linux/wmi.h index 8a643c39fcce..50f7f1e4fd4f 100644 --- a/include/linux/wmi.h +++ b/include/linux/wmi.h @@ -11,7 +11,6 @@ #include #include #include -#include /** * struct wmi_device - WMI device structure @@ -47,8 +46,6 @@ acpi_status wmidev_block_set(struct wmi_device *wdev, u8 instance, const struct u8 wmidev_instance_count(struct wmi_device *wdev); -extern int set_required_buffer_size(struct wmi_device *wdev, u64 length); - /** * struct wmi_driver - WMI driver structure * @driver: Driver model structure @@ -57,11 +54,8 @@ extern int set_required_buffer_size(struct wmi_device *wdev, u64 length); * @probe: Callback for device binding * @remove: Callback for device unbinding * @notify: Callback for receiving WMI events - * @filter_callback: Callback for filtering device IOCTLs * * This represents WMI drivers which handle WMI devices. - * @filter_callback is only necessary for drivers which - * want to set up a WMI IOCTL interface. */ struct wmi_driver { struct device_driver driver; @@ -71,8 +65,6 @@ struct wmi_driver { int (*probe)(struct wmi_device *wdev, const void *context); void (*remove)(struct wmi_device *wdev); void (*notify)(struct wmi_device *device, union acpi_object *data); - long (*filter_callback)(struct wmi_device *wdev, unsigned int cmd, - struct wmi_ioctl_buffer *arg); }; extern int __must_check __wmi_driver_register(struct wmi_driver *driver, From patchwork Thu Dec 7 22:26:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 175461 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5101136vqy; Thu, 7 Dec 2023 14:27:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdev7h+Rvq75qM1JqLYEo31mzringiZ5hfEtofNjJKOweJ2gCiwcnlAAkkcrbQ4rpu141m X-Received: by 2002:a05:6358:7e83:b0:16d:d0e7:e7ee with SMTP id o3-20020a0563587e8300b0016dd0e7e7eemr4064773rwn.28.1701988067903; Thu, 07 Dec 2023 14:27:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701988067; cv=none; d=google.com; s=arc-20160816; b=0g/IhdbGmcjHXfjarlI3hylzYSuATvEqgKBMVkeWtR1jPr2aFuQ2IbUAqOs+1Jmwb8 gtPMYpKLgcpTd4OFOhMWKl6i8gpFo5ikUc0WPWw4JXkbot//WvTJEU1rx2D4Z4U4kZ0Q FuZgA5GJ+Zlgs75I1EyMoQPNcpoD9au/zfwLgm+9TZyOviHaC74KdXvBJWe00+kDsM+0 +sXAilYEeDV52m8kHwHP04CSkXnotKABN7632fN0AynVCQR5ZRmTklIZnQbGqNWvbhCh I3OO1sNM5DZIoSmDIfXhqdokKvIBuPlIcf0OQQ4kkaEN3DYvwAH8kggOjThzBLqv1Q6A WCFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=a+2e/St1tb1ZqfjsIP6Gmw1PHIk69I66XxhTyOFHZS0=; fh=li8yxIESWfZR7lmBO8wCmgOg4WdXsWPyQvEuWPhaOvo=; b=rHJoDU22Z4B6ObkLrvWgvgQsvN9m4kse1vEXHW/GQlVfGJWt1Ol+iImPXOqRZogCRV PCWCxi1xAOnU6t7T7+uxVFvj2is3pd/p+zG72XGHTOi00SQkm+zfCTeNbCKvq6bfJRuv bbbmBdWpqzC9uaOwgqKmvd4lIefjNcLTAF9boqmI6Ntl7LLu3eGyAhQKWya5oyIc+tRD DwazsuW5wwODFgteGzMVN2bVEmT/NFCDddz2Pxar8eZJcT8i9yawWuZhqIJqweqJY9Vb FCSnIFQc1zZXkVlEwZ6sq1bQd4QSMT9cBV3ucw3LGk0A+bmlX71/o0rEmrpvX4eqyqtB Iu2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=II+4uhQ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id n8-20020a654508000000b005c5e279f40csi360897pgq.553.2023.12.07.14.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 14:27:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=II+4uhQ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A1238833AB0E; Thu, 7 Dec 2023 14:27:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235379AbjLGW1P (ORCPT + 99 others); Thu, 7 Dec 2023 17:27:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232430AbjLGW04 (ORCPT ); Thu, 7 Dec 2023 17:26:56 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BE591711; Thu, 7 Dec 2023 14:27:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1701988010; x=1702592810; i=w_armin@gmx.de; bh=16WGdSv1+wfNklniu4sIQ3a5/s+FjR905kU76pYmoek=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=II+4uhQ47c/heN/9/Kv9a3ubuYSXD6Bq3S2q8MW6tDrxQlf3RGaDxUzlik4/HLeg tnLaU20ueLBKeQluHIxlS+rEKEAOLdniLucywJR5TYR5zJtigo7CLMsroIHUtfTaU itp4JUnwjsBqDTwV6jTNeu9HEjkcPkMzP87YoQM+3atzXGj0IkebGwkNw0dxq7ks6 uKRmNTtyQI0c9hKJJ6OZCl7DkLbE1A1yqUKcb3Wu34yeC1ZeFKj2bQ93KHBpDtQb/ oTRvmIek9VL32T/mxZg9TAyov9pv0jeSTO7KMHgEvkinqo2Kx8xpcpjr6PLGiYEN7 aO2CEXlhDzs+iXSVLQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M9Wuk-1r852z3pQK-005aLd; Thu, 07 Dec 2023 23:26:49 +0100 From: Armin Wolf To: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, corbet@lwn.net Cc: Dell.Client.Kernel@dell.com, linux-doc@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] platform/x86: wmi: Add driver development guide Date: Thu, 7 Dec 2023 23:26:23 +0100 Message-Id: <20231207222623.232074-6-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231207222623.232074-1-W_Armin@gmx.de> References: <20231207222623.232074-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:2qa6zIdjybo5q629oAtjbiXMkCrTpt+gIGIfAX5ZpzSG5Dy44i5 Ip69bUk3E+GN/Xq4ChdcANtHh0/d0jtCb89eKTap7xeSlJIc74+Ei+050cM3LBj1MDljV+Z FItLSj84qZuaaM7DhpAK26XJdpiS2yybmflZ7+2UycBM2RL7VdH3anbhcXzMd+sE2TxMBPu e8KkQKe/twR+19lTu6JQw== UI-OutboundReport: notjunk:1;M01:P0:YQBEAL5gS1I=;qafX62ughQgYefvaW5PcGYW4NfN og+e4JKSRBWlhZ+OfbVcii/qfl4wcX8eIdFMi2w2wMrzCZor84RvRBHnemYFKbfnkmSVFgoml C7XIWRfFsQI1mEgakfDV3k1D96l+++AX8XX+rBxUlQvvNemDgwbGdgFS5M06OpGcxJKEHLXiV rPs7Jpa4AWkedthXHLWelgt5aXncx+FAtGPpHqqOUyTT6j2BxRowgU4PSvQVvRN8+SUGyXS/e XBdIpSqsPTjpE2PjNZVZ1JT3w1EHOedSmbb/MXsehBcn48qFMLKpa5D00DZFK8e9pj62b435h fK7KcJiS1PYLYz3XqJtArvtNJL9QeTKttyEoINGVMDip9hD1ngWcMQBwEYm7ytr34iiF/xohJ gbHkLRoDRsHiN3LVV1Spt2lo+KRLLWN1cLtwcYq5vqNMUMuX1koeC/C6+c6OgnsusXjvk+Hdt Jm1AZoJMSnYPGIM/zm2HefApjtKsTaqQ52BzbnxkNfmHVUhKFk60cqnluOO2MUr5Ry5P4oA4R /i9MkVeW/gmiJHCy4ds/EbNEigcK6A96a+DCEfg6lImwsuVMJuyGw1Q35ztZPDR5prulsCG1J arwVf8LMJzl40Ahz3bfJTUgzyxiHlmI1T3pohUoYW0mVpxsKxSCiI3gotHKTTidTaEg8r2UFs KCY51v3PUF0Zeoj6VTDDuuWdwYc+Y5WkEQe/bc0+/TZ+tfs7Tmf4enWudvqC1nua97TUiXAU0 F+MsDvOFhKDbt2QEnRrS5o16l5hKVYyZOnP6y/sE96On9rSWTTuwC26DVad4sATQgjJveoKMM AdH5vfeES8EFxlQWrR/rJjiBIBZwKLIifBNGj8LLGdcE1vUZF8g2kR8pETdSnW0xHkaKmhDJI tSYIARd1aMbxoA2WnkB8H38UdaI2bs+NgPuT+chcz0azkqIbs35JWSGmnlj21PEo8nMNh7Dx/ 0/hBR8+q2msPyIDnSHB0tOGwonQ= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 07 Dec 2023 14:27:44 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784663840432047873 X-GMAIL-MSGID: 1784663840432047873 Since 2010, an LWN article covering WMI drivers exists: https://lwn.net/Articles/391230/ Since the introduction of the modern bus-based interface and other userspace tooling (fwts wmi, bmfdec, ...), this article is outdated and causes people to still submit new WMI drivers using the deprecated GUID-based interface. Fix this by adding a short guid on how to develop WMI drivers using the modern bus-based interface. Signed-off-by: Armin Wolf --- .../wmi/driver-development-guide.rst | 126 ++++++++++++++++++ Documentation/wmi/index.rst | 1 + 2 files changed, 127 insertions(+) create mode 100644 Documentation/wmi/driver-development-guide.rst -- 2.39.2 diff --git a/Documentation/wmi/driver-development-guide.rst b/Documentation/wmi/driver-development-guide.rst new file mode 100644 index 000000000000..a831e2728d25 --- /dev/null +++ b/Documentation/wmi/driver-development-guide.rst @@ -0,0 +1,126 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +============================ +WMI driver development guide +============================ + +The WMI subsystem provides a rich driver api for implementing WMI drivers, +documented at Documentation/driver-api/wmi.rst. This document will serve +as an introductory guide for WMI driver writers using this API. It is supposed +t be an successor to the original `LWN article `_ +which deals with WMI drivers using the deprecated GUID-based WMI interface. + +Optaining WMI device information +-------------------------------- + +Before developing an WMI driver, information about the WMI device in question +must be optained. The `lswmi `_ utility can be +used to display detailed WMI device information using the following command: + +:: + + lswmi -V + +The resulting output will contain information about all WMI devices inside a given +machine, plus some extra information. + +In order to find out more about the interface used to communicate with a WMI device, +the `bmfdec `_ utilities can be used to decode +the Binary MOF information used to describe WMI devices. The ``wmi-bmof`` driver +exposes this information to userspace, see Documentation/ABI/stable/sysfs-platform-wmi-bmof. +In order to retrieve the decoded Binary MOF information, use the following command (requires root): + +:: + + ./bmf2mof /sys/bus/wmi/devices/05901221-D566-11D1-B2F0-00A0C9062910[-X]/bmof + +Sometimes, looking at the disassembled ACPI tables used to describe the WMI device +helps in understanding how the WMI device is supposed to work. To find out which +ACPI method handles which WMI device, the `fwts `_ +program can be used with the following command (requires root): + +:: + + fwts wmi - + +Basic WMI driver structure +-------------------------- + +The basic WMI driver is build around the struct wmi_driver, which is then bound +to matching WMI devices using an struct wmi_device_id table. Please note that each +WMI driver should be able to be instantiated multiple times. + +:: + + static const struct wmi_device_id foo_id_table[] = { + { "936DA01F-9ABD-4D9D-80C7-02AF85C822A8", NULL }, + { } + }; + MODULE_DEVICE_TABLE(wmi, foo_id_table); + + static struct wmi_driver foo_driver = { + .driver = { + .name = "foo", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, /* optional */ + .pm = pm_sleep_ptr(&foo_dev_pm_ops), /* optional */ + }, + .id_table = foo_id_table, + .probe = foo_probe, + .remove = foo_remove, /* optional, devres is preferred */ + .notify = foo_notify, /* optional, for event handling */ + }; + module_wmi_driver(foo_driver); + +If your WMI driver is not using any deprecated GUID-based WMI functions and is +able to be instantiated multiple times, please add its GUID to ``allow_duplicates`` +inside drivers/platform/x86/wmi.c, so that the WMI subsystem does not block duplicate +GUIDs for it. + +WMI method drivers +------------------ + +WMI drivers can call WMI device methods using wmidev_evaluate_method(), the +structure of the ACPI buffer passed to this function is device-specific and usually +needs some tinkering to get right. Looking at the ACPI tables containing the WMI +device usually helps here. The method id and instance number passed to this function +are also device-specific, looking at the decoded Binary MOF is usually enough to +find the right values. +The maximum instance number can be retrieved during runtime using wmidev_instance_count(). + +Take a look at drivers/platform/x86/inspur_platform_profile.c for an example WMI method driver. + +WMI data block drivers +---------------------- + +WMI drivers can query WMI device data blocks using wmidev_block_query(), the +structure of the returned ACPI object is again device-specific. Some WMI devices +also allow for setting data blocks using wmidev_block_set(). +The maximum instance number can also be retrieved using wmidev_instance_count(). + +Take a look at drivers/platform/x86/intel/wmi/sbl-fw-update.c for an example +WMI data block driver. + +WMI event drivers +----------------- + +WMI drivers can receive WMI event notifications by providing the notify() callback +inside the struct wmi_driver. The WMI subsystem will then take care of setting +up the WMI event accordingly. Plase note that the ACPI object passed to this callback +is optional and its structure device-specific. It also does not need to be freed, +the WMI subsystem takes care of that. + +Take a look at drivers/platform/x86/xiaomi-wmi.c for an example WMI event driver. + +Things to avoid +--------------- + +When developing WMI drivers, there are a couple of things which should be avoid +if feasible: + +- usage of the deprecated GUID-based WMI interface +- bypassing of the WMI subsystem when talking to WMI devices +- WMI drivers which cannot be instantiated multiple times. + +Many older WMI drivers violate one or more points from this list. The reason for +this is that the WMI subsystem evolved significantly over the last two decades, +so there is a lot of legacy cruft inside older WMI drivers. diff --git a/Documentation/wmi/index.rst b/Documentation/wmi/index.rst index 537cff188e14..fec4b6ae97b3 100644 --- a/Documentation/wmi/index.rst +++ b/Documentation/wmi/index.rst @@ -8,6 +8,7 @@ WMI Subsystem :maxdepth: 1 acpi-interface + driver-development-guide devices/index .. only:: subproject and html