From: Xingang Wang wangxingang5@huawei.com
ascend inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I49RB2 CVE: NA
-------------------------------------------------
This reverts commit c50ad40d63ef0cc9e0b158354af08f1f98419273. The commit "svm: Add svm_set_user_mpam_en to enable/disable mpam for smmu" add and export interface in svm module, this makes the mpam depend on the svm module, just revert this to avoid coupling.
Signed-off-by: Xingang Wang wangxingang5@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/char/svm.c | 64 ------------------------------------- include/linux/ascend_smmu.h | 3 -- 2 files changed, 67 deletions(-)
diff --git a/drivers/char/svm.c b/drivers/char/svm.c index c877c75fdcd5f..000b9ad01c350 100644 --- a/drivers/char/svm.c +++ b/drivers/char/svm.c @@ -135,14 +135,11 @@ struct meminfo { struct svm_mpam { #define SVM_GET_DEV_MPAM (1 << 0) #define SVM_SET_DEV_MPAM (1 << 1) -#define SVM_GET_USER_MPAM_EN (1 << 2) -#define SVM_SET_USER_MPAM_EN (1 << 3) int flags; int pasid; int partid; int pmg; int s1mpam; - int user_mpam_en; };
struct phymeminfo { @@ -1505,14 +1502,6 @@ static int svm_get_core_mpam(struct device *dev, void *data) } }
- if (mpam->flags & SVM_GET_USER_MPAM_EN) { - err = arm_smmu_get_dev_user_mpam_en(dev, &mpam->user_mpam_en); - if (err) { - dev_err(dev, "set user_mpam_en failed, %d\n", err); - return err; - } - } - return err; }
@@ -1554,14 +1543,6 @@ static int svm_set_core_mpam(struct device *dev, void *data) } }
- if (mpam->flags & SVM_SET_USER_MPAM_EN) { - err = arm_smmu_set_dev_user_mpam_en(dev, mpam->user_mpam_en); - if (err) { - dev_err(dev, "set user_mpam_en failed, %d\n", err); - return err; - } - } - return 0; }
@@ -1655,51 +1636,6 @@ int svm_get_mpam(int pasid, int *partid, int *pmg, int *s1mpam) } EXPORT_SYMBOL_GPL(svm_get_mpam);
-/** - * svm_set_user_mpam_en() - set user_mpam_en - * @user_mpam_en: 0 for smmu mpam, 1 for user mpam - */ -int svm_set_user_mpam_en(int user_mpam_en) -{ - int err; - struct svm_mpam mpam, old_mpam; - - old_mpam.flags = SVM_GET_USER_MPAM_EN; - err = __svm_get_mpam(&old_mpam); - - mpam.flags = SVM_SET_USER_MPAM_EN, - mpam.user_mpam_en = user_mpam_en, - err = __svm_set_mpam(&mpam); - if (err) - goto rollback; - - return 0; - -rollback: - __svm_set_mpam(&mpam); - return err; -} -EXPORT_SYMBOL_GPL(svm_set_user_mpam_en); - -/** - * svm_set_user_mpam_en() - set user_mpam_en - * @user_mpam_en: pointer to user_mpam_en - */ -int svm_get_user_mpam_en(int *user_mpam_en) -{ - int err; - struct svm_mpam mpam; - - mpam.flags = SVM_GET_USER_MPAM_EN; - err = __svm_get_mpam(&mpam); - if (err) - return err; - - *user_mpam_en = mpam.user_mpam_en; - return 0; -} -EXPORT_SYMBOL_GPL(svm_get_user_mpam_en); - static int svm_set_rc(unsigned long __user *arg) { unsigned long addr, size, rc; diff --git a/include/linux/ascend_smmu.h b/include/linux/ascend_smmu.h index 32241a02a8a89..e570acfc8f6ac 100644 --- a/include/linux/ascend_smmu.h +++ b/include/linux/ascend_smmu.h @@ -15,7 +15,4 @@ extern int arm_smmu_get_dev_user_mpam_en(struct device *dev, int *user_mpam_en); extern int svm_get_mpam(int pasid, int *partid, int *pmg, int *s1mpam); extern int svm_set_mpam(int pasid, int partid, int pmg, int s1mpam);
-extern int svm_set_user_mpam_en(int user_mpam_en); -extern int svm_get_user_mpam_en(int *user_mpam_en); - #endif /* __LINUX_ASCEND_SMMU_H */
From: Xingang Wang wangxingang5@huawei.com
ascend inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I49RB2 CVE: NA
-------------------------------------------------
This reverts commit 464f69903da18e4248ecd76d5237acd60e5b3bf5. The commit "svm: Add support to set svm mpam configuration" add and export interface in svm module, this makes the mpam depend on the svm module, just revert this to avoid coupling.
Signed-off-by: Xingang Wang wangxingang5@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/char/svm.c | 79 ------------------------------------- include/linux/ascend_smmu.h | 1 - 2 files changed, 80 deletions(-)
diff --git a/drivers/char/svm.c b/drivers/char/svm.c index 000b9ad01c350..b4f3f4bbd0be9 100644 --- a/drivers/char/svm.c +++ b/drivers/char/svm.c @@ -134,7 +134,6 @@ struct meminfo {
struct svm_mpam { #define SVM_GET_DEV_MPAM (1 << 0) -#define SVM_SET_DEV_MPAM (1 << 1) int flags; int pasid; int partid; @@ -1529,84 +1528,6 @@ int __svm_get_mpam(struct svm_mpam *mpam) return 0; }
-static int svm_set_core_mpam(struct device *dev, void *data) -{ - int err = 0; - struct svm_mpam *mpam = data; - - if (mpam->flags & SVM_SET_DEV_MPAM) { - err = arm_smmu_set_dev_mpam(dev, mpam->pasid, mpam->partid, - mpam->pmg, mpam->s1mpam); - if (err) { - dev_err(dev, "set mpam failed, %d\n", err); - return err; - } - } - - return 0; -} - -static int __svm_set_mpam(struct svm_mpam *mpam) -{ - int err = 0; -#ifdef CONFIG_ACPI - struct core_device *cdev = NULL; -#else - struct svm_device *sdev = NULL; -#endif - -#ifdef CONFIG_ACPI - list_for_each_entry(cdev, &child_list, entry) { - err = svm_set_core_mpam(&cdev->dev, mpam); - if (err) - return err; - } -#else - list_for_each_entry(sdev, &sdev_list, entry) { - err = device_for_each_child(sdev->dev, mpam, svm_set_core_mpam); - if (err) - return err; - } -#endif - - return 0; -} - -/** - * svm_set_mpam() - set mpam configuration of all core device in smmu - * @pasid: substream id - * @partid: mpam partition id - * @pmg: mpam pmg - * @s1mpam: 0 for ste mpam, 1 for cd mpam - */ -int svm_set_mpam(int pasid, int partid, int pmg, int s1mpam) -{ - int err; - struct svm_mpam mpam, old_mpam; - - old_mpam.flags = SVM_GET_DEV_MPAM; - old_mpam.pasid = pasid; - err = __svm_get_mpam(&old_mpam); - if (err) - return err; - - mpam.flags = SVM_SET_DEV_MPAM; - mpam.pasid = pasid; - mpam.partid = partid; - mpam.pmg = pmg; - mpam.s1mpam = s1mpam; - err = __svm_set_mpam(&mpam); - if (err) - goto rollback; - - return 0; - -rollback: - __svm_set_mpam(&old_mpam); - return err; -} -EXPORT_SYMBOL_GPL(svm_set_mpam); - /** * svm_get_mpam() - get smmu mpam configuration of core device * @pasid: substream id diff --git a/include/linux/ascend_smmu.h b/include/linux/ascend_smmu.h index e570acfc8f6ac..a6d2058599be5 100644 --- a/include/linux/ascend_smmu.h +++ b/include/linux/ascend_smmu.h @@ -13,6 +13,5 @@ extern int arm_smmu_set_dev_user_mpam_en(struct device *dev, int user_mpam_en); extern int arm_smmu_get_dev_user_mpam_en(struct device *dev, int *user_mpam_en);
extern int svm_get_mpam(int pasid, int *partid, int *pmg, int *s1mpam); -extern int svm_set_mpam(int pasid, int partid, int pmg, int s1mpam);
#endif /* __LINUX_ASCEND_SMMU_H */
From: Xingang Wang wangxingang5@huawei.com
ascend inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I49RB2 CVE: NA
-------------------------------------------------
This reverts commit 0cc88dd88008d71ccc6fcbbcc4c027383eb6f5a6. The commit "svm: Add support to get svm mpam configuration" add and export interface in svm module, this makes the mpam depend on the svm module, just revert this to avoid coupling.
Signed-off-by: Xingang Wang wangxingang5@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/char/svm.c | 85 ------------------------------------- include/linux/ascend_smmu.h | 2 - 2 files changed, 87 deletions(-)
diff --git a/drivers/char/svm.c b/drivers/char/svm.c index b4f3f4bbd0be9..dd0a9babcbee2 100644 --- a/drivers/char/svm.c +++ b/drivers/char/svm.c @@ -32,7 +32,6 @@ #include <linux/sched/mm.h> #include <linux/msi.h> #include <linux/acpi.h> -#include <linux/ascend_smmu.h> #include <linux/share_pool.h>
#define SVM_DEVICE_NAME "svm" @@ -77,11 +76,8 @@ struct svm_device { struct device *dev; phys_addr_t l2buff; unsigned long l2size; - struct list_head entry; };
-static LIST_HEAD(sdev_list); - struct svm_bind_process { pid_t vpid; u64 ttbr; @@ -132,15 +128,6 @@ struct meminfo { unsigned long hugetlbtotal; };
-struct svm_mpam { -#define SVM_GET_DEV_MPAM (1 << 0) - int flags; - int pasid; - int partid; - int pmg; - int s1mpam; -}; - struct phymeminfo { unsigned long normal_total; unsigned long normal_free; @@ -1487,76 +1474,6 @@ int svm_get_pasid(pid_t vpid, int dev_id __maybe_unused) } EXPORT_SYMBOL_GPL(svm_get_pasid);
-static int svm_get_core_mpam(struct device *dev, void *data) -{ - int err = 0; - struct svm_mpam *mpam = data; - - if (mpam->flags & SVM_GET_DEV_MPAM) { - err = arm_smmu_get_dev_mpam(dev, mpam->pasid, &mpam->partid, - &mpam->pmg, &mpam->s1mpam); - if (err) { - dev_err(dev, "get mpam failed, %d\n", err); - return err; - } - } - - return err; -} - -int __svm_get_mpam(struct svm_mpam *mpam) -{ - int err = 0; -#ifdef CONFIG_ACPI - struct core_device *cdev = NULL; -#else - struct svm_device *sdev = NULL; -#endif -#ifdef CONFIG_ACPI - list_for_each_entry(cdev, &child_list, entry) { - err = svm_get_core_mpam(&cdev->dev, mpam); - if (err) - return err; - } -#else - list_for_each_entry(sdev, &sdev_list, entry) { - err = device_for_each_child(sdev->dev, mpam, svm_get_core_mpam); - if (err) - return err; - } -#endif - return 0; -} - -/** - * svm_get_mpam() - get smmu mpam configuration of core device - * @pasid: substream id - * @partid: pointer to partid - * @pmg: pointer to pmg - * @s1mpam: pointer to s1mpam - */ -int svm_get_mpam(int pasid, int *partid, int *pmg, int *s1mpam) -{ - int err = 0; - struct svm_mpam mpam; - - if (!partid || !pmg || !s1mpam) - return -EINVAL; - - mpam.flags = SVM_GET_DEV_MPAM, - mpam.pasid = pasid, - err = __svm_get_mpam(&mpam); - if (err) - return err; - - *partid = mpam.partid; - *pmg = mpam.pmg; - *s1mpam = mpam.s1mpam; - - return 0; -} -EXPORT_SYMBOL_GPL(svm_get_mpam); - static int svm_set_rc(unsigned long __user *arg) { unsigned long addr, size, rc; @@ -2237,7 +2154,6 @@ static int svm_device_probe(struct platform_device *pdev) if (sdev->miscdev.name == NULL) return -ENOMEM;
- list_add(&sdev->entry, &sdev_list); dev_set_drvdata(dev, sdev); err = misc_register(&sdev->miscdev); if (err) { @@ -2294,7 +2210,6 @@ static int svm_device_remove(struct platform_device *pdev)
device_for_each_child(sdev->dev, NULL, svm_remove_core); misc_deregister(&sdev->miscdev); - list_del(&sdev->entry);
return 0; } diff --git a/include/linux/ascend_smmu.h b/include/linux/ascend_smmu.h index a6d2058599be5..c52968e98944c 100644 --- a/include/linux/ascend_smmu.h +++ b/include/linux/ascend_smmu.h @@ -12,6 +12,4 @@ extern int arm_smmu_get_dev_mpam(struct device *dev, int ssid, int *partid, extern int arm_smmu_set_dev_user_mpam_en(struct device *dev, int user_mpam_en); extern int arm_smmu_get_dev_user_mpam_en(struct device *dev, int *user_mpam_en);
-extern int svm_get_mpam(int pasid, int *partid, int *pmg, int *s1mpam); - #endif /* __LINUX_ASCEND_SMMU_H */