forked from Minki/linux
iommu: Clean up bus_set_iommu()
Clean up the remaining trivial bus_set_iommu() callsites along with the implementation. Now drivers only have to know and care about iommu_device instances, phew! Reviewed-by: Kevin Tian <kevin.tian@intel.com> Tested-by: Matthew Rosato <mjrosato@linux.ibm.com> # s390 Tested-by: Niklas Schnelle <schnelle@linux.ibm.com> # s390 Signed-off-by: Robin Murphy <robin.murphy@arm.com> Link: https://lore.kernel.org/r/ea383d5f4d74ffe200ab61248e5de6e95846180a.1660572783.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
19d3607c74
commit
29e932295b
@ -837,8 +837,6 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
|
||||
goto err_pm_disable;
|
||||
}
|
||||
|
||||
bus_set_iommu(&platform_bus_type, &qcom_iommu_ops);
|
||||
|
||||
if (qcom_iommu->local_base) {
|
||||
pm_runtime_get_sync(dev);
|
||||
writel_relaxed(0xffffffff, qcom_iommu->local_base + SMMU_INTR_SEL_NS);
|
||||
@ -856,8 +854,6 @@ static int qcom_iommu_device_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct qcom_iommu_dev *qcom_iommu = platform_get_drvdata(pdev);
|
||||
|
||||
bus_set_iommu(&platform_bus_type, NULL);
|
||||
|
||||
pm_runtime_force_suspend(&pdev->dev);
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
iommu_device_sysfs_remove(&qcom_iommu->iommu);
|
||||
|
@ -476,11 +476,7 @@ int __init pamu_domain_init(void)
|
||||
if (ret) {
|
||||
iommu_device_sysfs_remove(&pamu_iommu);
|
||||
pr_err("Can't register iommu device\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bus_set_iommu(&platform_bus_type, &fsl_pamu_ops);
|
||||
bus_set_iommu(&pci_bus_type, &fsl_pamu_ops);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -3890,7 +3890,6 @@ static int __init probe_acpi_namespace_devices(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
pn->dev->bus->iommu_ops = &intel_iommu_ops;
|
||||
ret = iommu_probe_device(pn->dev);
|
||||
if (ret)
|
||||
break;
|
||||
@ -4023,7 +4022,6 @@ int __init intel_iommu_init(void)
|
||||
}
|
||||
up_read(&dmar_global_lock);
|
||||
|
||||
bus_set_iommu(&pci_bus_type, &intel_iommu_ops);
|
||||
if (si_domain && !hw_pass_through)
|
||||
register_memory_notifier(&intel_iommu_memory_nb);
|
||||
|
||||
|
@ -1826,30 +1826,6 @@ int bus_iommu_probe(struct bus_type *bus)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* bus_set_iommu - set iommu-callbacks for the bus
|
||||
* @bus: bus.
|
||||
* @ops: the callbacks provided by the iommu-driver
|
||||
*
|
||||
* This function is called by an iommu driver to set the iommu methods
|
||||
* used for a particular bus. Drivers for devices on that bus can use
|
||||
* the iommu-api after these ops are registered.
|
||||
* This special function is needed because IOMMUs are usually devices on
|
||||
* the bus itself, so the iommu drivers are not initialized when the bus
|
||||
* is set up. With this function the iommu-driver can set the iommu-ops
|
||||
* afterwards.
|
||||
*/
|
||||
int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops)
|
||||
{
|
||||
if (bus->iommu_ops && ops && bus->iommu_ops != ops)
|
||||
return -EBUSY;
|
||||
|
||||
bus->iommu_ops = ops;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bus_set_iommu);
|
||||
|
||||
bool iommu_present(struct bus_type *bus)
|
||||
{
|
||||
return bus->iommu_ops != NULL;
|
||||
|
@ -792,8 +792,6 @@ static int msm_iommu_probe(struct platform_device *pdev)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bus_set_iommu(&platform_bus_type, &msm_iommu_ops);
|
||||
|
||||
pr_info("device mapped at %p, irq %d with %d ctx banks\n",
|
||||
iommu->base, iommu->irq, iommu->ncb);
|
||||
|
||||
|
@ -1300,8 +1300,6 @@ static int rk_iommu_probe(struct platform_device *pdev)
|
||||
if (!dma_dev)
|
||||
dma_dev = &pdev->dev;
|
||||
|
||||
bus_set_iommu(&platform_bus_type, &rk_iommu_ops);
|
||||
|
||||
pm_runtime_enable(dev);
|
||||
|
||||
for (i = 0; i < iommu->num_irq; i++) {
|
||||
|
@ -390,9 +390,3 @@ static const struct iommu_ops s390_iommu_ops = {
|
||||
.free = s390_domain_free,
|
||||
}
|
||||
};
|
||||
|
||||
static int __init s390_iommu_init(void)
|
||||
{
|
||||
return bus_set_iommu(&pci_bus_type, &s390_iommu_ops);
|
||||
}
|
||||
subsys_initcall(s390_iommu_init);
|
||||
|
@ -496,9 +496,6 @@ static int sprd_iommu_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
goto remove_sysfs;
|
||||
|
||||
if (!iommu_present(&platform_bus_type))
|
||||
bus_set_iommu(&platform_bus_type, &sprd_iommu_ops);
|
||||
|
||||
ret = sprd_iommu_clk_enable(sdev);
|
||||
if (ret)
|
||||
goto unregister_iommu;
|
||||
@ -534,8 +531,6 @@ static int sprd_iommu_remove(struct platform_device *pdev)
|
||||
iommu_group_put(sdev->group);
|
||||
sdev->group = NULL;
|
||||
|
||||
bus_set_iommu(&platform_bus_type, NULL);
|
||||
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
iommu_device_sysfs_remove(&sdev->iommu);
|
||||
iommu_device_unregister(&sdev->iommu);
|
||||
|
@ -965,8 +965,6 @@ static int sun50i_iommu_probe(struct platform_device *pdev)
|
||||
if (ret < 0)
|
||||
goto err_unregister;
|
||||
|
||||
bus_set_iommu(&platform_bus_type, &sun50i_iommu_ops);
|
||||
|
||||
return 0;
|
||||
|
||||
err_unregister:
|
||||
|
@ -416,7 +416,6 @@ static inline const struct iommu_ops *dev_iommu_ops(struct device *dev)
|
||||
return dev->iommu->iommu_dev->ops;
|
||||
}
|
||||
|
||||
extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
|
||||
extern int bus_iommu_probe(struct bus_type *bus);
|
||||
extern bool iommu_present(struct bus_type *bus);
|
||||
extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap);
|
||||
|
Loading…
Reference in New Issue
Block a user