aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/iommu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iommu/iommu.c')
-rw-r--r--drivers/iommu/iommu.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3b67144dead2..770ba7e7ef4d 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -36,6 +36,7 @@
36 36
37static struct kset *iommu_group_kset; 37static struct kset *iommu_group_kset;
38static DEFINE_IDA(iommu_group_ida); 38static DEFINE_IDA(iommu_group_ida);
39static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA;
39 40
40struct iommu_callback_data { 41struct iommu_callback_data {
41 const struct iommu_ops *ops; 42 const struct iommu_ops *ops;
@@ -112,6 +113,18 @@ static int __iommu_attach_group(struct iommu_domain *domain,
112static void __iommu_detach_group(struct iommu_domain *domain, 113static void __iommu_detach_group(struct iommu_domain *domain,
113 struct iommu_group *group); 114 struct iommu_group *group);
114 115
116static int __init iommu_set_def_domain_type(char *str)
117{
118 bool pt;
119
120 if (!str || strtobool(str, &pt))
121 return -EINVAL;
122
123 iommu_def_domain_type = pt ? IOMMU_DOMAIN_IDENTITY : IOMMU_DOMAIN_DMA;
124 return 0;
125}
126early_param("iommu.passthrough", iommu_set_def_domain_type);
127
115static ssize_t iommu_group_attr_show(struct kobject *kobj, 128static ssize_t iommu_group_attr_show(struct kobject *kobj,
116 struct attribute *__attr, char *buf) 129 struct attribute *__attr, char *buf)
117{ 130{
@@ -1015,10 +1028,19 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
1015 * IOMMU driver. 1028 * IOMMU driver.
1016 */ 1029 */
1017 if (!group->default_domain) { 1030 if (!group->default_domain) {
1018 group->default_domain = __iommu_domain_alloc(dev->bus, 1031 struct iommu_domain *dom;
1019 IOMMU_DOMAIN_DMA); 1032
1033 dom = __iommu_domain_alloc(dev->bus, iommu_def_domain_type);
1034 if (!dom && iommu_def_domain_type != IOMMU_DOMAIN_DMA) {
1035 dev_warn(dev,
1036 "failed to allocate default IOMMU domain of type %u; falling back to IOMMU_DOMAIN_DMA",
1037 iommu_def_domain_type);
1038 dom = __iommu_domain_alloc(dev->bus, IOMMU_DOMAIN_DMA);
1039 }
1040
1041 group->default_domain = dom;
1020 if (!group->domain) 1042 if (!group->domain)
1021 group->domain = group->default_domain; 1043 group->domain = dom;
1022 } 1044 }
1023 1045
1024 ret = iommu_group_add_device(group, dev); 1046 ret = iommu_group_add_device(group, dev);