Re: [Bug 10030] Suspend doesn't work when SD card is inserted

From: Alan Stern
Date: Sun Feb 24 2008 - 14:28:14 EST


On Sun, 24 Feb 2008, Rafael J. Wysocki wrote:

> > You know, with this new patch we probably don't need
> > device_pm_schedule_removal() any more.
>
> No, we don't. However, because of that dpm_suspend() and device_power_down()
> need to be changed not to assume that the removed devices will end up on
> dpm_destroy.

Yes. The safest approach will be to check whether the device is still
at the end of the dpm_locked or dpm_off list; if it hasn't then we can
assume that it has been removed (or scheduled for removal).

> IMO you also should add this change in device_power_down():
>
> @@ -388,18 +343,15 @@ int device_power_down(pm_message_t state
> struct list_head *entry = dpm_off.prev;
> struct device *dev = to_device(entry);
>
> - list_del_init(&dev->power.entry);
> error = suspend_device_late(dev, state);
> if (error) {
> printk(KERN_ERR "Could not power down device %s: "
> "error %d\n",
> kobject_name(&dev->kobj), error);
> - if (list_empty(&dev->power.entry))
> - list_add(&dev->power.entry, &dpm_off);
> break;
> }
> - if (list_empty(&dev->power.entry))
> - list_add(&dev->power.entry, &dpm_off_irq);
> + if (!list_empty(&dev->power.entry))
> + list_move(&dev->power.entry, &dpm_off_irq);
> }

Actually I changed the last two lines to:

+
+ /* Don't move the entry if the device has been unregistered */
+ if (entry == dpm_off.prev)
+ list_move(entry, &dpm_off_irq);

with analogous changes to dpm_suspend().

Any more suggestions for updates?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/