Skip to content

Commit ebfdc45

Browse files
jgunthorpejoergroedel
authored andcommitted
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: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/7-v1-c869a95191f2+5e8-iommu_single_grp_jgg@nvidia.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 8f68911 commit ebfdc45

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

drivers/iommu/omap-iommu.c

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,18 +1225,15 @@ static int omap_iommu_probe(struct platform_device *pdev)
12251225
platform_set_drvdata(pdev, obj);
12261226

12271227
if (omap_iommu_can_register(pdev)) {
1228-
obj->group = iommu_group_alloc();
1229-
if (IS_ERR(obj->group))
1230-
return PTR_ERR(obj->group);
1231-
12321228
err = iommu_device_sysfs_add(&obj->iommu, obj->dev, NULL,
12331229
obj->name);
12341230
if (err)
1235-
goto out_group;
1231+
return err;
12361232

12371233
err = iommu_device_register(&obj->iommu, &omap_iommu_ops, &pdev->dev);
12381234
if (err)
12391235
goto out_sysfs;
1236+
obj->has_iommu_driver = true;
12401237
}
12411238

12421239
pm_runtime_enable(obj->dev);
@@ -1252,19 +1249,14 @@ static int omap_iommu_probe(struct platform_device *pdev)
12521249

12531250
out_sysfs:
12541251
iommu_device_sysfs_remove(&obj->iommu);
1255-
out_group:
1256-
iommu_group_put(obj->group);
12571252
return err;
12581253
}
12591254

12601255
static void omap_iommu_remove(struct platform_device *pdev)
12611256
{
12621257
struct omap_iommu *obj = platform_get_drvdata(pdev);
12631258

1264-
if (obj->group) {
1265-
iommu_group_put(obj->group);
1266-
obj->group = NULL;
1267-
1259+
if (obj->has_iommu_driver) {
12681260
iommu_device_sysfs_remove(&obj->iommu);
12691261
iommu_device_unregister(&obj->iommu);
12701262
}
@@ -1729,26 +1721,12 @@ static void omap_iommu_release_device(struct device *dev)
17291721

17301722
}
17311723

1732-
static struct iommu_group *omap_iommu_device_group(struct device *dev)
1733-
{
1734-
struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev);
1735-
struct iommu_group *group = ERR_PTR(-EINVAL);
1736-
1737-
if (!arch_data)
1738-
return ERR_PTR(-ENODEV);
1739-
1740-
if (arch_data->iommu_dev)
1741-
group = iommu_group_ref_get(arch_data->iommu_dev->group);
1742-
1743-
return group;
1744-
}
1745-
17461724
static const struct iommu_ops omap_iommu_ops = {
17471725
.identity_domain = &omap_iommu_identity_domain,
17481726
.domain_alloc_paging = omap_iommu_domain_alloc_paging,
17491727
.probe_device = omap_iommu_probe_device,
17501728
.release_device = omap_iommu_release_device,
1751-
.device_group = omap_iommu_device_group,
1729+
.device_group = generic_single_device_group,
17521730
.pgsize_bitmap = OMAP_IOMMU_PGSIZES,
17531731
.default_domain_ops = &(const struct iommu_domain_ops) {
17541732
.attach_dev = omap_iommu_attach_dev,

drivers/iommu/omap-iommu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct omap_iommu {
8080
u32 id;
8181

8282
struct iommu_device iommu;
83-
struct iommu_group *group;
83+
bool has_iommu_driver;
8484

8585
u8 pwrst;
8686
};

0 commit comments

Comments
 (0)