sysfs support for ide disks
Hi!
sc1200 was doing ide disk suspension by hand. That's wrong -- how to suspend ide-disk has nothing to do with sc1200. This fixes it, and relies on sysfs to iterate over disks to do the suspension.
As a side effect, swsusp should no longer damage data. [It is incremental to previous patch].
I had to select between standby written in ide-disk.c (uses ide_raw_taskfile) and standby written in sc1200.c (uses ide_wait_cmd). I do not know which one is correct, but I tend to trust ide-disk.c version a bit more, and used that.
Apply if it looks good to you,
Pavel
drivers/ide/ide-disk.c +37 -0
@@ -1536,6 +1536,39 @@#endif } +static int idedisk_suspend (struct device *dev,u32 state,u32 level) +{ +ide_drive_t *drive = dev->driver_data; + +printk ("Suspending device %p\n" , dev->driver_data); + +/* I hope that every freeze operation from the upper levels have +* already been done... +*/ + +if (level !=SUSPEND_SAVE_STATE ) +return 0 ; + +/* set the drive to standby */ +printk (KERN_INFO "suspending: %s " , drive->name); +do_idedisk_standby (drive); + drive->blocked =1 ; + +BUG_ON (HWGROUP (drive)->handler); +return 0 ; +} + +static int idedisk_resume (struct device *dev,u32 level) +{ +ide_drive_t *drive = dev->driver_data; + +if (level !=RESUME_RESTORE_STATE ) +return 0 ; +BUG_ON (!drive->blocked); + drive->blocked =0 ; +return 0 ; +} +static void idedisk_setup (ide_drive_t *drive) {struct hd_driveid *id = drive->id;
@@ -1682,6 +1715,10 @@ .proc = idedisk_proc, .attach = idedisk_attach, .drives = LIST_HEAD_INIT(idedisk_driver.drives), + .gen_driver = { + .suspend = idedisk_suspend, + .resume = idedisk_resume, + } };static int idedisk_open (struct inode *inode,struct file *filp)
drivers/ide/ide-probe.c +1 -0
@@ -1060,6 +1060,7 @@ "%s","IDE Drive"); drive->gendev.parent = &hwif->gendev; drive->gendev.bus = &ide_bus_type; + drive->gendev.driver_data = drive; sprintf (name, "host%d/bus%d/target%d/lun%d", (hwif->channel && hwif->mate) ? hwif->mate->index : hwif->index,
drivers/ide/pci/sc1200.c +3 -32
@@ -373,19 +373,6 @@ } } -static int sc1200_spindown_drive (ide_drive_t *drive) -{ -int rc; - -#if 0 -fsync_dev (MKDEV (HWIF (drive)->major,0 ));// what to do instead of this? nothing? -#endif -if ((rc =ide_wait_cmd (drive,WIN_STANDBYNOW1 ,0 ,0 ,0 ,NULL )) - && (rc =ide_wait_cmd (drive,WIN_STANDBYNOW2 ,0 ,0 ,0 ,NULL ))) -printk ("%s: spindown failed\n" , drive->name); -return rc; -} -static ide_hwif_t *lookup_pci_dev (ide_hwif_t *prev,struct pci_dev *dev) {int h;
@@ -446,25 +433,9 @@ {ide_hwif_t *hwif =NULL ; -printk ("SC1200: suspend(%u)\n" , state); -// -// loop over all interfaces that are part of this pci device: -// -while ((hwif =lookup_pci_dev (hwif, dev)) !=NULL ) { -unsigned int d; -printk ("%s: SC1200: suspend\n" , hwif->name); -// -// Spin down all drives on this interface -// -for (d =0 ; d <MAX_DRIVES ; ++d) { -ide_drive_t *drive = &(hwif->drives[d]); -if (drive->present && drive->media == ide_disk) { -if (sc1200_spindown_drive (drive)) { -return -EBUSY ;// failed to suspend - } - } - } - } +printk ("SC1200: suspend(%u)\n" , state); +/* You don't need to iterate over disks -- sysfs should have done that for you already */ +pci_disable_device (dev);pci_set_power_state (dev,state); dev->current_state = state;
Signature · 2 lines
Worst form of spam? Adding advertisment signatures ala sourceforge.net. What goes next? Inserting advertisment *into* email?
Quoted 4 lines
I had to select between standby written in
ide-disk.c(useside_raw_taskfile) and standby written insc1200.c(useside_wait_cmd). I do not know which one is correct, but I tend to trustide-disk.cversion a bit more, and used that.
They'll both ultimately do the same thing.
Quoted 1 line
Apply if it looks good to you,
Ok will do. My only gripe is about printk levels this time 8)
Hi!
Quoted 10 lines
Quoted 4 lines
I had to select between standby written in
ide-disk.c(useside_raw_taskfile) and standby written insc1200.c(useside_wait_cmd). I do not know which one is correct, but I tend to trustide-disk.cversion a bit more, and used that.They'll both ultimately do the same thing.
Quoted 1 line
Apply if it looks good to you,
Ok will do. My only gripe is about printk levels this time 8)
Well, feel free to kill printks altogether. They are only for me, anyway.
Pavel
Signature · 2 lines
Casualities in World Trade Center: ~3k dead inside the building, cryptography in U.S.A. and free speech in Czech Republic.