qcacld-3.0: Add rtpm_tput_policy API to dp component

Add rtpm tput policy helper functions

Change-Id: Ic8cb3889d9d67fbffab02f5b355c002db63650e3
CRs-Fixed: 3165000
This commit is contained in:
Amit Mehta
2022-02-02 04:58:39 -08:00
committed by Madan Koyyalamudi
parent e52153adec
commit 4f0c6b8658
3 changed files with 173 additions and 0 deletions

View File

@@ -481,3 +481,115 @@ void dp_bbm_context_deinit(struct wlan_objmgr_psoc *psoc)
qdf_mem_free(bbm_ctx);
}
#endif /* FEATURE_BUS_BANDWIDTH_MGR */
#if defined(WLAN_FEATURE_DP_BUS_BANDWIDTH) && defined(FEATURE_RUNTIME_PM)
void dp_rtpm_tput_policy_init(struct wlan_objmgr_psoc *psoc)
{
struct wlan_dp_psoc_context *dp_ctx;
struct dp_rtpm_tput_policy_context *ctx;
dp_ctx = dp_psoc_get_priv(psoc);
if (!dp_ctx) {
dp_err("Unable to get DP context");
return;
}
ctx = &dp_ctx->rtpm_tput_policy_ctx;
qdf_runtime_lock_init(&ctx->rtpm_lock);
ctx->curr_state = DP_RTPM_TPUT_POLICY_STATE_REQUIRED;
qdf_atomic_init(&ctx->high_tput_vote);
}
void dp_rtpm_tput_policy_deinit(struct wlan_objmgr_psoc *psoc)
{
struct wlan_dp_psoc_context *dp_ctx;
struct dp_rtpm_tput_policy_context *ctx;
dp_ctx = dp_psoc_get_priv(psoc);
if (!dp_ctx) {
dp_err("Unable to get DP context");
return;
}
ctx = &dp_ctx->rtpm_tput_policy_ctx;
ctx->curr_state = DP_RTPM_TPUT_POLICY_STATE_INVALID;
qdf_runtime_lock_deinit(&ctx->rtpm_lock);
}
/**
* dp_rtpm_tput_policy_prevent() - prevent a runtime bus suspend
* @dp_ctx: DP handle
*
* return: None
*/
static void dp_rtpm_tput_policy_prevent(struct wlan_dp_psoc_context *dp_ctx)
{
struct dp_rtpm_tput_policy_context *ctx;
ctx = &dp_ctx->rtpm_tput_policy_ctx;
qdf_runtime_pm_prevent_suspend(&ctx->rtpm_lock);
}
/**
* dp_rtpm_tput_policy_allow() - allow a runtime bus suspend
* @dp_ctx: DP handle
*
* return: None
*/
static void dp_rtpm_tput_policy_allow(struct wlan_dp_psoc_context *dp_ctx)
{
struct dp_rtpm_tput_policy_context *ctx;
ctx = &dp_ctx->rtpm_tput_policy_ctx;
qdf_runtime_pm_allow_suspend(&ctx->rtpm_lock);
}
#define DP_RTPM_POLICY_HIGH_TPUT_THRESH TPUT_LEVEL_MEDIUM
void dp_rtpm_tput_policy_apply(struct wlan_dp_psoc_context *dp_ctx,
enum tput_level tput_level)
{
int vote;
enum dp_rtpm_tput_policy_state temp_state;
struct dp_rtpm_tput_policy_context *ctx;
ol_txrx_soc_handle soc = cds_get_context(QDF_MODULE_ID_SOC);
if (qdf_unlikely(!soc))
return;
ctx = &dp_ctx->rtpm_tput_policy_ctx;
if (tput_level >= DP_RTPM_POLICY_HIGH_TPUT_THRESH)
temp_state = DP_RTPM_TPUT_POLICY_STATE_NOT_REQUIRED;
else
temp_state = DP_RTPM_TPUT_POLICY_STATE_REQUIRED;
if (ctx->curr_state == temp_state)
return;
if (temp_state == DP_RTPM_TPUT_POLICY_STATE_REQUIRED) {
cdp_set_rtpm_tput_policy_requirement(soc, false);
qdf_atomic_dec(&ctx->high_tput_vote);
dp_rtpm_tput_policy_allow(dp_ctx);
} else {
cdp_set_rtpm_tput_policy_requirement(soc, true);
qdf_atomic_inc(&ctx->high_tput_vote);
dp_rtpm_tput_policy_prevent(dp_ctx);
}
ctx->curr_state = temp_state;
vote = qdf_atomic_read(&ctx->high_tput_vote);
if (vote < 0 || vote > 1) {
dp_alert_rl("Incorrect vote!");
QDF_BUG(0);
}
}
int dp_rtpm_tput_policy_get_vote(struct wlan_dp_psoc_context *dp_ctx)
{
struct dp_rtpm_tput_policy_context *ctx;
ctx = &dp_ctx->rtpm_tput_policy_ctx;
return qdf_atomic_read(&ctx->high_tput_vote);
}
#endif

View File

@@ -24,6 +24,7 @@
* Bus Bandwidth Manager implementation
*/
#include "wlan_dp_priv.h"
#include <qdf_types.h>
#include <qca_vendor.h>
#include <wlan_objmgr_psoc_obj.h>
@@ -93,4 +94,62 @@ void dp_bbm_apply_independent_policy(struct wlan_objmgr_psoc *psoc,
{
}
#endif /* FEATURE_BUS_BANDWIDTH_MGR */
#if defined(WLAN_FEATURE_DP_BUS_BANDWIDTH) && defined(FEATURE_RUNTIME_PM)
/**
* dp_rtpm_tput_policy_init() - Initialize RTPM tput policy
* @psoc: psoc handle
*
* Returns: None
*/
void dp_rtpm_tput_policy_init(struct wlan_objmgr_psoc *psoc);
/**
* dp_rtpm_tput_policy_deinit() - Deinitialize RTPM tput policy
* @psoc: psoc handle
*
* Returns: None
*/
void dp_rtpm_tput_policy_deinit(struct wlan_objmgr_psoc *psoc);
/**
* dp_rtpm_tput_policy_apply() - Apply RTPM tput policy
* @dp_ctx: dp_ctx handle
* @tput_level : Tput level
*
* Returns: None
*/
void dp_rtpm_tput_policy_apply(struct wlan_dp_psoc_context *dp_ctx,
enum tput_level tput_level);
/**
* dp_rtpm_tput_policy_get_vote() - Get RTPM tput policy vote
* @dp_ctx: dp_ctx handle
*
* Returns: Current vote
*/
int dp_rtpm_tput_policy_get_vote(struct wlan_dp_psoc_context *dp_ctx);
#else
static inline
void dp_rtpm_tput_policy_init(struct wlan_objmgr_psoc *psoc)
{
}
static inline
void dp_rtpm_tput_policy_deinit(struct wlan_objmgr_psoc *psoc)
{
}
static inline
void dp_rtpm_tput_policy_apply(struct wlan_dp_psoc_context *dp_ctx,
enum tput_level tput_level)
{
}
static inline int
dp_rtpm_tput_policy_get_vote(struct wlan_dp_psoc_context *dp_ctx)
{
return -EINVAL;
}
#endif /* WLAN_FEATURE_DP_BUS_BANDWIDTH && FEATURE_RUNTIME_PM */
#endif /* WLAN_DP_BUS_BANDWIDTH_H */

View File

@@ -350,6 +350,7 @@ ucfg_dp_store_qdf_dev(struct wlan_objmgr_psoc *psoc)
QDF_STATUS ucfg_dp_psoc_open(struct wlan_objmgr_psoc *psoc)
{
ucfg_dp_store_qdf_dev(psoc);
dp_rtpm_tput_policy_init(psoc);
dp_register_pmo_handler();
return QDF_STATUS_SUCCESS;
@@ -357,6 +358,7 @@ QDF_STATUS ucfg_dp_psoc_open(struct wlan_objmgr_psoc *psoc)
QDF_STATUS ucfg_dp_psoc_close(struct wlan_objmgr_psoc *psoc)
{
dp_rtpm_tput_policy_deinit(psoc);
dp_unregister_pmo_handler();
return QDF_STATUS_SUCCESS;