Pavel Machek <pavel@xxxxxxx> wrote: > Hi! > >> #include <linux/ide.h> >> #include <linux/completion.h> >> #include <linux/device.h> >> +#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_HIBERNATION) >> +# include <linux/suspend.h> >> +#endif > > This ifdef should be unneccessary. Right. > > >> +#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_HIBERNATION) >> +static int ide_park_count = 1; >> +DECLARE_WAIT_QUEUE_HEAD(ide_park_wq); >> + >> +static inline int suspend_parking(void) >> +{ >> + spin_lock_irq(&ide_lock); >> + if (ide_park_count == 1) >> + ide_park_count = 0; >> + spin_unlock_irq(&ide_lock); >> + return !ide_park_count; >> +} >> + >> +static int ide_pm_notifier(struct notifier_block *nb, unsigned long val, >> + void *null) >> +{ >> + switch (val) { >> + case PM_SUSPEND_PREPARE: >> + wait_event(ide_park_wq, suspend_parking()); >> + break; >> + case PM_POST_SUSPEND: >> + ide_park_count = 1; >> + break; >> + default: >> + return NOTIFY_DONE; >> + } >> + return NOTIFY_OK; >> +} >> + >> +static struct notifier_block ide_pm_notifier_block = { >> + .notifier_call = ide_pm_notifier, >> +}; >> + >> +static inline int ide_register_pm_notifier(void) >> +{ >> + return register_pm_notifier(&ide_pm_notifier_block); >> +} >> + >> +static inline int ide_unregister_pm_notifier(void) >> +{ >> + return unregister_pm_notifier(&ide_pm_notifier_block); >> +} > > Any reason this does not use normal driver model suspend/resume > callbacks? Yes, two in fact. Firstly, it would appear that after freeze_processes() has completed, timers don't fire anymore. That's why we have to call the unpark hook manually. The ATA suspend callback would be the place to do that but the scsi ULD's suspend callback issues a cache sync and a disk start_stop command before and waits indefinitely for completion. Secondly and more importantly, using pm_notifiers is the right thing to do as long as user processes control when to park and unpark the disks. This way we can hold back from suspending until user space gives the all clear. Regards, Elias -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html