iommu/exynos: Rework iommu group initialization
This patch replaces custom code in add_device implementation with iommu_group_get_for_dev() call and provides the needed callback. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
81f70ba233
commit
6c2ae7e291
|
@ -1114,28 +1114,32 @@ static phys_addr_t exynos_iommu_iova_to_phys(struct iommu_domain *iommu_domain,
|
||||||
return phys;
|
return phys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct iommu_group *get_device_iommu_group(struct device *dev)
|
||||||
|
{
|
||||||
|
struct iommu_group *group;
|
||||||
|
|
||||||
|
group = iommu_group_get(dev);
|
||||||
|
if (!group)
|
||||||
|
group = iommu_group_alloc();
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
static int exynos_iommu_add_device(struct device *dev)
|
static int exynos_iommu_add_device(struct device *dev)
|
||||||
{
|
{
|
||||||
struct iommu_group *group;
|
struct iommu_group *group;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!has_sysmmu(dev))
|
if (!has_sysmmu(dev))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
group = iommu_group_get(dev);
|
group = iommu_group_get_for_dev(dev);
|
||||||
|
|
||||||
if (!group) {
|
if (IS_ERR(group))
|
||||||
group = iommu_group_alloc();
|
|
||||||
if (IS_ERR(group)) {
|
|
||||||
dev_err(dev, "Failed to allocate IOMMU group\n");
|
|
||||||
return PTR_ERR(group);
|
return PTR_ERR(group);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = iommu_group_add_device(group, dev);
|
|
||||||
iommu_group_put(group);
|
iommu_group_put(group);
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void exynos_iommu_remove_device(struct device *dev)
|
static void exynos_iommu_remove_device(struct device *dev)
|
||||||
|
@ -1182,6 +1186,7 @@ static struct iommu_ops exynos_iommu_ops = {
|
||||||
.unmap = exynos_iommu_unmap,
|
.unmap = exynos_iommu_unmap,
|
||||||
.map_sg = default_iommu_map_sg,
|
.map_sg = default_iommu_map_sg,
|
||||||
.iova_to_phys = exynos_iommu_iova_to_phys,
|
.iova_to_phys = exynos_iommu_iova_to_phys,
|
||||||
|
.device_group = get_device_iommu_group,
|
||||||
.add_device = exynos_iommu_add_device,
|
.add_device = exynos_iommu_add_device,
|
||||||
.remove_device = exynos_iommu_remove_device,
|
.remove_device = exynos_iommu_remove_device,
|
||||||
.pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
|
.pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
|
||||||
|
|
Loading…
Reference in New Issue