Skip to contentSkip to conversation

PM / Runtime: Do not send suspend request after the device is shutdown

PATCH New Peter Chen 1 participant 1 message Nov 9, 2011

Subsystems (4)
lore
Share & tools
lore

Peter Chen

author
#0 lore raw

PATCH 1/1 PM / Runtime: Do not send suspend request after the device is shutdown

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.

---
 drivers/base/power/runtime.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/base/power/runtime.c +7 -0
index acb3f83..a439227 100644
@@ -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;
 }
Signature · 1 line
1.7.1