From: Hanjun Guo guohanjun@huawei.com
hulk inclusion category: feature bugzilla: NA CVE: NA
-------------------------------------
The device bypass code can be cleanuped to be more readable.
Signed-off-by: Hanjun Guo guohanjun@huawei.com Cc: Guo Hui guohui@uniontech.com Cc: Cheng Jian cj.chengjian@huawei.com Cc: Zhen Lei thunder.leizhen@huawei.com Cc: Xiuqi Xie xiexiuqi@huawei.com Signed-off-by: Cheng Jian cj.chengjian@huawei.com --- drivers/iommu/arm-smmu-v3.c | 2 +- drivers/iommu/iommu.c | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 5bd7103e48e1..aecd07c31953 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -3089,10 +3089,10 @@ static struct iommu_ops arm_smmu_ops = { .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, .put_resv_regions = arm_smmu_put_resv_regions, + .pgsize_bitmap = -1UL, /* Restricted during device attach */ #ifdef CONFIG_SMMU_BYPASS_DEV .device_domain_type = arm_smmu_device_domain_type, #endif - .pgsize_bitmap = -1UL, /* Restricted during device attach */ };
/* Probing and initialisation functions */ diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 8cd0604049f0..63bd5940b290 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1270,9 +1270,8 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev) const struct iommu_ops *ops = dev->bus->iommu_ops; struct iommu_group *group; int ret; -#ifdef CONFIG_SMMU_BYPASS_DEV unsigned int type = iommu_def_domain_type; -#endif + group = iommu_group_get(dev); if (group) return group; @@ -1296,17 +1295,13 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
#ifdef CONFIG_SMMU_BYPASS_DEV /* direct allocate required default domain type for some specific devices. */ - if (ops->device_domain_type != NULL) { + if (ops->device_domain_type) { if (ops->device_domain_type(dev, &type)) type = iommu_def_domain_type; - } - + } +#endif dom = __iommu_domain_alloc(dev->bus, type); if (!dom && type != IOMMU_DOMAIN_DMA) { -#else - dom = __iommu_domain_alloc(dev->bus, iommu_def_domain_type); - if (!dom && iommu_def_domain_type != IOMMU_DOMAIN_DMA) { -#endif dev_warn(dev, "failed to allocate default IOMMU domain of type %u; falling back to IOMMU_DOMAIN_DMA", iommu_def_domain_type);