cnss2: Check driver link state before prevent/allow PCIe L1

Avoid calling prevent/allow PCIe L1 APIs if driver has already known
link is not accessible.

Change-Id: Ia12c6b932fb7d99916ca2b76323bd2c01bdb655d
Signed-off-by: Yue Ma <yuem@codeaurora.org>
This commit is contained in:
Yue Ma 2020-03-31 15:20:56 -07:00 • committed by Gerrit - the friendly Code Review server
commit dc06247a66

View file

@ -828,6 +828,22 @@ out:
int cnss_pci_prevent_l1(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev);
if (!pci_priv) {
cnss_pr_err("pci_priv is NULL\n");
return -ENODEV;
}
if (pci_priv->pci_link_state == PCI_LINK_DOWN) {
cnss_pr_dbg("PCIe link is suspended\n");
return -EIO;
}
if (pci_priv->pci_link_down_ind) {
cnss_pr_err("PCIe link is down\n");
return -EIO;
}
return msm_pcie_prevent_l1(pci_dev);
}
@ -836,6 +852,22 @@ EXPORT_SYMBOL(cnss_pci_prevent_l1);
void cnss_pci_allow_l1(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev);
if (!pci_priv) {
cnss_pr_err("pci_priv is NULL\n");
return;
}
if (pci_priv->pci_link_state == PCI_LINK_DOWN) {
cnss_pr_dbg("PCIe link is suspended\n");
return;
}
if (pci_priv->pci_link_down_ind) {
cnss_pr_err("PCIe link is down\n");
return;
}
msm_pcie_allow_l1(pci_dev);
}