* sysfs support for ide disks
@ 2002-11-13 21:56 Pavel Machek
2002-11-13 22:01 ` Alan Cox
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2002-11-13 21:56 UTC (permalink / raw)
To: alan, kernel list
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
--- linux-ac.kill/drivers/ide/ide-disk.c 2002-11-13 22:00:22.000000000 +0100
+++ linux-ac/drivers/ide/ide-disk.c 2002-11-13 22:44:03.000000000 +0100
@@ -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)
--- linux-ac.kill/drivers/ide/ide-probe.c 2002-11-13 21:38:11.000000000 +0100
+++ linux-ac/drivers/ide/ide-probe.c 2002-11-13 22:22:36.000000000 +0100
@@ -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,
--- linux-ac.kill/drivers/ide/pci/sc1200.c 2002-11-13 21:38:11.000000000 +0100
+++ linux-ac/drivers/ide/pci/sc1200.c 2002-11-13 22:31:35.000000000 +0100
@@ -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;
--
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: sysfs support for ide disks
2002-11-13 21:56 sysfs support for ide disks Pavel Machek
@ 2002-11-13 22:01 ` Alan Cox
2002-11-13 22:03 ` Pavel Machek
0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2002-11-13 22:01 UTC (permalink / raw)
To: Pavel Machek; +Cc: alan, kernel list
> 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.
They'll both ultimately do the same thing.
> Apply if it looks good to you,
Ok will do. My only gripe is about printk levels this time 8)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: sysfs support for ide disks
2002-11-13 22:01 ` Alan Cox
@ 2002-11-13 22:03 ` Pavel Machek
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2002-11-13 22:03 UTC (permalink / raw)
To: Alan Cox; +Cc: kernel list
Hi!
> > 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.
>
> They'll both ultimately do the same thing.
>
> > 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
--
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-11-13 21:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-13 21:56 sysfs support for ide disks Pavel Machek
2002-11-13 22:01 ` Alan Cox
2002-11-13 22:03 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).