From patchwork Wed Apr 26 21:28:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 87990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp516491vqo; Wed, 26 Apr 2023 14:31:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YULBfbLU20fIB0ULSkNy1u5bHFdXfXLzk9h7dNXcQYfQLCg2OpOWWwtbmI19xuFZRyDelz X-Received: by 2002:a05:6a21:100e:b0:ef:166a:acf9 with SMTP id nk14-20020a056a21100e00b000ef166aacf9mr23500008pzb.43.1682544665983; Wed, 26 Apr 2023 14:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682544665; cv=none; d=google.com; s=arc-20160816; b=s2cCoSqWkZL6+sS3UJqhkrzIM2EcUuDqjEmGtrx92zVTkjT8N245Oz4ZaNgUf8DoSc 7UfTHPsuhUPcyO0Oj/kBqY0tUEY++dGjGuD2kMQfXMJw9smht6uMa/fgv7Li9Xqo/A68 xza5rMtbCgwV6TdtMOyvtetfB1IEl3cZJjv/kk6a/BB4RFdtq00Bn54tuLoW99OE1N/J hEmfZhljNFYUu1LpUSbbsqrlegBx1D/8hdkQm7nCUcTliju/6MD+oUx4XjijM/PezLDq hBaHzIjtM0y2/dWoaWF6VJC9Otii/Aro0IadG44DJhbMWpU6Td6TOFnezmTgngjd4xg8 KWIg== 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=NlCtZCWJk00XcmpY7mjl7ud+19dOFERAGe9N+5rmtQ8=; b=THwsmcS0tdfLd+bmzVnOi1hr9lAWOVhkTLlyMXgt9hDe01gZOc6HpDb+NeyR2krIw4 os+O4oL/QZxhQs3e9VOAMwZmAXCspVLbKj5ll7cL2g5Mmda5qnncnQOj2k2Qy0zp/Vge 8NKlzYfKwEBHa0d3BPzVN9PHU1KUQOWTU4TNBCIFVQw0DRRdwBxRQLMxliYHL/BXB6Zk gaHTwI9XMGeLFpEyGyA7jlpYOXgCqR70gjuPxs/E+5F58kNQghIe5qkmnBZ6ubaPrz2n YquPMJxx0SGCEvk9AzQQah32rHiaH+BAQBReEUYJ3tmC4Bp36nvuo9DAC697yyDtlvoU zXGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=c+jhaqnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a63eb0a000000b0052069c10102si17058585pgh.75.2023.04.26.14.30.49; Wed, 26 Apr 2023 14:31:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=c+jhaqnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239871AbjDZV3Z (ORCPT + 99 others); Wed, 26 Apr 2023 17:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239843AbjDZV3X (ORCPT ); Wed, 26 Apr 2023 17:29:23 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C77943AB3; Wed, 26 Apr 2023 14:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1682544537; i=w_armin@gmx.de; bh=/NvD9oCO/r0GrFnR01vAe+1hQd5sbYS115i1sHjdYVU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=c+jhaqnQYsjNniJayHeKrbysCjrX6izuZRB7X9qDmVdBKK9hpSqjEFA7rtMXwo0Wt pAqYg9mBuGr1WTvKZUGZVHu22FhInlnnyUpDC/46yQJ7iWFCewruJaovn1fXBNkzpp Vvhn4q6a4kJ9Xs/ZIuUiBCT7b1XKcyGWEYxCYMY0z7ts26Clwb7MBJBGIXg4Sr3w/w j1jOWPnfGJdfkkJ/MPjpYr4DvikFiYdxaft8Osn9IcPImU/4uZki6lYLEbowqr6wKc OUuEI9COjPM0xzlLiTB/e9MEEN72vXsEQQ6BZNP6JYApj94hAMwJSezYrNu9UgjHIi hznPILmWgMRTQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MAfUe-1pyQXR1NzE-00B300; Wed, 26 Apr 2023 23:28:57 +0200 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: Mario.Limonciello@amd.com, prasanth.ksr@dell.com, jorgealtxwork@gmail.com, james@equiv.tech, Dell.Client.Kernel@dell.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC v2 1/2] platform/x86: wmi: Allow retrieving the number of WMI object instances Date: Wed, 26 Apr 2023 23:28:47 +0200 Message-Id: <20230426212848.108562-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230426212848.108562-1-W_Armin@gmx.de> References: <20230426212848.108562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/1nT3+mD7F5KYF84DpAtJT+C0oErXH08ZfbRkrBq/cU/swp fcC6icx1JqLTgUbzLKWM6g37hk4HjJawLTfiVJoGBocKb/TdcxBIcg/NIeYFtLWLMhezOgRjA WVeOHwUgSQvBqAGuUYSz8dHQPRyRnGXJePm2AIqCQuUBPq3jLnyUYFZ55l6h41mlcuwaMwkAO uEGMVvA65cQQbvsZMVFccwYOXIQ= 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_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764275955560859992?= X-GMAIL-MSGID: =?utf-8?q?1764275955560859992?= Currently, the WMI driver core knows how many instances of a given WMI object exist, but WMI drivers cannot access this information. At the same time, some current and upcoming WMI drivers want to have access to this information. Add wmi_instance_count() and wmidev_instance_count() to allow WMI drivers to get the number of WMI object instances. Signed-off-by: Armin Wolf Tested-by: James Seo --- drivers/platform/x86/wmi.c | 40 ++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 2 ++ include/linux/wmi.h | 2 ++ 3 files changed, 44 insertions(+) -- 2.30.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index c226dd4163a1..7c1a904dec5f 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -263,6 +263,46 @@ int set_required_buffer_size(struct wmi_device *wdev, u64 length) } 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 + * @instance_count: variable to hold the instance count + * + * Get the number of WMI object instances. + * + * Returns: acpi_status signaling success or error. + */ +acpi_status wmi_instance_count(const char *guid_string, u8 *instance_count) +{ + struct wmi_block *wblock; + acpi_status status; + + status = find_guid(guid_string, &wblock); + if (ACPI_FAILURE(status)) + return status; + + *instance_count = wmidev_instance_count(&wblock->dev); + + return AE_OK; +} +EXPORT_SYMBOL_GPL(wmi_instance_count); + +/** + * wmidev_instance_count - Get number of WMI object instances + * @wdev: A wmi bus device from a driver + * + * Get the number of WMI object instances. + * + * Returns: Number of WMI object instances. + */ +u8 wmidev_instance_count(struct wmi_device *wdev) +{ + struct wmi_block *wblock = container_of(wdev, struct wmi_block, dev); + + return wblock->gblock.instance_count; +} +EXPORT_SYMBOL_GPL(wmidev_instance_count); + /** * wmi_evaluate_method - Evaluate a WMI method (deprecated) * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba diff --git a/include/linux/acpi.h b/include/linux/acpi.h index efff750f326d..ab2a4b23e7a3 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -412,6 +412,8 @@ extern bool acpi_is_pnp_device(struct acpi_device *); typedef void (*wmi_notify_handler) (u32 value, void *context); +acpi_status wmi_instance_count(const char *guid, u8 *instance_count); + extern acpi_status wmi_evaluate_method(const char *guid, u8 instance, u32 method_id, const struct acpi_buffer *in, diff --git a/include/linux/wmi.h b/include/linux/wmi.h index c1a3bd4e4838..763bd382cf2d 100644 --- a/include/linux/wmi.h +++ b/include/linux/wmi.h @@ -35,6 +35,8 @@ extern acpi_status wmidev_evaluate_method(struct wmi_device *wdev, extern union acpi_object *wmidev_block_query(struct wmi_device *wdev, u8 instance); +u8 wmidev_instance_count(struct wmi_device *wdev); + extern int set_required_buffer_size(struct wmi_device *wdev, u64 length); /** From patchwork Wed Apr 26 21:28:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 87991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp516643vqo; Wed, 26 Apr 2023 14:31:23 -0700 (PDT) X-Google-Smtp-Source: AKy350Z5EB8Wmgi7PDMrUDLqDIjmrXmiDMPWHvG+lJ72is7dLKw1RVeBmxxHnrtswFjmIsjR0Iod X-Received: by 2002:a05:6a20:3d1b:b0:f0:3724:a9b0 with SMTP id y27-20020a056a203d1b00b000f03724a9b0mr29179881pzi.3.1682544682926; Wed, 26 Apr 2023 14:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682544682; cv=none; d=google.com; s=arc-20160816; b=lmo71xyjxYqIuFlceG7lDWYEmMExC1oiWnRb/I89ZOPQ52uzcG9a1IAzMS3TauoZwd +Ev2FdVZr9hvF6ArAbfS9FmWnwivNreeJoecLHuoMcDYiCgFMp03d1r3enXTPOQUoAGZ WSCy8UwWk+fYrQqfYayd35hpI5J6MhMUN/pq/VP9Euj4pdGgtQCv4pLJXIyh+b/lU31U 50fAENa+UkKi3IHGfQThkZ6BWHUqEo/mxeYd/j5ElsWESiEpUkfDIk9YjrHQeDq/dofq 3TnhLrbFF6AU3Z9klSA5WkBr50SGS+WYmDllxjtRzEGCqyC3L1sOZVhKYEBa1pfVV+dB cmTA== 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=0N0VoagqnDF2dXw109/DOG5Y4839yAXWcDIwsE7XeQs=; b=nVtYTCTA3Xy2ndz181++ltAmetArnnIgijBwhFV0+AXDeCSbdx1hBKW1dR9ZEZENiY r5gFzW01JP7yOk3T9TYW9jlnZHTNmX8KBdQrR2NS9doz2YztYQ1KvK3tb1gmsSuI/ONP ODuR+p4ZQPc4E24FdAuELZ2Wga3jblxTHYCOnTTxVSIkbje0WgkF4J6yNrMGLmPg6z6b 5c/RVI8/i8/Ht/AL5YNwBigDAIRPugfF6HZuVR9JIp7he1FBWDShCe+19sQBBQPyYmzw O4JeYeU/+3CeknTN10RAu3fbSj4p+CiYWTEu9pp0DUswajaLx64O9qJ8Q0Zq4RpYIsAY DczQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=d9hJlwlL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a63f34a000000b0051a8a22a43csi17010470pgj.450.2023.04.26.14.31.07; Wed, 26 Apr 2023 14:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=d9hJlwlL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239947AbjDZV3j (ORCPT + 99 others); Wed, 26 Apr 2023 17:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239910AbjDZV3Z (ORCPT ); Wed, 26 Apr 2023 17:29:25 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B5243ABD; Wed, 26 Apr 2023 14:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1682544539; i=w_armin@gmx.de; bh=w0oARY4CbAc6zKzf6JtPUqR+03JXON4Kw0RqkAkLgZI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=d9hJlwlLij5eF36umbIBVFK1ufeo6ydGXvSRfiW9vjLWfbFReHH0jCwDhoQwwDvGK pMBytG46itblNlVvH3+58y5xaM0MHrGYva3Qu3ZSxxMielMa0A9nNYiChTwDWaOiNY tNn5+TpVEhayv8D4AhC06Ibjsctg6InLVrTrqrhVb4vji8nHV0f4HoaypXuVSBsGj/ bh6RruEPeGaGqNPPBLUJN5jXQRcNjwf0xYMnn4VZFtwht08nN2HvWV0cGBlEMcwC9b RNas4EDYqupdX6DL234VQt/f/TD5HNAP9UCzEtBi9ORaIJ0C/8jhADFsR7n0/ZDGLz M40As4pDXb1rA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MDywu-1q1iKV2b6i-009ybF; Wed, 26 Apr 2023 23:28:59 +0200 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: Mario.Limonciello@amd.com, prasanth.ksr@dell.com, jorgealtxwork@gmail.com, james@equiv.tech, Dell.Client.Kernel@dell.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC v2 2/2] platform/x86: dell-sysman: Improve instance detection Date: Wed, 26 Apr 2023 23:28:48 +0200 Message-Id: <20230426212848.108562-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230426212848.108562-1-W_Armin@gmx.de> References: <20230426212848.108562-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:4q9pu12CWhdJrKzj8Vw67SJ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0eGOeuMSzlrPOYEGGDmD62Fn+au3gGslRMkilDNKhxdgoi2TWbXd4oNb1xbXC eyr3OecMk2ciGFRvi0P0t7W/4wUf2Sx0wPIDP/Zb2lJYyr+MpmDzwRXhKzoJfoOFqwpaILheP +m/pOPgVkBLzOoCiu6QA2PF5ueM= 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_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764275973167542678?= X-GMAIL-MSGID: =?utf-8?q?1764275973167542678?= The WMI driver core already knows how many WMI object instances are available, use this information instead of probing the WMI object manually. Compile-tested only. Signed-off-by: Armin Wolf --- .../platform/x86/dell/dell-wmi-sysman/sysman.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) -- 2.30.2 diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index 0285b47d99d1..526d60b510bb 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -7,6 +7,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -303,16 +304,14 @@ union acpi_object *get_wmiobj_pointer(int instance_id, const char *guid_string) */ int get_instance_count(const char *guid_string) { - union acpi_object *wmi_obj = NULL; - int i = 0; + acpi_status status; + u8 instance_count; - do { - kfree(wmi_obj); - wmi_obj = get_wmiobj_pointer(i, guid_string); - i++; - } while (wmi_obj); + status = wmi_instance_count(guid_string, &instance_count); + if (ACPI_FAILURE(status)) + return 0; - return (i-1); + return instance_count; } /**