summaryrefslogtreecommitdiff
path: root/drivers/iommu
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2015-05-28 19:41:32 +0300
committerJoerg Roedel <jroedel@suse.de>2015-06-09 09:55:23 +0300
commit2c1296d92ac0367364bcb73a43c12a0bdfbfee75 (patch)
treeb1cd702a8a1bb45143421bc839f5dad791028196 /drivers/iommu
parente39cb8a3aa988a74433a3f26443b454cca033651 (diff)
downloadlinux-2c1296d92ac0367364bcb73a43c12a0bdfbfee75.tar.xz
iommu: Add iommu_get_domain_for_dev function
This function can be used to request the current domain a device is attached to. Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/iommu.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 7bce522c2367..a0a38bd2668b 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1076,6 +1076,24 @@ out_unlock:
}
EXPORT_SYMBOL_GPL(iommu_detach_device);
+struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
+{
+ struct iommu_domain *domain;
+ struct iommu_group *group;
+
+ group = iommu_group_get(dev);
+ /* FIXME: Remove this when groups a mandatory for iommu drivers */
+ if (group == NULL)
+ return NULL;
+
+ domain = group->domain;
+
+ iommu_group_put(group);
+
+ return domain;
+}
+EXPORT_SYMBOL_GPL(iommu_get_domain_for_dev);
+
/*
* IOMMU groups are really the natrual working unit of the IOMMU, but
* the IOMMU API works on domains and devices. Bridge that gap by