diff options
author | Aaro Koskinen <aaro.koskinen@iki.fi> | 2015-03-08 16:07:42 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-03-24 10:15:37 -0400 |
commit | e606ee200a83bec648aaf5442ce9e71fc07b215d (patch) | |
tree | a81d367508d4b5f5a353f257df4ef037066c3371 /arch/mips/cavium-octeon/crypto | |
parent | f7715e72f5630b42c33360dbf8d22e52aaa76f8e (diff) |
CRYPTO: Octeon: always disable preemption when using crypto engine
Always disable preemption on behalf of the drivers when crypto engine
is taken into use. This will simplify the usage.
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David S. Miller <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/9494/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/cavium-octeon/crypto')
-rw-r--r-- | arch/mips/cavium-octeon/crypto/octeon-crypto.c | 4 | ||||
-rw-r--r-- | arch/mips/cavium-octeon/crypto/octeon-md5.c | 4 |
2 files changed, 3 insertions, 5 deletions
diff --git a/arch/mips/cavium-octeon/crypto/octeon-crypto.c b/arch/mips/cavium-octeon/crypto/octeon-crypto.c index 7c82ff463b65..f66bd1adc7ff 100644 --- a/arch/mips/cavium-octeon/crypto/octeon-crypto.c +++ b/arch/mips/cavium-octeon/crypto/octeon-crypto.c | |||
@@ -17,7 +17,7 @@ | |||
17 | * crypto operations in calls to octeon_crypto_enable/disable in order to make | 17 | * crypto operations in calls to octeon_crypto_enable/disable in order to make |
18 | * sure the state of COP2 isn't corrupted if userspace is also performing | 18 | * sure the state of COP2 isn't corrupted if userspace is also performing |
19 | * hardware crypto operations. Allocate the state parameter on the stack. | 19 | * hardware crypto operations. Allocate the state parameter on the stack. |
20 | * Preemption must be disabled to prevent context switches. | 20 | * Returns with preemption disabled. |
21 | * | 21 | * |
22 | * @state: Pointer to state structure to store current COP2 state in. | 22 | * @state: Pointer to state structure to store current COP2 state in. |
23 | * | 23 | * |
@@ -28,6 +28,7 @@ unsigned long octeon_crypto_enable(struct octeon_cop2_state *state) | |||
28 | int status; | 28 | int status; |
29 | unsigned long flags; | 29 | unsigned long flags; |
30 | 30 | ||
31 | preempt_disable(); | ||
31 | local_irq_save(flags); | 32 | local_irq_save(flags); |
32 | status = read_c0_status(); | 33 | status = read_c0_status(); |
33 | write_c0_status(status | ST0_CU2); | 34 | write_c0_status(status | ST0_CU2); |
@@ -62,5 +63,6 @@ void octeon_crypto_disable(struct octeon_cop2_state *state, | |||
62 | else | 63 | else |
63 | write_c0_status(read_c0_status() & ~ST0_CU2); | 64 | write_c0_status(read_c0_status() & ~ST0_CU2); |
64 | local_irq_restore(flags); | 65 | local_irq_restore(flags); |
66 | preempt_enable(); | ||
65 | } | 67 | } |
66 | EXPORT_SYMBOL_GPL(octeon_crypto_disable); | 68 | EXPORT_SYMBOL_GPL(octeon_crypto_disable); |
diff --git a/arch/mips/cavium-octeon/crypto/octeon-md5.c b/arch/mips/cavium-octeon/crypto/octeon-md5.c index 3dd88450d440..12dccdb38286 100644 --- a/arch/mips/cavium-octeon/crypto/octeon-md5.c +++ b/arch/mips/cavium-octeon/crypto/octeon-md5.c | |||
@@ -97,7 +97,6 @@ static int octeon_md5_update(struct shash_desc *desc, const u8 *data, | |||
97 | memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), data, | 97 | memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), data, |
98 | avail); | 98 | avail); |
99 | 99 | ||
100 | preempt_disable(); | ||
101 | flags = octeon_crypto_enable(&state); | 100 | flags = octeon_crypto_enable(&state); |
102 | octeon_md5_store_hash(mctx); | 101 | octeon_md5_store_hash(mctx); |
103 | 102 | ||
@@ -113,7 +112,6 @@ static int octeon_md5_update(struct shash_desc *desc, const u8 *data, | |||
113 | 112 | ||
114 | octeon_md5_read_hash(mctx); | 113 | octeon_md5_read_hash(mctx); |
115 | octeon_crypto_disable(&state, flags); | 114 | octeon_crypto_disable(&state, flags); |
116 | preempt_enable(); | ||
117 | 115 | ||
118 | memcpy(mctx->block, data, len); | 116 | memcpy(mctx->block, data, len); |
119 | 117 | ||
@@ -131,7 +129,6 @@ static int octeon_md5_final(struct shash_desc *desc, u8 *out) | |||
131 | 129 | ||
132 | *p++ = 0x80; | 130 | *p++ = 0x80; |
133 | 131 | ||
134 | preempt_disable(); | ||
135 | flags = octeon_crypto_enable(&state); | 132 | flags = octeon_crypto_enable(&state); |
136 | octeon_md5_store_hash(mctx); | 133 | octeon_md5_store_hash(mctx); |
137 | 134 | ||
@@ -149,7 +146,6 @@ static int octeon_md5_final(struct shash_desc *desc, u8 *out) | |||
149 | 146 | ||
150 | octeon_md5_read_hash(mctx); | 147 | octeon_md5_read_hash(mctx); |
151 | octeon_crypto_disable(&state, flags); | 148 | octeon_crypto_disable(&state, flags); |
152 | preempt_enable(); | ||
153 | 149 | ||
154 | memcpy(out, mctx->hash, sizeof(mctx->hash)); | 150 | memcpy(out, mctx->hash, sizeof(mctx->hash)); |
155 | memset(mctx, 0, sizeof(*mctx)); | 151 | memset(mctx, 0, sizeof(*mctx)); |