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

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

cnss2: Do not suspend MHI if PCIe is not going to be suspended



If PCIe doesn't suspend while MHI does, MHI driver may miss some
firmware notifications. Hence add the support that if PCIe is not
going to be suspended, do not suspend MHI as well.

Change-Id: Ibc6907a002c6299e1949ad13e322b1febee8ac09
Signed-off-by: default avatarYue Ma <yuem@codeaurora.org>
parent 4c206427
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1010,7 +1010,7 @@ static int cnss_pci_suspend(struct device *dev)
		}
	}

	if (pci_priv->pci_link_state == PCI_LINK_UP) {
	if (pci_priv->pci_link_state == PCI_LINK_UP && !pci_priv->disable_pc) {
		ret = cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_SUSPEND);
		if (ret) {
			if (driver_ops && driver_ops->resume)
@@ -1051,7 +1051,7 @@ static int cnss_pci_resume(struct device *dev)
	if (pci_priv->pci_link_down_ind)
		goto out;

	if (pci_priv->pci_link_state == PCI_LINK_UP) {
	if (pci_priv->pci_link_state == PCI_LINK_UP && !pci_priv->disable_pc) {
		ret = pci_enable_device(pci_dev);
		if (ret)
			cnss_pr_err("Failed to enable PCI device, err = %d\n",
@@ -1182,11 +1182,23 @@ static int cnss_pci_runtime_idle(struct device *dev)
int cnss_wlan_pm_control(struct device *dev, bool vote)
{
	struct pci_dev *pci_dev = to_pci_dev(dev);
	struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev);
	int ret = 0;

	if (!pci_priv)
		return -ENODEV;

	return msm_pcie_pm_control(vote ? MSM_PCIE_DISABLE_PC :
	ret = msm_pcie_pm_control(vote ? MSM_PCIE_DISABLE_PC :
				  MSM_PCIE_ENABLE_PC,
				  pci_dev->bus->number, pci_dev,
				  NULL, PM_OPTIONS_DEFAULT);
	if (ret)
		return ret;

	pci_priv->disable_pc = vote;
	cnss_pr_dbg("%s PCIe power collapse\n", vote ? "disable" : "enable");

	return 0;
}
EXPORT_SYMBOL(cnss_wlan_pm_control);

+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -71,6 +71,7 @@ struct cnss_pci_data {
	u32 msi_ep_base_data;
	struct mhi_controller *mhi_ctrl;
	unsigned long mhi_state;
	bool disable_pc;
};

static inline void cnss_set_pci_priv(struct pci_dev *pci_dev, void *data)