Browse Source

qcacld-3.0: Add runtime suspend and resume support in PMO

As part of UMAC componentization add runtime suspend and resume
support in PMO.

Change-Id: I120044bb5638ca75e6ac46b22bb194520da22fea
CRs-Fixed: 2030194
Sravan Kumar Kairam 8 years ago
parent
commit
27296783b7

+ 7 - 1
core/cds/src/cds_api.c

@@ -545,6 +545,8 @@ QDF_STATUS cds_open(struct wlan_objmgr_psoc *psoc)
 			gp_cds_context->htc_ctx, gp_cds_context->qdf_ctx,
 			&dp_ol_if_ops, psoc);
 
+	pmo_ucfg_psoc_update_dp_handle(psoc, gp_cds_context->dp_soc);
+
 	cds_set_ac_specs_params(cds_cfg);
 
 	cds_cdp_cfg_attach(cds_cfg);
@@ -583,6 +585,7 @@ QDF_STATUS cds_open(struct wlan_objmgr_psoc *psoc)
 		QDF_ASSERT(0);
 		goto err_sme_close;
 	}
+	pmo_ucfg_psoc_set_txrx_handle(psoc, gp_cds_context->pdev_txrx_ctx);
 
 	QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_INFO_HIGH,
 		  "%s: CDS successfully Opened", __func__);
@@ -599,13 +602,14 @@ err_mac_close:
 err_wma_close:
 	cds_shutdown_notifier_purge();
 	wma_close(gp_cds_context);
-
 	wma_wmi_service_close(gp_cds_context);
+	pmo_ucfg_psoc_update_dp_handle(psoc, NULL);
 
 err_htc_close:
 	if (gp_cds_context->htc_ctx) {
 		htc_destroy(gp_cds_context->htc_ctx);
 		gp_cds_context->htc_ctx = NULL;
+		pmo_ucfg_psoc_update_htc_handle(psoc, NULL);
 	}
 
 err_bmi_close:
@@ -1025,6 +1029,7 @@ QDF_STATUS cds_close(struct wlan_objmgr_psoc *psoc, v_CONTEXT_t cds_context)
 
 	ctx = cds_get_context(QDF_MODULE_ID_TXRX);
 	cds_set_context(QDF_MODULE_ID_TXRX, NULL);
+	pmo_ucfg_psoc_set_txrx_handle(psoc, NULL);
 	cdp_pdev_detach(cds_get_context(QDF_MODULE_ID_SOC),
 		       (struct cdp_pdev *)ctx, 1);
 
@@ -1045,6 +1050,7 @@ QDF_STATUS cds_close(struct wlan_objmgr_psoc *psoc, v_CONTEXT_t cds_context)
 	((p_cds_contextType) cds_context)->pMACContext = NULL;
 
 	cdp_soc_detach(gp_cds_context->dp_soc);
+	pmo_ucfg_psoc_update_dp_handle(psoc, NULL);
 
 	cds_shutdown_notifier_purge();
 

+ 2 - 1
core/hdd/inc/wlan_hdd_driver_ops.h

@@ -103,11 +103,12 @@ int wlan_hdd_bus_resume_noirq(void);
 
 /**
  * hdd_hif_close() - HIF close helper
+ * @hdd_ctx: HDD context
  * @hif_ctx: HIF context
  *
  * Helper function to close HIF
  */
-void hdd_hif_close(void *hif_ctx);
+void hdd_hif_close(hdd_context_t *hdd_ctx, void *hif_ctx);
 
 /**
  * hdd_hif_open() - HIF open helper

+ 86 - 59
core/hdd/src/wlan_hdd_driver_ops.c

@@ -251,6 +251,8 @@ int hdd_hif_open(struct device *dev, void *bdev, const hif_bus_id *bid,
 		}
 	}
 
+	pmo_ucfg_psoc_set_hif_handle(hdd_ctx->hdd_psoc, hif_ctx);
+
 	return 0;
 
 err_hif_close:
@@ -259,8 +261,13 @@ err_hif_close:
 	return ret;
 }
 
-void hdd_hif_close(void *hif_ctx)
+void hdd_hif_close(hdd_context_t *hdd_ctx, void *hif_ctx)
 {
+	if (!hdd_ctx) {
+		hdd_err("hdd_ctx error");
+		return;
+	}
+
 	if (hif_ctx == NULL)
 		return;
 
@@ -270,6 +277,8 @@ void hdd_hif_close(void *hif_ctx)
 
 	hdd_deinit_cds_hif_context();
 	hif_close(hif_ctx);
+
+	pmo_ucfg_psoc_set_hif_handle(hdd_ctx->hdd_psoc, NULL);
 }
 
 /**
@@ -933,6 +942,23 @@ static int wlan_hdd_bus_reset_resume(void)
 }
 
 #ifdef FEATURE_RUNTIME_PM
+/**
+ * hdd_pld_runtime_suspend_cb() - Runtime suspend callback from PMO
+ *
+ * Return: 0 on success or error value otherwise
+ */
+static int hdd_pld_runtime_suspend_cb(void)
+{
+	qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
+
+	if (!qdf_dev) {
+		hdd_err("Invalid context");
+		return -EINVAL;
+	}
+
+	return pld_auto_suspend(qdf_dev->dev);
+}
+
 /**
  * __wlan_hdd_runtime_suspend() - suspend the wlan bus without apps suspend
  *
@@ -944,60 +970,37 @@ static int wlan_hdd_bus_reset_resume(void)
  */
 static int __wlan_hdd_runtime_suspend(struct device *dev)
 {
-	hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
-	void *txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX);
-	void *htc_ctx = cds_get_context(QDF_MODULE_ID_HTC);
-	int status = wlan_hdd_validate_context(hdd_ctx);
-	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
-	struct wow_enable_params wow_params = {0};
-
-	if (0 != status)
-		goto process_failure;
+	int err;
+	QDF_STATUS status;
+	hdd_context_t *hdd_ctx;
 
-	status = hif_pre_runtime_suspend(hif_ctx);
-	if (status)
-		goto process_failure;
+	hdd_debug("Starting runtime suspend");
 
-	status = qdf_status_to_os_return(cdp_runtime_suspend(soc,
-				(struct cdp_pdev *)txrx_pdev));
-	if (status)
-		goto process_failure;
-
-	status = htc_runtime_suspend(htc_ctx);
-	if (status)
-		goto resume_txrx;
+	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	err = wlan_hdd_validate_context(hdd_ctx);
+	if (err)
+		return err;
 
-	status = wma_runtime_suspend(wow_params);
-	if (status)
-		goto resume_htc;
+	if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) {
+		hdd_debug("Driver module closed skipping runtime suspend");
+		return 0;
+	}
 
-	status = hif_runtime_suspend(hif_ctx);
-	if (status)
-		goto resume_wma;
+	if (ucfg_scan_get_pdev_status(hdd_ctx->hdd_pdev) !=
+	    SCAN_NOT_IN_PROGRESS) {
+		hdd_debug("Scan in progress, ignore runtime suspend");
+		return -EBUSY;
+	}
 
-	status = pld_auto_suspend(dev);
-	if (status)
-		goto resume_hif;
+	status = pmo_ucfg_psoc_bus_runtime_suspend(hdd_ctx->hdd_psoc,
+						   hdd_pld_runtime_suspend_cb);
+	err = qdf_status_to_os_return(status);
 
-	hif_process_runtime_suspend_success(hif_ctx);
-	return status;
+	hdd_debug("Runtime suspend done result: %d", err);
 
-resume_hif:
-	QDF_BUG(!hif_runtime_resume(hif_ctx));
-resume_wma:
-	QDF_BUG(!wma_runtime_resume());
-resume_htc:
-	QDF_BUG(!htc_runtime_resume(htc_ctx));
-resume_txrx:
-	QDF_BUG(!qdf_status_to_os_return(cdp_runtime_resume(soc,
-				(struct cdp_pdev *)txrx_pdev)));
-process_failure:
-	hif_process_runtime_suspend_failure(hif_ctx);
-	return status;
+	return err;
 }
 
-
 /**
  * wlan_hdd_runtime_suspend() - suspend the wlan bus without apps suspend
  *
@@ -1017,6 +1020,23 @@ static int wlan_hdd_runtime_suspend(struct device *dev)
 	return ret;
 }
 
+/**
+ * hdd_pld_runtime_resume_cb() - Runtime resume callback from PMO
+ *
+ * Return: 0 on success or error value otherwise
+ */
+static int hdd_pld_runtime_resume_cb(void)
+{
+	qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
+
+	if (!qdf_dev) {
+		hdd_err("Invalid context");
+		return -EINVAL;
+	}
+
+	return pld_auto_resume(qdf_dev->dev);
+}
+
 /**
  * __wlan_hdd_runtime_resume() - resume the wlan bus from runtime suspend
  *
@@ -1027,19 +1047,26 @@ static int wlan_hdd_runtime_suspend(struct device *dev)
  */
 static int __wlan_hdd_runtime_resume(struct device *dev)
 {
-	void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
-	void *htc_ctx = cds_get_context(QDF_MODULE_ID_HTC);
-	void *txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX);
-	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
-
-	hif_pre_runtime_resume(hif_ctx);
-	QDF_BUG(!pld_auto_resume(dev));
-	QDF_BUG(!hif_runtime_resume(hif_ctx));
-	QDF_BUG(!wma_runtime_resume());
-	QDF_BUG(!htc_runtime_resume(htc_ctx));
-	QDF_BUG(!qdf_status_to_os_return(cdp_runtime_resume(soc,
-				(struct cdp_pdev *)txrx_pdev)));
-	hif_process_runtime_resume_success(hif_ctx);
+	hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	QDF_STATUS status;
+
+	hdd_debug("Starting runtime resume");
+
+	if (wlan_hdd_validate_context(hdd_ctx))
+		return 0;
+
+	if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) {
+		hdd_debug("Driver module closed skipping runtime resume");
+		return 0;
+	}
+
+	status = pmo_ucfg_psoc_bus_runtime_resume(hdd_ctx->hdd_psoc,
+						  hdd_pld_runtime_resume_cb);
+	if (status != QDF_STATUS_SUCCESS)
+		hdd_err("PMO Runtime resume failed: %d", status);
+
+	hdd_debug("Runtime resume done");
+
 	return 0;
 }
 

+ 2 - 2
core/hdd/src/wlan_hdd_main.c

@@ -2100,7 +2100,7 @@ ol_cds_free:
 	ol_cds_free();
 
 hif_close:
-	hdd_hif_close(p_cds_context->pHIFContext);
+	hdd_hif_close(hdd_ctx, p_cds_context->pHIFContext);
 power_down:
 	if (!reinit && !unint)
 		pld_power_off(qdf_dev->dev);
@@ -8962,7 +8962,7 @@ int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx, bool ftm_mode)
 		ret = -EINVAL;
 	}
 
-	hdd_hif_close(hif_ctx);
+	hdd_hif_close(hdd_ctx, hif_ctx);
 
 	ol_cds_free();
 

+ 0 - 2
core/mac/src/sys/legacy/src/utils/src/mac_trace.c

@@ -523,8 +523,6 @@ uint8_t *mac_trace_get_wma_msg_string(uint16_t wma_msg)
 		CASE_RETURN_STRING(WMA_WLAN_SET_APP_TYPE2_PARAMS);
 #endif
 		CASE_RETURN_STRING(WMA_MSG_TYPES_END);
-		CASE_RETURN_STRING(WMA_RUNTIME_PM_SUSPEND_IND);
-		CASE_RETURN_STRING(WMA_RUNTIME_PM_RESUME_IND);
 		CASE_RETURN_STRING(WMA_AGGR_QOS_REQ);
 		CASE_RETURN_STRING(WMA_AGGR_QOS_RSP);
 		CASE_RETURN_STRING(WMA_FTM_CMD_REQ);

+ 0 - 1
core/wma/inc/wma.h

@@ -1486,7 +1486,6 @@ typedef struct {
 		tpSirBssDescription  bss_desc_ptr);
 	qdf_wake_lock_t wmi_cmd_rsp_wake_lock;
 	qdf_runtime_lock_t wmi_cmd_rsp_runtime_lock;
-	qdf_runtime_lock_t wma_runtime_resume_lock;
 	uint32_t fine_time_measurement_cap;
 	bool bpf_enabled;
 	bool bpf_packet_filter_enable;

+ 0 - 3
core/wma/inc/wma_api.h

@@ -135,9 +135,6 @@ QDF_STATUS wma_get_wcnss_software_version(void *p_cds_gctx,
 					  uint8_t *pVersion,
 					  uint32_t versionBufferSize);
 
-int wma_runtime_suspend(struct wow_enable_params wow_params);
-int wma_runtime_resume(void);
-
 bool wma_check_scan_in_progress(WMA_HANDLE handle);
 void wma_set_peer_authorized_cb(void *wma_ctx, wma_peer_authorized_fp auth_cb);
 QDF_STATUS wma_set_peer_param(void *wma_ctx, uint8_t *peer_addr,

+ 0 - 4
core/wma/inc/wma_internal.h

@@ -934,8 +934,6 @@ int wma_wow_wakeup_host_event(void *handle, uint8_t *event,
 				     uint32_t len);
 int wma_pdev_resume_event_handler(void *handle, uint8_t *event, uint32_t len);
 
-QDF_STATUS wma_resume_req(tp_wma_handle wma, enum qdf_suspend_type type);
-
 QDF_STATUS wma_wow_add_pattern(tp_wma_handle wma,
 			struct wow_add_pattern *ptrn);
 
@@ -946,8 +944,6 @@ QDF_STATUS wma_wow_enter(tp_wma_handle wma, tpSirHalWowlEnterParams info);
 
 QDF_STATUS wma_wow_exit(tp_wma_handle wma, tpSirHalWowlExitParams info);
 
-QDF_STATUS wma_suspend_req(tp_wma_handle wma, enum qdf_suspend_type type);
-
 void wma_calculate_and_update_conn_state(tp_wma_handle wma);
 void wma_update_conn_state(tp_wma_handle wma, uint32_t conn_mask);
 void wma_update_conn_state(tp_wma_handle wma, uint32_t conn_mask);

+ 0 - 3
core/wma/inc/wma_types.h

@@ -265,9 +265,6 @@
 #define WMA_WLAN_RESUME_REQ           SIR_HAL_WLAN_RESUME_REQ
 #define WMA_MSG_TYPES_END    SIR_HAL_MSG_TYPES_END
 
-#define WMA_RUNTIME_PM_SUSPEND_IND	SIR_HAL_RUNTIME_PM_SUSPEND_IND
-#define WMA_RUNTIME_PM_RESUME_IND	SIR_HAL_RUNTIME_PM_RESUME_IND
-
 #define WMA_AGGR_QOS_REQ               SIR_HAL_AGGR_QOS_REQ
 #define WMA_AGGR_QOS_RSP               SIR_HAL_AGGR_QOS_RSP
 

+ 0 - 126
core/wma/src/wma_features.c

@@ -2560,33 +2560,6 @@ static inline void wma_set_wow_bus_suspend(tp_wma_handle wma, int val)
 	wmi_set_is_wow_bus_suspended(wma->wmi_handle, val);
 }
 
