From 099d24dee631990e5f1e17bc34449c702d12ab89 Mon Sep 17 00:00:00 2001 From: Huashan Qu Date: Mon, 1 Feb 2021 17:42:31 +0800 Subject: [PATCH] cnss2: Check CNSS_MHI_POWER_OFF state in cnss_pci_suspend_bus() In the process of idle shutdown, cnss_pci_power_off_mhi() already done with CNSS_MHI_POWER_OFF state set, but cnss_suspend_pci_link() doesn't complete yet, so PCI_LINK_DOWN won't be set, at the same time system suspend comes, it will be failed with CNSS_MHI_SUSPEND state set checking at cnss_pci_suspend_bus()/cnss_pci_set_mhi_state(). When mhi state is already CNSS_MHI_POWER_OFF, no need to do pci suspend link related operation while such actions also will be done through cnss_qca6290_shutdown()/cnss_suspend_pci_link(). Fix is to check CNSS_MHI_POWER_OFF state in cnss_pci_suspend_bus(). Change-Id: I2e03dffdc29b5c9743209cbd29c16345d414af35 Signed-off-by: Huashan Qu --- drivers/net/wireless/cnss2/pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/cnss2/pci.c b/drivers/net/wireless/cnss2/pci.c index def4116e18d8..472522bbcae2 100644 --- a/drivers/net/wireless/cnss2/pci.c +++ b/drivers/net/wireless/cnss2/pci.c @@ -1569,12 +1569,15 @@ static void cnss_pci_set_mhi_state_bit(struct cnss_pci_data *pci_priv, clear_bit(CNSS_MHI_INIT, &pci_priv->mhi_state); break; case CNSS_MHI_POWER_ON: + clear_bit(CNSS_MHI_POWER_OFF, &pci_priv->mhi_state); set_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state); break; case CNSS_MHI_POWERING_OFF: set_bit(CNSS_MHI_POWERING_OFF, &pci_priv->mhi_state); break; case CNSS_MHI_POWER_OFF: + set_bit(CNSS_MHI_POWER_OFF, &pci_priv->mhi_state); + fallthrough; case CNSS_MHI_FORCE_POWER_OFF: clear_bit(CNSS_MHI_POWER_ON, &pci_priv->mhi_state); clear_bit(CNSS_MHI_POWERING_OFF, &pci_priv->mhi_state); @@ -3025,7 +3028,8 @@ int cnss_pci_suspend_bus(struct cnss_pci_data *pci_priv) struct pci_dev *pci_dev = pci_priv->pci_dev; int ret = 0; - if (pci_priv->pci_link_state == PCI_LINK_DOWN) + if (pci_priv->pci_link_state == PCI_LINK_DOWN || + test_bit(CNSS_MHI_POWER_OFF, &pci_priv->mhi_state)) goto out; if (cnss_pci_set_mhi_state(pci_priv, CNSS_MHI_SUSPEND)) {