Kaynağa Gözat

qcacld-3.0: Fix incorrect logic of atomic variable dfs_radar_found

Change "qcacld-3.0: change dfs_radar_found to atomic variable"
(Change-Id If95e2ce5a0c837f36a92673312ea4d2fc7b96abe) some of the
operations on atomic variable dfs_radar_found are incorrect. If the
operation require to test and set atomic variable then using two
different atomic operation to test and then set value does not make
whole operation atomic.

Must use single operation to test and set atomic variable.

Change-Id: I93e322ed26c51bf75432738cc24be525224f47a4
CRs-Fixed: 1043085
Arif Hussain 8 yıl önce
ebeveyn
işleme
2a7c1f3467
2 değiştirilmiş dosya ile 10 ekleme ve 10 silme
  1. 9 7
      core/hdd/src/wlan_hdd_hostapd.c
  2. 1 3
      core/hdd/src/wlan_hdd_main.c

+ 9 - 7
core/hdd/src/wlan_hdd_hostapd.c

@@ -1971,10 +1971,6 @@ int hdd_softap_set_channel_change(struct net_device *dev, int target_channel,
 		}
 	}
 
-	if (qdf_atomic_read(&pHddCtx->dfs_radar_found)) {
-		hdd_err("Channel switch in progress!!");
-		return -EBUSY;
-	}
 	/*
 	 * Set the dfs_radar_found flag to mimic channel change
 	 * when a radar is found. This will enable synchronizing
@@ -1984,7 +1980,11 @@ int hdd_softap_set_channel_change(struct net_device *dev, int target_channel,
 	 * once the channel change is completed and SAP will
 	 * post eSAP_START_BSS_EVENT success event to HDD.
 	 */
-	qdf_atomic_set(&pHddCtx->dfs_radar_found, 1);
+	if (qdf_atomic_inc_return(&pHddCtx->dfs_radar_found) > 1) {
+		hdd_err("Channel switch in progress!!");
+		return -EBUSY;
+	}
+
 	/*
 	 * Post the Channel Change request to SAP.
 	 */
@@ -2794,19 +2794,21 @@ static __iw_softap_setparam(struct net_device *dev,
 			(WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->
 			operatingChannel;
 		bool isDfsch;
+		int32_t dfs_radar_found;
 
 		isDfsch = (CHANNEL_STATE_DFS ==
 			   cds_get_channel_state(ch));
 
 		hdd_notice("Set QCASAP_SET_RADAR_CMD val %d", set_value);
 
-		if (!qdf_atomic_read(&pHddCtx->dfs_radar_found) && isDfsch) {
+		dfs_radar_found = qdf_atomic_read(&pHddCtx->dfs_radar_found);
+		if (!dfs_radar_found && isDfsch) {
 			ret = wma_cli_set_command(pHostapdAdapter->sessionId,
 						  WMA_VDEV_DFS_CONTROL_CMDID,
 						  set_value, VDEV_CMD);
 		} else {
 			hdd_err("Ignore, radar_found: %d,  dfs_channel: %d",
-			       qdf_atomic_read(&pHddCtx->dfs_radar_found), isDfsch);
+				dfs_radar_found, isDfsch);
 		}
 		break;
 	}

+ 1 - 3
core/hdd/src/wlan_hdd_main.c

@@ -1426,7 +1426,7 @@ bool hdd_dfs_indicate_radar(void *context, void *param)
 		return true;
 
 	if (true == hdd_radar_event->dfs_radar_status) {
-		if (qdf_atomic_read(&hdd_ctx->dfs_radar_found)) {
+		if (qdf_atomic_inc_return(&hdd_ctx->dfs_radar_found) > 1) {
 			/*
 			 * Application already triggered channel switch
 			 * on current channel, so return here.
@@ -1434,8 +1434,6 @@ bool hdd_dfs_indicate_radar(void *context, void *param)
 			return false;
 		}
 
-		qdf_atomic_set(&hdd_ctx->dfs_radar_found, 1);
-
 		status = hdd_get_front_adapter(hdd_ctx, &adapterNode);
 		while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) {
 			adapter = adapterNode->pAdapter;