diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2015-07-21 22:07:47 -0700 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-07-23 18:14:28 +0800 |
commit | 8f5ea2df02fb0a50d81701e0c5dc8a5f00381147 (patch) | |
tree | 37f43cde0760e36149fe3d3972abcfe5bcc5f9ef /drivers/crypto/qat | |
parent | 3cf080a7b747d800efc231d29bd3a07659c6aeb6 (diff) | |
download | talos-obmc-linux-8f5ea2df02fb0a50d81701e0c5dc8a5f00381147.tar.gz talos-obmc-linux-8f5ea2df02fb0a50d81701e0c5dc8a5f00381147.zip |
crypto: qat - Don't attempt to register algorithm multiple times
When multiple devices are present in the system the driver attempts
to register the same algorithm many times.
Changes in v2:
- use proper synchronization mechanizm between register and unregister
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/qat')
-rw-r--r-- | drivers/crypto/qat/qat_common/qat_asym_algs.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c index 557a7408710d..fe352a6a1630 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -58,6 +58,9 @@ #include "adf_common_drv.h" #include "qat_crypto.h" +static DEFINE_MUTEX(algs_lock); +static unsigned int active_devs; + struct qat_rsa_input_params { union { struct { @@ -629,11 +632,21 @@ static struct akcipher_alg rsa = { int qat_asym_algs_register(void) { - rsa.base.cra_flags = 0; - return crypto_register_akcipher(&rsa); + int ret = 0; + + mutex_lock(&algs_lock); + if (++active_devs == 1) { + rsa.base.cra_flags = 0; + ret = crypto_register_akcipher(&rsa); + } + mutex_unlock(&algs_lock); + return ret; } void qat_asym_algs_unregister(void) { - crypto_unregister_akcipher(&rsa); + mutex_lock(&algs_lock); + if (--active_devs == 0) + crypto_unregister_akcipher(&rsa); + mutex_unlock(&algs_lock); } |