Skip to contentSkip to conversation

Patch: linux-2.5.42/kernel/sys.c - warm reboot should not suspend devices

DISCUSSION Adam J. Richter 2 participants 2 messages Oct 15, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 8 lines · Eric W. Biederman
Quoted 8 lines

You do not understand. The fundamental problem is that
sys_reboot in linux-2.5.42/kernel/sys.c makes exactly the same power management call for a reboot and for a halt (device_shutdown()). I want my IDE, SCSI, USB, and FireWire hard disks to spin down if I do a halt. I do not want them to do that when I reboot. I also do not want my reboot to wait for an interrupt from a sound card because remove() needs to determine if it is being called because the device had just been unplugged. It is not just about IDE disk drives.

[...]

Quoted 2 lines

Do you seriously have a hot-plug sound card, that waits for an interrupt to be certain the card is plugged in during remove?

Although I was being hypothetical, come to think of it, I do
some USB speakers that I have not been using, and detecting their removal is done by the host contoller polling the hub for an "interrupt", typically once per millisecond.

Quoted 5 lines

If there is non-trivial work to detect if a card is present it probably makes sense to factor remove into
->quiet() and ->remove()
Where quiet would put the device into a quiescent state, and remove would simply clean up the driver state.

        Splitting into ->quiet() and ->removed() would be helpful

in any case, where removed() would normally not touch the hardware, since it is quite possible the device has already been removed, since the callers of these routines generally know if they are calling because the device has been removed or because they want just want to turn it off, while ->remove() currently has to guess, which not only wastes time but also can be difficult to do safely when you don't know if the device that you're talking to is even present anymore.

Adam J. Richter     __     ______________   575 Oroville Road
[email protected]     \ /                  Milpitas, California 95035
+1 408 309-6081         | g g d r a s i l   United States of America
#1 lore raw
Quoted 9 lines · Adam J. Richter
Quoted 5 lines · Eric W. Biederman

If there is non-trivial work to detect if a card is present it probably makes sense to factor remove into
->quiet() and ->remove()
Where quiet would put the device into a quiescent state, and remove would simply clean up the driver state.

        Splitting into ->quiet() and ->removed() would be helpful
Quoted 8 lines

in any case, where removed() would normally not touch the hardware, since it is quite possible the device has already been removed, since the callers of these routines generally know if they are calling because the device has been removed or because they want just want to turn it off, while ->remove() currently has to guess, which not only wastes time but also can be difficult to do safely when you don't know if the device that you're talking to is even present anymore.

Except for the case when a device is physically swapped before ->remove() which is really, really, nasty. But it is quiet unlikely anyone will actually be that fast. Whatever talks to the hardware has to check to see if it's device is present. But if usb is anything like PCI it should be a very inexpensive check to see if a driver is present. And writes to a non-existent device should be safe.

Splitting ->remove() into quiet() and ->removed() will be racy. So unless there is shown to be a compelling reason to do the split I don't want to go there. It appears easier to write correct code with a single ->remove() method than two separate methods in the hot-plug case.

Eric