Skip to contentSkip to conversation

Calling suspend() in halt/restart/shutdown -> not a good idea

DISCUSSION Benjamin Herrenschmidt 6 participants 18 messages Aug 1, 2005 – Aug 4, 2005

lore
Share & tools
lore
#0 lore raw

Hi !

Why are we calling driver suspend routines in these ? This is _not_ a good idea ! On various machines, the mecanisms for shutting down are quite different from suspend/resume, and current drivers have too many bugs to make that safe. I keep getting all sort of reports of machines not shutting down anymore.

Ben.

#1 lore raw
Quoted 7 lines · On Mon, 01 Aug 2005 17:09:31 +0200 Benjamin Herrenschmidt…

Hi !

Why are we calling driver suspend routines in these ? This is _not_ a good idea ! On various machines, the mecanisms for shutting down are quite different from suspend/resume, and current drivers have too many bugs to make that safe. I keep getting all sort of reports of machines not shutting down anymore.

For example, my Centrino laptop will restart instead of power down with -mm kernels.

To "fix" this I can either:
- unplug power. Shutdown works when on battery power.
- attach an external USB hard disk => power down always works.
- remove device_suspend(PMSG_SUSPEND) => power down always works.

Marc

#2 lore raw
Quoted 11 lines · Marc Ballarin
Quoted 7 lines · On Mon, 01 Aug 2005 17:09:31 +0200 Benjamin Herrenschmidt…

Hi !

Why are we calling driver suspend routines in these ? This is _not_ a good idea ! On various machines, the mecanisms for shutting down are quite different from suspend/resume, and current drivers have too many bugs to make that safe. I keep getting all sort of reports of machines not shutting down anymore.

Quoted 7 lines

For example, my Centrino laptop will restart instead of power down with -mm kernels.

To "fix" this I can either:
- unplug power. Shutdown works when on battery power.
- attach an external USB hard disk => power down always works.
- remove device_suspend(PMSG_SUSPEND) => power down always works.-

Yes, this is just one of the gazillion setup that got broken by this change. Drivers already have a shutdown() callback anyway, and if we want to re-use the suspend one, then we need to define some sane parameter, not "fake" a system suspend.

Ben.

#3 lore raw

Hi!

Quoted 14 lines
Quoted 6 lines
Quoted 5 lines

Why are we calling driver suspend routines in these ? This is _not_ a good idea ! On various machines, the mecanisms for shutting down are quite different from suspend/resume, and current drivers have too many bugs to make that safe. I keep getting all sort of reports of machines not shutting down anymore.

Quoted 7 lines

For example, my Centrino laptop will restart instead of power down with -mm kernels.

To "fix" this I can either:
- unplug power. Shutdown works when on battery power.
- attach an external USB hard disk => power down always works.
- remove device_suspend(PMSG_SUSPEND) => power down always works.-

Quoted 4 lines

Yes, this is just one of the gazillion setup that got broken by this change. Drivers already have a shutdown() callback anyway, and if we want to re-use the suspend one, then we need to define some sane parameter, not "fake" a system suspend.

I'd like to get rid of shutdown callback. Having two copies of code (one in callback, one in suspend) is ugly.
Pavel

Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
#4 lore raw
Quoted 3 lines

I'd like to get rid of shutdown callback. Having two copies of code (one in callback, one in suspend) is ugly.

Well, it's obviously not a good time for this. First, suspend and shutdown don't necessarily do the same thing, then it just doesn't work in practice. So either do it right completely or not at all, but 2.6.13 isn't the place for an half-assed hack that looks like a solution to you.

I do agree that there are enough similarities between the suspend and shutdown process that we could use the same callback, but then, please, at least with a different argument and with drivers beeing fixed to handle it. Most drivers should probably just "ignore" shutdown anyway.

BTW. I suppose we still have the same constant for PMSG_FREEZE and PMSG_SUSPEND ? That could have been fixed ages ago and is more important imho....

Ben.

#5 lore raw
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 2 lines

I'd like to get rid of shutdown callback. Having two copies of code (one in callback, one in suspend) is ugly.

Well, it's obviously not a good time for this. First, suspend and shutdown don't necessarily do the same thing, then it just doesn't work in practice. So either do it right completely or not at all, but 2.6.13 isn't the place for an half-assed hack that looks like a solution to you.

