Fix floppy hibernation
Subsystems (2)
PATCH 1/1 Fix floppy hibernation
Hello,
floppy driver was always missing hibernation support. After resume, floppy did not work (until a couple of disk reinserts and retries), producing errors like this:end_request: I/O error, dev fd0, sector 0
Ingo Molnar tried to fix it in 2006: http://lkml.org/lkml/2006/11/12/92
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
drivers/block/floppy.c +26 -1
@@ -4148,6 +4148,24 @@ { } +static int floppy_resume (struct platform_device *dev) +{ +int i; + +for (i =0 ; i <N_FDC ; i++) +if (FDCS ->address !=-1 ) +user_reset_fdc (-1 ,FD_RESET_ALWAYS ,0 ); + +return 0 ; +} + +static struct platform_driver floppy_driver = { + .resume = floppy_resume, + .driver = { + .name ="floppy" , + }, +}; +static struct platform_device floppy_device[N_DRIVE ];static struct kobject *floppy_find (dev_t dev,int *part,void *data)
@@ -4196,10 +4214,14 @@if (err) goto out_put_disk; + err =platform_driver_register (&floppy_driver); +if (err) + goto out_unreg_blkdev; + floppy_queue =blk_init_queue (do_fd_request, &floppy_lock);if (!floppy_queue) { err = -ENOMEM ; - goto out_unreg_blkdev; + goto out_unreg_driver; }blk_queue_max_sectors (floppy_queue,64 );
@@ -4346,6 +4368,8 @@ out_unreg_region:blk_unregister_region (MKDEV (FLOPPY_MAJOR ,0 ),256 );blk_cleanup_queue (floppy_queue); +out_unreg_driver: +platform_driver_unregister (&floppy_driver); out_unreg_blkdev:unregister_blkdev (FLOPPY_MAJOR ,"fd" ); out_put_disk:
@@ -4566,6 +4590,7 @@blk_unregister_region (MKDEV (FLOPPY_MAJOR ,0 ),256 );unregister_blkdev (FLOPPY_MAJOR ,"fd" ); +platform_driver_unregister (&floppy_driver);for (drive =0 ; drive <N_DRIVE ; drive++) {del_timer_sync (&motor_off_timer[drive]);
Signature · 1 line
Ondrej Zary
Quoted 11 lines · Ondrej Zary
Hello,
floppy driver was always missing hibernation support. After resume, floppy did not work (until a couple of disk reinserts and retries), producing errors like this:end_request: I/O error, dev fd0, sector 0Ingo Molnar tried to fix it in 2006: http://lkml.org/lkml/2006/11/12/92
Quoted 5 lines
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
Signed-off-by Ondrej Zary <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 12 lines · Pavel Machek
Quoted 11 lines · Ondrej Zary
Hello,
floppy driver was always missing hibernation support. After resume, floppy did not work (until a couple of disk reinserts and retries), producing errors like this:end_request: I/O error, dev fd0, sector 0Ingo Molnar tried to fix it in 2006: http://lkml.org/lkml/2006/11/12/92
Quoted 6 lines
Quoted 5 lines
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
Signed-off-by Ondrej Zary <[email protected]>Acked-by Pavel Machek <[email protected]>
nice patch ... thanks for picking up what i left unfinished.
Ingo
Quoted 15 lines · Ingo Molnar
Quoted 12 lines · Pavel Machek
Quoted 11 lines · Ondrej Zary
Hello,
floppy driver was always missing hibernation support. After resume, floppy did not work (until a couple of disk reinserts and retries), producing errors like this:end_request: I/O error, dev fd0, sector 0Ingo Molnar tried to fix it in 2006: http://lkml.org/lkml/2006/11/12/92
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
Signed-off-by Ondrej Zary <[email protected]>Acked-by Pavel Machek <[email protected]>nice patch ... thanks for picking up what i left unfinished.
I guess I'll take it to the suspend tree. Or is it a better place?
Best,
Rafael
Quoted 20 lines · Rafael J. Wysocki
Quoted 19 lines · Ingo Molnar
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Ondrej Zary
Hello,
floppy driver was always missing hibernation support. After resume, floppy did not work (until a couple of disk reinserts and retries), producing errors like this:end_request: I/O error, dev fd0, sector 0Ingo Molnar tried to fix it in 2006: http://lkml.org/lkml/2006/11/12/92
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Ondrej Zary <[email protected]>Acked-by Pavel Machek <[email protected]>nice patch ... thanks for picking up what i left unfinished.
I guess I'll take it to the suspend tree. Or is it a better place?
Sounds like a good idea.
Ingo
Quoted 23 lines · On Sat, 30 May 2009 18:04:25 +0200 Ondrej Zary <[email protected]>…
Hello,
floppy driver was always missing hibernation support. After resume, floppy did not work (until a couple of disk reinserts and retries), producing errors like this:end_request: I/O error, dev fd0, sector 0Ingo Molnar tried to fix it in 2006: http://lkml.org/lkml/2006/11/12/92
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
Signed-off-by Ondrej Zary <[email protected]>drivers/block/floppy.c +0
-0@@ -4148,6 +4148,24 @@ { }
drivers/block/floppy.c line 4160
Quoted 10 lines
drivers/block/floppy.c +10
-0+static int floppy_resume (struct platform_device *dev) +{ +int i; + +for (i =0 ; i <N_FDC ; i++) +if (FDCS ->address !=-1 ) +user_reset_fdc (-1 ,FD_RESET_ALWAYS ,0 ); + +return 0 ; +}
hm, how does this work?
FDCS is a revolting should-not-exist macro which assumes the presence of a local variable called `fdc'.
So I think the loop control variable here should be called fdc', not i'.
It's pretty amazing that something like this still exists in a core driver. Someone please save us!
Quoted 39 lines · On Tuesday 02 June 2009 01:45:20 Andrew Morton wrote:
On Sat, 30 May 2009 18:04:25 +0200
Quoted 23 lines · Ondrej Zary
Hello,
floppy driver was always missing hibernation support. After resume, floppy did not work (until a couple of disk reinserts and retries), producing errors like this:end_request: I/O error, dev fd0, sector 0Ingo Molnar tried to fix it in 2006: http://lkml.org/lkml/2006/11/12/92
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
Signed-off-by Ondrej Zary <[email protected]>---
linux-2.6.29.4-orig/drivers/block/floppy.c2009-05-30
14:38:29.000000000 +0200 +++linux/drivers/block/floppy.c2009-05-30
17:50:32.000000000 +0200 @@ -4148,6 +4148,24 @@
{
}Review
Quoted 10 lines
(quoted diff) +10
-0+static int floppy_resume(struct platform_device *dev) +{ + int i; + + for (i = 0; i < N_FDC; i++) + if (FDCS->address != -1) + user_reset_fdc(-1, FD_RESET_ALWAYS, 0); + + return 0; +}hm, how does this work?
Quoted 2 lines
FDCS is a revolting should-not-exist macro which assumes the presence of a local variable called `fdc'.
The driver is complete mess - there is also a global static fdc variable. So it worked because I have only one floppy controller.
Quoted 1 line
So I think the loop control variable here should be called
fdc', noti'.
See the v2 patch below. Tested and works too.
Quoted 3 lines
It's pretty amazing that something like this still exists in a core driver. Someone please save us!
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
drivers/block/floppy.c +26 -1
@@ -4148,6 +4148,24 @@ { } +static int floppy_resume (struct platform_device *dev) +{ +int fdc; + +for (fdc =0 ; fdc <N_FDC ; fdc++) +if (FDCS ->address !=-1 ) +user_reset_fdc (-1 ,FD_RESET_ALWAYS ,0 ); + +return 0 ; +} + +static struct platform_driver floppy_driver = { + .resume = floppy_resume, + .driver = { + .name ="floppy" , + }, +}; +static struct platform_device floppy_device[N_DRIVE ];static struct kobject *floppy_find (dev_t dev,int *part,void *data)
@@ -4196,10 +4214,14 @@if (err) goto out_put_disk; + err =platform_driver_register (&floppy_driver); +if (err) + goto out_unreg_blkdev; + floppy_queue =blk_init_queue (do_fd_request, &floppy_lock);if (!floppy_queue) { err = -ENOMEM ; - goto out_unreg_blkdev; + goto out_unreg_driver; }blk_queue_max_sectors (floppy_queue,64 );
@@ -4346,6 +4368,8 @@ out_unreg_region:blk_unregister_region (MKDEV (FLOPPY_MAJOR ,0 ),256 );blk_cleanup_queue (floppy_queue); +out_unreg_driver: +platform_driver_unregister (&floppy_driver); out_unreg_blkdev:unregister_blkdev (FLOPPY_MAJOR ,"fd" ); out_put_disk:
@@ -4566,6 +4590,7 @@blk_unregister_region (MKDEV (FLOPPY_MAJOR ,0 ),256 );unregister_blkdev (FLOPPY_MAJOR ,"fd" ); +platform_driver_unregister (&floppy_driver);for (drive =0 ; drive <N_DRIVE ; drive++) {del_timer_sync (&motor_off_timer[drive]);
Signature · 1 line
Ondrej Zary
Quoted 16 lines · On Tue, 2 Jun 2009 18:30:50 +0200 Ondrej Zary <[email protected]>…
Quoted 13 lines
drivers/block/floppy.c line 4160
Quoted 10 lines
drivers/block/floppy.c +10
-0+static int floppy_resume (struct platform_device *dev) +{ +int i; + +for (i =0 ; i <N_FDC ; i++) +if (FDCS ->address !=-1 ) +user_reset_fdc (-1 ,FD_RESET_ALWAYS ,0 ); + +return 0 ; +}hm, how does this work?
Quoted 2 lines
FDCS is a revolting should-not-exist macro which assumes the presence of a local variable called `fdc'.
Quoted 6 lines
The driver is complete mess - there is also a global static fdc variable. So it worked because I have only one floppy controller.
Quoted 1 line
So I think the loop control variable here should be called
fdc', noti'.See the v2 patch below. Tested and works too.
OK.
Quoted 10 lines
Quoted 3 lines
It's pretty amazing that something like this still exists in a core driver. Someone please save us!
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
That's a very skimpy changelog. The lack of any useful reference to the referred-to Ingopatch doesn't aid things..
Quoted 6 lines
drivers/block/floppy.c +0
-0@@ -4148,6 +4148,24 @@ { }
drivers/block/floppy.c line 4160
Quoted 10 lines
drivers/block/floppy.c +10
-0+static int floppy_resume (struct platform_device *dev) +{ +int fdc; + +for (fdc =0 ; fdc <N_FDC ; fdc++) +if (FDCS ->address !=-1 ) +user_reset_fdc (-1 ,FD_RESET_ALWAYS ,0 ); + +return 0 ; +}
The patch changes the driver so that it calls user_reset_fdc() for each device at resume-time.
Why? What effect does this have on the hardware and why does it fix things?
Thanks.
Quoted 58 lines · Andrew Morton
On Tue, 2 Jun 2009 18:30:50 +0200
Quoted 16 lines · Ondrej Zary
Quoted 13 lines
drivers/block/floppy.c line 4160
Quoted 10 lines
drivers/block/floppy.c +10
-0+static int floppy_resume (struct platform_device *dev) +{ +int i; + +for (i =0 ; i <N_FDC ; i++) +if (FDCS ->address !=-1 ) +user_reset_fdc (-1 ,FD_RESET_ALWAYS ,0 ); + +return 0 ; +}hm, how does this work?
Quoted 2 lines
FDCS is a revolting should-not-exist macro which assumes the presence of a local variable called `fdc'.
Quoted 7 lines
The driver is complete mess - there is also a global static fdc variable. So it worked because I have only one floppy controller.
Quoted 2 lines
So I think the loop control variable here should be called
fdc', noti'.See the v2 patch below. Tested and works too.
OK.
Quoted 5 lines
Quoted 2 lines
It's pretty amazing that something like this still exists in a core driver. Someone please save us!
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine.
That's a very skimpy changelog. The lack of any useful reference to the referred-to Ingopatch doesn't aid things..
Quoted 6 lines
---
linux-2.6.29.4-orig/drivers/block/floppy.c2009-05-30
14:38:29.000000000 +0200 +++linux/drivers/block/floppy.c2009-06-02
17:32:56.000000000 +0200 @@ -4148,6 +4148,24 @@
{
}drivers/block/floppy.c line 4160
Quoted 10 lines
drivers/block/floppy.c +10
-0+static int floppy_resume (struct platform_device *dev) +{ +int fdc; + +for (fdc =0 ; fdc <N_FDC ; fdc++) +if (FDCS ->address !=-1 ) +user_reset_fdc (-1 ,FD_RESET_ALWAYS ,0 ); + +return 0 ; +}The patch changes the driver so that it calls
user_reset_fdc()for each device at resume-time.
Quoted 2 lines
Why? What effect does this have on the hardware and why does it fix things?
I don't know at all, it's complete guesswork. The first thing I tested was rmmod floppy && modprobe floppy after resume - it worked. Narrowing the initialization code down resulted in this patch.
Signature · 1 line
Ondrej Zary
Quoted 14 lines · On Wed, 3 Jun 2009 08:13:26 +0200 Ondrej Zary <[email protected]>…
Quoted 14 lines
drivers/block/floppy.c line 4160
Quoted 10 lines
drivers/block/floppy.c +10
-0+static int floppy_resume (struct platform_device *dev) +{ +int fdc; + +for (fdc =0 ; fdc <N_FDC ; fdc++) +if (FDCS ->address !=-1 ) +user_reset_fdc (-1 ,FD_RESET_ALWAYS ,0 ); + +return 0 ; +}The patch changes the driver so that it calls
user_reset_fdc()for each device at resume-time.
Quoted 6 lines
Quoted 2 lines
Why? What effect does this have on the hardware and why does it fix things?
I don't know at all, it's complete guesswork. The first thing I tested was rmmod floppy && modprobe floppy after resume - it worked. Narrowing the initialization code down resulted in this patch.
lol, OK. I added this to the changelog:
This fix resets the floppy controller on resume. It was experimentally determined to bring the controller back to life - we don't really know why it works.
floppy_init() does the same thing at boot/modprobe time.
Let's see how it goes... If someone reports breakage then we can always change the driver so that activation of your new code requires a module parameter.