[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 4/6] pci/arm: Use iommu_add_dt_pci_device() instead of arch hook
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx> On Arm we need to parse DT PCI-IOMMU specifier and provide it to the driver (for describing the relationship between PCI devices and IOMMUs) before adding a device to it. Also clarify the check of the return value as iommu_add_pci_device can return >0 if a device doesn't need to be protected by the IOMMU and print a warning if iommu_add_pci_device failed. Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx> --- downstream->v1: * rebase * add __maybe_unused attribute to const struct domain_iommu *hd; * Rename: s/iommu_add_pci_device/iommu_add_dt_pci_device/ * guard iommu_add_dt_pci_device call with CONFIG_HAS_DEVICE_TREE instead of CONFIG_ARM (cherry picked from commit 2b9d26badab8b24b5a80d028c4499a5022817213 from the downstream branch poc/pci-passthrough from https://gitlab.com/xen-project/people/bmarquis/xen-arm-poc.git) --- xen/drivers/passthrough/pci.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index b42acb8d7c09..ed5a6ede7847 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1305,7 +1305,7 @@ __initcall(setup_dump_pcidevs); static int iommu_add_device(struct pci_dev *pdev) { - const struct domain_iommu *hd; + const struct domain_iommu *hd __maybe_unused; int rc; unsigned int devfn = pdev->devfn; @@ -1318,17 +1318,30 @@ static int iommu_add_device(struct pci_dev *pdev) if ( !is_iommu_enabled(pdev->domain) ) return 0; +#ifdef CONFIG_HAS_DEVICE_TREE + rc = iommu_add_dt_pci_device(devfn, pdev); +#else rc = iommu_call(hd->platform_ops, add_device, devfn, pci_to_dev(pdev)); - if ( rc || !pdev->phantom_stride ) +#endif + if ( rc < 0 || !pdev->phantom_stride ) + { + if ( rc < 0 ) + printk(XENLOG_WARNING "IOMMU: add %pp failed (%d)\n", + &pdev->sbdf, rc); return rc; + } for ( ; ; ) { devfn += pdev->phantom_stride; if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) return 0; +#ifdef CONFIG_HAS_DEVICE_TREE + rc = iommu_add_dt_pci_device(devfn, pdev); +#else rc = iommu_call(hd->platform_ops, add_device, devfn, pci_to_dev(pdev)); - if ( rc ) +#endif + if ( rc < 0 ) printk(XENLOG_WARNING "IOMMU: add %pp failed (%d)\n", &PCI_SBDF(pdev->seg, pdev->bus, devfn), rc); } -- 2.40.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |