linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] PCI / PM: Add needs_resume flag to avoid suspend complete optimization
@ 2017-04-28 14:16 Imre Deak
  2017-04-28 14:16 ` [PATCH v3 2/2] drm/i915: Prevent the system " Imre Deak
  2017-04-28 21:33 ` [PATCH v3 1/2] PCI / PM: Add needs_resume flag to avoid " Rafael J. Wysocki
  0 siblings, 2 replies; 8+ messages in thread
From: Imre Deak @ 2017-04-28 14:16 UTC (permalink / raw)
  To: intel-gfx
  Cc: Jani Nikula, Rafael J. Wysocki, Bjorn Helgaas, linux-pci, stable

Some drivers - like i915 - may not support the system suspend direct
complete optimization due to differences in their runtime and system
suspend sequence. Add a flag that when set resumes the device before
calling the driver's system suspend handlers which effectively disables
the optimization.

Needed by the next patch fixing suspend/resume on i915.

Suggested by Rafael.

Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Imre Deak <imre.deak@intel.com>
---

[ After discussing with Jani, I'm going to apply this and the next patch
  for now to the intel-gfx specific CI branch to unblock our testing. ]

 drivers/pci/pci.c   | 3 ++-
 include/linux/pci.h | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7904d02..020f02d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2141,7 +2141,8 @@ bool pci_dev_keep_suspended(struct pci_dev *pci_dev)
 
 	if (!pm_runtime_suspended(dev)
 	    || pci_target_state(pci_dev) != pci_dev->current_state
-	    || platform_pci_need_resume(pci_dev))
+	    || platform_pci_need_resume(pci_dev)
+	    || pci_dev->needs_resume)
 		return false;
 
 	/*
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5948cfd..2f012f8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -316,6 +316,9 @@ struct pci_dev {
 	unsigned int	hotplug_user_indicators:1; /* SlotCtl indicators
 						      controlled exclusively by
 						      user sysfs */
+	unsigned int	needs_resume:1;	/* Resume before calling the driver's
+					   system suspend hooks, disabling the
+					   direct_complete optimization. */
 	unsigned int	d3_delay;	/* D3->D0 transition time in ms */
 	unsigned int	d3cold_delay;	/* D3cold->D0 transition time in ms */
 
@@ -1110,6 +1113,10 @@ bool pci_check_pme_status(struct pci_dev *dev);
 void pci_pme_wakeup_bus(struct pci_bus *bus);
 void pci_d3cold_enable(struct pci_dev *dev);
 void pci_d3cold_disable(struct pci_dev *dev);
+static inline void pci_resume_before_suspend(struct pci_dev *dev, bool enable)
+{
+	dev->needs_resume = enable;
+}
 
 static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
 				  bool enable)
-- 
2.5.0

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

end of thread, other threads:[~2017-05-02 21:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-28 14:16 [PATCH v3 1/2] PCI / PM: Add needs_resume flag to avoid suspend complete optimization Imre Deak
2017-04-28 14:16 ` [PATCH v3 2/2] drm/i915: Prevent the system " Imre Deak
2017-04-28 21:33 ` [PATCH v3 1/2] PCI / PM: Add needs_resume flag to avoid " Rafael J. Wysocki
2017-04-29 10:21   ` Rafael J. Wysocki
2017-04-30 12:57     ` Imre Deak
2017-05-01 20:36       ` Rafael J. Wysocki
2017-05-02  9:05         ` Imre Deak
2017-05-02 20:57           ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).