]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
tegra-se: Unregister algs support from tegra-se
authorAmith Ramachandra <aramachan@nvidia.com>
Sat, 20 Sep 2014 21:45:12 +0000 (14:45 -0700)
committerDhiren Parmar <dparmar@nvidia.com>
Sat, 27 Sep 2014 12:40:46 +0000 (05:40 -0700)
Owing to lower perf, prefer CPU over SE HW for crypto
operations. However, we may still need SE for save/restore
key context across Lp0 so keep the driver to do this.

Change-Id: I16ffaf64400e70615cdb0d4326f5480d172f6be6
Signed-off-by: Amith Ramachandra <aramachan@nvidia.com>
Signed-off-by: Gagan Grover <ggrover@nvidia.com>
Reviewed-on: http://git-master/r/501214
(cherry picked from commit 9bc76d18fe31233e6aad5ab9b142725b9d0a3875)
Reviewed-on: http://git-master/r/539875
Reviewed-by: Dhiren Parmar <dparmar@nvidia.com>
Tested-by: Dhiren Parmar <dparmar@nvidia.com>
arch/arm/configs/tegra12_android_defconfig
drivers/crypto/Kconfig
drivers/crypto/tegra-se.c

index 8d6afe377b994f5eafaca1f621941df6006db000..3c3e7daeefa7264bfdcfcb0d17672c45fe3078d2 100644 (file)
@@ -625,4 +625,6 @@ CONFIG_SECURITY_SELINUX=y
 CONFIG_CRYPTO_TEST=m
 CONFIG_CRYPTO_TWOFISH=y
 # CONFIG_CRYPTO_ANSI_CPRNG is not set
+CONFIG_CRYPTO_DEV_TEGRA_SE=y
+CONFIG_CRYPTO_DEV_TEGRA_SE_NO_ALG_SUPPORT=y
 CONFIG_TEGRA_NVDUMPER=y
index be3be6297b6cc769956b2093c8cfaa7086a24b88..45500340aaa41b25323854cd3a6eb3552aa77a19 100644 (file)
@@ -316,6 +316,13 @@ config CRYPTO_DEV_TEGRA_SE
          This option allows you to have support of Security Engine for crypto
          acceleration.
 
+config CRYPTO_DEV_TEGRA_SE_NO_ALG_SUPPORT
+       bool "Do not register crypto algorithms"
+       depends on CRYPTO_DEV_TEGRA_SE
+       help
+         This option disables registration of crypto algorithms with the kernel.
+         The SE driver has other uses in save restoring context across Lp0.
+
 config CRYPTO_DEV_NX
        bool "Support for IBM Power7+ in-Nest cryptographic acceleration"
        depends on PPC64 && IBMVIO
index d6d17445c0c2c01a07bcd464893918d98f761eff..8db2710d79b5c7b1d8692cf205b798d9447547e7 100644 (file)
@@ -2592,12 +2592,74 @@ static struct of_device_id tegra_se_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, tegra_se_of_match);
 
