diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index dd92ebe95a12..40af514e8761 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -161,6 +161,7 @@ #else #define WLAN_WAIT_TIME_DISCONNECT 5000 #endif +#define WLAN_WAIT_DISCONNECT_ALREADY_IN_PROGRESS 1000 #define WLAN_WAIT_TIME_STOP_ROAM 4000 #define WLAN_WAIT_TIME_STATS 800 #define WLAN_WAIT_TIME_POWER 800 diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 3f8e565bc14f..e10d60c162f6 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -17207,6 +17207,7 @@ static int wlan_hdd_disconnect(struct hdd_adapter *adapter, u16 reason) struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); eConnectionState prev_conn_state; tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); + uint32_t wait_time = WLAN_WAIT_TIME_DISCONNECT; ENTER(); @@ -17264,7 +17265,14 @@ static int wlan_hdd_disconnect(struct hdd_adapter *adapter, u16 reason) prev_conn_state != eConnectionState_Connecting) { hdd_debug("status = %d, already disconnected", status); result = 0; - goto disconnected; + /* + * Wait here instead of returning directly. This will block the + * next connect command and allow processing of the disconnect + * in SME else we might hit some race conditions leading to SME + * and HDD out of sync. As disconnect is already in progress, + * wait here for 1 sec instead of 5 sec. + */ + wait_time = WLAN_WAIT_DISCONNECT_ALREADY_IN_PROGRESS; } else if (QDF_STATUS_CMD_NOT_QUEUED == status) { /* * Wait here instead of returning directly, this will block the @@ -17281,8 +17289,7 @@ static int wlan_hdd_disconnect(struct hdd_adapter *adapter, u16 reason) } wait_for_disconnect: rc = wait_for_completion_timeout(&adapter->disconnect_comp_var, - msecs_to_jiffies - (WLAN_WAIT_TIME_DISCONNECT)); + msecs_to_jiffies(wait_time)); if (!rc && (QDF_STATUS_CMD_NOT_QUEUED != status)) { hdd_err("Failed to disconnect, timed out");