All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] PCI: pciehp: Do not disable interrupt twice on suspend
@ 2019-08-12 14:31 Mika Westerberg
  2019-08-12 14:31 ` [PATCH v2 2/2] PCI: pciehp: Prevent deadlock on disconnect Mika Westerberg
  2019-09-19  6:42 ` [PATCH v2 1/2] PCI: pciehp: Do not disable interrupt twice on suspend Mika Westerberg
  0 siblings, 2 replies; 15+ messages in thread
From: Mika Westerberg @ 2019-08-12 14:31 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki
  Cc: Lukas Wunner, Keith Busch, Andy Shevchenko, Frederick Lawler,
	Gustavo A . R . Silva, Sinan Kaya, Kai-Heng Feng,
	Mika Westerberg, linux-pci, linux-kernel

We try to keep PCIe hotplug ports runtime suspended when entering system
suspend. Due to the fact that the PCIe portdrv sets NEVER_SKIP driver PM
flag the PM core always calls system suspend/resume hooks even if the
device is left runtime suspended. Since PCIe hotplug driver re-uses the
same function for both it ends up disabling hotplug interrupt twice and
the second time following is printed:

  pciehp 0000:03:01.0:pcie204: pcie_do_write_cmd: no response from device

Prevent this from happening by checking whether the device is already
runtime suspended when system suspend hook is called.

Fixes: 9c62f0bfb832 ("PCI: pciehp: Implement runtime PM callbacks")
Reported-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
Changes from previous version:

  * Move .resume inside CONFIG_PM_SLEEP
  * Added tags from Kai-Heng and Rafael

 drivers/pci/hotplug/pciehp_core.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 6ad0d86762cb..e9f82afa3773 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -248,7 +248,7 @@ static bool pme_is_native(struct pcie_device *dev)
 	return pcie_ports_native || host->native_pme;
 }
 
-static int pciehp_suspend(struct pcie_device *dev)
+static void pciehp_disable_interrupt(struct pcie_device *dev)
 {
 	/*
 	 * Disable hotplug interrupt so that it does not trigger
@@ -256,7 +256,19 @@ static int pciehp_suspend(struct pcie_device *dev)
 	 */
 	if (pme_is_native(dev))
 		pcie_disable_interrupt(get_service_data(dev));
+}
 
+#ifdef CONFIG_PM_SLEEP
+static int pciehp_suspend(struct pcie_device *dev)
+{
+	/*
+	 * If the port is already runtime suspended we can keep it that
+	 * way.
+	 */
+	if (dev_pm_smart_suspend_and_suspended(&dev->port->dev))
+		return 0;
+
+	pciehp_disable_interrupt(dev);
 	return 0;
 }
 
@@ -274,6 +286,7 @@ static int pciehp_resume_noirq(struct pcie_device *dev)
 
 	return 0;
 }
+#endif
 
 static int pciehp_resume(struct pcie_device *dev)
 {
@@ -287,6 +300,12 @@ static int pciehp_resume(struct pcie_device *dev)
 	return 0;
 }
 
+static int pciehp_runtime_suspend(struct pcie_device *dev)
+{
+	pciehp_disable_interrupt(dev);
+	return 0;
+}
+
 static int pciehp_runtime_resume(struct pcie_device *dev)
 {
 	struct controller *ctrl = get_service_data(dev);
@@ -313,10 +332,12 @@ static struct pcie_port_service_driver hpdriver_portdrv = {
 	.remove		= pciehp_remove,
 
 #ifdef	CONFIG_PM
+#ifdef	CONFIG_PM_SLEEP
 	.suspend	= pciehp_suspend,
 	.resume_noirq	= pciehp_resume_noirq,
 	.resume		= pciehp_resume,
-	.runtime_suspend = pciehp_suspend,
+#endif
+	.runtime_suspend = pciehp_runtime_suspend,
 	.runtime_resume	= pciehp_runtime_resume,
 #endif	/* PM */
 };
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-10-24 17:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12 14:31 [PATCH v2 1/2] PCI: pciehp: Do not disable interrupt twice on suspend Mika Westerberg
2019-08-12 14:31 ` [PATCH v2 2/2] PCI: pciehp: Prevent deadlock on disconnect Mika Westerberg
2019-08-19  2:28   ` Sinan Kaya
2019-08-19  8:56     ` Mika Westerberg
2019-08-19 12:28       ` Sinan Kaya
2019-09-23  5:34   ` Lukas Wunner
2019-09-23  8:12     ` Mika Westerberg
2019-09-23  8:28       ` Lukas Wunner
2019-09-23  8:28       ` Mika Westerberg
2019-10-18  7:10         ` Kai-Heng Feng
2019-10-22 23:00   ` Bjorn Helgaas
2019-10-23  7:52     ` Mika Westerberg
2019-10-24  9:38       ` Mika Westerberg
2019-10-24 17:11         ` Bjorn Helgaas
2019-09-19  6:42 ` [PATCH v2 1/2] PCI: pciehp: Do not disable interrupt twice on suspend Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.