aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorAntonios Motakis <a.motakis@virtualopensystems.com>2014-05-12 02:14:59 -0400
committerJoerg Roedel <jroedel@suse.de>2014-05-13 13:12:58 -0400
commitbf4a1c920286076609779c2c70c5a2bf69169fc7 (patch)
tree63c13531824d2e32739cd9c87ce4ec6691a0eddd /drivers/iommu
parentd09d78fc986be8355928256d1b86b713588999d7 (diff)
iommu/exynos: Add devices attached to the System MMU to an IOMMU group
Patch written by Antonios Motakis <a.motakis@virtualopensystems.com>: IOMMU groups are expected by certain users of the IOMMU API, e.g. VFIO. Since each device is behind its own System MMU, we can allocate a new IOMMU group for each device. Reviewed-by: Cho KyongHo <pullip.cho@samsung.com> Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com> Signed-off-by: Shaik Ameeer Basha <shaik.ameer@samsung.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/exynos-iommu.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 3291619c9db0..d18dc379f536 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -964,6 +964,32 @@ static phys_addr_t exynos_iommu_iova_to_phys(struct iommu_domain *domain,
964 return phys; 964 return phys;
965} 965}
966 966
967static int exynos_iommu_add_device(struct device *dev)
968{
969 struct iommu_group *group;
970 int ret;
971
972 group = iommu_group_get(dev);
973
974 if (!group) {
975 group = iommu_group_alloc();
976 if (IS_ERR(group)) {
977 dev_err(dev, "Failed to allocate IOMMU group\n");
978 return PTR_ERR(group);
979 }
980 }
981
982 ret = iommu_group_add_device(group, dev);
983 iommu_group_put(group);
984
985 return ret;
986}
987
988static void exynos_iommu_remove_device(struct device *dev)
989{
990 iommu_group_remove_device(dev);
991}
992
967static struct iommu_ops exynos_iommu_ops = { 993static struct iommu_ops exynos_iommu_ops = {
968 .domain_init = &exynos_iommu_domain_init, 994 .domain_init = &exynos_iommu_domain_init,
969 .domain_destroy = &exynos_iommu_domain_destroy, 995 .domain_destroy = &exynos_iommu_domain_destroy,
@@ -972,6 +998,8 @@ static struct iommu_ops exynos_iommu_ops = {
972 .map = &exynos_iommu_map, 998 .map = &exynos_iommu_map,
973 .unmap = &exynos_iommu_unmap, 999 .unmap = &exynos_iommu_unmap,
974 .iova_to_phys = &exynos_iommu_iova_to_phys, 1000 .iova_to_phys = &exynos_iommu_iova_to_phys,
1001 .add_device = &exynos_iommu_add_device,
1002 .remove_device = &exynos_iommu_remove_device,
975 .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, 1003 .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
976}; 1004};
977 1005