diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2014-05-12 07:44:28 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-05-22 09:03:10 -0400 |
commit | 5fc8005ba3e0bb5ea791fcc7248d0a2fb3e6c680 (patch) | |
tree | cba34e8991d4275ae76e7a32c3e2b29d3b7bcd74 /drivers/crypto/mxs-dcp.c | |
parent | 75ecb231ff45b54afa9f4ec9137965c3c00868f4 (diff) |
crypto: mxs-dcp - Remove global mutex
Remove mutex_lock from probe in order to avoid the following warning:
[ 8.526613] Freeing unused kernel memory: 232K (c0683000 - c06bd000)
starting pid 56, tty '': '/etc/rc.d/rcS'
[ 9.110314]
[ 9.111864] =====================================
[ 9.116603] [ BUG: init/1 still has locks held! ]
[ 9.121488] 3.15.0-rc4-next-20140509-00001-g319564e #1154 Not tainted
[ 9.128071] -------------------------------------
[ 9.132825] 1 lock held by init/1:
[ 9.136252] #0: (global_mutex){+.+.+.}, at: [<c0387d68>] mxs_dcp_probe+0x14
[ 9.144196]
[ 9.144196] stack backtrace:
[ 9.148888] CPU: 0 PID: 1 Comm: init Not tainted 3.15.0-rc4-next-20140509-004
[ 9.157610] [<c000da40>] (unwind_backtrace) from [<c000bda4>] (show_stack+0x)
[ 9.165595] [<c000bda4>] (show_stack) from [<c00153d4>] (do_fork+0x2c8/0x3cc)
[ 9.172921] [<c00153d4>] (do_fork) from [<c0015550>] (sys_vfork+0x20/0x2c)
[ 9.179973] [<c0015550>] (sys_vfork) from [<c0009580>] (ret_fast_syscall+0x0)
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/mxs-dcp.c')
-rw-r--r-- | drivers/crypto/mxs-dcp.c | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c index 7bbe0ab21eca..e48f0b87c383 100644 --- a/drivers/crypto/mxs-dcp.c +++ b/drivers/crypto/mxs-dcp.c | |||
@@ -104,7 +104,6 @@ struct dcp_sha_req_ctx { | |||
104 | * design of Linux Crypto API. | 104 | * design of Linux Crypto API. |
105 | */ | 105 | */ |
106 | static struct dcp *global_sdcp; | 106 | static struct dcp *global_sdcp; |
107 | static DEFINE_MUTEX(global_mutex); | ||
108 | 107 | ||
109 | /* DCP register layout. */ | 108 | /* DCP register layout. */ |
110 | #define MXS_DCP_CTRL 0x00 | 109 | #define MXS_DCP_CTRL 0x00 |
@@ -907,60 +906,49 @@ static int mxs_dcp_probe(struct platform_device *pdev) | |||
907 | struct resource *iores; | 906 | struct resource *iores; |
908 | int dcp_vmi_irq, dcp_irq; | 907 | int dcp_vmi_irq, dcp_irq; |
909 | 908 | ||
910 | mutex_lock(&global_mutex); | ||
911 | if (global_sdcp) { | 909 | if (global_sdcp) { |
912 | dev_err(dev, "Only one DCP instance allowed!\n"); | 910 | dev_err(dev, "Only one DCP instance allowed!\n"); |
913 | ret = -ENODEV; | 911 | return -ENODEV; |
914 | goto err_mutex; | ||
915 | } | 912 | } |
916 | 913 | ||
917 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 914 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
918 | dcp_vmi_irq = platform_get_irq(pdev, 0); | 915 | dcp_vmi_irq = platform_get_irq(pdev, 0); |
919 | if (dcp_vmi_irq < 0) { | 916 | if (dcp_vmi_irq < 0) |
920 | ret = dcp_vmi_irq; | 917 | return dcp_vmi_irq; |
921 | goto err_mutex; | ||
922 | } | ||
923 | 918 | ||
924 | dcp_irq = platform_get_irq(pdev, 1); | 919 | dcp_irq = platform_get_irq(pdev, 1); |
925 | if (dcp_irq < 0) { | 920 | if (dcp_irq < 0) |
926 | ret = dcp_irq; | 921 | return dcp_irq; |
927 | goto err_mutex; | ||
928 | } | ||
929 | 922 | ||
930 | sdcp = devm_kzalloc(dev, sizeof(*sdcp), GFP_KERNEL); | 923 | sdcp = devm_kzalloc(dev, sizeof(*sdcp), GFP_KERNEL); |
931 | if (!sdcp) { | 924 | if (!sdcp) |
932 | ret = -ENOMEM; | 925 | return -ENOMEM; |
933 | goto err_mutex; | ||
934 | } | ||
935 | 926 | ||
936 | sdcp->dev = dev; | 927 | sdcp->dev = dev; |
937 | sdcp->base = devm_ioremap_resource(dev, iores); | 928 | sdcp->base = devm_ioremap_resource(dev, iores); |
938 | if (IS_ERR(sdcp->base)) { | 929 | if (IS_ERR(sdcp->base)) |
939 | ret = PTR_ERR(sdcp->base); | 930 | return PTR_ERR(sdcp->base); |
940 | goto err_mutex; | 931 | |
941 | } | ||
942 | 932 | ||
943 | ret = devm_request_irq(dev, dcp_vmi_irq, mxs_dcp_irq, 0, | 933 | ret = devm_request_irq(dev, dcp_vmi_irq, mxs_dcp_irq, 0, |
944 | "dcp-vmi-irq", sdcp); | 934 | "dcp-vmi-irq", sdcp); |
945 | if (ret) { | 935 | if (ret) { |
946 | dev_err(dev, "Failed to claim DCP VMI IRQ!\n"); | 936 | dev_err(dev, "Failed to claim DCP VMI IRQ!\n"); |
947 | goto err_mutex; | 937 | return ret; |
948 | } | 938 | } |
949 | 939 | ||
950 | ret = devm_request_irq(dev, dcp_irq, mxs_dcp_irq, 0, | 940 | ret = devm_request_irq(dev, dcp_irq, mxs_dcp_irq, 0, |
951 | "dcp-irq", sdcp); | 941 | "dcp-irq", sdcp); |
952 | if (ret) { | 942 | if (ret) { |
953 | dev_err(dev, "Failed to claim DCP IRQ!\n"); | 943 | dev_err(dev, "Failed to claim DCP IRQ!\n"); |
954 | goto err_mutex; | 944 | return ret; |
955 | } | 945 | } |
956 | 946 | ||
957 | /* Allocate coherent helper block. */ | 947 | /* Allocate coherent helper block. */ |
958 | sdcp->coh = devm_kzalloc(dev, sizeof(*sdcp->coh) + DCP_ALIGNMENT, | 948 | sdcp->coh = devm_kzalloc(dev, sizeof(*sdcp->coh) + DCP_ALIGNMENT, |
959 | GFP_KERNEL); | 949 | GFP_KERNEL); |
960 | if (!sdcp->coh) { | 950 | if (!sdcp->coh) |
961 | ret = -ENOMEM; | 951 | return -ENOMEM; |
962 | goto err_mutex; | ||
963 | } | ||
964 | 952 | ||
965 | /* Re-align the structure so it fits the DCP constraints. */ | 953 | /* Re-align the structure so it fits the DCP constraints. */ |
966 | sdcp->coh = PTR_ALIGN(sdcp->coh, DCP_ALIGNMENT); | 954 | sdcp->coh = PTR_ALIGN(sdcp->coh, DCP_ALIGNMENT); |
@@ -968,7 +956,7 @@ static int mxs_dcp_probe(struct platform_device *pdev) | |||
968 | /* Restart the DCP block. */ | 956 | /* Restart the DCP block. */ |
969 | ret = stmp_reset_block(sdcp->base); | 957 | ret = stmp_reset_block(sdcp->base); |
970 | if (ret) | 958 | if (ret) |
971 | goto err_mutex; | 959 | return ret; |
972 | 960 | ||
973 | /* Initialize control register. */ | 961 | /* Initialize control register. */ |
974 | writel(MXS_DCP_CTRL_GATHER_RESIDUAL_WRITES | | 962 | writel(MXS_DCP_CTRL_GATHER_RESIDUAL_WRITES | |
@@ -1006,8 +994,7 @@ static int mxs_dcp_probe(struct platform_device *pdev) | |||
1006 | NULL, "mxs_dcp_chan/sha"); | 994 | NULL, "mxs_dcp_chan/sha"); |
1007 | if (IS_ERR(sdcp->thread[DCP_CHAN_HASH_SHA])) { | 995 | if (IS_ERR(sdcp->thread[DCP_CHAN_HASH_SHA])) { |
1008 | dev_err(dev, "Error starting SHA thread!\n"); | 996 | dev_err(dev, "Error starting SHA thread!\n"); |
1009 | ret = PTR_ERR(sdcp->thread[DCP_CHAN_HASH_SHA]); | 997 | return PTR_ERR(sdcp->thread[DCP_CHAN_HASH_SHA]); |
1010 | goto err_mutex; | ||
1011 | } | 998 | } |
1012 | 999 | ||
1013 | sdcp->thread[DCP_CHAN_CRYPTO] = kthread_run(dcp_chan_thread_aes, | 1000 | sdcp->thread[DCP_CHAN_CRYPTO] = kthread_run(dcp_chan_thread_aes, |
@@ -1064,9 +1051,6 @@ err_destroy_aes_thread: | |||
1064 | 1051 | ||
1065 | err_destroy_sha_thread: | 1052 | err_destroy_sha_thread: |
1066 | kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]); | 1053 | kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]); |
1067 | |||
1068 | err_mutex: | ||
1069 | mutex_unlock(&global_mutex); | ||
1070 | return ret; | 1054 | return ret; |
1071 | } | 1055 | } |
1072 | 1056 | ||
@@ -1088,9 +1072,7 @@ static int mxs_dcp_remove(struct platform_device *pdev) | |||
1088 | 1072 | ||
1089 | platform_set_drvdata(pdev, NULL); | 1073 | platform_set_drvdata(pdev, NULL); |
1090 | 1074 | ||
1091 | mutex_lock(&global_mutex); | ||
1092 | global_sdcp = NULL; | 1075 | global_sdcp = NULL; |
1093 | mutex_unlock(&global_mutex); | ||
1094 | 1076 | ||
1095 | return 0; | 1077 | return 0; |
1096 | } | 1078 | } |