One possible way to proceed might be to add a new callback that takes a
pm_message_t: powerdown() If it exists, it would be called in both the suspend and shutdown paths, before the suspend() and shutdown() calls to that driver are made. As drivers are fixed to clean up and combine that code, they could put the merged result into the powerdown() function, and remove their suspend() and shutdown() functions.

Cheers,
Kyle Moffett

--
I lost interest in "blade servers" when I found they didn't throw knives at people who weren't supposed to be in your machine room.
-- Anthony de Boer

#6 lore raw
Quoted 12 lines · Kyle Moffett
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 2 lines

I'd like to get rid of shutdown callback. Having two copies of code (one in callback, one in suspend) is ugly.

Well, it's obviously not a good time for this. First, suspend and shutdown don't necessarily do the same thing, then it just doesn't work
in practice. So either do it right completely or not at all, but 2.6.13
isn't the place for an half-assed hack that looks like a solution to you.

Quoted 6 lines

One possible way to proceed might be to add a new callback that takes a
pm_message_t: powerdown() If it exists, it would be called in both the suspend and shutdown paths, before the suspend() and shutdown() calls to that driver are made. As drivers are fixed to clean up and combine that code, they could put the merged result into the powerdown() function, and remove their suspend() and shutdown() functions.

We already have shutdown() for that.

Ben.

#7 lore raw
In reply to Kyle Moffett

Hi!

Quoted 11 lines
Quoted 10 lines
Quoted 2 lines

I'd like to get rid of shutdown callback. Having two copies of code (one in callback, one in suspend) is ugly.

Well, it's obviously not a good time for this. First, suspend and shutdown don't necessarily do the same thing, then it just doesn't work
in practice. So either do it right completely or not at all, but 2.6.13
isn't the place for an half-assed hack that looks like a solution to you.

Quoted 4 lines

One possible way to proceed might be to add a new callback that takes a
pm_message_t: powerdown() If it exists, it would be called in both the suspend and shutdown paths, before the suspend() and shutdown() calls to that driver are made. As drivers are fixed to clean up and combine

No; please don't make driver model more complex than it already is.
Pavel

Signature · 1 line
if you have sharp zaurus hardware you don't need... you know my address
#8 lore raw
In reply to Benjamin Herrenschmidt

Hi!

Quoted 8 lines
Quoted 2 lines

I'd like to get rid of shutdown callback. Having two copies of code (one in callback, one in suspend) is ugly.

Well, it's obviously not a good time for this. First, suspend and shutdown don't necessarily do the same thing, then it just doesn't work in practice. So either do it right completely or not at all, but 2.6.13 isn't the place for an half-assed hack that looks like a solution to you.

Well, if that "hack" broke something, it was broken
w.r.t. suspend-to-disk already, but... it caused enough problems that it is not good idea for 2.6.13, agreed.

Quoted 5 lines

I do agree that there are enough similarities between the suspend and shutdown process that we could use the same callback, but then, please, at least with a different argument and with drivers beeing fixed to handle it. Most drivers should probably just "ignore" shutdown anyway.

Yes, we should have different argument, but code should be really similar in suspend-to-disk-powerdown and normal powerdown, so I'd like to use same callback. This is post-2.6.13 material (but I'd like patch to stay in -mm, so that drivers keep getting tested).

Quoted 3 lines

BTW. I suppose we still have the same constant for PMSG_FREEZE and PMSG_SUSPEND ? That could have been fixed ages ago and is more important imho....

That one is fixed in -mm already. But I guess it will not make it into 2.6.13.
Pavel

Signature · 1 line
if you have sharp zaurus hardware you don't need... you know my address
#9 lore raw
In reply to Benjamin Herrenschmidt

Hi!

Quoted 1 line

Why are we calling driver suspend routines in these ? This is _not_

Well, reason is that if you remove device_suspend() you'll get emergency hard disk park during powerdown. As harddrives can survive only limited number of emergency stops, that is not a good idea.

Pavel

Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
#10 lore raw
Quoted 7 lines · Pavel Machek

Hi!

Quoted 1 line

Why are we calling driver suspend routines in these ? This is _not_

Well, reason is that if you remove device_suspend() you'll get emergency hard disk park during powerdown. As harddrives can survive only limited number of emergency stops, that is not a good idea.

