Skip to contentSkip to conversation

PM resume must allow device removal

PATCH New David Brownell 1 participant 1 message Oct 13, 2003

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM resume must allow device removal

Hi Patrick,

Here's a patch that resolves the PM problem I reported last week:
the self-deadlock during PM resume, in the case where devices vanished during suspend. That's typical in certain OHCI-HCD resume scenarios (where the HC loses power) and may eventually happen in other cases, as drivers for hotpluggable buses become more intelligent about things getting unplugged.

You may want to have a more elaborate fix. It looked to me like that lock was overloaded ... it's serving not just to protect the list of PM devices against concurrent changes, but also to make sure only one task was managing PM suspend/resume. It seems to me that the "one task" rule would better be handled by some sort of state flag.

- Dave

drivers/base/power/resume.c +11 -2
@@ -22,8 +22,17 @@
 
 int resume_device(struct device * dev)
 {
-	if (dev->bus && dev->bus->resume)
-		return dev->bus->resume(dev);
+	if (dev->bus && dev->bus->resume) {
+		int retval;
+
+		/* drop lock so the call can use device_del() to clean up
+		 * after unplugged (or otherwise vanished) child devices
+		 */
+		up(&dpm_sem);
+		retval = dev->bus->resume(dev);
+		down(&dpm_sem);
+		return retval;
+	}
 	return 0;
 }