]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
iommu: qcom: check scm avaiablity before initialization.
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tue, 23 Feb 2016 09:07:33 +0000 (09:07 +0000)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Fri, 13 Apr 2018 14:00:39 +0000 (16:00 +0200)
This patch moves the scm call checks to probe and also adds check to see
if the scm is available and makes a defer probe from then.

This should prevent execution of scm calls on non qcom platfroms
resulting in crashes.

Bugzilla: https://bugs.linaro.org/show_bug.cgi?id=2061
Reported-by: Ricardo Salveti <ricardo.salveti@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
drivers/iommu/qcom/msm_iommu_dev-v1.c

index 0989c5c47b0f53d85a5517eed2eeabd5149f02c3..2153c43de953d696add51bc9433b100c1779e1c7 100644 (file)
@@ -345,6 +345,13 @@ static int msm_iommu_probe(struct platform_device *pdev)
        u32 temp;
        unsigned long rate;
 
+       if (!qcom_scm_is_available())
+               return -EPROBE_DEFER;
+
+       msm_iommu_check_scm_call_avail();
+       msm_set_iommu_access_ops(&iommu_access_ops_v1);
+       msm_iommu_sec_set_access_ops(&iommu_access_ops_v1);
+
        drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
        if (!drvdata)
                return -ENOMEM;
@@ -607,6 +614,9 @@ static int msm_iommu_ctx_probe(struct platform_device *pdev)
        struct msm_iommu_ctx_drvdata *ctx_drvdata;
        int ret;
 
+       if (!qcom_scm_is_available())
+               return -EPROBE_DEFER;
+
        if (!pdev->dev.parent)
                return -EINVAL;
 
@@ -671,10 +681,6 @@ static int __init msm_iommu_driver_init(void)
 {
        int ret;
 
-       msm_iommu_check_scm_call_avail();
-       msm_set_iommu_access_ops(&iommu_access_ops_v1);
-       msm_iommu_sec_set_access_ops(&iommu_access_ops_v1);
-
        ret = platform_driver_register(&msm_iommu_driver);
        if (ret) {
                pr_err("Failed to register IOMMU driver\n");
@@ -696,7 +702,6 @@ static void __exit msm_iommu_driver_exit(void)
        platform_driver_unregister(&msm_iommu_ctx_driver);
        platform_driver_unregister(&msm_iommu_driver);
 }
-
 subsys_initcall(msm_iommu_driver_init);
 module_exit(msm_iommu_driver_exit);