Then the practical question is: do we suspend the disk by calling device_suspend() for every device. Or do we modify the ->shutdown() method for the disk.

Eric

#11 lore raw

Hi!

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Why are we calling driver suspend routines in these ? This is _not_

Well, reason is that if you remove device_suspend() you'll get emergency hard disk park during powerdown. As harddrives can survive only limited number of emergency stops, that is not a good idea.

Then the practical question is: do we suspend the disk by calling device_suspend() for every device. Or do we modify the ->shutdown() method for the disk.

The additional data in pm_message_t are usefull, and sharing code between suspend-to-ram and suspend-to-disk is usefull => option #1...

Pavel

Signature · 1 line
Boycott Kodak -- for their patent abuse against Java.
#12 lore raw
Quoted 8 lines · Pavel Machek

Hi!

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Why are we calling driver suspend routines in these ? This is _not_

Well, reason is that if you remove device_suspend() you'll get emergency hard disk park during powerdown. As harddrives can survive only limited number of emergency stops, that is not a good idea.

Quoted 6 lines
Quoted 3 lines

Then the practical question is: do we suspend the disk by calling device_suspend() for every device. Or do we modify the ->shutdown() method for the disk.

The additional data in pm_message_t are usefull, and sharing code between suspend-to-ram and suspend-to-disk is usefull => option #1...

No.

Ben.

#13 lore raw
In reply to Eric W. Biederman
Quoted 6 lines · Eric W. Biederman
Quoted 4 lines · Pavel Machek

Hi!

Quoted 1 line

Why are we calling driver suspend routines in these ? This is _not_

Quoted 7 lines
Quoted 3 lines

Well, reason is that if you remove device_suspend() you'll get emergency hard disk park during powerdown. As harddrives can survive only limited number of emergency stops, that is not a good idea.

Then the practical question is: do we suspend the disk by calling device_suspend() for every device. Or do we modify the ->shutdown() method for the disk.

afaik, IDE used to have a shutdown callback or a shutdown notifier already anyway. If that was lost, then this is a different problem. If SATA and/or SCSI aren't doing it, then they need fixing, but suspend() isn't the solution.

Ben.

#14 lore raw
In reply to Pavel Machek
Quoted 7 lines · Pavel Machek

Hi!

Quoted 1 line

Why are we calling driver suspend routines in these ? This is _not_

Well, reason is that if you remove device_suspend() you'll get emergency hard disk park during powerdown. As harddrives can survive only limited number of emergency stops, that is not a good idea.

No, that is bogus. We have shutdown() already for that and it used to be implemented at least by IDE.

You are just blindly "dropping" the device_suspend() call in there without thinking. There is a lot of differences between suspend and shutdown, you can't "just do that". In addition to the number of drivers with broken suspend of course, causing many boxes to not shutdown anymore (and not only PPCs)

Andrew, please back that off before 2.6.13. I'll try to send a patch if you want later today if I find some time with a kernel source at hand.

Ben.

#15 lore raw
Quoted 3 lines · Benjamin Herrenschmidt

Andrew, please back that off before 2.6.13. I'll try to send a patch if
you want later today if I find some time with a kernel source at hand.

Please do.

#16 lore raw
In reply to Benjamin Herrenschmidt

Hi!

Quoted 4 lines

Why are we calling driver suspend routines in these ? This is _not_ a good idea ! On various machines, the mecanisms for shutting down are quite different from suspend/resume, and current drivers have too many bugs to make that safe. I keep getting all sort of reports of machines

Well, powerdown at the end of suspend-to-disk should be *very* similar to normal powerdown => if device_suspend() breaks something, it is a bug in driver anyway.

Now, we may have a lot of such bugs, and the change went in too early, but in the long run...

Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
#17 lore raw
Quoted 10 lines · Pavel Machek

Hi!

Quoted 4 lines

Why are we calling driver suspend routines in these ? This is _not_ a good idea ! On various machines, the mecanisms for shutting down are quite different from suspend/resume, and current drivers have too many bugs to make that safe. I keep getting all sort of reports of machines

Well, powerdown at the end of suspend-to-disk should be *very* similar to normal powerdown => if device_suspend() breaks something, it is a bug in driver anyway.

Power Down != Suspend. Period.

Quoted 2 lines

Now, we may have a lot of such bugs, and the change went in too early, but in the long run...

Crap. It's not the same thing.

Ben.