mirror of https://gitee.com/openkylin/linux.git
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 <jroedel@suse.de> Link: https://lore.kernel.org/r/20200429133712.31431-27-joro@8bytes.org Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
d826044324
commit
b287ba7378
|
@ -243,28 +243,16 @@ static bool gart_iommu_capable(enum iommu_cap cap)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gart_iommu_add_device(struct device *dev)
|
static struct iommu_device *gart_iommu_probe_device(struct device *dev)
|
||||||
{
|
{
|
||||||
struct iommu_group *group;
|
|
||||||
|
|
||||||
if (!dev_iommu_fwspec_get(dev))
|
if (!dev_iommu_fwspec_get(dev))
|
||||||
return -ENODEV;
|
return ERR_PTR(-ENODEV);
|
||||||
|
|
||||||
group = iommu_group_get_for_dev(dev);
|
return &gart_handle->iommu;
|
||||||
if (IS_ERR(group))
|
|
||||||
return PTR_ERR(group);
|
|
||||||
|
|
||||||
iommu_group_put(group);
|
|
||||||
|
|
||||||
iommu_device_link(&gart_handle->iommu, dev);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gart_iommu_remove_device(struct device *dev)
|
static void gart_iommu_release_device(struct device *dev)
|
||||||
{
|
{
|
||||||
iommu_group_remove_device(dev);
|
|
||||||
iommu_device_unlink(&gart_handle->iommu, dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gart_iommu_of_xlate(struct device *dev,
|
static int gart_iommu_of_xlate(struct device *dev,
|
||||||
|
@ -290,8 +278,8 @@ static const struct iommu_ops gart_iommu_ops = {
|
||||||
.domain_free = gart_iommu_domain_free,
|
.domain_free = gart_iommu_domain_free,
|
||||||
.attach_dev = gart_iommu_attach_dev,
|
.attach_dev = gart_iommu_attach_dev,
|
||||||
.detach_dev = gart_iommu_detach_dev,
|
.detach_dev = gart_iommu_detach_dev,
|
||||||
.add_device = gart_iommu_add_device,
|
.probe_device = gart_iommu_probe_device,
|
||||||
.remove_device = gart_iommu_remove_device,
|
.release_device = gart_iommu_release_device,
|
||||||
.device_group = generic_device_group,
|
.device_group = generic_device_group,
|
||||||
.map = gart_iommu_map,
|
.map = gart_iommu_map,
|
||||||
.unmap = gart_iommu_unmap,
|
.unmap = gart_iommu_unmap,
|
||||||
|
|
|
@ -757,11 +757,10 @@ static int tegra_smmu_configure(struct tegra_smmu *smmu, struct device *dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tegra_smmu_add_device(struct device *dev)
|
static struct iommu_device *tegra_smmu_probe_device(struct device *dev)
|
||||||
{
|
{
|
||||||
struct device_node *np = dev->of_node;
|
struct device_node *np = dev->of_node;
|
||||||
struct tegra_smmu *smmu = NULL;
|
struct tegra_smmu *smmu = NULL;
|
||||||
struct iommu_group *group;
|
|
||||||
struct of_phandle_args args;
|
struct of_phandle_args args;
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
int err;
|
int err;
|
||||||
|
@ -774,7 +773,7 @@ static int tegra_smmu_add_device(struct device *dev)
|
||||||
of_node_put(args.np);
|
of_node_put(args.np);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return ERR_PTR(err);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only a single IOMMU master interface is currently
|
* Only a single IOMMU master interface is currently
|
||||||
|
@ -783,8 +782,6 @@ static int tegra_smmu_add_device(struct device *dev)
|
||||||
*/
|
*/
|
||||||
dev->archdata.iommu = smmu;
|
dev->archdata.iommu = smmu;
|
||||||
|
|
||||||
iommu_device_link(&smmu->iommu, dev);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,26 +790,14 @@ static int tegra_smmu_add_device(struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!smmu)
|
if (!smmu)
|
||||||
return -ENODEV;
|
return ERR_PTR(-ENODEV);
|
||||||
|
|
||||||
group = iommu_group_get_for_dev(dev);
|
return &smmu->iommu;
|
||||||
if (IS_ERR(group))
|
|
||||||
return PTR_ERR(group);
|
|
||||||
|
|
||||||
iommu_group_put(group);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tegra_smmu_remove_device(struct device *dev)
|
static void tegra_smmu_release_device(struct device *dev)
|
||||||
{
|
{
|
||||||
struct tegra_smmu *smmu = dev->archdata.iommu;
|
|
||||||
|
|
||||||
if (smmu)
|
|
||||||
iommu_device_unlink(&smmu->iommu, dev);
|
|
||||||
|
|
||||||
dev->archdata.iommu = NULL;
|
dev->archdata.iommu = NULL;
|
||||||
iommu_group_remove_device(dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct tegra_smmu_group_soc *
|
static const struct tegra_smmu_group_soc *
|
||||||
|
@ -895,8 +880,8 @@ static const struct iommu_ops tegra_smmu_ops = {
|
||||||
.domain_free = tegra_smmu_domain_free,
|
.domain_free = tegra_smmu_domain_free,
|
||||||
.attach_dev = tegra_smmu_attach_dev,
|
.attach_dev = tegra_smmu_attach_dev,
|
||||||
.detach_dev = tegra_smmu_detach_dev,
|
.detach_dev = tegra_smmu_detach_dev,
|
||||||
.add_device = tegra_smmu_add_device,
|
.probe_device = tegra_smmu_probe_device,
|
||||||
.remove_device = tegra_smmu_remove_device,
|
.release_device = tegra_smmu_release_device,
|
||||||
.device_group = tegra_smmu_device_group,
|
.device_group = tegra_smmu_device_group,
|
||||||
.map = tegra_smmu_map,
|
.map = tegra_smmu_map,
|
||||||
.unmap = tegra_smmu_unmap,
|
.unmap = tegra_smmu_unmap,
|
||||||
|
@ -1015,7 +1000,7 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,
|
||||||
* value. However the IOMMU registration process will attempt to add
|
* value. However the IOMMU registration process will attempt to add
|
||||||
* all devices to the IOMMU when bus_set_iommu() is called. In order
|
* all devices to the IOMMU when bus_set_iommu() is called. In order
|
||||||
* not to rely on global variables to track the IOMMU instance, we
|
* not to rely on global variables to track the IOMMU instance, we
|
||||||
* set it here so that it can be looked up from the .add_device()
|
* set it here so that it can be looked up from the .probe_device()
|
||||||
* callback via the IOMMU device's .drvdata field.
|
* callback via the IOMMU device's .drvdata field.
|
||||||
*/
|
*/
|
||||||
mc->smmu = smmu;
|
mc->smmu = smmu;
|
||||||
|
|
Loading…
Reference in New Issue