* [PATCH] ACPI: VIOT: Initialize the correct IOMMU fwspec
@ 2023-03-14 16:44 Jean-Philippe Brucker
2023-03-20 17:41 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Jean-Philippe Brucker @ 2023-03-14 16:44 UTC (permalink / raw)
To: eric.auger, rafael; +Cc: lenb, linux-acpi, iommu, Jean-Philippe Brucker
When setting up DMA for a PCI device, we need to initialize its
iommu_fwspec with all possible alias RIDs (such as PCI bridges). To do
this we use pci_for_each_dma_alias() which calls
viot_pci_dev_iommu_init(). This function incorrectly initializes the
fwspec of the bridge instead of the device being configured. Fix it by
passing the original device as context to pci_for_each_dma_alias().
Fixes: 3cf485540e7b ("ACPI: Add driver for the VIOT table")
Reported-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
This fixes issue (1) reported here:
https://lore.kernel.org/all/Y8qzOKm6kvhGWG1T@myrica/
---
drivers/acpi/viot.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/viot.c b/drivers/acpi/viot.c
index ed752cbbe636..c8025921c129 100644
--- a/drivers/acpi/viot.c
+++ b/drivers/acpi/viot.c
@@ -328,6 +328,7 @@ static int viot_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
{
u32 epid;
struct viot_endpoint *ep;
+ struct device *aliased_dev = data;
u32 domain_nr = pci_domain_nr(pdev->bus);
list_for_each_entry(ep, &viot_pci_ranges, list) {
@@ -338,7 +339,7 @@ static int viot_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
epid = ((domain_nr - ep->segment_start) << 16) +
dev_id - ep->bdf_start + ep->endpoint_id;
- return viot_dev_iommu_init(&pdev->dev, ep->viommu,
+ return viot_dev_iommu_init(aliased_dev, ep->viommu,
epid);
}
}
@@ -372,7 +373,7 @@ int viot_iommu_configure(struct device *dev)
{
if (dev_is_pci(dev))
return pci_for_each_dma_alias(to_pci_dev(dev),
- viot_pci_dev_iommu_init, NULL);
+ viot_pci_dev_iommu_init, dev);
else if (dev_is_platform(dev))
return viot_mmio_dev_iommu_init(to_platform_device(dev));
return -ENODEV;
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI: VIOT: Initialize the correct IOMMU fwspec
2023-03-14 16:44 [PATCH] ACPI: VIOT: Initialize the correct IOMMU fwspec Jean-Philippe Brucker
@ 2023-03-20 17:41 ` Rafael J. Wysocki
2023-03-20 18:19 ` Jean-Philippe Brucker
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2023-03-20 17:41 UTC (permalink / raw)
To: Jean-Philippe Brucker
Cc: eric.auger, rafael, lenb, linux-acpi, iommu, Linux PCI, Bjorn Helgaas
This should have been posted with a CC to linux-pci really (now added).
I would recommend resending afresh with linux-pci in the CC list, so
that the people on it don't miss this.
On Tue, Mar 14, 2023 at 5:44 PM Jean-Philippe Brucker
<jean-philippe@linaro.org> wrote:
>
> When setting up DMA for a PCI device, we need to initialize its
> iommu_fwspec with all possible alias RIDs (such as PCI bridges). To do
> this we use pci_for_each_dma_alias() which calls
> viot_pci_dev_iommu_init(). This function incorrectly initializes the
> fwspec of the bridge instead of the device being configured. Fix it by
> passing the original device as context to pci_for_each_dma_alias().
>
> Fixes: 3cf485540e7b ("ACPI: Add driver for the VIOT table")
> Reported-by: Eric Auger <eric.auger@redhat.com>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> ---
> This fixes issue (1) reported here:
> https://lore.kernel.org/all/Y8qzOKm6kvhGWG1T@myrica/
> ---
> drivers/acpi/viot.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/viot.c b/drivers/acpi/viot.c
> index ed752cbbe636..c8025921c129 100644
> --- a/drivers/acpi/viot.c
> +++ b/drivers/acpi/viot.c
> @@ -328,6 +328,7 @@ static int viot_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
> {
> u32 epid;
> struct viot_endpoint *ep;
> + struct device *aliased_dev = data;
> u32 domain_nr = pci_domain_nr(pdev->bus);
>
> list_for_each_entry(ep, &viot_pci_ranges, list) {
> @@ -338,7 +339,7 @@ static int viot_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
> epid = ((domain_nr - ep->segment_start) << 16) +
> dev_id - ep->bdf_start + ep->endpoint_id;
>
> - return viot_dev_iommu_init(&pdev->dev, ep->viommu,
> + return viot_dev_iommu_init(aliased_dev, ep->viommu,
> epid);
> }
> }
> @@ -372,7 +373,7 @@ int viot_iommu_configure(struct device *dev)
> {
> if (dev_is_pci(dev))
> return pci_for_each_dma_alias(to_pci_dev(dev),
> - viot_pci_dev_iommu_init, NULL);
> + viot_pci_dev_iommu_init, dev);
> else if (dev_is_platform(dev))
> return viot_mmio_dev_iommu_init(to_platform_device(dev));
> return -ENODEV;
> --
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI: VIOT: Initialize the correct IOMMU fwspec
2023-03-20 17:41 ` Rafael J. Wysocki
@ 2023-03-20 18:19 ` Jean-Philippe Brucker
0 siblings, 0 replies; 3+ messages in thread
From: Jean-Philippe Brucker @ 2023-03-20 18:19 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: eric.auger, lenb, linux-acpi, iommu, Linux PCI, Bjorn Helgaas
On Mon, Mar 20, 2023 at 06:41:09PM +0100, Rafael J. Wysocki wrote:
> This should have been posted with a CC to linux-pci really (now added).
>
> I would recommend resending afresh with linux-pci in the CC list, so
> that the people on it don't miss this.
Sure, I resent it with the PCI list
https://lore.kernel.org/linux-pci/20230320180528.281755-1-jean-philippe@linaro.org/
Thanks,
Jean
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-20 18:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 16:44 [PATCH] ACPI: VIOT: Initialize the correct IOMMU fwspec Jean-Philippe Brucker
2023-03-20 17:41 ` Rafael J. Wysocki
2023-03-20 18:19 ` Jean-Philippe Brucker
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).