+
+#if defined(CONFIG_CRYPTO_DEV_TEGRA_SE_NO_ALG_SUPPORT)
+static void tegra_se_unregister_algs(struct tegra_se_dev *se_dev,
+                                    int nalgs, int nhash)
+{
+}
+
+static int tegra_se_register_algs(struct tegra_se_dev *se_dev)
+{
+       return 0;
+}
+
+#else
+static void tegra_se_unregister_algs(struct tegra_se_dev *se_dev,
+                                           int nalgs, int nhash)
+{
+       int k;
+
+       for (k = 0; k < nalgs; k++)
+               crypto_unregister_alg(&aes_algs[k]);
+
+       for (k = 0; k < nhash; k++)
+               crypto_unregister_ahash(&hash_algs[k]);
+}
+
+
+static int tegra_se_register_algs(struct tegra_se_dev *se_dev)
+{
+       int err = 0, i = 0, j = 0;
+
+       for (i = 0; i < ARRAY_SIZE(aes_algs); i++) {
+               if (isAlgoSupported(se_dev, aes_algs[i].cra_name)) {
+                       INIT_LIST_HEAD(&aes_algs[i].cra_list);
+                       err = crypto_register_alg(&aes_algs[i]);
+                       if (err) {
+                               dev_err(se_dev->dev,
+                               "crypto_register_alg failed index[%d]\n", i);
+                               goto err_exit;
+                       }
+               }
+       }
+
+       for (j = 0; j < ARRAY_SIZE(hash_algs); j++) {
+               if (isAlgoSupported(se_dev, hash_algs[j].halg.base.cra_name)) {
+                       err = crypto_register_ahash(&hash_algs[j]);
+                       if (err) {
+                               dev_err(se_dev->dev,
+                               "crypto_register_sha alg failed index[%d]\n",
+                               i);
+                               goto err_exit;
+                       }
+               }
+       }
+
+       return 0;
+
+err_exit:
+       tegra_se_unregister_algs(se_dev, i, j);
+       return err;
+}
+#endif
+
 static int tegra_se_probe(struct platform_device *pdev)
 {
        struct tegra_se_dev *se_dev = NULL;
        struct resource *res = NULL;
        const struct of_device_id *match;
-       int err = 0, i = 0, j = 0, k = 0;
+       int err = 0;
 
        se_dev = kzalloc(sizeof(struct tegra_se_dev), GFP_KERNEL);
        if (!se_dev) {
@@ -2714,29 +2776,9 @@ static int tegra_se_probe(struct platform_device *pdev)
                goto clean;
        }
 
-       for (i = 0; i < ARRAY_SIZE(aes_algs); i++) {
-               if (isAlgoSupported(se_dev, aes_algs[i].cra_name)) {
-                       INIT_LIST_HEAD(&aes_algs[i].cra_list);
-                       err = crypto_register_alg(&aes_algs[i]);
-                       if (err) {
-                               dev_err(se_dev->dev,
-                               "crypto_register_alg failed index[%d]\n", i);
-                               goto clean;
-                       }
-               }
-       }
-
-       for (j = 0; j < ARRAY_SIZE(hash_algs); j++) {
-               if (isAlgoSupported(se_dev, hash_algs[j].halg.base.cra_name)) {
-                       err = crypto_register_ahash(&hash_algs[j]);
-                       if (err) {
-                               dev_err(se_dev->dev,
-                               "crypto_register_sha alg failed index[%d]\n",
-                               i);
-                               goto clean;
-                       }
-               }
-       }
+       err = tegra_se_register_algs(se_dev);
+       if (err)
+               goto clean;
 
 #if defined(CONFIG_PM)
        if (!se_dev->chipdata->drbg_supported)
@@ -2786,11 +2828,6 @@ static int tegra_se_probe(struct platform_device *pdev)
 
 clean:
        pm_runtime_disable(se_dev->dev);
-       for (k = 0; k < i; k++)
-               crypto_unregister_alg(&aes_algs[k]);
-
-       for (k = 0; k < j; k++)
-               crypto_unregister_ahash(&hash_algs[j]);
 
        tegra_se_free_ll_buf(se_dev);
 
@@ -2821,7 +2858,6 @@ fail:
 static int tegra_se_remove(struct platform_device *pdev)
 {
        struct tegra_se_dev *se_dev = platform_get_drvdata(pdev);
-       int i;
 
        if (!se_dev)
                return -ENODEV;
@@ -2832,11 +2868,9 @@ static int tegra_se_remove(struct platform_device *pdev)
        if (se_work_q)
                destroy_workqueue(se_work_q);
        free_irq(se_dev->irq, &pdev->dev);
-       for (i = 0; i < ARRAY_SIZE(aes_algs); i++)
-               crypto_unregister_alg(&aes_algs[i]);
-       for (i = 0; i < ARRAY_SIZE(hash_algs); i++)
-               crypto_unregister_ahash(&hash_algs[i]);
 
+       tegra_se_unregister_algs(se_dev, ARRAY_SIZE(aes_algs),
+                                ARRAY_SIZE(hash_algs));
        if (se_dev->enclk)
                clk_put(se_dev->enclk);