* [PATCH] iommu/amd: Allow matching ACPI HID devices without matching UIDs
@ 2025-04-24 4:53 Mario Limonciello
2025-04-25 4:59 ` Suthikulpanit, Suravee
0 siblings, 1 reply; 3+ messages in thread
From: Mario Limonciello @ 2025-04-24 4:53 UTC (permalink / raw)
To: mario.limonciello, joro, will; +Cc: Vasant.Hegde, iommu
From: Mario Limonciello <mario.limonciello@amd.com>
A BIOS upgrade has changed the IVRS DTE UID for a device that no
longer matches the UID in the SSDT. Checking with BIOS team, this is
intended behavior, however it breaks the existing logic check in
get_acpihid_device_id().
In this case there is only one ACPI device on the system with that _HID
but the _UID mismatch.
IVRS:
```
[1E4h 0484 001h] Subtable Type : F0 [Device Entry: ACPI HID Named Device]
[1E5h 0485 002h] Device ID : 0060
[1E7h 0487 001h] Data Setting (decoded below) : 40
INITPass : 0
EIntPass : 0
NMIPass : 0
Reserved : 0
System MGMT : 0
LINT0 Pass : 1
LINT1 Pass : 0
[1E8h 0488 008h] ACPI HID : "MSFT0201"
[1F0h 0496 008h] ACPI CID : 0000000000000000
[1F8h 0504 001h] UID Format : 02
[1F9h 0505 001h] UID Length : 09
[1FAh 0506 009h] UID : "\_SB.MHSP"
```
SSDT:
```
Device (MHSP)
{
Name (_ADR, Zero) // _ADR: Address
Name (_HID, "MSFT0201") // _HID: Hardware ID
Name (_UID, One) // _UID: Unique ID
```
To handle this case; while enumerating ACPI devices in get_acpihid_device_id()
count the number of matching ACPI devices with a matching _HID. If there is
exactly one _HID match then accept it even if the UID doesn't match.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/iommu/amd/iommu.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index b19e8c0f48fa2..f9fad07edeeb7 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -109,7 +109,8 @@ static inline int get_acpihid_device_id(struct device *dev,
struct acpihid_map_entry **entry)
{
struct acpi_device *adev = ACPI_COMPANION(dev);
- struct acpihid_map_entry *p;
+ struct acpihid_map_entry *p, *p1;
+ int hid_count = 0;
if (!adev)
return -ENODEV;
@@ -117,12 +118,25 @@ static inline int get_acpihid_device_id(struct device *dev,
list_for_each_entry(p, &acpihid_map, list) {
if (acpi_dev_hid_uid_match(adev, p->hid,
p->uid[0] ? p->uid : NULL)) {
- if (entry)
- *entry = p;
- return p->devid;
+ p1 = p;
+ hid_count = 1;
+ break;
+ }
+
+ /* If there is no UID match, but exactly one HID match, return that match */
+ if (acpi_dev_hid_match(adev, p->hid)) {
+ p1 = p;
+ hid_count++;
}
}
- return -EINVAL;
+
+ if (hid_count != 1)
+ return -EINVAL;
+
+ if (entry)
+ *entry = p1;
+
+ return p1->devid;
}
static inline int get_device_sbdf_id(struct device *dev)
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] iommu/amd: Allow matching ACPI HID devices without matching UIDs
2025-04-24 4:53 [PATCH] iommu/amd: Allow matching ACPI HID devices without matching UIDs Mario Limonciello
@ 2025-04-25 4:59 ` Suthikulpanit, Suravee
2025-04-25 5:13 ` Mario Limonciello
0 siblings, 1 reply; 3+ messages in thread
From: Suthikulpanit, Suravee @ 2025-04-25 4:59 UTC (permalink / raw)
To: Mario Limonciello, mario.limonciello, joro, will; +Cc: Vasant.Hegde, iommu
Mario,
This is actually a bug in the BIOS, and should be fixed in by the BIOS.
I would prefer FW BUG in the dmesg to report the issue.
As a workarond, Linux can override this using the command line option.
Suravee
On 4/24/2025 11:53 AM, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> A BIOS upgrade has changed the IVRS DTE UID for a device that no
> longer matches the UID in the SSDT. Checking with BIOS team, this is
> intended behavior, however it breaks the existing logic check in
> get_acpihid_device_id().
>
> In this case there is only one ACPI device on the system with that _HID
> but the _UID mismatch.
>
> IVRS:
> ```
> [1E4h 0484 001h] Subtable Type : F0 [Device Entry: ACPI HID Named Device]
> [1E5h 0485 002h] Device ID : 0060
> [1E7h 0487 001h] Data Setting (decoded below) : 40
> INITPass : 0
> EIntPass : 0
> NMIPass : 0
> Reserved : 0
> System MGMT : 0
> LINT0 Pass : 1
> LINT1 Pass : 0
> [1E8h 0488 008h] ACPI HID : "MSFT0201"
> [1F0h 0496 008h] ACPI CID : 0000000000000000
> [1F8h 0504 001h] UID Format : 02
> [1F9h 0505 001h] UID Length : 09
> [1FAh 0506 009h] UID : "\_SB.MHSP"
> ```
>
> SSDT:
> ```
> Device (MHSP)
> {
> Name (_ADR, Zero) // _ADR: Address
> Name (_HID, "MSFT0201") // _HID: Hardware ID
> Name (_UID, One) // _UID: Unique ID
> ```
>
> To handle this case; while enumerating ACPI devices in get_acpihid_device_id()
> count the number of matching ACPI devices with a matching _HID. If there is
> exactly one _HID match then accept it even if the UID doesn't match.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/iommu/amd/iommu.c | 24 +++++++++++++++++++-----
> 1 file changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index b19e8c0f48fa2..f9fad07edeeb7 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -109,7 +109,8 @@ static inline int get_acpihid_device_id(struct device *dev,
> struct acpihid_map_entry **entry)
> {
> struct acpi_device *adev = ACPI_COMPANION(dev);
> - struct acpihid_map_entry *p;
> + struct acpihid_map_entry *p, *p1;
> + int hid_count = 0;
>
> if (!adev)
> return -ENODEV;
> @@ -117,12 +118,25 @@ static inline int get_acpihid_device_id(struct device *dev,
> list_for_each_entry(p, &acpihid_map, list) {
> if (acpi_dev_hid_uid_match(adev, p->hid,
> p->uid[0] ? p->uid : NULL)) {
> - if (entry)
> - *entry = p;
> - return p->devid;
> + p1 = p;
> + hid_count = 1;
> + break;
> + }
> +
> + /* If there is no UID match, but exactly one HID match, return that match */
> + if (acpi_dev_hid_match(adev, p->hid)) {
> + p1 = p;
> + hid_count++;
> }
> }
> - return -EINVAL;
> +
> + if (hid_count != 1)
> + return -EINVAL;
> +
> + if (entry)
> + *entry = p1;
> +
> + return p1->devid;
> }
>
> static inline int get_device_sbdf_id(struct device *dev)
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] iommu/amd: Allow matching ACPI HID devices without matching UIDs
2025-04-25 4:59 ` Suthikulpanit, Suravee
@ 2025-04-25 5:13 ` Mario Limonciello
0 siblings, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2025-04-25 5:13 UTC (permalink / raw)
To: Suthikulpanit, Suravee, mario.limonciello, joro, will
Cc: Vasant.Hegde, iommu, Blinzer, Paul
On 4/24/2025 11:59 PM, Suthikulpanit, Suravee wrote:
> Mario,
>
> This is actually a bug in the BIOS, and should be fixed in by the BIOS.
> I would prefer FW BUG in the dmesg to report the issue.
>
> As a workarond, Linux can override this using the command line option.
>
> Suravee
+Paul
Suravee,
This was my initial inclination as well. We actually had a test BIOS
that lines up the SSDT and IVRS which fixes Linux but it causes problems
outside of Linux.
Paul clarified that UID matching should be considered "optional" and
just be used as more weight for an identifier which is how we got to
this patch.
Thanks,
>
> On 4/24/2025 11:53 AM, Mario Limonciello wrote:
>> From: Mario Limonciello <mario.limonciello@amd.com>
>>
>> A BIOS upgrade has changed the IVRS DTE UID for a device that no
>> longer matches the UID in the SSDT. Checking with BIOS team, this is
>> intended behavior, however it breaks the existing logic check in
>> get_acpihid_device_id().
>>
>> In this case there is only one ACPI device on the system with that _HID
>> but the _UID mismatch.
>>
>> IVRS:
>> ```
>> [1E4h 0484 001h] Subtable Type : F0 [Device Entry: ACPI
>> HID Named Device]
>> [1E5h 0485 002h] Device ID : 0060
>> [1E7h 0487 001h] Data Setting (decoded below) : 40
>> INITPass : 0
>> EIntPass : 0
>> NMIPass : 0
>> Reserved : 0
>> System MGMT : 0
>> LINT0 Pass : 1
>> LINT1 Pass : 0
>> [1E8h 0488 008h] ACPI HID : "MSFT0201"
>> [1F0h 0496 008h] ACPI CID : 0000000000000000
>> [1F8h 0504 001h] UID Format : 02
>> [1F9h 0505 001h] UID Length : 09
>> [1FAh 0506 009h] UID : "\_SB.MHSP"
>> ```
>>
>> SSDT:
>> ```
>> Device (MHSP)
>> {
>> Name (_ADR, Zero) // _ADR: Address
>> Name (_HID, "MSFT0201") // _HID: Hardware ID
>> Name (_UID, One) // _UID: Unique ID
>> ```
>>
>> To handle this case; while enumerating ACPI devices in
>> get_acpihid_device_id()
>> count the number of matching ACPI devices with a matching _HID. If
>> there is
>> exactly one _HID match then accept it even if the UID doesn't match.
>>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> drivers/iommu/amd/iommu.c | 24 +++++++++++++++++++-----
>> 1 file changed, 19 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
>> index b19e8c0f48fa2..f9fad07edeeb7 100644
>> --- a/drivers/iommu/amd/iommu.c
>> +++ b/drivers/iommu/amd/iommu.c
>> @@ -109,7 +109,8 @@ static inline int get_acpihid_device_id(struct
>> device *dev,
>> struct acpihid_map_entry **entry)
>> {
>> struct acpi_device *adev = ACPI_COMPANION(dev);
>> - struct acpihid_map_entry *p;
>> + struct acpihid_map_entry *p, *p1;
>> + int hid_count = 0;
>> if (!adev)
>> return -ENODEV;
>> @@ -117,12 +118,25 @@ static inline int get_acpihid_device_id(struct
>> device *dev,
>> list_for_each_entry(p, &acpihid_map, list) {
>> if (acpi_dev_hid_uid_match(adev, p->hid,
>> p->uid[0] ? p->uid : NULL)) {
>> - if (entry)
>> - *entry = p;
>> - return p->devid;
>> + p1 = p;
>> + hid_count = 1;
>> + break;
>> + }
>> +
>> + /* If there is no UID match, but exactly one HID match,
>> return that match */
>> + if (acpi_dev_hid_match(adev, p->hid)) {
>> + p1 = p;
>> + hid_count++;
>> }
>> }
>> - return -EINVAL;
>> +
>> + if (hid_count != 1)
>> + return -EINVAL;
>> +
>> + if (entry)
>> + *entry = p1;
>> +
>> + return p1->devid;
>> }
>> static inline int get_device_sbdf_id(struct device *dev)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-25 5:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-24 4:53 [PATCH] iommu/amd: Allow matching ACPI HID devices without matching UIDs Mario Limonciello
2025-04-25 4:59 ` Suthikulpanit, Suravee
2025-04-25 5:13 ` Mario Limonciello
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.