linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] PM / Runtime: Do not send suspend request after the device is shutdown
@ 2011-11-09  9:42 Peter Chen
  0 siblings, 0 replies; only message in thread
From: Peter Chen @ 2011-11-09  9:42 UTC (permalink / raw)
  To: linux-pm; +Cc: hzpeterchen

There may be an issue when the user issue "reboot" command, then the
device has shut down its hardware, after that, this runtime-pm featured
device's driver will probably be scheduled to do its suspend routine,
and at its suspend routine, it may access hardware, but the device has
already shutdown physically, then the system hang may be occurred.

I ran out this issue with a auto-suspend supported USB devices, like
3G modem, keyboard. The usb runtime suspend routine may be scheduled
after the usb controller has been shut down, and the usb runtime suspend
routine will try to suspend its roothub(controller), it will access
register, then the system hang occurs as the controller is shutdown.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/base/power/runtime.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index acb3f83..a439227 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -150,6 +150,13 @@ static int rpm_check_suspend_allowed(struct device *dev)
 		retval = -EAGAIN;
 	else if (dev->power.runtime_status == RPM_SUSPENDED)
 		retval = 1;
+	/* 
+	 * If the device has already been shut down, DO NOT
+	 * send suspend request.
+	 */
+	else if (list_empty(&dev->kobj.entry)) {
+		retval = -ESHUTDOWN;
+	}
 
 	return retval;
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-11-09  9:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-09  9:42 [PATCH 1/1] PM / Runtime: Do not send suspend request after the device is shutdown Peter Chen

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).