cnss2: Update time sync period based on tsf sync start/stop
Add cnss_update_time_sync_period and cnss_reset_time_sync_period to update time sync period vote sent from wlan driver based on use-case. CNSS driver stores both wlan driver and sys config time sync period value and will apply the minimum value of all votes. Change-Id: I46ad2866bd70aefe121c8a68a9c869e75ffd8345 CRs-Fixed: 3502060 Signed-off-by: Shailendra Singh<quic_shasing@quicinc.com>
This commit is contained in:
parent
79c52b747e
commit
3d016eede6
@ -58,6 +58,7 @@
|
||||
#define CNSS_CAL_DB_FILE_NAME "wlfw_cal_db.bin"
|
||||
#define CNSS_CAL_START_PROBE_WAIT_RETRY_MAX 100
|
||||
#define CNSS_CAL_START_PROBE_WAIT_MS 500
|
||||
#define CNSS_TIME_SYNC_PERIOD_INVALID 0xFFFFFFFF
|
||||
|
||||
enum cnss_cal_db_op {
|
||||
CNSS_CAL_DB_UPLOAD,
|
||||
@ -3184,6 +3185,26 @@ static ssize_t time_sync_period_show(struct device *dev,
|
||||
plat_priv->ctrl_params.time_sync_period);
|
||||
}
|
||||
|
||||
/**
|
||||
* cnss_get_min_time_sync_period_by_vote() - Get minimum time sync period
|
||||
* @plat_priv: Platform data structure
|
||||
*
|
||||
* Result: return minimum time sync period present in vote from wlan and sys
|
||||
*/
|
||||
uint32_t cnss_get_min_time_sync_period_by_vote(struct cnss_plat_data *plat_priv)
|
||||
{
|
||||
unsigned int i, min_time_sync_period = CNSS_TIME_SYNC_PERIOD_INVALID;
|
||||
unsigned int time_sync_period;
|
||||
|
||||
for (i = 0; i < TIME_SYNC_VOTE_MAX; i++) {
|
||||
time_sync_period = plat_priv->ctrl_params.time_sync_period_vote[i];
|
||||
if (min_time_sync_period > time_sync_period)
|
||||
min_time_sync_period = time_sync_period;
|
||||
}
|
||||
|
||||
return min_time_sync_period;
|
||||
}
|
||||
|
||||
static ssize_t time_sync_period_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
@ -3199,12 +3220,94 @@ static ssize_t time_sync_period_store(struct device *dev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (time_sync_period >= CNSS_MIN_TIME_SYNC_PERIOD)
|
||||
cnss_bus_update_time_sync_period(plat_priv, time_sync_period);
|
||||
if (time_sync_period < CNSS_MIN_TIME_SYNC_PERIOD) {
|
||||
cnss_pr_err("Invalid time sync value\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
plat_priv->ctrl_params.time_sync_period_vote[TIME_SYNC_VOTE_CNSS] =
|
||||
time_sync_period;
|
||||
time_sync_period = cnss_get_min_time_sync_period_by_vote(plat_priv);
|
||||
|
||||
if (time_sync_period == CNSS_TIME_SYNC_PERIOD_INVALID) {
|
||||
cnss_pr_err("Invalid min time sync value\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cnss_bus_update_time_sync_period(plat_priv, time_sync_period);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* cnss_update_time_sync_period() - Set time sync period given by driver
|
||||
* @dev: device structure
|
||||
* @time_sync_period: time sync period value
|
||||
*
|
||||
* Update time sync period vote of driver and set minimum of time sync period
|
||||
* from stored vote through wlan and sys config
|
||||
* Result: return 0 for success, error in case of invalid value and no dev
|
||||
*/
|
||||
int cnss_update_time_sync_period(struct device *dev, uint32_t time_sync_period)
|
||||
{
|
||||
struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev);
|
||||
|
||||
if (!plat_priv)
|
||||
return -ENODEV;
|
||||
|
||||
if (time_sync_period < CNSS_MIN_TIME_SYNC_PERIOD) {
|
||||
cnss_pr_err("Invalid time sync value\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
plat_priv->ctrl_params.time_sync_period_vote[TIME_SYNC_VOTE_WLAN] =
|
||||
time_sync_period;
|
||||
time_sync_period = cnss_get_min_time_sync_period_by_vote(plat_priv);
|
||||
|
||||
if (time_sync_period == CNSS_TIME_SYNC_PERIOD_INVALID) {
|
||||
cnss_pr_err("Invalid min time sync value\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cnss_bus_update_time_sync_period(plat_priv, time_sync_period);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cnss_update_time_sync_period);
|
||||
|
||||
/**
|
||||
* cnss_reset_time_sync_period() - Reset time sync period
|
||||
* @dev: device structure
|
||||
*
|
||||
* Update time sync period vote of driver as invalid
|
||||
* and reset minimum of time sync period from
|
||||
* stored vote through wlan and sys config
|
||||
* Result: return 0 for success, error in case of no dev
|
||||
*/
|
||||
int cnss_reset_time_sync_period(struct device *dev)
|
||||
{
|
||||
struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev);
|
||||
unsigned int time_sync_period = 0;
|
||||
|
||||
if (!plat_priv)
|
||||
return -ENODEV;
|
||||
|
||||
/* Driver vote is set to invalid in case of reset
|
||||
* In this case, only vote valid to check is sys config
|
||||
*/
|
||||
plat_priv->ctrl_params.time_sync_period_vote[TIME_SYNC_VOTE_WLAN] =
|
||||
CNSS_TIME_SYNC_PERIOD_INVALID;
|
||||
time_sync_period = cnss_get_min_time_sync_period_by_vote(plat_priv);
|
||||
|
||||
if (time_sync_period == CNSS_TIME_SYNC_PERIOD_INVALID) {
|
||||
cnss_pr_err("Invalid min time sync value\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cnss_bus_update_time_sync_period(plat_priv, time_sync_period);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cnss_reset_time_sync_period);
|
||||
|
||||
static ssize_t recovery_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
@ -3568,6 +3671,14 @@ static void cnss_misc_deinit(struct cnss_plat_data *plat_priv)
|
||||
kfree(plat_priv->on_chip_pmic_board_ids);
|
||||
}
|
||||
|
||||
static void cnss_init_time_sync_period_default(struct cnss_plat_data *plat_priv)
|
||||
{
|
||||
plat_priv->ctrl_params.time_sync_period_vote[TIME_SYNC_VOTE_WLAN] =
|
||||
CNSS_TIME_SYNC_PERIOD_INVALID;
|
||||
plat_priv->ctrl_params.time_sync_period_vote[TIME_SYNC_VOTE_CNSS] =
|
||||
CNSS_TIME_SYNC_PERIOD_DEFAULT;
|
||||
}
|
||||
|
||||
static void cnss_init_control_params(struct cnss_plat_data *plat_priv)
|
||||
{
|
||||
plat_priv->ctrl_params.quirks = CNSS_QUIRKS_DEFAULT;
|
||||
@ -3581,6 +3692,7 @@ static void cnss_init_control_params(struct cnss_plat_data *plat_priv)
|
||||
plat_priv->ctrl_params.qmi_timeout = CNSS_QMI_TIMEOUT_DEFAULT;
|
||||
plat_priv->ctrl_params.bdf_type = CNSS_BDF_TYPE_DEFAULT;
|
||||
plat_priv->ctrl_params.time_sync_period = CNSS_TIME_SYNC_PERIOD_DEFAULT;
|
||||
cnss_init_time_sync_period_default(plat_priv);
|
||||
/* Set adsp_pc_enabled default value to true as ADSP pc is always
|
||||
* enabled by default
|
||||
*/
|
||||
|
@ -369,6 +369,18 @@ struct cnss_cal_info {
|
||||
enum cnss_cal_status cal_status;
|
||||
};
|
||||
|
||||
/**
|
||||
* enum cnss_time_sync_period_vote - to get per vote time sync period
|
||||
* @TIME_SYNC_VOTE_WLAN: WLAN Driver vote
|
||||
* @TIME_SYNC_VOTE_CNSS: sys config vote
|
||||
* @TIME_SYNC_VOTE_MAX
|
||||
*/
|
||||
enum cnss_time_sync_period_vote {
|
||||
TIME_SYNC_VOTE_WLAN,
|
||||
TIME_SYNC_VOTE_CNSS,
|
||||
TIME_SYNC_VOTE_MAX,
|
||||
};
|
||||
|
||||
struct cnss_control_params {
|
||||
unsigned long quirks;
|
||||
unsigned int mhi_timeout;
|
||||
@ -376,6 +388,7 @@ struct cnss_control_params {
|
||||
unsigned int qmi_timeout;
|
||||
unsigned int bdf_type;
|
||||
unsigned int time_sync_period;
|
||||
unsigned int time_sync_period_vote[TIME_SYNC_VOTE_MAX];
|
||||
};
|
||||
|
||||
struct cnss_tcs_info {
|
||||
|
@ -321,4 +321,7 @@ extern void cnss_thermal_cdev_unregister(struct device *dev, int tcdev_id);
|
||||
extern int cnss_get_curr_therm_cdev_state(struct device *dev,
|
||||
unsigned long *thermal_state,
|
||||
int tcdev_id);
|
||||
extern int cnss_update_time_sync_period(struct device *dev,
|
||||
uint32_t time_sync_period);
|
||||
extern int cnss_reset_time_sync_period(struct device *dev);
|
||||
#endif /* _NET_CNSS2_H */
|
||||
|
Loading…
Reference in New Issue
Block a user