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

Commit db449926 authored by Yan He's avatar Yan He
Browse files

msm: pcie: improve the mechanism to suspend PCIe link



Improve the mechanism to suspend PCIe link to avoid race condition.

CRs-fixed: 675718
Change-Id: Ifc94d990c866c62bf48fd84d47af20443dd29290
Signed-off-by: default avatarYan He <yanhe@codeaurora.org>
parent 9c0df937
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -1338,15 +1338,6 @@ void msm_pcie_disable(struct msm_pcie_dev_t *dev, u32 options)

	mutex_lock(&dev->setup_lock);

	if ((dev->link_status == MSM_PCIE_LINK_DISABLED)
		&& !(options & PM_EXPT)) {
		PCIE_ERR(dev,
			"PCIe: the link of RC%d is already disabled\n",
			dev->rc_idx);
		mutex_unlock(&dev->setup_lock);
		return;
	}

	if (!dev->power_on) {
		PCIE_DBG(dev,
			"PCIe: the link of RC%d is already power down.\n",
@@ -1355,6 +1346,9 @@ void msm_pcie_disable(struct msm_pcie_dev_t *dev, u32 options)
		return;
	}

	dev->link_status = MSM_PCIE_LINK_DISABLED;
	dev->power_on = false;

	PCIE_INFO(dev, "PCIe: Assert the reset of endpoint of RC%d.\n",
		dev->rc_idx);

@@ -1374,9 +1368,6 @@ void msm_pcie_disable(struct msm_pcie_dev_t *dev, u32 options)
	if (options & PM_PIPE_CLK)
		msm_pcie_pipe_clk_deinit(dev);

	dev->link_status = MSM_PCIE_LINK_DISABLED;
	dev->power_on = false;

	mutex_unlock(&dev->setup_lock);
}

@@ -1842,6 +1833,13 @@ static int msm_pcie_pm_suspend(struct pci_dev *dev,
	pcie_dev->suspending = true;
	PCIE_DBG(pcie_dev, "RC%d\n", pcie_dev->rc_idx);

	if (!pcie_dev->power_on) {
		PCIE_DBG(pcie_dev,
			"PCIe: power of RC%d has been turned off.\n",
			pcie_dev->rc_idx);
		return ret;
	}

	if (dev && !(options & MSM_PCIE_CONFIG_NO_CFG_RESTORE)) {
		ret = pci_save_state(dev);
		pcie_dev->saved_state =	pci_store_saved_state(dev);