wlan: Disable WLAN driver initiated SSR if Riva crashes during unload

 When there is a Riva crash, SSR is invoked by WCNSS Kernel driver.
 WLAN driver may also try to invoke SSR, since a Riva crash might end up
 in a WDI timeout during unload. So if there is a Riva crash, disable
 the SSR from WLAN driver in the unload path.

 Fixed CRs: 408941

Change-Id: Ia5d72a524d09cdf98a42fb4e2fca110dd0404a39
diff --git a/CORE/HDD/inc/wlan_hdd_main.h b/CORE/HDD/inc/wlan_hdd_main.h
index bd917c3..9a4909c 100644
--- a/CORE/HDD/inc/wlan_hdd_main.h
+++ b/CORE/HDD/inc/wlan_hdd_main.h
@@ -451,6 +451,14 @@
 }hdd_cfg80211_state_t;
 
 #endif
+
+typedef enum{
+    HDD_SSR_NOT_REQUIRED,
+    HDD_SSR_REQUIRED,
+    HDD_SSR_DISABLED,
+}e_hdd_ssr_required;
+
+
 struct hdd_station_ctx
 {
   /** Handle to the Wireless Extension State */
@@ -972,8 +980,8 @@
 void hdd_prevent_suspend(void);
 void hdd_allow_suspend(void);
 void hdd_allow_suspend_timeout(v_U32_t timeout);
-v_U8_t hdd_is_ssr_required(void);
-void hdd_set_ssr_required(v_U8_t value);
+bool hdd_is_ssr_required(void);
+void hdd_set_ssr_required(e_hdd_ssr_required value);
 
 VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx);
 VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type);
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index 2385238..c7d9f28 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -156,7 +156,7 @@
 static struct wake_lock wlan_wake_lock;
 #endif
 /* set when SSR is needed after unload */
-static v_U8_t      isSsrRequired;
+static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED;
 
 //internal function declaration
 static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx);
@@ -2181,13 +2181,17 @@
    return VOS_STATUS_SUCCESS;
 }
 
-v_U8_t hdd_is_ssr_required( void)
+bool hdd_is_ssr_required( void)
 {
-    return isSsrRequired;
+    return (isSsrRequired == HDD_SSR_REQUIRED);
 }
 
-void hdd_set_ssr_required( v_U8_t value)
+/* Once SSR is disabled then it cannot be set. */
+void hdd_set_ssr_required( e_hdd_ssr_required value)
 {
+    if (HDD_SSR_DISABLED == isSsrRequired)
+        return;
+
     isSsrRequired = value;
 }
 
diff --git a/CORE/VOSS/src/vos_api.c b/CORE/VOSS/src/vos_api.c
index b75c02e..13bde79 100644
--- a/CORE/VOSS/src/vos_api.c
+++ b/CORE/VOSS/src/vos_api.c
@@ -1083,7 +1083,7 @@
      vosStatus = WDA_shutdown( vosContext, VOS_TRUE );
      if (VOS_IS_STATUS_SUCCESS( vosStatus ) )
      {
-        hdd_set_ssr_required( VOS_TRUE );
+        hdd_set_ssr_required( HDD_SSR_REQUIRED );
      }
      else
      {
diff --git a/CORE/VOSS/src/vos_sched.c b/CORE/VOSS/src/vos_sched.c
index 3562863..8d851a4 100644
--- a/CORE/VOSS/src/vos_sched.c
+++ b/CORE/VOSS/src/vos_sched.c
@@ -2059,6 +2059,9 @@
         VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                 "%s: Load/unload in Progress. Ignoring signaling Watchdog",
                 __FUNCTION__);
+        /* wcnss has crashed, and SSR has alredy been started by Kernel driver.
+         * So disable SSR from WLAN driver */
+        hdd_set_ssr_required( HDD_SSR_DISABLED );
         return VOS_STATUS_E_FAILURE;
     }
     /* Update Riva Reset Statistics */