Commit 8f5ea2df authored by Tadeusz Struk's avatar Tadeusz Struk Committed by Herbert Xu

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: default avatarTadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 3cf080a7
...@@ -58,6 +58,9 @@ ...@@ -58,6 +58,9 @@
#include "adf_common_drv.h" #include "adf_common_drv.h"
#include "qat_crypto.h" #include "qat_crypto.h"
static DEFINE_MUTEX(algs_lock);
static unsigned int active_devs;
struct qat_rsa_input_params { struct qat_rsa_input_params {
union { union {
struct { struct {
...@@ -629,11 +632,21 @@ static struct akcipher_alg rsa = { ...@@ -629,11 +632,21 @@ static struct akcipher_alg rsa = {
int qat_asym_algs_register(void) int qat_asym_algs_register(void)
{ {
rsa.base.cra_flags = 0; int ret = 0;
return crypto_register_akcipher(&rsa);
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) 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);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment