aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-dpdk/odp_crypto.c
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2019-11-27 17:17:55 +0200
committerMatias Elo <matias.elo@nokia.com>2019-12-02 11:09:32 +0200
commitb56aa023e3152b13db513ee7b12d3104062e687c (patch)
treee072b6f13c0781e10d92bf12884385eb76db3805 /platform/linux-dpdk/odp_crypto.c
parent113c9de182fd2570fe7a5b991e6f323a73f0f3f9 (diff)
linux-dpdk: crypto: improve locking
Remove unnecessary locks from global init and terminate, and fix possible deadlock in odp_crypto_int(). Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'platform/linux-dpdk/odp_crypto.c')
-rw-r--r--platform/linux-dpdk/odp_crypto.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/platform/linux-dpdk/odp_crypto.c b/platform/linux-dpdk/odp_crypto.c
index 61c74b12c..9602d9c90 100644
--- a/platform/linux-dpdk/odp_crypto.c
+++ b/platform/linux-dpdk/odp_crypto.c
@@ -326,7 +326,6 @@ int _odp_crypto_init_global(void)
global->enabled_crypto_devs = 0;
odp_spinlock_init(&global->lock);
- odp_spinlock_lock(&global->lock);
if (global->is_crypto_dev_initialized)
return 0;
@@ -470,7 +469,6 @@ int _odp_crypto_init_global(void)
}
global->is_crypto_dev_initialized = 1;
- odp_spinlock_unlock(&global->lock);
return 0;
}
@@ -1540,7 +1538,6 @@ int _odp_crypto_term_global(void)
if (odp_global_ro.disable.crypto || global == NULL)
return 0;
- odp_spinlock_lock(&global->lock);
for (session = global->free; session != NULL; session = session->next)
count++;
if (count != MAX_SESSIONS) {
@@ -1551,8 +1548,6 @@ int _odp_crypto_term_global(void)
if (global->crypto_op_pool != NULL)
rte_mempool_free(global->crypto_op_pool);
- odp_spinlock_unlock(&global->lock);
-
ret = odp_shm_free(global->shm);
if (ret < 0) {
ODP_ERR("shm free failed for crypto_pool\n");
@@ -1849,13 +1844,13 @@ int odp_crypto_int(odp_packet_t pkt_in,
odp_spinlock_lock(&global->lock);
op = rte_crypto_op_alloc(global->crypto_op_pool,
RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ odp_spinlock_unlock(&global->lock);
+
if (op == NULL) {
ODP_ERR("Failed to allocate crypto operation");
goto err;
}
- odp_spinlock_unlock(&global->lock);
-
if (cipher_is_aead(session->p.cipher_alg))
crypto_fill_aead_param(session, out_pkt, param, op,
&rc_cipher, &rc_auth);