hulk inclusion category: feature bugzilla: NA DTS: 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 --- 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 592ccae..cc1db70 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -3092,10 +3092,10 @@ static int arm_smmu_device_domain_type(struct device *dev, unsigned int *type) .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 a5a27ba..73e51b3 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1291,9 +1291,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; @@ -1317,17 +1316,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);