cnss2: Avoid race condition between time sync and system suspend

Add mutex to protect time sync operation and PCIe bus suspend from
system suspend to avoid race condition between msm_pcie_pm_suspend
and msm_pcie_prevent_l1/allow_l1.

Change-Id: I8ff0f258e8928b97deeada134982ee2cbe93ae9a
Signed-off-by: Yue Ma <yuem@codeaurora.org>
This commit is contained in:
Yue Ma 2020-11-04 17:25:12 -08:00
commit 542be88454

View file

@ -1685,7 +1685,9 @@ static void cnss_pci_time_sync_work_hdlr(struct work_struct *work)
if (cnss_pci_pm_runtime_get_sync(pci_priv, RTPM_ID_CNSS) < 0)
goto runtime_pm_put;
mutex_lock(&pci_priv->bus_lock);
cnss_pci_update_timestamp(pci_priv);
mutex_unlock(&pci_priv->bus_lock);
schedule_delayed_work(&pci_priv->time_sync_work,
msecs_to_jiffies(time_sync_period_ms));
@ -2791,7 +2793,9 @@ static int cnss_pci_suspend(struct device *dev)
goto clear_flag;
if (!pci_priv->disable_pc) {
mutex_lock(&pci_priv->bus_lock);
ret = cnss_pci_suspend_bus(pci_priv);
mutex_unlock(&pci_priv->bus_lock);
if (ret)
goto resume_driver;
}