Skip to contentSkip to conversation

floppy: suspend/resume fix

PATCH Mikael Pettersson 3 participants 3 messages Nov 12, 2006 – Nov 15, 2006

lore
Share & tools
lore
#0 lore raw
Quoted 23 lines · Bodo Eggert
Quoted 9 lines

1. You suspend and then resume, leaving the disk in the floppy drive.

2. You suspend, remove the floppy disk, insert a totally different disk in the same drive, and then resume.

What should you do? (Hint: without reading the disk and comparing it with what you have cached you don't know if the disk has been changed or not.)

Quoted 6 lines

If you argue that in case (1) you should continue to allow IO, then you potentially end up scribbling over a disk when someone does (2).

So I'd argue that the behaviour being seen by Mikael is the _safest_ behaviour, and the most correct behaviour given the limitations of the hardware.

- If a user suspends with a floppy in the drive, it will mostly be an error, and he'll unsuspend in order to correct it.
- If it is no error, putting a different/modified floppy into the drive before resume is unlikely
- Even if somebody does this, you can mostly detect the different disk by comparing the first sector or just the FAT "serial number".

Quoted 4 lines

Therefore you can implement a relatively safe resume that will mostly DTRT but destroy data in some unlikely cases, while doing the "safe thing" would mostly cause a harmless (unless not noticed) kind of data loss and sometimes safe you from real data loss.

The bug occurs regardless of whether I leave the floppy disc in the drive during suspend or not. 2.6.19-rc5 (vanilla and with Ingo's suspend/resume hooks) fails the following use case as well:

1. boot
2. insert floppy disc
3. tar tvf /dev/fd0 (works)
4. manually eject floppy disc
5. suspend, later resume
6. insert floppy disc
7. tar tvf /dev/fd0 (fails with I/O errors)
8. tar tvf /dev/fd0 (works)

Like Ingo said, something happens to the HW during suspend and we need to figure out how to reinitialise the HW and the driver so that things work immediately after resume.

/Mikael

#1 lore raw
Quoted 13 lines · Mikael Pettersson

The bug occurs regardless of whether I leave the floppy disc in the drive during suspend or not. 2.6.19-rc5 (vanilla and with Ingo's suspend/resume hooks) fails the following use case as well:

1. boot
2. insert floppy disc
3. tar tvf /dev/fd0 (works)
4. manually eject floppy disc
5. suspend, later resume
6. insert floppy disc
7. tar tvf /dev/fd0 (fails with I/O errors)
8. tar tvf /dev/fd0 (works)

Quoted 3 lines

Like Ingo said, something happens to the HW during suspend and we need to figure out how to reinitialise the HW and the driver so that things work immediately after resume.

Now this is interesting - I know there's been a long standing bug with kernels on my Thinkpad which behave in a similar way to your description above. Basically whenever I change the disk in the drive I tend to need _two_ goes to do anything with it - the first mostly always fails with IO errors.

I've not bothered to report it because it runs a _very_ old 2.6 kernel and upgrading the machine to something modern would be extremely painful (read - would need new hard drive, and probably more RAM than the laptop can take.)

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#2 lore raw
Quoted 18 lines · Russell King
Quoted 13 lines · Mikael Pettersson

The bug occurs regardless of whether I leave the floppy disc in the drive during suspend or not. 2.6.19-rc5 (vanilla and with Ingo's suspend/resume hooks) fails the following use case as well:

1. boot
2. insert floppy disc
3. tar tvf /dev/fd0 (works)
4. manually eject floppy disc
5. suspend, later resume
6. insert floppy disc
7. tar tvf /dev/fd0 (fails with I/O errors)
8. tar tvf /dev/fd0 (works)

Quoted 3 lines

Like Ingo said, something happens to the HW during suspend and we need to figure out how to reinitialise the HW and the driver so that things work immediately after resume.

Quoted 5 lines

Now this is interesting - I know there's been a long standing bug with kernels on my Thinkpad which behave in a similar way to your description above. Basically whenever I change the disk in the drive I tend to need _two_ goes to do anything with it - the first mostly always fails with IO errors.

yeah. But somehow the pre-lockdep-change driver gets this right - purely by virtue of unregistering the IRQ line and the DMA channel - neither of which should have any material effect on behavior ... [and when i restored this in suspend/resume it didnt fix the bug] Weird.

Ingo