public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RE: swsusp: don't eat ide disks
@ 2002-11-07 18:26 Grover, Andrew
  2002-11-07 22:25 ` David Woodhouse
  0 siblings, 1 reply; 44+ messages in thread
From: Grover, Andrew @ 2002-11-07 18:26 UTC (permalink / raw)
  To: 'David Woodhouse', Pavel Machek
  Cc: Alan Cox, benh, Alan Cox, Linus Torvalds,
	Linux Kernel Mailing List

> From: David Woodhouse [mailto:dwmw2@infradead.org] 
> Why /proc/acpi/sleep ?
> 
> Other PM implementations gave us /proc/sys/pm/suspend -- why 
> doesn't ACPI 
> use that?
> 
> The stuff in /proc/acpi should be ACPI-specific. Anything 
> _generic_ like 
> battery info, sleep states, etc. should have a generic 
> interface which can 
> be used by any implementation. 

Yes, ACPI can and should use standard kernel interfaces when they are
available. The interfaces you're talking about don't exist yet, but could be
added.

An example of this is cpufreq. ACPI exposed its own proc interface before
cpufreq was integrated, but now it recently started working through cpufreq.
It should be relatively easy to establish generic interfaces for other areas
and hook ACPI into them.

Regards -- Andy

^ permalink raw reply	[flat|nested] 44+ messages in thread
* swsusp: don't eat ide disks
@ 2002-11-02 18:47 Pavel Machek
  2002-11-02 19:39 ` Linus Torvalds
  2002-11-02 20:06 ` Alan Cox
  0 siblings, 2 replies; 44+ messages in thread
From: Pavel Machek @ 2002-11-02 18:47 UTC (permalink / raw)
  To: torvalds, kernel list; +Cc: alan

Hi!

Here's patch to prevent random scribling over disks during
suspend... In the meantime alan killed (unreferenced at that time)
idedisk_suspend() and idedisk_release(), so I have to reintroduce
them.

Now... There is *another* do_idedisk_suspend / do_idedisk_resume
method in ide_disk.c. As far as I can see, it is not used anywhere,
and is certainly not enough to prevent corruption on swsusp. [Besides,
doing suspend/resume support generically using devicefs, not with ide
stuff seems more right.] Should I go ahead and kill do_idedisk_suspend
and related code?
								Pavel 

--- clean/drivers/ide/ide-disk.c	2002-11-01 00:37:14.000000000 +0100
+++ linux-swsusp/drivers/ide/ide-disk.c	2002-11-01 21:36:54.000000000 +0100
@@ -1561,6 +1561,56 @@
 #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;
+	BUG_ON(in_interrupt());
+
+	printk("Waiting for commands to finish\n");
+
+	/* wait until all commands are finished */
+	/* FIXME: waiting for spinlocks should be done instead. */
+	if (!(HWGROUP(drive)))
+		printk("No hwgroup?\n");
+	while (HWGROUP(drive)->handler)
+		yield();
+
+	/* set the drive to standby */
+	printk(KERN_INFO "suspending: %s ", drive->name);
+	if (drive->driver) {
+		if (drive->driver->standby)
+			drive->driver->standby(drive);
+	}
+	drive->blocked = 1;
+
+	while (HWGROUP(drive)->handler)
+		yield();
+
+	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;
+	if (!drive->blocked)
+		panic("ide: Resume but not suspended?\n");
+
+	drive->blocked = 0;
+	return 0;
+}
+
 static void idedisk_setup (ide_drive_t *drive)
 {
 	struct hd_driveid *id = drive->id;
@@ -1709,6 +1759,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)
@@ -1835,8 +1889,7 @@
 
 static int idedisk_init (void)
 {
-	ide_register_driver(&idedisk_driver);
-	return 0;
+	return ide_register_driver(&idedisk_driver);
 }
 
 module_init(idedisk_init);
--- clean/drivers/ide/ide-probe.c	2002-11-01 00:37:14.000000000 +0100
+++ linux-swsusp/drivers/ide/ide-probe.c	2002-11-01 01:26:37.000000000 +0100
@@ -1054,6 +1054,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,

-- 
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2002-11-12 17:34 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-07 18:26 swsusp: don't eat ide disks Grover, Andrew
2002-11-07 22:25 ` David Woodhouse
2002-11-08 11:09   ` Benjamin Herrenschmidt
2002-11-10 11:54   ` Pavel Machek
2002-11-11  6:38     ` David Woodhouse
2002-11-12 17:41       ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2002-11-02 18:47 Pavel Machek
2002-11-02 19:39 ` Linus Torvalds
2002-11-02 20:06 ` Alan Cox
2002-11-02 20:25   ` Pavel Machek
2002-11-02 22:04     ` Alan Cox
2002-11-03 20:11       ` Pavel Machek
2002-11-04  1:04         ` Rik van Riel
2002-11-06 12:34           ` Pavel Machek
2002-11-03 14:57   ` benh
2002-11-03 16:25     ` Alan Cox
2002-11-03 16:24       ` benh
2002-11-03 16:36         ` Alan Cox
2002-11-04  7:47           ` benh
2002-11-03 20:12       ` Pavel Machek
2002-11-03 21:33         ` Alan Cox
2002-11-03 22:09           ` Pavel Machek
2002-11-03 22:41             ` Alan Cox
2002-11-03 22:27               ` Pavel Machek
2002-11-03 23:56                 ` Alan Cox
2002-11-04  8:16                   ` benh
2002-11-04 13:33                     ` Alan Cox
2002-11-03 22:48             ` Linus Torvalds
2002-11-03 22:53               ` Linus Torvalds
2002-11-04  8:08                 ` benh
2002-11-04 14:59                   ` Linus Torvalds
2002-11-04 15:27                     ` Benjamin Herrenschmidt
2002-11-04  9:44                 ` Jens Axboe
2002-11-04 13:37                   ` Alan Cox
2002-11-03 22:56               ` Pavel Machek
2002-11-03 23:38                 ` Linus Torvalds
2002-11-06 13:57                   ` Pavel Machek
2002-11-04  7:57               ` benh
2002-11-04  9:39               ` Jens Axboe
2002-11-04  9:50                 ` Jens Axboe
2002-11-07 13:06       ` David Woodhouse
2002-11-07 16:15         ` Pavel Machek
2002-11-07 16:18           ` David Woodhouse
2002-11-07 20:52             ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox