Pārlūkot izejas kodu

qcacmn: Add throughput based RTPM API support

Add support to invoke HIF runtime PM APIs in TX packet path based on
throughput level. Essentially at high throughputs, where runtime PM is
not expected to provide power gains, invoking the APIs is deterimental to
performance.
Hence invoke runtime_pm APIs based on throughput level.

CRs-Fixed: 3059712
Change-Id: I49d111bffa8a37c68abbdd54911f9ecc22430562
Mohit Khanna 3 gadi atpakaļ
vecāks
revīzija
81e29163db

+ 38 - 0
dp/inc/cdp_txrx_cmn.h

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -2713,4 +2714,41 @@ cdp_get_tx_inqueue(ol_txrx_soc_handle soc)
 
 	return soc->ol_ops->dp_get_tx_inqueue(soc);
 }
+
+#ifdef FEATURE_RUNTIME_PM
+
+/**
+ * cdp_set_rtpm_tput_policy_requirement() - Set RTPM throughput policy
+ * @soc: opaque soc handle
+ * @is_high_tput: flag indicating whether throughput requirement is high or not
+ *
+ * The functions sets RTPM throughput policy requirement. If 'is_high_tput' is
+ * set, the expectation is that runtime_pm APIs will not be invoked per packet.
+ */
+
+static inline
+void cdp_set_rtpm_tput_policy_requirement(ol_txrx_soc_handle soc,
+					  bool is_high_tput)
+{
+	if (!soc || !soc->ops) {
+		dp_cdp_debug("Invalid Instance");
+		QDF_BUG(0);
+		return;
+	}
+
+	if (!soc->ops->cmn_drv_ops ||
+	    !soc->ops->cmn_drv_ops->set_rtpm_tput_policy)
+		return;
+
+	soc->ops->cmn_drv_ops->set_rtpm_tput_policy(soc, is_high_tput);
+}
+#else
+static inline
+void cdp_set_rtpm_tput_policy_requirement(ol_txrx_soc_handle soc,
+					  bool is_high_tput)
+{
+}
+
+#endif /* FEATURE_RUNTIME_PM */
+
 #endif /* _CDP_TXRX_CMN_H_ */

+ 4 - 0
dp/inc/cdp_txrx_ops.h

@@ -590,6 +590,10 @@ struct cdp_cmn_ops {
 #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
 	void (*set_pkt_capture_mode)(struct cdp_soc_t *soc, bool val);
 #endif
+
+#ifdef FEATURE_RUNTIME_PM
+	void (*set_rtpm_tput_policy)(struct cdp_soc_t *soc, bool val);
+#endif
 };
 
 struct cdp_ctrl_ops {

+ 3 - 0
dp/wifi3.0/dp_main.c

@@ -11297,6 +11297,9 @@ static struct cdp_cmn_ops dp_ops_cmn = {
 #if defined(FEATURE_RUNTIME_PM) || defined(DP_POWER_SAVE)
 	.txrx_drain = dp_drain_txrx,
 #endif
+#if defined(FEATURE_RUNTIME_PM)
+	.set_rtpm_tput_policy = dp_set_rtpm_tput_policy_requirement,
+#endif
 #ifdef WLAN_SYSFS_DP_STATS
 	.txrx_sysfs_fill_stats = dp_sysfs_fill_stats,
 	.txrx_sysfs_set_stat_type = dp_sysfs_set_stat_type,

+ 18 - 0
dp/wifi3.0/dp_tx.c

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -1418,6 +1419,10 @@ dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
 #endif
 
 #ifdef FEATURE_RUNTIME_PM
+static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc)
+{
+	return qdf_atomic_read(&soc->rtpm_high_tput_flag);
+}
 /**
  * dp_tx_ring_access_end_wrapper() - Wrapper for ring access end
  * @soc: Datapath soc handle
@@ -1436,6 +1441,14 @@ dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
 {
 	int ret;
 
+	/*
+	 * Avoid runtime get and put APIs under high throughput scenarios.
+	 */
+	if (dp_get_rtpm_tput_policy_requirement(soc)) {
+		dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
+		return;
+	}
+
 	ret = hif_pm_runtime_get(soc->hif_handle,
 				 RTPM_ID_DW_TX_HW_ENQUEUE, true);
 	switch (ret) {
@@ -1474,6 +1487,11 @@ dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
 		dp_runtime_put(soc);
 	}
 }
+#else
+static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc)
+{
+	return 0;
+}
 #endif
 
 /**

+ 21 - 0
dp/wifi3.0/dp_tx.h

@@ -739,6 +739,22 @@ dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
 #endif /* WLAN_DP_FEATURE_SW_LATENCY_MGR */
 
 #ifdef FEATURE_RUNTIME_PM
+/**
+ * dp_set_rtpm_tput_policy_requirement() - Update RTPM throughput policy
+ * @soc_hdl: DP soc handle
+ * @is_high_tput: flag to indicate whether throughput is high
+ *
+ * Returns: none
+ */
+static inline
+void dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
+					 bool is_high_tput)
+{
+	struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
+
+	qdf_atomic_set(&soc->rtpm_high_tput_flag, is_high_tput);
+}
+
 void
 dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
 			      hal_ring_handle_t hal_ring_hdl,
@@ -751,6 +767,11 @@ dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
 {
 	dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
 }
+
+static inline void
+dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
+				    bool is_high_tput)
+{ }
 #endif
 #endif /* QCA_HOST_MODE_WIFI_DISABLED */
 

+ 4 - 0
dp/wifi3.0/dp_types.h

@@ -2206,6 +2206,10 @@ struct dp_soc {
 
 	/* Number of Rx refill rings */
 	uint8_t num_rx_refill_buf_rings;
+#ifdef FEATURE_RUNTIME_PM
+	/* flag to indicate vote for runtime_pm for high tput castt*/
+	qdf_atomic_t rtpm_high_tput_flag;
+#endif
 };
 
 #ifdef IPA_OFFLOAD

+ 3 - 0
utils/host_diag_log/inc/host_diag_core_event.h

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -948,6 +949,7 @@ enum wifi_connectivity_events {
  * @WIFI_POWER_EVENT_WAKELOCK_CFR: Wakelock for CFR
  * @WIFI_POWER_EVENT_WAKELOCK_SAP_D3_WOW: Wakelock for SAP D3 WOW max clinets
  * @WIFI_POWER_EVENT_WAKELOCK_GO_D3_WOW: Wakelock for GO D3 WOW max clients
+ * @WIFI_POWER_EVENT_WAKELOCK_RTPM_TPUT_POLICY: Wakelock for RTPM Tput policy
  *
  * Indicates the reason for which the wakelock was taken/released
  */
@@ -981,6 +983,7 @@ enum wake_lock_reason {
 	WIFI_POWER_EVENT_WAKELOCK_CFR,
 	WIFI_POWER_EVENT_WAKELOCK_SAP_D3_WOW,
 	WIFI_POWER_EVENT_WAKELOCK_GO_D3_WOW,
+	WIFI_POWER_EVENT_WAKELOCK_RTPM_TPUT_POLICY,
 };
 
 /* The length of interface name should >= IFNAMSIZ */