From b6b87dc9fa29e5c5212268bf69e14e2329f5cb65 Mon Sep 17 00:00:00 2001 From: Sujeev Dias Date: Wed, 27 Feb 2019 14:59:23 -0800 Subject: [PATCH] ANDROID: GKI: pci: framework: disable auto suspend link Some endpoint devices do not go into D3hot during suspend. By pass auto suspend if device do not allow D3hot. CRs-Fixed: 2418347 Bug: 150638680 Change-Id: Ida6e4a2b60b7d08932bfff79144afd67787ca0f2 Signed-off-by: Sujeev Dias Signed-off-by: Will McVicker (cherry picked from commit 02f0bed29fd81f0cd55a60c6460b82d69e630b4c) --- drivers/pci/pci-driver.c | 16 +++++++++++++++- include/linux/pci.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 78ae1cab9af7..6537eabb83c5 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -829,6 +829,10 @@ static int pci_pm_suspend_noirq(struct device *dev) } } + /* if d3hot is not supported bail out */ + if (pci_dev->no_d3hot) + return 0; + if (!pci_dev->state_saved) { pci_save_state(pci_dev); if (pci_power_manageable(pci_dev)) @@ -885,7 +889,8 @@ static int pci_pm_resume_noirq(struct device *dev) if (dev_pm_smart_suspend_and_suspended(dev)) pm_runtime_set_active(dev); - pci_pm_default_resume_early(pci_dev); + if (!pci_dev->no_d3hot) + pci_pm_default_resume_early(pci_dev); if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume_early(dev); @@ -1288,6 +1293,10 @@ static int pci_pm_runtime_suspend(struct device *dev) return 0; } + /* if d3hot is not supported bail out */ + if (pci_dev->no_d3hot) + return 0; + if (!pci_dev->state_saved) { pci_save_state(pci_dev); pci_finish_runtime_suspend(pci_dev); @@ -1302,6 +1311,10 @@ static int pci_pm_runtime_resume(struct device *dev) struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + /* we skipped d3hot processing so skip re-init */ + if (pci_dev->no_d3hot) + goto skip_restore; + /* * Restoring config space is necessary even if the device is not bound * to a driver because although we left it in D0, it may have gone to @@ -1316,6 +1329,7 @@ static int pci_pm_runtime_resume(struct device *dev) pci_enable_wake(pci_dev, PCI_D0, false); pci_fixup_device(pci_fixup_resume, pci_dev); +skip_restore: if (pm && pm->runtime_resume) rc = pm->runtime_resume(dev); diff --git a/include/linux/pci.h b/include/linux/pci.h index b1f297f4b7b0..f00ce74f3d54 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -333,6 +333,7 @@ struct pci_dev { unsigned int d2_support:1; /* Low power state D2 is supported */ unsigned int no_d1d2:1; /* D1 and D2 are forbidden */ unsigned int no_d3cold:1; /* D3cold is forbidden */ + unsigned int no_d3hot:1; /* D3hot is forbidden */ unsigned int bridge_d3:1; /* Allow D3 for bridge */ unsigned int d3cold_allowed:1; /* D3cold is allowed by user */ unsigned int mmio_always_on:1; /* Disallow turning off io/mem