提交 02aceb41 编写于 作者: J Jiankang Chen 提交者: Xie XiuQi

svm: init the children device of svm device

ascend inclusion
category: feature
bugzilla: 16554
CVE: NA

--------

svm need to init the children device , so, we
add the acpi and dts functions to read the childen
device of svm device;
Signed-off-by: NJiankang Chen <chenjiankang1@huawei.com>
Signed-off-by: NLijun Fang <fanglijun3@huawei.com>
Reviewed-by: NLi Zefan <lizefan@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 dbd155d4
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#ifndef CONFIG_ACPI #ifndef CONFIG_ACPI
static int probe_index; static int probe_index;
#endif #endif
static DECLARE_RWSEM(svm_sem);
struct core_device { struct core_device {
struct device dev; struct device dev;
...@@ -88,23 +89,121 @@ struct svm_context { ...@@ -88,23 +89,121 @@ struct svm_context {
atomic_t ref; atomic_t ref;
}; };
static struct bus_type svm_bus_type = {
.name = "svm_bus",
};
static int svm_open(struct inode *inode, struct file *file) static int svm_open(struct inode *inode, struct file *file)
{ {
return 0; return 0;
} }
static int svm_remove_core(struct device *dev, void *data)
{
/*TODO*/
return 0;
}
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
static int svm_init_core(struct svm_device *sdev) static int svm_acpi_add_core(struct svm_device *sdev,
struct acpi_device *children, int id)
{ {
/*TODO init hi1910 and hi1980 cores for ai*/ /*TODO*/
return 0; return 0;
} }
static int svm_init_core(struct svm_device *sdev)
{
int err = 0;
struct device *dev = sdev->dev;
struct acpi_device *adev = ACPI_COMPANION(sdev->dev);
struct acpi_device *cdev = NULL;
int id = 0;
down_write(&svm_sem);
if (!svm_bus_type.iommu_ops) {
err = bus_register(&svm_bus_type);
if (err) {
up_write(&svm_sem);
dev_err(dev, "failed to register svm_bus_type\n");
return err;
}
err = bus_set_iommu(&svm_bus_type, dev->bus->iommu_ops);
if (err) {
up_write(&svm_sem);
dev_err(dev, "failed to set iommu for svm_bus_type\n");
goto err_unregister_bus;
}
} else if (svm_bus_type.iommu_ops != dev->bus->iommu_ops) {
err = -EBUSY;
up_write(&svm_sem);
dev_err(dev, "iommu_ops configured, but changed!\n");
goto err_unregister_bus;
}
up_write(&svm_sem);
list_for_each_entry(cdev, &adev->children, node) {
err = svm_acpi_add_core(sdev, cdev, id++);
if (err)
device_for_each_child(dev, NULL, svm_remove_core);
}
return err;
err_unregister_bus:
bus_unregister(&svm_bus_type);
return err;
}
#else #else
static int svm_init_core(struct svm_device *sdev, struct device_node *np) static int svm_of_add_core(struct svm_device *sdev, struct device_node *np)
{ {
/*TODO*/ /*TODO*/
return 0; return 0;
} }
static int svm_init_core(struct svm_device *sdev, struct device_node *np)
{
int err = 0;
struct device_node *child = NULL;
struct device *dev = sdev->dev;
down_write(&svm_sem);
if (svm_bus_type.iommu_ops == NULL) {
err = bus_register(&svm_bus_type);
if (err) {
up_write(&svm_sem);
dev_err(dev, "failed to register svm_bus_type\n");
return err;
}
err = bus_set_iommu(&svm_bus_type, dev->bus->iommu_ops);
if (err) {
up_write(&svm_sem);
dev_err(dev, "failed to set iommu for svm_bus_type\n");
goto err_unregister_bus;
}
} else if (svm_bus_type.iommu_ops != dev->bus->iommu_ops) {
err = -EBUSY;
up_write(&svm_sem);
dev_err(dev, "iommu_ops configured, but changed!\n");
goto err_unregister_bus;
}
up_write(&svm_sem);
for_each_available_child_of_node(np, child) {
err = svm_of_add_core(sdev, child);
if (err)
device_for_each_child(dev, NULL, svm_remove_core);
}
return err;
err_unregister_bus:
bus_unregister(&svm_bus_type);
return err;
}
#endif #endif
/*svm ioctl will include some case for HI1980 and HI1910*/ /*svm ioctl will include some case for HI1980 and HI1910*/
static long svm_ioctl(struct file *file, unsigned int cmd, static long svm_ioctl(struct file *file, unsigned int cmd,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册