Browse Source

qcacld-3.0: Acquire wake lock timeout for rrm scan

Currently driver acquires wakelock for scans received from hdd.
But for RRM scan initiated from AP for beacon reports, the
wakelock is not acquired and if host goes to suspend while scan
is in progress,FW asserts.

Fix is to avoid the system suspend by taking the wakelock
before rrm scan start.

Change-Id: I02ddc9b5e6ba5f1782d00e34f044ace34c54d0b0
CRs-Fixed: 2331741
Abhinav Kumar 6 years ago
parent
commit
03522c2330
2 changed files with 44 additions and 0 deletions
  1. 1 0
      core/sme/inc/sme_rrm_internal.h
  2. 43 0
      core/sme/src/rrm/sme_rrm.c

+ 1 - 0
core/sme/inc/sme_rrm_internal.h

@@ -85,6 +85,7 @@ typedef struct sRrmSMEContext {
 #endif /* FEATURE_WLAN_ESE */
 	tRrmMsgReqSource msgSource;
 	wlan_scan_requester req_id;
+	qdf_wake_lock_t scan_wake_lock;
 } tRrmSMEContext, *tpRrmSMEContext;
 
 typedef struct sRrmNeighborReq {

+ 43 - 0
core/sme/src/rrm/sme_rrm.c

@@ -901,6 +901,38 @@ free_ch_lst:
 	return status;
 }
 
+/**
+ * sme_rrm_calculate_total_scan_time() - calculate total time req for
+ * scan for all channels
+ * @mac_ctx: The handle returned by mac_open.
+ *
+ * Return: total rrm scan time
+ */
+static uint32_t sme_rrm_calculate_total_scan_time(tpAniSirGlobal mac_ctx)
+{
+	uint32_t dwell_time_active;
+	uint16_t interval;
+	tpRrmSMEContext pSmeRrmContext = &mac_ctx->rrm.rrmSmeContext;
+	uint8_t num_channels;
+	uint32_t rrm_scan_time = 0;
+
+	num_channels = pSmeRrmContext->channelList.numOfChannels;
+
+	interval = pSmeRrmContext->randnIntvl + 10;
+
+	dwell_time_active = pSmeRrmContext->duration[0];
+
+	/*
+	 * Add 1 sec extra in actual total rrm scan time
+	 * to accommodate any delay
+	 */
+	if (num_channels)
+		rrm_scan_time = ((num_channels * dwell_time_active) +
+				 ((num_channels - 1) * interval) + 1000);
+
+	return rrm_scan_time;
+}
+
 /**
  * sme_rrm_process_beacon_report_req_ind() -Process beacon report request
  * @pMac:- Global Mac structure
@@ -919,6 +951,7 @@ QDF_STATUS sme_rrm_process_beacon_report_req_ind(tpAniSirGlobal pMac,
 	tpSirBeaconReportReqInd pBeaconReq = (tpSirBeaconReportReqInd) pMsgBuf;
 	tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
 	uint32_t len = 0, i = 0;
+	uint32_t total_rrm_scan_time;
 
 	sme_debug("Received Beacon report request ind Channel = %d",
 		pBeaconReq->channelInfo.channelNum);
@@ -1015,6 +1048,12 @@ QDF_STATUS sme_rrm_process_beacon_report_req_ind(tpAniSirGlobal pMac,
 		pSmeRrmContext->token, pSmeRrmContext->regClass,
 		pSmeRrmContext->randnIntvl, pSmeRrmContext->msgSource);
 
+	total_rrm_scan_time = sme_rrm_calculate_total_scan_time(pMac);
+
+	if (total_rrm_scan_time)
+		qdf_wake_lock_timeout_acquire(&pSmeRrmContext->scan_wake_lock,
+					      total_rrm_scan_time);
+
 	return sme_rrm_issue_scan_req(pMac);
 }
 
@@ -1417,6 +1456,8 @@ QDF_STATUS rrm_open(tpAniSirGlobal pMac)
 	QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
 
 	pSmeRrmContext->rrmConfig.max_randn_interval = 50;        /* ms */
+	qdf_wake_lock_create(&pSmeRrmContext->scan_wake_lock,
+			     "wlan_rrm_scan_wl");
 
 	qdf_status = qdf_mc_timer_init(&pSmeRrmContext->IterMeasTimer,
 				       QDF_TIMER_TYPE_SW,
@@ -1510,6 +1551,8 @@ QDF_STATUS rrm_close(tpAniSirGlobal pMac)
 
 	csr_ll_close(&pSmeRrmContext->neighborReportCache);
 
+	qdf_wake_lock_destroy(&pSmeRrmContext->scan_wake_lock);
+
 	return qdf_status;
 
 }