Skip to content

Commit 47d2668

Browse files
Jean-Philippe Bruckerrafaeljw
authored andcommitted
ACPI: VIOT: Initialize the correct IOMMU fwspec
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: 3cf4855 ("ACPI: Add driver for the VIOT table") Link: https://lore.kernel.org/all/Y8qzOKm6kvhGWG1T@myrica Reported-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Reviewed-by: Eric Auger <eric.auger@redhat.com> Tested-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent dcf0c2e commit 47d2668

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/acpi/viot.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ static int viot_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
328328
{
329329
u32 epid;
330330
struct viot_endpoint *ep;
331+
struct device *aliased_dev = data;
331332
u32 domain_nr = pci_domain_nr(pdev->bus);
332333

333334
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)
338339
epid = ((domain_nr - ep->segment_start) << 16) +
339340
dev_id - ep->bdf_start + ep->endpoint_id;
340341

341-
return viot_dev_iommu_init(&pdev->dev, ep->viommu,
342+
return viot_dev_iommu_init(aliased_dev, ep->viommu,
342343
epid);
343344
}
344345
}
@@ -372,7 +373,7 @@ int viot_iommu_configure(struct device *dev)
372373
{
373374
if (dev_is_pci(dev))
374375
return pci_for_each_dma_alias(to_pci_dev(dev),
375-
viot_pci_dev_iommu_init, NULL);
376+
viot_pci_dev_iommu_init, dev);
376377
else if (dev_is_platform(dev))
377378
return viot_mmio_dev_iommu_init(to_platform_device(dev));
378379
return -ENODEV;

0 commit comments

Comments
 (0)