mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>
Cc: Saket Dumbre <saket.dumbre@intel.com>,
	Len Brown <lenb@kernel.org>,
	"open list:ACPI COMPONENT ARCHITECTURE (ACPICA)"
	<linux-acpi@vger.kernel.org>,
	"open list:ACPI COMPONENT ARCHITECTURE (ACPICA)"
	<acpica-devel@lists.linux.dev>,
	open list <linux-kernel@vger.kernel.org>,
	Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH v2] ACPI: utils: Ignore leading root scope prefix in string _UID match
Date: Mon, 7 Sep 2026 23:31:24 -0500	[thread overview]
Message-ID: <20260908043124.53175-1-mario.limonciello@amd.com> (raw)

Firmware may express an ACPI namespace path used as a _UID with or
without the leading root scope character ('\'). For example, an AMD
IVRS IVHD ACPI HID device entry may carry a character UID of
"\_SB.MHSP" while the corresponding device's _UID evaluates to
"_SB.MHSP" (or vice versa).  This semantic difference is due to how
Windows PnP enumerates and uses devices.

acpi_str_uid_match() compared the two strings verbatim, so such
entries failed to match on the UID even though they refer to the same
object. In the AMD IOMMU case (get_acpihid_device_id()) this caused
the exact HID+UID match to be missed and the code to fall through to
the HID-only path, spuriously raising a FW_BUG.

Skip a single leading '\' on either string before comparing so that
paths that differ only by the root scope prefix are treated as a
match. The integer _UID path is unaffected.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v2:
 * Add kdoc
 * Make sure the string is at least two characters long to normalize
---
 include/acpi/acpi_bus.h | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index a10a591c18b23..cfc3c8a21cb8e 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -826,11 +826,29 @@ static inline bool acpi_dev_hid_match(struct acpi_device *adev, const char *hid2
 	return hid1 && hid2 && !strcmp(hid1, hid2);
 }
 
+/**
+ * acpi_str_uid_match - Compare ACPI string _UID values
+ * @adev: ACPI device providing the primary _UID
+ * @uid2: Secondary _UID string to check against
+ *
+ * Returns true when both _UID strings match after optionally removing a
+ * leading root scope character ('\') when the string contains additional
+ * characters. Returns false if either _UID is missing or differs after the
+ * normalization.
+ */
 static inline bool acpi_str_uid_match(struct acpi_device *adev, const char *uid2)
 {
 	const char *uid1 = acpi_device_uid(adev);
 
-	return uid1 && uid2 && !strcmp(uid1, uid2);
+	if (!uid1 || !uid2)
+		return false;
+
+	if (*uid1 == '\\' && uid1[1])
+		uid1++;
+	if (*uid2 == '\\' && uid2[1])
+		uid2++;
+
+	return !strcmp(uid1, uid2);
 }
 
 static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2)
-- 
2.43.0


             reply	other threads:[~2026-09-08  4:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  4:31 Mario Limonciello [this message]
2026-09-08 12:07 ` Rafael J. Wysocki (Intel)

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=20260908043124.53175-1-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=acpica-devel@lists.linux.dev \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=saket.dumbre@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®