iommu/amd: return devid as alias for ACPI HID devices
PATCH 1/1 iommu/amd: return devid as alias for ACPI HID devices
ACPI HID devices do not actually have an alias for them in the IVRS. But dev_data->alias is still used for indexing into the IOMMU device table for devices being handled by the IOMMU. So for ACPI HID devices, we simply return the corresponding devid as an alias, as parsed from IVRS table.
--- drivers/iommu/amd_iommu.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/iommu/amd_iommu.c +6 -0
@@ -246,7 +246,13 @@ static u16 get_alias(struct device *dev)/* The callers make sure that get_device_id() does not fail here */ devid =get_device_id (dev); + +/* For ACPI HID devices, we simply return the devid as such */ +if (!dev_is_pci (dev)) +return devid; + ivrs_alias = amd_iommu_alias_table[devid]; +pci_for_each_dma_alias (pdev, __last_alias, &pci_alias);if (ivrs_alias == pci_alias)
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Arindam,
drivers/iommu/amd_iommu.c static u16 get_alias(struct device *dev) · line 253
Quoted 9 lines · Arindam Nath
drivers/iommu/amd_iommu.c +5
-0@@ -246,7 +246,13 @@ static u16 get_alias(struct device *dev)/* The callers make sure that get_device_id() does not fail here */ devid =get_device_id (dev); + +/* For ACPI HID devices, we simply return the devid as such */ +if (!dev_is_pci (dev)) +return devid; +
Does this fix some bug? If there is no alias defined for the device-id, it should just return the correct devid even without that change.
Regards,
Joerg
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Joerg,
Quoted 13 lines
-----Original Message-----
From: Joerg Roedel <[email protected]>
Sent: Tuesday, September 25, 2018 7:02 PM
To: Nath, Arindam <[email protected]>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; Suthikulpanit, Suravee <[email protected]>
Subject: Re: [PATCH] iommu/amd: return devid as alias for ACPI HID devicesHi Arindam,
Quoted 2 lines · Arindam Nath
(quoted diff) +0
-0@@ -246,7 +246,13 @@ static u16 get_alias(struct device *dev)
Quoted 10 lines
drivers/iommu/amd_iommu.c static u16 get_alias(struct device *dev) · line 253
Quoted 7 lines
drivers/iommu/amd_iommu.c +5
-0/* The callers make sure that get_device_id() does not fail here */ devid =get_device_id (dev); + +/* For ACPI HID devices, we simply return the devid as such */ +if (!dev_is_pci (dev)) +return devid; +Does this fix some bug? If there is no alias defined for the device-id, it should just return the correct devid even without that change.
It does fix an issue where eMMC controller is an ACPI HID device and it fails to work with IOMMU enabled.
Since for the ACPI HID, there is no actual pci_dev backing it, there is a NULL pointer de-referencing inside pci_for_each_dma_alias() while trying to access pdev->bus->number.
Thanks,
Arindam
Quoted 4 lines
Regards,
Joerg
A message that is not in the archive (sent off-list or not yet received): BLUPR12MB05166F5680FA08277A8CC4F99C160-7LeqcoF/[email protected]
Quoted 6 lines · Arindam
It does fix an issue where eMMC controller is an ACPI HID device and it fails to work with IOMMU enabled.
Since for the ACPI HID, there is no actual
pci_devbacking it, there is a NULL pointer de-referencing insidepci_for_each_dma_alias()while trying to accesspdev->bus->number.
Okay, added a Fixes: tag and applied for v4.19, thanks Arindam.