[qca-nss-drv] Fix NSS Core-1 hang during IPsec
NSS Core-1 hangs during IPsec start, after NSS is scaled
down to Idle frequency. This is a random behavior.
The Frequency workqueue handler which can be executed by
NSS autoscale handler and Crypto session create function
is prone to race condition. Add Mutex lock for frequency
handler to avoid this scenario.
Change-Id: I9d15dd71ce5aa5d8edf0af22a9ee7c394976e0d5
Signed-off-by: c_athand <athand@codeaurora.org>
diff --git a/nss_core.h b/nss_core.h
index 79b79ea..4c659df 100644
--- a/nss_core.h
+++ b/nss_core.h
@@ -928,6 +928,7 @@
uint32_t clk_src; /* Clock source: default/alternate */
spinlock_t lock; /* Big lock for NSS driver */
spinlock_t stats_lock; /* Statistics lock */
+ struct mutex wq_lock; /* Mutex for NSS Work queue function */
struct dentry *top_dentry; /* Top dentry for nss */
struct dentry *stats_dentry; /* Top dentry for nss stats */
struct dentry *ipv4_dentry; /* IPv4 stats dentry */
diff --git a/nss_init.c b/nss_init.c
index 8411e09..3ec702a 100644
--- a/nss_init.c
+++ b/nss_init.c
@@ -180,12 +180,14 @@
bool auto_scale;
bool turbo;
+ mutex_lock(&nss_top_main.wq_lock);
/*
* If crypto clock is in Turbo, disable scaling for other
* NSS subsystem components and retain them at turbo
*/
if (nss_crypto_is_scaled) {
nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency;
+ mutex_unlock(&nss_top_main.wq_lock);
return;
}
#endif
@@ -248,6 +250,7 @@
}
#endif
#endif
+ mutex_unlock(&nss_top_main.wq_lock);
kfree((void *)work);
}
@@ -690,6 +693,7 @@
*/
spin_lock_init(&(nss_top_main.lock));
spin_lock_init(&(nss_top_main.stats_lock));
+ mutex_init(&(nss_top_main.wq_lock));
/*
* Enable NSS statistics