未验证 提交 bc2051ce 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!168 SPR: Add vfio_group_iommu_domain interface to support DLB

Merge Pull Request from: @allen-shi 
 
This PR is to add vfio_group_iommu_domain interface to support DLB. Without this patch, OOT DLB kernel driver failed to build with error due to lack of vfio_group_iommu_domain interface support. 

 **Intel-Kernel Issue** 
[#I5BEBU](https://gitee.com/openeuler/intel-kernel/issues/I5BEBU)

 **Test** 
1. Built and run the kernel successfully
2. DLB kernel driver built successfully and insmod dlb2.ko successfully

 **Known Issue** 
N/A

 **Default config change** 
N/A 
 
Link:https://gitee.com/openeuler/kernel/pulls/168 
Reviewed-by: Kevin Zhu <zhukeqian1@huawei.com> 
Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> 
Reviewed-by: Chen Wei <chenwei@xfusion.com> 
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> 
......@@ -2331,6 +2331,24 @@ int vfio_unregister_notifier(struct device *dev, enum vfio_notify_type type,
}
EXPORT_SYMBOL(vfio_unregister_notifier);
struct iommu_domain *vfio_group_iommu_domain(struct vfio_group *group)
{
struct vfio_container *container;
struct vfio_iommu_driver *driver;
if (!group)
return ERR_PTR(-EINVAL);
container = group->container;
driver = container->iommu_driver;
if (likely(driver && driver->ops->group_iommu_domain))
return driver->ops->group_iommu_domain(container->iommu_data,
group->iommu_group);
return ERR_PTR(-ENOTTY);
}
EXPORT_SYMBOL_GPL(vfio_group_iommu_domain);
/**
* Module/class support
*/
......
......@@ -3769,6 +3769,29 @@ static int vfio_iommu_type1_dma_rw(void *iommu_data, dma_addr_t user_iova,
return ret;
}
static struct iommu_domain *
vfio_iommu_type1_group_iommu_domain(void *iommu_data,
struct iommu_group *iommu_group)
{
struct iommu_domain *domain = ERR_PTR(-ENODEV);
struct vfio_iommu *iommu = iommu_data;
struct vfio_domain *d;
if (!iommu || !iommu_group)
return ERR_PTR(-EINVAL);
mutex_lock(&iommu->lock);
list_for_each_entry(d, &iommu->domain_list, next) {
if (find_iommu_group(d, iommu_group)) {
domain = d->domain;
break;
}
}
mutex_unlock(&iommu->lock);
return domain;
}
static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = {
.name = "vfio-iommu-type1",
.owner = THIS_MODULE,
......@@ -3782,6 +3805,7 @@ static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = {
.register_notifier = vfio_iommu_type1_register_notifier,
.unregister_notifier = vfio_iommu_type1_unregister_notifier,
.dma_rw = vfio_iommu_type1_dma_rw,
.group_iommu_domain = vfio_iommu_type1_group_iommu_domain,
};
static int __init vfio_iommu_type1_init(void)
......
......@@ -90,6 +90,8 @@ struct vfio_iommu_driver_ops {
struct notifier_block *nb);
int (*dma_rw)(void *iommu_data, dma_addr_t user_iova,
void *data, size_t count, bool write);
KABI_EXTEND(struct iommu_domain *(*group_iommu_domain)(void *iommu_data,
struct iommu_group *group))
};
extern int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops);
......@@ -126,6 +128,8 @@ extern int vfio_group_unpin_pages(struct vfio_group *group,
extern int vfio_dma_rw(struct vfio_group *group, dma_addr_t user_iova,
void *data, size_t len, bool write);
extern struct iommu_domain *vfio_group_iommu_domain(struct vfio_group *group);
/* each type has independent events */
enum vfio_notify_type {
VFIO_IOMMU_NOTIFY = 0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册