Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc27a98c authored by Yue Ma's avatar Yue Ma Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarYue Ma <yuem@codeaurora.org>
parent d2f766c6
Loading
Loading
Loading
Loading
+43 −10
Original line number Diff line number Diff line
@@ -606,6 +606,34 @@ int cnss_driver_event_post(struct cnss_plat_data *plat_priv,
	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:
		return ((qmi_timeout << 1) + WLAN_WD_TIMEOUT_MS);
	case CNSS_TIMEOUT_CALIBRATION:
		return (qmi_timeout << 2);
	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);
@@ -615,7 +643,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);

@@ -641,13 +669,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;
	}
@@ -713,10 +742,9 @@ int cnss_idle_restart(struct device *dev)
		goto out;
	}

	timeout = cnss_get_boot_timeout(dev);
	timeout = cnss_get_timeout(plat_priv, CNSS_TIMEOUT_IDLE_RESTART);
	ret = wait_for_completion_timeout(&plat_priv->power_up_complete,
					  msecs_to_jiffies((timeout << 1) +
							   WLAN_WD_TIMEOUT_MS));
					  msecs_to_jiffies(timeout));
	if (plat_priv->power_up_error) {
		ret = plat_priv->power_up_error;
		clear_bit(CNSS_DRIVER_IDLE_RESTART, &plat_priv->driver_state);
@@ -726,7 +754,8 @@ int cnss_idle_restart(struct device *dev)
	}

	if (!ret) {
		cnss_pr_err("Timeout waiting for idle restart to complete\n");
		cnss_pr_err("Timeout (%ums) waiting for idle restart to complete\n",
			    timeout);
		ret = -ETIMEDOUT;
		goto out;
	}
@@ -772,7 +801,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);
	}

@@ -1352,8 +1382,11 @@ int cnss_force_collect_rddm(struct device *dev)
	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;
	}

	return ret;
}
+10 −0
Original line number Diff line number Diff line
@@ -331,6 +331,14 @@ enum cnss_ce_index {
	CNSS_CE_COMMON,
};

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;
@@ -466,5 +474,7 @@ int cnss_minidump_add_region(struct cnss_plat_data *plat_priv,
int cnss_minidump_remove_region(struct cnss_plat_data *plat_priv,
				enum cnss_fw_dump_type type, int seg_no,
				void *va, phys_addr_t pa, size_t size);
unsigned int cnss_get_timeout(struct cnss_plat_data *plat_priv,
			      enum cnss_timeout_type);

#endif /* _CNSS_MAIN_H */
+11 −9
Original line number Diff line number Diff line
@@ -2024,7 +2024,7 @@ static int cnss_qca6290_powerup(struct cnss_pci_data *pci_priv)
	}

	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) {
@@ -2310,11 +2310,12 @@ int cnss_wlan_register_driver(struct cnss_wlan_driver *driver_ops)

	cnss_pr_dbg("Start to wait for calibration to complete\n");

	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,
					  msecs_to_jiffies(timeout) << 2);
					  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_pci_dump_bl_sram_mem(pci_priv);
			CNSS_ASSERT(0);
@@ -2362,12 +2363,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);
	}

@@ -2380,7 +2381,8 @@ void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver_ops)
	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);
	}

+0 −2
Original line number Diff line number Diff line
@@ -1779,8 +1779,6 @@ int cnss_wlfw_get_info_send_sync(struct cnss_plat_data *plat_priv, int type,

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;
}