-/**
- * wma_suspend_req() -  Handles suspend indication request received from umac.
- * @wma: wma handle
- * @type: type of suspend
- *
- * The type controlls how we notify the indicator that the indication has
- * been processed
- *
- * Return: QDF status
- */
-QDF_STATUS wma_suspend_req(tp_wma_handle wma, enum qdf_suspend_type type)
-{
-	return QDF_STATUS_SUCCESS;
-}
-
-/**
- * wma_resume_req() - clear configured wow patterns in fw
- * @wma: wma handle
- * @type: type of suspend
- *
- * Return: QDF status
- */
-QDF_STATUS wma_resume_req(tp_wma_handle wma, enum qdf_suspend_type type)
-{
-	return QDF_STATUS_SUCCESS;
-}
-
 /**
  * wma_wow_add_pattern() - add wow pattern in target
  * @wma: wma handle
@@ -3953,105 +3926,6 @@ void wma_send_regdomain_info_to_fw(uint32_t reg_dmn, uint16_t regdmn2G,
 	return;
 }
 
-/**
- * wma_post_runtime_resume_msg() - post the resume request
- * @handle: validated wma handle
- *
- * request the MC thread unpaus the vdev and set resume dtim
- *
- * Return: qdf status of the mq post
- */
-static QDF_STATUS wma_post_runtime_resume_msg(WMA_HANDLE handle)
-{
-	struct scheduler_msg resume_msg = {0};
-	QDF_STATUS status;
-	tp_wma_handle wma = (tp_wma_handle) handle;
-
-	qdf_runtime_pm_prevent_suspend(wma->wma_runtime_resume_lock);
-
-	resume_msg.bodyptr = NULL;
-	resume_msg.type    = WMA_RUNTIME_PM_RESUME_IND;
-
-	status = scheduler_post_msg(QDF_MODULE_ID_WMA, &resume_msg);
-
-	if (!QDF_IS_STATUS_SUCCESS(status)) {
-		WMA_LOGE("Failed to post Runtime PM Resume IND to VOS");
-		qdf_runtime_pm_allow_suspend(wma->wma_runtime_resume_lock);
-	}
-
-	return status;
-}
-
-/**
- * __wma_bus_suspend(): handles bus suspend for wma
- * @type: is this suspend part of runtime suspend or system suspend?
- * @wow_params: collection of wow enable override parameters
- *
- * Bails if a scan is in progress.
- * Calls the appropriate handlers based on configuration and event.
- *
- * Return: 0 for success or error code
- */
-static int __wma_bus_suspend(enum qdf_suspend_type type,
-			     struct wow_enable_params wow_params)
-{
-	return 0;
-}
-
-/**
- * wma_runtime_suspend() - handles runtime suspend request from hdd
- * @wow_params: collection of wow enable override parameters
- *
- * Calls the appropriate handler based on configuration and event.
- * Last busy marking should prevent race conditions between processing
- * of asyncronous fw events and the running of runtime suspend.
- * (eg. last busy marking should guarantee that any auth requests have
- * been processed)
- * Events comming from the host are not protected, but aren't expected
- * to be an issue.
- *
- * Return: 0 for success or error code
- */
-int wma_runtime_suspend(struct wow_enable_params wow_params)
-{
-	return __wma_bus_suspend(QDF_RUNTIME_SUSPEND, wow_params);
-}
-
-/**
- * __wma_bus_resume() - bus resume for wma
- *
- * does the part of the bus resume common to bus and system suspend
- *
- * Return: os error code.
- */
-static int __wma_bus_resume(WMA_HANDLE handle)
-{
-	return 0;
-}
-
-/**
- * wma_runtime_resume() - do the runtime resume operation for wma
- *
- * Return: os error code.
- */
-int wma_runtime_resume(void)
-{
-	int ret;
-	QDF_STATUS status;
-	WMA_HANDLE handle = cds_get_context(QDF_MODULE_ID_WMA);
-	if (NULL == handle) {
-		WMA_LOGE("%s: wma context is NULL", __func__);
-		return -EFAULT;
-	}
-
-	ret = __wma_bus_resume(handle);
-	if (ret)
-		return ret;
-
-	status = wma_post_runtime_resume_msg(handle);
-	return qdf_status_to_os_return(status);
-}
-
 /**
  * wma_suspend_target_timeout() - Handles the target suspend timeout
  * @is_self_recovery_enabled: Is self recovery enabled or not

+ 0 - 13
core/wma/src/wma_main.c

@@ -2161,9 +2161,6 @@ QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc, void *cds_context,
 	wma_handle->qdf_dev = qdf_dev;
 	wma_handle->max_scan = cds_cfg->max_scan;
 
-	wma_handle->wma_runtime_resume_lock =
-		qdf_runtime_lock_init("wma_runtime_resume");
-
 	/* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
 	wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
 	/* Cap maxStation based on the target version */
@@ -2553,7 +2550,6 @@ err_wma_handle:
 		qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
 	}
 
-	qdf_runtime_lock_deinit(wma_handle->wma_runtime_resume_lock);
 	cds_free_context(cds_context, QDF_MODULE_ID_WMA, wma_handle);
 
 	WMA_LOGD("%s: Exit", __func__);
@@ -6539,15 +6535,6 @@ QDF_STATUS wma_mc_process_msg(void *cds_context, struct scheduler_msg *msg)
 		wma_wow_exit(wma_handle, (tpSirHalWowlExitParams) msg->bodyptr);
 		break;
 
-	case WMA_RUNTIME_PM_SUSPEND_IND:
-		wma_calculate_and_update_conn_state(wma_handle);
-		wma_suspend_req(wma_handle, QDF_RUNTIME_SUSPEND);
-		break;
-
-	case WMA_RUNTIME_PM_RESUME_IND:
-		wma_resume_req(wma_handle, QDF_RUNTIME_SUSPEND);
-		break;
-
 	case WMA_8023_MULTICAST_LIST_REQ:
 		wma_process_mcbc_set_filter_req(wma_handle,
 				(tpSirRcvFltMcAddrList) msg->bodyptr);