mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
iommu/renesas: Convert to probe/release_device() call-backs
Convert the Renesas IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel <jroedel@suse.de> Link: https://lore.kernel.org/r/20200429133712.31431-28-joro@8bytes.org Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
b287ba7378
commit
6580c8a784
@ -805,24 +805,8 @@ static int ipmmu_of_xlate(struct device *dev,
|
||||
static int ipmmu_init_arm_mapping(struct device *dev)
|
||||
{
|
||||
struct ipmmu_vmsa_device *mmu = to_ipmmu(dev);
|
||||
struct iommu_group *group;
|
||||
int ret;
|
||||
|
||||
/* Create a device group and add the device to it. */
|
||||
group = iommu_group_alloc();
|
||||
if (IS_ERR(group)) {
|
||||
dev_err(dev, "Failed to allocate IOMMU group\n");
|
||||
return PTR_ERR(group);
|
||||
}
|
||||
|
||||
ret = iommu_group_add_device(group, dev);
|
||||
iommu_group_put(group);
|
||||
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Failed to add device to IPMMU group\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the ARM mapping, used by the ARM DMA mapping core to allocate
|
||||
* VAs. This will allocate a corresponding IOMMU domain.
|
||||
@ -856,48 +840,39 @@ static int ipmmu_init_arm_mapping(struct device *dev)
|
||||
return 0;
|
||||
|
||||
error:
|
||||
iommu_group_remove_device(dev);
|
||||
if (mmu->mapping)
|
||||
arm_iommu_release_mapping(mmu->mapping);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ipmmu_add_device(struct device *dev)
|
||||
static struct iommu_device *ipmmu_probe_device(struct device *dev)
|
||||
{
|
||||
struct ipmmu_vmsa_device *mmu = to_ipmmu(dev);
|
||||
struct iommu_group *group;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Only let through devices that have been verified in xlate()
|
||||
*/
|
||||
if (!mmu)
|
||||
return -ENODEV;
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
if (IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_IOMMU_DMA)) {
|
||||
ret = ipmmu_init_arm_mapping(dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
group = iommu_group_get_for_dev(dev);
|
||||
if (IS_ERR(group))
|
||||
return PTR_ERR(group);
|
||||
|
||||
iommu_group_put(group);
|
||||
}
|
||||
|
||||
iommu_device_link(&mmu->iommu, dev);
|
||||
return 0;
|
||||
return &mmu->iommu;
|
||||
}
|
||||
|
||||
static void ipmmu_remove_device(struct device *dev)
|
||||
static void ipmmu_probe_finalize(struct device *dev)
|
||||
{
|
||||
struct ipmmu_vmsa_device *mmu = to_ipmmu(dev);
|
||||
int ret = 0;
|
||||
|
||||
iommu_device_unlink(&mmu->iommu, dev);
|
||||
if (IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_IOMMU_DMA))
|
||||
ret = ipmmu_init_arm_mapping(dev);
|
||||
|
||||
if (ret)
|
||||
dev_err(dev, "Can't create IOMMU mapping - DMA-OPS will not work\n");
|
||||
}
|
||||
|
||||
static void ipmmu_release_device(struct device *dev)
|
||||
{
|
||||
arm_iommu_detach_device(dev);
|
||||
iommu_group_remove_device(dev);
|
||||
}
|
||||
|
||||
static struct iommu_group *ipmmu_find_group(struct device *dev)
|
||||
@ -925,9 +900,14 @@ static const struct iommu_ops ipmmu_ops = {
|
||||
.flush_iotlb_all = ipmmu_flush_iotlb_all,
|
||||
.iotlb_sync = ipmmu_iotlb_sync,
|
||||
.iova_to_phys = ipmmu_iova_to_phys,
|
||||
.add_device = ipmmu_add_device,
|
||||
.remove_device = ipmmu_remove_device,
|
||||
.probe_device = ipmmu_probe_device,
|
||||
.release_device = ipmmu_release_device,
|
||||
.probe_finalize = ipmmu_probe_finalize,
|
||||
#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)
|
||||
.device_group = generic_device_group,
|
||||
#else
|
||||
.device_group = ipmmu_find_group,
|
||||
#endif
|
||||
.pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K,
|
||||
.of_xlate = ipmmu_of_xlate,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user