提交 d7d55cac 编写于 作者: H Hanjun Guo 提交者: Cheng Jian

iommu: dev_bypass: cleanup dev bypass code

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I41AUQ
CVE: NA

-------------------------------------

The device bypass code can be cleanuped to be more readable.
Signed-off-by: NHanjun 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>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 92dfb050
......@@ -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 */
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册