Commit ebfdc456 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Joerg Roedel

iommu/omap: Convert to generic_single_device_group()

Use the new helper.

For some reason omap will probe its driver even if it doesn't load an
iommu driver. Keep this working by keeping a bool to track if the iommu
driver was started.
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/7-v1-c869a95191f2+5e8-iommu_single_grp_jgg@nvidia.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 8f68911e
...@@ -1225,18 +1225,15 @@ static int omap_iommu_probe(struct platform_device *pdev) ...@@ -1225,18 +1225,15 @@ static int omap_iommu_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, obj); platform_set_drvdata(pdev, obj);
if (omap_iommu_can_register(pdev)) { if (omap_iommu_can_register(pdev)) {
obj->group = iommu_group_alloc();
if (IS_ERR(obj->group))
return PTR_ERR(obj->group);
err = iommu_device_sysfs_add(&obj->iommu, obj->dev, NULL, err = iommu_device_sysfs_add(&obj->iommu, obj->dev, NULL,
obj->name); obj->name);
if (err) if (err)
goto out_group; return err;
err = iommu_device_register(&obj->iommu, &omap_iommu_ops, &pdev->dev); err = iommu_device_register(&obj->iommu, &omap_iommu_ops, &pdev->dev);
if (err) if (err)
goto out_sysfs; goto out_sysfs;
obj->has_iommu_driver = true;
} }
pm_runtime_enable(obj->dev); pm_runtime_enable(obj->dev);
...@@ -1252,8 +1249,6 @@ static int omap_iommu_probe(struct platform_device *pdev) ...@@ -1252,8 +1249,6 @@ static int omap_iommu_probe(struct platform_device *pdev)
out_sysfs: out_sysfs:
iommu_device_sysfs_remove(&obj->iommu); iommu_device_sysfs_remove(&obj->iommu);
out_group:
iommu_group_put(obj->group);
return err; return err;
} }
...@@ -1261,10 +1256,7 @@ static void omap_iommu_remove(struct platform_device *pdev) ...@@ -1261,10 +1256,7 @@ static void omap_iommu_remove(struct platform_device *pdev)
{ {
struct omap_iommu *obj = platform_get_drvdata(pdev); struct omap_iommu *obj = platform_get_drvdata(pdev);
if (obj->group) { if (obj->has_iommu_driver) {
iommu_group_put(obj->group);
obj->group = NULL;
iommu_device_sysfs_remove(&obj->iommu); iommu_device_sysfs_remove(&obj->iommu);
iommu_device_unregister(&obj->iommu); iommu_device_unregister(&obj->iommu);
} }
...@@ -1729,26 +1721,12 @@ static void omap_iommu_release_device(struct device *dev) ...@@ -1729,26 +1721,12 @@ static void omap_iommu_release_device(struct device *dev)
} }
static struct iommu_group *omap_iommu_device_group(struct device *dev)
{
struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev);
struct iommu_group *group = ERR_PTR(-EINVAL);
if (!arch_data)
return ERR_PTR(-ENODEV);
if (arch_data->iommu_dev)
group = iommu_group_ref_get(arch_data->iommu_dev->group);
return group;
}
static const struct iommu_ops omap_iommu_ops = { static const struct iommu_ops omap_iommu_ops = {
.identity_domain = &omap_iommu_identity_domain, .identity_domain = &omap_iommu_identity_domain,
.domain_alloc_paging = omap_iommu_domain_alloc_paging, .domain_alloc_paging = omap_iommu_domain_alloc_paging,
.probe_device = omap_iommu_probe_device, .probe_device = omap_iommu_probe_device,
.release_device = omap_iommu_release_device, .release_device = omap_iommu_release_device,
.device_group = omap_iommu_device_group, .device_group = generic_single_device_group,
.pgsize_bitmap = OMAP_IOMMU_PGSIZES, .pgsize_bitmap = OMAP_IOMMU_PGSIZES,
.default_domain_ops = &(const struct iommu_domain_ops) { .default_domain_ops = &(const struct iommu_domain_ops) {
.attach_dev = omap_iommu_attach_dev, .attach_dev = omap_iommu_attach_dev,
......
...@@ -80,7 +80,7 @@ struct omap_iommu { ...@@ -80,7 +80,7 @@ struct omap_iommu {
u32 id; u32 id;
struct iommu_device iommu; struct iommu_device iommu;
struct iommu_group *group; bool has_iommu_driver;
u8 pwrst; u8 pwrst;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment