All of lore.kernel.org
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: jithu.joseph@intel.com, linux@weissschuh.net, pali@kernel.org
Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com,
	Dell.Client.Kernel@dell.com, jdelvare@suse.com,
	linux@roeck-us.net, platform-driver-x86@vger.kernel.org,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] platform/x86: wmi: Ignore duplicated GUIDs in legacy matches
Date: Mon, 26 Feb 2024 20:35:55 +0100	[thread overview]
Message-ID: <20240226193557.2888-1-W_Armin@gmx.de> (raw)

When matching a WMI device to a GUID used by the legacy GUID-based
API, devices with a duplicated GUID should be ignored.

Add an additional WMI device flag signaling that the GUID used by
the WMI device is also used by another WMI device. Ignore such
devices inside the match functions used by the legacy GUID-based API.

Tested on a ASUS Prime B650-Plus.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/platform/x86/wmi.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index abd0183c4107..29dfe52eb802 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -57,6 +57,7 @@ static_assert(__alignof__(struct guid_block) == 1);

 enum {	/* wmi_block flags */
 	WMI_READ_TAKES_NO_ARGS,
+	WMI_GUID_DUPLICATED,
 	WMI_NO_EVENT_DATA,
 };

@@ -196,6 +197,12 @@ static int wmidev_match_guid(struct device *dev, const void *data)
 	struct wmi_block *wblock = dev_to_wblock(dev);
 	const guid_t *guid = data;

+	/* Legacy GUID-based functions are restricted to only see
+	 * a single WMI device for each GUID.
+	 */
+	if (test_bit(WMI_GUID_DUPLICATED, &wblock->flags))
+		return 0;
+
 	if (guid_equal(guid, &wblock->gblock.guid))
 		return 1;

@@ -207,6 +214,12 @@ static int wmidev_match_notify_id(struct device *dev, const void *data)
 	struct wmi_block *wblock = dev_to_wblock(dev);
 	const u32 *notify_id = data;

+	/* Legacy GUID-based functions are restricted to only see
+	 * a single WMI device for each GUID.
+	 */
+	if (test_bit(WMI_GUID_DUPLICATED, &wblock->flags))
+		return 0;
+
 	if (wblock->gblock.flags & ACPI_WMI_EVENT && wblock->gblock.notify_id == *notify_id)
 		return 1;

@@ -1036,10 +1049,12 @@ static int wmi_create_device(struct device *wmi_bus_dev,
 	wblock->dev.dev.parent = wmi_bus_dev;

 	count = guid_count(&wblock->gblock.guid);
-	if (count)
+	if (count) {
 		dev_set_name(&wblock->dev.dev, "%pUL-%d", &wblock->gblock.guid, count);
-	else
+		set_bit(WMI_GUID_DUPLICATED, &wblock->flags);
+	} else {
 		dev_set_name(&wblock->dev.dev, "%pUL", &wblock->gblock.guid);
+	}

 	device_initialize(&wblock->dev.dev);

--
2.39.2


             reply	other threads:[~2024-02-26 19:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 19:35 Armin Wolf [this message]
2024-02-26 19:35 ` [PATCH 2/3] platform/x86: wmi: Do not instantiate older WMI drivers multiple times Armin Wolf
2024-02-27 20:30   ` Pali Rohár
2024-02-27 22:47     ` Armin Wolf
2024-02-27 22:53       ` Pali Rohár
2024-02-28 13:23       ` Hans de Goede
2024-02-28 20:40         ` Armin Wolf
2024-02-26 19:35 ` [PATCH 3/3] platform/x86: wmi: Remove obsolete duplicate GUID allowlist Armin Wolf
2024-02-27 13:05   ` Ilpo Järvinen
2024-02-27 22:55 ` [PATCH 1/3] platform/x86: wmi: Ignore duplicated GUIDs in legacy matches Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240226193557.2888-1-W_Armin@gmx.de \
    --to=w_armin@gmx.de \
    --cc=Dell.Client.Kernel@dell.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jdelvare@suse.com \
    --cc=jithu.joseph@intel.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=linux@weissschuh.net \
    --cc=pali@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.