* [PATCH] iommu/amd: return devid as alias for ACPI HID devices
@ 2018-09-18 10:10 Arindam Nath
[not found] ` <20180918101058.2365-1-arindam.nath-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Arindam Nath @ 2018-09-18 10:10 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Arindam Nath, Joerg Roedel
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.
Signed-off-by: Arindam Nath <arindam.nath-5C7GfCeVMHo@public.gmane.org>
---
drivers/iommu/amd_iommu.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 4e04fff23977..73e47d93e7a0 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -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)
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/amd: return devid as alias for ACPI HID devices
[not found] ` <20180918101058.2365-1-arindam.nath-5C7GfCeVMHo@public.gmane.org>
@ 2018-09-25 13:31 ` Joerg Roedel
[not found] ` <20180925133143.h46eopc5j7mnw5ac-l3A5Bk7waGM@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Joerg Roedel @ 2018-09-25 13:31 UTC (permalink / raw)
To: Arindam Nath; +Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Hi Arindam,
On Tue, Sep 18, 2018 at 03:40:58PM +0530, Arindam Nath wrote:
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] iommu/amd: return devid as alias for ACPI HID devices
[not found] ` <20180925133143.h46eopc5j7mnw5ac-l3A5Bk7waGM@public.gmane.org>
@ 2018-09-25 15:41 ` Nath, Arindam
[not found] ` <BLUPR12MB05166F5680FA08277A8CC4F99C160-7LeqcoF/hwreJlb8bxc+dwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Nath, Arindam @ 2018-09-25 15:41 UTC (permalink / raw)
To: Joerg Roedel
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Hi Joerg,
> -----Original Message-----
> From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
> Sent: Tuesday, September 25, 2018 7:02 PM
> To: Nath, Arindam <Arindam.Nath-5C7GfCeVMHo@public.gmane.org>
> Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; Suthikulpanit, Suravee
> <Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org>
> Subject: Re: [PATCH] iommu/amd: return devid as alias for ACPI HID devices
>
> Hi Arindam,
>
> On Tue, Sep 18, 2018 at 03:40:58PM +0530, Arindam Nath wrote:
> > @@ -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.
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
>
> Regards,
>
> Joerg
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/amd: return devid as alias for ACPI HID devices
[not found] ` <BLUPR12MB05166F5680FA08277A8CC4F99C160-7LeqcoF/hwreJlb8bxc+dwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2018-09-26 7:42 ` Joerg Roedel
0 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2018-09-26 7:42 UTC (permalink / raw)
To: Nath, Arindam
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
On Tue, Sep 25, 2018 at 03:41:34PM +0000, Nath, Arindam wrote:
> 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.
Okay, added a Fixes: tag and applied for v4.19, thanks Arindam.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-09-26 7:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-18 10:10 [PATCH] iommu/amd: return devid as alias for ACPI HID devices Arindam Nath
[not found] ` <20180918101058.2365-1-arindam.nath-5C7GfCeVMHo@public.gmane.org>
2018-09-25 13:31 ` Joerg Roedel
[not found] ` <20180925133143.h46eopc5j7mnw5ac-l3A5Bk7waGM@public.gmane.org>
2018-09-25 15:41 ` Nath, Arindam
[not found] ` <BLUPR12MB05166F5680FA08277A8CC4F99C160-7LeqcoF/hwreJlb8bxc+dwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-09-26 7:42 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).