Skip to content

Commit b287ba7

Browse files
committed
iommu/tegra: Convert to probe/release_device() call-backs
Convert the Tegra IOMMU drivers 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent d826044 commit b287ba7

File tree

2 files changed

+14
-41
lines changed

2 files changed

+14
-41
lines changed

drivers/iommu/tegra-gart.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -243,28 +243,16 @@ static bool gart_iommu_capable(enum iommu_cap cap)
243243
return false;
244244
}
245245

246-
static int gart_iommu_add_device(struct device *dev)
246+
static struct iommu_device *gart_iommu_probe_device(struct device *dev)
247247
{
248-
struct iommu_group *group;
249-
250248
if (!dev_iommu_fwspec_get(dev))
251-
return -ENODEV;
252-
253-
group = iommu_group_get_for_dev(dev);
254-
if (IS_ERR(group))
255-
return PTR_ERR(group);
256-
257-
iommu_group_put(group);
249+
return ERR_PTR(-ENODEV);
258250

259-
iommu_device_link(&gart_handle->iommu, dev);
260-
261-
return 0;
251+
return &gart_handle->iommu;
262252
}
263253

264-
static void gart_iommu_remove_device(struct device *dev)
254+
static void gart_iommu_release_device(struct device *dev)
265255
{
266-
iommu_group_remove_device(dev);
267-
iommu_device_unlink(&gart_handle->iommu, dev);
268256
}
269257

270258
static int gart_iommu_of_xlate(struct device *dev,
@@ -290,8 +278,8 @@ static const struct iommu_ops gart_iommu_ops = {
290278
.domain_free = gart_iommu_domain_free,
291279
.attach_dev = gart_iommu_attach_dev,
292280
.detach_dev = gart_iommu_detach_dev,
293-
.add_device = gart_iommu_add_device,
294-
.remove_device = gart_iommu_remove_device,
281+
.probe_device = gart_iommu_probe_device,
282+
.release_device = gart_iommu_release_device,
295283
.device_group = generic_device_group,
296284
.map = gart_iommu_map,
297285
.unmap = gart_iommu_unmap,

drivers/iommu/tegra-smmu.c

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,10 @@ static int tegra_smmu_configure(struct tegra_smmu *smmu, struct device *dev,
757757
return 0;
758758
}
759759

760-
static int tegra_smmu_add_device(struct device *dev)
760+
static struct iommu_device *tegra_smmu_probe_device(struct device *dev)
761761
{
762762
struct device_node *np = dev->of_node;
763763
struct tegra_smmu *smmu = NULL;
764-
struct iommu_group *group;
765764
struct of_phandle_args args;
766765
unsigned int index = 0;
767766
int err;
@@ -774,7 +773,7 @@ static int tegra_smmu_add_device(struct device *dev)
774773
of_node_put(args.np);
775774

776775
if (err < 0)
777-
return err;
776+
return ERR_PTR(err);
778777

779778
/*
780779
* Only a single IOMMU master interface is currently
@@ -783,8 +782,6 @@ static int tegra_smmu_add_device(struct device *dev)
783782
*/
784783
dev->archdata.iommu = smmu;
785784

786-
iommu_device_link(&smmu->iommu, dev);
787-
788785
break;
789786
}
790787

@@ -793,26 +790,14 @@ static int tegra_smmu_add_device(struct device *dev)
793790
}
794791

795792
if (!smmu)
796-
return -ENODEV;
797-
798-
group = iommu_group_get_for_dev(dev);
799-
if (IS_ERR(group))
800-
return PTR_ERR(group);
801-
802-
iommu_group_put(group);
793+
return ERR_PTR(-ENODEV);
803794

804-
return 0;
795+
return &smmu->iommu;
805796
}
806797

807-
static void tegra_smmu_remove_device(struct device *dev)
798+
static void tegra_smmu_release_device(struct device *dev)
808799
{
809-
struct tegra_smmu *smmu = dev->archdata.iommu;
810-
811-
if (smmu)
812-
iommu_device_unlink(&smmu->iommu, dev);
813-
814800
dev->archdata.iommu = NULL;
815-
iommu_group_remove_device(dev);
816801
}
817802

818803
static const struct tegra_smmu_group_soc *
@@ -895,8 +880,8 @@ static const struct iommu_ops tegra_smmu_ops = {
895880
.domain_free = tegra_smmu_domain_free,
896881
.attach_dev = tegra_smmu_attach_dev,
897882
.detach_dev = tegra_smmu_detach_dev,
898-
.add_device = tegra_smmu_add_device,
899-
.remove_device = tegra_smmu_remove_device,
883+
.probe_device = tegra_smmu_probe_device,
884+
.release_device = tegra_smmu_release_device,
900885
.device_group = tegra_smmu_device_group,
901886
.map = tegra_smmu_map,
902887
.unmap = tegra_smmu_unmap,
@@ -1015,7 +1000,7 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,
10151000
* value. However the IOMMU registration process will attempt to add
10161001
* all devices to the IOMMU when bus_set_iommu() is called. In order
10171002
* not to rely on global variables to track the IOMMU instance, we
1018-
* set it here so that it can be looked up from the .add_device()
1003+
* set it here so that it can be looked up from the .probe_device()
10191004
* callback via the IOMMU device's .drvdata field.
10201005
*/
10211006
mc->smmu = smmu;

0 commit comments

Comments
 (0)