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

Commit de31e2c4 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "cnss2: Use unified API to get RDDM and recovery timeouts"

parents a1d2376a 87bd498f
Loading
Loading
Loading
Loading
+55 −15
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */

#include <linux/delay.h>
#include <linux/jiffies.h>
@@ -606,6 +606,38 @@ 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);
	case CNSS_TIMEOUT_RDDM:
		return CNSS_RDDM_TIMEOUT_MS;
	case CNSS_TIMEOUT_RECOVERY:
		return RECOVERY_TIMEOUT;
	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 +647,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 +673,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 +746,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 +758,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;
	}
@@ -750,6 +783,7 @@ EXPORT_SYMBOL(cnss_idle_restart);
int cnss_idle_shutdown(struct device *dev)
{
	struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev);
	unsigned int timeout;
	int ret;

	if (!plat_priv) {
@@ -769,10 +803,12 @@ int cnss_idle_shutdown(struct device *dev)
		goto skip_wait;

	reinit_completion(&plat_priv->recovery_complete);
	timeout = cnss_get_timeout(plat_priv, CNSS_TIMEOUT_RECOVERY);
	ret = wait_for_completion_timeout(&plat_priv->recovery_complete,
					  msecs_to_jiffies(RECOVERY_TIMEOUT));
					  msecs_to_jiffies(timeout));
	if (!ret) {
		cnss_pr_err("Timeout waiting for recovery to complete\n");
		cnss_pr_err("Timeout (%ums) waiting for recovery to complete\n",
			    timeout);
		CNSS_ASSERT(0);
	}

@@ -1314,6 +1350,7 @@ EXPORT_SYMBOL(cnss_force_fw_assert);
int cnss_force_collect_rddm(struct device *dev)
{
	struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev);
	unsigned int timeout;
	int ret = 0;

	if (!plat_priv) {
@@ -1349,11 +1386,14 @@ int cnss_force_collect_rddm(struct device *dev)
		return ret;

	reinit_completion(&plat_priv->rddm_complete);
	ret = wait_for_completion_timeout
		(&plat_priv->rddm_complete,
		 msecs_to_jiffies(CNSS_RDDM_TIMEOUT_MS));
	if (!ret)
	timeout = cnss_get_timeout(plat_priv, CNSS_TIMEOUT_RDDM);
	ret = wait_for_completion_timeout(&plat_priv->rddm_complete,
					  msecs_to_jiffies(timeout));
	if (!ret) {
		cnss_pr_err("Timeout (%ums) waiting for RDDM to complete\n",
			    timeout);
		ret = -ETIMEDOUT;
	}

	return ret;
}
+13 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */

#ifndef _CNSS_MAIN_H
#define _CNSS_MAIN_H
@@ -331,6 +331,16 @@ 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,
	CNSS_TIMEOUT_RDDM,
	CNSS_TIMEOUT_RECOVERY,
};

struct cnss_plat_data {
	struct platform_device *plat_dev;
	void *bus_priv;
@@ -466,5 +476,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 */
+13 −10
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);
	}

@@ -2377,10 +2378,12 @@ void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver_ops)
		goto skip_wait_recovery;

	reinit_completion(&plat_priv->recovery_complete);
	timeout = cnss_get_timeout(plat_priv, CNSS_TIMEOUT_RECOVERY);
	ret = wait_for_completion_timeout(&plat_priv->recovery_complete,
					  msecs_to_jiffies(RECOVERY_TIMEOUT));
					  msecs_to_jiffies(timeout));
	if (!ret) {
		cnss_pr_err("Timeout waiting for recovery to complete\n");
		cnss_pr_err("Timeout (%ums) waiting for recovery to complete\n",
			    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;
}