mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 13:49:24 -04:00
cnss2: Add new API to get QMI related timeouts
Refactor and add new API to get QMI related timeouts. Also remove printing timeout value from cnss_get_qmi_timeout(). Instead print it in the callers of the API separately. Change-Id: Ifb0891b955c4b7f1ab5b20d1e37c8059ad1d7b29 Signed-off-by: Yue Ma <yuem@codeaurora.org>
This commit is contained in:
parent
fd7dcb16e5
commit
ba7ceb499a
4 changed files with 70 additions and 27 deletions
|
|
@ -616,6 +616,40 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* cnss_get_timeout - Get timeout for corresponding type.
|
||||
* @plat_priv: Pointer to platform driver context.
|
||||
* @cnss_timeout_type: Timeout type.
|
||||
*
|
||||
* Return: Timeout in milliseconds.
|
||||
*/
|
||||
unsigned int cnss_get_timeout(struct cnss_plat_data *plat_priv,
|
||||
enum cnss_timeout_type timeout_type)
|
||||
{
|
||||
unsigned int qmi_timeout = cnss_get_qmi_timeout(plat_priv);
|
||||
|
||||
switch (timeout_type) {
|
||||
case CNSS_TIMEOUT_QMI:
|
||||
return qmi_timeout;
|
||||
case CNSS_TIMEOUT_POWER_UP:
|
||||
return (qmi_timeout << 2);
|
||||
case CNSS_TIMEOUT_IDLE_RESTART:
|
||||
/* In idle restart power up sequence, we have fw_boot_timer to
|
||||
* handle FW initialization failure.
|
||||
* It uses WLAN_MISSION_MODE_TIMEOUT, so setup 3x that time to
|
||||
* account for FW dump collection and FW re-initialization on
|
||||
* retry.
|
||||
*/
|
||||
return (qmi_timeout + WLAN_MISSION_MODE_TIMEOUT * 3);
|
||||
case CNSS_TIMEOUT_CALIBRATION:
|
||||
return (qmi_timeout + WLAN_COLD_BOOT_CAL_TIMEOUT);
|
||||
case CNSS_TIMEOUT_WLAN_WATCHDOG:
|
||||
return ((qmi_timeout << 1) + WLAN_WD_TIMEOUT_MS);
|
||||
default:
|
||||
return qmi_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int cnss_get_boot_timeout(struct device *dev)
|
||||
{
|
||||
struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev);
|
||||
|
|
@ -625,7 +659,7 @@ unsigned int cnss_get_boot_timeout(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return cnss_get_qmi_timeout(plat_priv);
|
||||
return cnss_get_timeout(plat_priv, CNSS_TIMEOUT_QMI);
|
||||
}
|
||||
EXPORT_SYMBOL(cnss_get_boot_timeout);
|
||||
|
||||
|
|
@ -651,13 +685,14 @@ int cnss_power_up(struct device *dev)
|
|||
if (plat_priv->device_id == QCA6174_DEVICE_ID)
|
||||
goto out;
|
||||
|
||||
timeout = cnss_get_boot_timeout(dev);
|
||||
timeout = cnss_get_timeout(plat_priv, CNSS_TIMEOUT_POWER_UP);
|
||||
|
||||
reinit_completion(&plat_priv->power_up_complete);
|
||||
ret = wait_for_completion_timeout(&plat_priv->power_up_complete,
|
||||
msecs_to_jiffies(timeout) << 2);
|
||||
msecs_to_jiffies(timeout));
|
||||
if (!ret) {
|
||||
cnss_pr_err("Timeout waiting for power up to complete\n");
|
||||
cnss_pr_err("Timeout (%ums) waiting for power up to complete\n",
|
||||
timeout);
|
||||
ret = -EAGAIN;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -723,20 +758,15 @@ int cnss_idle_restart(struct device *dev)
|
|||
goto out;
|
||||
}
|
||||
|
||||
timeout = cnss_get_boot_timeout(dev);
|
||||
/* In Idle restart power up sequence, we have fw_boot_timer to handle
|
||||
* FW initialization failure. It uses WLAN_DRIVER_LOAD_TIMEOUT.
|
||||
* Thus setup 3x that completion wait time to account for FW reinit /
|
||||
* dump collection on retry.
|
||||
*/
|
||||
timeout = cnss_get_timeout(plat_priv, CNSS_TIMEOUT_IDLE_RESTART);
|
||||
ret = wait_for_completion_timeout(&plat_priv->power_up_complete,
|
||||
msecs_to_jiffies(timeout +
|
||||
WLAN_MISSION_MODE_TIMEOUT * 3));
|
||||
msecs_to_jiffies(timeout));
|
||||
if (!ret) {
|
||||
/* This exception occurs after attempting retry of FW recovery.
|
||||
* Thus we can safely power off the device.
|
||||
*/
|
||||
cnss_fatal_err("Timeout for idle restart to complete\n");
|
||||
cnss_fatal_err("Timeout (%ums) waiting for idle restart to complete\n",
|
||||
timeout);
|
||||
ret = -ETIMEDOUT;
|
||||
cnss_power_down(dev);
|
||||
CNSS_ASSERT(0);
|
||||
|
|
@ -784,7 +814,8 @@ int cnss_idle_shutdown(struct device *dev)
|
|||
ret = wait_for_completion_timeout(&plat_priv->recovery_complete,
|
||||
msecs_to_jiffies(RECOVERY_TIMEOUT));
|
||||
if (!ret) {
|
||||
cnss_pr_err("Timeout waiting for recovery to complete\n");
|
||||
cnss_pr_err("Timeout (%ums) waiting for recovery to complete\n",
|
||||
RECOVERY_TIMEOUT);
|
||||
CNSS_ASSERT(0);
|
||||
}
|
||||
|
||||
|
|
@ -1348,10 +1379,13 @@ wait_rddm:
|
|||
ret = wait_for_completion_timeout
|
||||
(&plat_priv->rddm_complete,
|
||||
msecs_to_jiffies(CNSS_RDDM_TIMEOUT_MS));
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
cnss_pr_err("Timeout (%ums) waiting for RDDM to complete\n",
|
||||
CNSS_RDDM_TIMEOUT_MS);
|
||||
ret = -ETIMEDOUT;
|
||||
else if (ret > 0)
|
||||
} else if (ret > 0) {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -385,6 +385,14 @@ struct cnss_dms_data {
|
|||
u8 mac[QMI_WLFW_MAC_ADDR_SIZE_V01];
|
||||
};
|
||||
|
||||
enum cnss_timeout_type {
|
||||
CNSS_TIMEOUT_QMI,
|
||||
CNSS_TIMEOUT_POWER_UP,
|
||||
CNSS_TIMEOUT_IDLE_RESTART,
|
||||
CNSS_TIMEOUT_CALIBRATION,
|
||||
CNSS_TIMEOUT_WLAN_WATCHDOG,
|
||||
};
|
||||
|
||||
struct cnss_plat_data {
|
||||
struct platform_device *plat_dev;
|
||||
void *bus_priv;
|
||||
|
|
@ -530,5 +538,7 @@ int cnss_minidump_remove_region(struct cnss_plat_data *plat_priv,
|
|||
void *va, phys_addr_t pa, size_t size);
|
||||
int cnss_enable_int_pow_amp_vreg(struct cnss_plat_data *plat_priv);
|
||||
int cnss_get_tcs_info(struct cnss_plat_data *plat_priv);
|
||||
unsigned int cnss_get_timeout(struct cnss_plat_data *plat_priv,
|
||||
enum cnss_timeout_type);
|
||||
|
||||
#endif /* _CNSS_MAIN_H */
|
||||
|
|
|
|||
|
|
@ -2131,7 +2131,7 @@ retry:
|
|||
}
|
||||
|
||||
cnss_pci_set_wlaon_pwr_ctrl(pci_priv, false, false, false);
|
||||
timeout = cnss_get_boot_timeout(&pci_priv->pci_dev->dev);
|
||||
timeout = cnss_get_timeout(plat_priv, CNSS_TIMEOUT_QMI);
|
||||
|
||||
ret = cnss_pci_start_mhi(pci_priv);
|
||||
if (ret) {
|
||||
|
|
@ -2430,12 +2430,12 @@ int cnss_wlan_register_driver(struct cnss_wlan_driver *driver_ops)
|
|||
return -EPERM;
|
||||
}
|
||||
|
||||
timeout = cnss_get_boot_timeout(&pci_priv->pci_dev->dev);
|
||||
timeout = cnss_get_timeout(plat_priv, CNSS_TIMEOUT_CALIBRATION);
|
||||
ret = wait_for_completion_timeout(&plat_priv->cal_complete,
|
||||
WLAN_COLD_BOOT_CAL_TIMEOUT +
|
||||
msecs_to_jiffies(timeout));
|
||||
if (!ret) {
|
||||
cnss_pr_err("Timeout waiting for calibration to complete\n");
|
||||
cnss_pr_err("Timeout (%ums) waiting for calibration to complete\n",
|
||||
timeout);
|
||||
if (!test_bit(CNSS_IN_REBOOT, &plat_priv->driver_state))
|
||||
CNSS_ASSERT(0);
|
||||
|
||||
|
|
@ -2480,12 +2480,12 @@ void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver_ops)
|
|||
if (plat_priv->device_id == QCA6174_DEVICE_ID)
|
||||
goto skip_wait_power_up;
|
||||
|
||||
timeout = cnss_get_qmi_timeout(plat_priv);
|
||||
timeout = cnss_get_timeout(plat_priv, CNSS_TIMEOUT_WLAN_WATCHDOG);
|
||||
ret = wait_for_completion_timeout(&plat_priv->power_up_complete,
|
||||
msecs_to_jiffies((timeout << 1) +
|
||||
WLAN_WD_TIMEOUT_MS));
|
||||
msecs_to_jiffies(timeout));
|
||||
if (!ret) {
|
||||
cnss_pr_err("Timeout waiting for driver power up to complete\n");
|
||||
cnss_pr_err("Timeout (%ums) waiting for driver power up to complete\n",
|
||||
timeout);
|
||||
CNSS_ASSERT(0);
|
||||
}
|
||||
|
||||
|
|
@ -2498,7 +2498,8 @@ skip_wait_power_up:
|
|||
ret = wait_for_completion_timeout(&plat_priv->recovery_complete,
|
||||
msecs_to_jiffies(RECOVERY_TIMEOUT));
|
||||
if (!ret) {
|
||||
cnss_pr_err("Timeout waiting for recovery to complete\n");
|
||||
cnss_pr_err("Timeout (%ums) waiting for recovery to complete\n",
|
||||
RECOVERY_TIMEOUT);
|
||||
CNSS_ASSERT(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1725,8 +1725,6 @@ out:
|
|||
|
||||
unsigned int cnss_get_qmi_timeout(struct cnss_plat_data *plat_priv)
|
||||
{
|
||||
cnss_pr_dbg("QMI timeout is %u ms\n", QMI_WLFW_TIMEOUT_MS);
|
||||
|
||||
return QMI_WLFW_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue