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

Commit a7958f33 authored by Yue Ma's avatar Yue Ma
Browse files

cnss2: Avoid suspending PCIe after QMI send get is called



Introduce usage count for QMI send get/put APIs. Make sure PCIe link
will not be suspended from runtime PM path if the usage count is not 0.
That means PCIe link should be always up when host driver starts to
proceed stats query from upper layer.

Change-Id: I0ff62874d62c4db2292236d8b4b5c2e09e439a5b
Signed-off-by: default avatarYue Ma <yuem@codeaurora.org>
parent 92efb2ac
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
@@ -2098,6 +2098,9 @@ static int cnss_qca6290_powerup(struct cnss_pci_data *pci_priv)
		cnss_pci_deinit_mhi(pci_priv);
	}

	/* Clear QMI send usage count during every power up */
	pci_priv->qmi_send_usage_count = 0;

retry:
	ret = cnss_power_on_device(plat_priv);
	if (ret) {
@@ -3194,11 +3197,13 @@ int cnss_auto_suspend(struct device *dev)
		return -ENODEV;

	mutex_lock(&pci_priv->bus_lock);
	if (!pci_priv->qmi_send_usage_count) {
		ret = cnss_pci_suspend_bus(pci_priv);
		if (ret) {
			mutex_unlock(&pci_priv->bus_lock);
			return ret;
		}
	}

	cnss_pci_set_auto_suspended(pci_priv, 1);
	mutex_unlock(&pci_priv->bus_lock);
@@ -3371,15 +3376,14 @@ int cnss_pci_qmi_send_get(struct cnss_pci_data *pci_priv)
		return -ENODEV;

	mutex_lock(&pci_priv->bus_lock);
	if (!cnss_pci_get_auto_suspended(pci_priv))
		goto out;

	cnss_pr_vdbg("Starting to handle get info prepare\n");

	if (cnss_pci_get_auto_suspended(pci_priv) &&
	    !pci_priv->qmi_send_usage_count)
		ret = cnss_pci_resume_bus(pci_priv);

out:
	pci_priv->qmi_send_usage_count++;
	cnss_pr_vdbg("Increased QMI send usage count to %d\n",
		     pci_priv->qmi_send_usage_count);
	mutex_unlock(&pci_priv->bus_lock);

	return ret;
}

@@ -3391,15 +3395,15 @@ int cnss_pci_qmi_send_put(struct cnss_pci_data *pci_priv)
		return -ENODEV;

	mutex_lock(&pci_priv->bus_lock);
	if (!cnss_pci_get_auto_suspended(pci_priv))
		goto out;

	cnss_pr_vdbg("Starting to handle get info done\n");

	if (pci_priv->qmi_send_usage_count)
		pci_priv->qmi_send_usage_count--;
	cnss_pr_vdbg("Decreased QMI send usage count to %d\n",
		     pci_priv->qmi_send_usage_count);
	if (cnss_pci_get_auto_suspended(pci_priv) &&
	    !pci_priv->qmi_send_usage_count)
		ret = cnss_pci_suspend_bus(pci_priv);

out:
	mutex_unlock(&pci_priv->bus_lock);

	return ret;
}

+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ struct cnss_pci_data {
	atomic_t auto_suspended;
	atomic_t drv_connected;
	u8 drv_connected_last;
	u32 qmi_send_usage_count;
	u16 def_link_speed;
	u16 def_link_width;
	struct completion wake_event;