Skip to contentSkip to conversation

software suspend in 2.5.70-mm3.

DISCUSSION hugang 6 participants 17 messages Jun 3, 2003 – Jun 8, 2003 Block layer

lore
Share & tools
lore

hugang

author
#0 lore raw

Hi Pavel Machek:

I try the 2.5.70-mm3 with software suspend function. When suspend it will oops at ide-disk.c 1526 line
BUG_ON (HWGROUP(drive)->handler);

I'm disable this check, The software suspend can work, and also can resumed. But this fix is not best way. I found in ide-io.c 1196
hwgroup->handler = NULL;
is the problem.

thanks.

Signature · 6 lines
Hu Gang / Steve
Email        : [email protected], [email protected]
GPG FinePrint: 4099 3F1D AE01 1817 68F7  D499 A6C2 C418 86C8 610E
http://soulinfo.com/~hugang/HuGang.asc
ICQ#         : 205800361
Registered Linux User : 204016
#1 lore raw
Quoted 8 lines · hugang

Hi Pavel Machek:

I try the 2.5.70-mm3 with software suspend function. When suspend it will oops at ide-disk.c 1526 line
BUG_ON (HWGROUP(drive)->handler);

I'm disable this check, The software suspend can work, and also can resumed. But this fix is not best way. I found in ide-io.c 1196
hwgroup->handler = NULL;
is the problem.

The only way to make the suspend work properly is to queue the suspend sequence wit the other requests. Ben was doing some playing with this but I'm not sure what happened to it.

author
#2 lore raw
Quoted 6 lines · On 03 Jun 2003 14:22:48 +0100 Alan Cox <[email protected]> wrote:
Quoted 5 lines · hugang

Hi Pavel Machek:

I try the 2.5.70-mm3 with software suspend function. When suspend it will oops at ide-disk.c 1526 line
BUG_ON (HWGROUP(drive)->handler);

Quoted 8 lines
Quoted 3 lines

I'm disable this check, The software suspend can work, and also can resumed. But this fix is not best way. I found in ide-io.c 1196
hwgroup->handler = NULL;
is the problem.

The only way to make the suspend work properly is to queue the suspend sequence wit the other requests. Ben was doing some playing with this but I'm not sure what happened to it.

Yes the above patch is not safe, When i'm run updatedb and suspsned, After resume will oops at kjournal.

Here is another test on it, it can works with updatedb.
-
I found a best way to fix it. here is it. With the patch, I'm run updatedb and suspend for 5 counts, every things is ok.

--- ide-disk.c.old Tue Jun 3 22:22:13 2003
+++ ide-disk.c Tue Jun 3 22:16:22 2003
@@ -1523,7 +1523,10 @@
do_idedisk_standby(drive);
drive->blocked = 1;

- BUG_ON (HWGROUP(drive)->handler);
+ /*BUG_ON (HWGROUP(drive)->handler);*/
+ while(HWGROUP(drive)->handler) {
+ schedule();
+ }
return 0;
}

Signature · 6 lines
Hu Gang / Steve
Email        : [email protected], [email protected]
GPG FinePrint: 4099 3F1D AE01 1817 68F7  D499 A6C2 C418 86C8 610E
http://soulinfo.com/~hugang/HuGang.asc
ICQ#         : 205800361
Registered Linux User : 204016
#3 lore raw
Quoted 7 lines · hugang
Quoted 4 lines

The only way to make the suspend work properly is to queue the suspend sequence wit the other requests. Ben was doing some playing with this but I'm not sure what happened to it.

Yes the above patch is not safe, When i'm run updatedb and suspsned, After resume will oops at kjournal.

Here is another test on it, it can works with updatedb.

Still races. Ben's stuff is needed

#4 lore raw
Quoted 10 lines · Alan Cox
Quoted 7 lines · hugang
Quoted 4 lines

The only way to make the suspend work properly is to queue the suspend sequence wit the other requests. Ben was doing some playing with this but I'm not sure what happened to it.

Yes the above patch is not safe, When i'm run updatedb and suspsned, After resume will oops at kjournal.

Here is another test on it, it can works with updatedb.

Still races. Ben's stuff is needed

I have it working with some fixes from what I sent earlier, I'll repost that tonight or tomorrow, I need to extract that from a half-broken tree ;)

Ben.

#13 lore raw
In reply to hugang

Hi!

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines

Hi Pavel Machek:

I try the 2.5.70-mm3 with software suspend function. When suspend it will oops at ide-disk.c 1526 line
BUG_ON (HWGROUP(drive)->handler);

Quoted 8 lines
Quoted 3 lines

I'm disable this check, The software suspend can work, and also can resumed. But this fix is not best way. I found in ide-io.c 1196
hwgroup->handler = NULL;
is the problem.

The only way to make the suspend work properly is to queue the suspend sequence wit the other requests. Ben was doing some playing with this but I'm not sure what happened to it.

Quoted 6 lines

Yes the above patch is not safe, When i'm run updatedb and suspsned, After resume will oops at kjournal.

Here is another test on it, it can works with updatedb.
-
I found a best way to fix it. here is it. With the patch, I'm run updatedb and suspend for 5 counts, every things is ok.

Locating Ben's patch and forward-porting
it would be way better...

Signature · 2 lines
				Pavel
Written on sharp zaurus, because my Velo1 broke. If you have Velo you don't need...
#5 lore raw

IDE Power Management (Was: software suspend in 2.5.70-mm3)

In reply to Benjamin Herrenschmidt
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 1 line · Alan Cox

Still races. Ben's stuff is needed

I have it working with some fixes from what I sent earlier, I'll repost that tonight or tomorrow, I need to extract that from a half-broken tree ;)

Ok, here is it. It still need a bit of cleanup (removal of magic number for "steps" -> enum, etc...) and we may want to do more things on wakeup especially for ide-cd, Also I don't deal with ide-tape or ide-floppy in there and haven't fully studied the impact with ide-scsi....

So it's not meant to be merged as-is, though I'd appreciate to know if it helps for you.

Bartolomiej: Any comments appreciated, I won't do the ide-tape/floppy part as I don't know/own these, I think i'll let you decide if anything more is needed on the wakeup path for ide-cd... Once I have enough feedback, I'll send you a cleanified version as candidate for upstream merge.

===== drivers/ide/ide-cd.c 1.49 vs edited =====

drivers/ide/ide-cd.c +46 -0
@@ -3253,6 +3253,46 @@
 
 static int ide_cdrom_attach (ide_drive_t *drive);
 
+static void ide_cdrom_complete_power_step (ide_drive_t *drive, ide_power_state_t *state, u8 stat, u8 error)
+{
+}
+
+/* Power Management state machine. 
+ *
+ * We don't do much for CDs right now
+ */
+static ide_startstop_t ide_cdrom_start_power_step (ide_drive_t *drive, ide_power_state_t *state)
+{
+	ide_task_t args;
+
+	memset(&args, 0, sizeof(ide_task_t));
+
+	if (state->step == 0) {
+		state->step = state->suspend ? 1 : 101;
+		return ide_stopped;
+	}
+	switch(state->step) {
+	case 1:
+		break;
+
+	case 101: /* Resume step 1 (restore DMA) */
+		/* Right now, all we do is call ide_dma_check for the HWIF,
+		 * we could be smarter and check for current xfer_speed
+		 * in struct drive etc...
+		 * Also, this step could be implemented as a generic helper
+		 * as most subdrivers will use it
+		 */
+		if (!drive->id || !(drive->id->capability & 1))
+			break;
+		if (HWIF(drive)->ide_dma_check == NULL)
+			break;
+		HWIF(drive)->ide_dma_check(drive);
+		break;
+	}
+	state->step = ide_power_state_completed;
+	return ide_stopped;
+}
+
 static ide_driver_t ide_cdrom_driver = {
 	.owner			= THIS_MODULE,
 	.name			= "ide-cdrom",
@@ -3269,6 +3309,12 @@
 	.capacity		= ide_cdrom_capacity,
 	.attach			= ide_cdrom_attach,
 	.drives			= LIST_HEAD_INIT(ide_cdrom_driver.drives),
+	.start_power_step	= ide_cdrom_start_power_step,
+	.complete_power_step	= ide_cdrom_complete_power_step,
+	.gen_driver		= {
+		.suspend	= generic_ide_suspend,
+		.resume		= generic_ide_resume,
+	}
 };
 
 static int idecd_open(struct inode * inode, struct file * file)

===== drivers/ide/ide-disk.c 1.45 vs edited =====

drivers/ide/ide-disk.c +59 -48

143 lines not on this page · raw message

===== drivers/ide/ide-io.c 1.11 vs edited =====

drivers/ide/ide-io.c +112 -5

175 lines not on this page · raw message

===== drivers/ide/ide-iops.c 1.17 vs edited =====

drivers/ide/ide-iops.c +27 -0
@@ -1318,5 +1318,32 @@
 	return do_reset1(drive, 0);
 }
 
+/*
+ * This function waits for the hwif to report a non-busy status
+ * see comments in probe_hwif()
+ */
+int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
+{
+	u8 stat = 0;
+	
+	while(timeout--) {
+		/* Turn this into a schedule() sleep once I'm sure
+		 * about locking issues (2.5 work ?)
+		 */
+		mdelay(1);
+		stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]);
+		if ((stat & BUSY_STAT) == 0)
+			break;
+		/* Assume a value of 0xff means nothing is connected to
+		 * the interface and it doesn't implement the pull-down
+		 * resistor on D7
+		 */
+		if (stat == 0xff)
+			break;
+	}
+	return ((stat & BUSY_STAT) == 0) ? 0 : -EBUSY;
+}
+
+
 EXPORT_SYMBOL(ide_do_reset);
 

===== drivers/ide/ide-probe.c 1.49 vs edited =====

drivers/ide/ide-probe.c +3 -33
@@ -723,35 +723,6 @@
 
 //EXPORT_SYMBOL(hwif_register);
 
-/* Enable code below on all archs later, for now, I want it on PPC
- */
-#ifdef CONFIG_PPC
-/*
- * This function waits for the hwif to report a non-busy status
- * see comments in probe_hwif()
- */
-static int wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
-{
-	u8 stat = 0;
-	
-	while(timeout--) {
-		/* Turn this into a schedule() sleep once I'm sure
-		 * about locking issues (2.5 work ?)
-		 */
-		mdelay(1);
-		stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]);
-		if ((stat & BUSY_STAT) == 0)
-			break;
-		/* Assume a value of 0xff means nothing is connected to
-		 * the interface and it doesn't implement the pull-down
-		 * resistor on D7
-		 */
-		if (stat == 0xff)
-			break;
-	}
-	return ((stat & BUSY_STAT) == 0) ? 0 : -EBUSY;
-}
-
 static int wait_hwif_ready(ide_hwif_t *hwif)
 {
 	int rc;
@@ -766,7 +737,7 @@
 	 * I know of at least one disk who takes 31 seconds, I use 35
 	 * here to be safe
 	 */
-	rc = wait_not_busy(hwif, 35000);
+	rc = ide_wait_not_busy(hwif, 35000);
 	if (rc)
 		return rc;
 
@@ -774,20 +745,19 @@
 	SELECT_DRIVE(&hwif->drives[0]);
 	hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]);
 	mdelay(2);
-	rc = wait_not_busy(hwif, 10000);
+	rc = ide_wait_not_busy(hwif, 10000);
 	if (rc)
 		return rc;
 	SELECT_DRIVE(&hwif->drives[1]);
 	hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]);
 	mdelay(2);
-	rc = wait_not_busy(hwif, 10000);
+	rc = ide_wait_not_busy(hwif, 10000);
 
 	/* Exit function with master reselected (let's be sane) */
 	SELECT_DRIVE(&hwif->drives[0]);
 	
 	return rc;
 }
-#endif /* CONFIG_PPC */
 
 /*
  * This routine only knows how to look for drive units 0 and 1

===== drivers/ide/ide.c 1.70 vs edited =====

drivers/ide/ide.c +46 -0

52 lines not on this page · raw message

===== include/linux/blkdev.h 1.106 vs edited =====

include/linux/blkdev.h +2 -0
@@ -130,6 +130,7 @@
 	__REQ_DRIVE_CMD,
 	__REQ_DRIVE_TASK,
 	__REQ_DRIVE_TASKFILE,
+	__REQ_POWER_MANAGEMENT,
 	__REQ_NR_BITS,	/* stops here */
 };
 
@@ -151,6 +152,7 @@
 #define REQ_DRIVE_CMD	(1 << __REQ_DRIVE_CMD)
 #define REQ_DRIVE_TASK	(1 << __REQ_DRIVE_TASK)
 #define REQ_DRIVE_TASKFILE	(1 << __REQ_DRIVE_TASKFILE)
+#define REQ_POWER_MANAGEMENT	(1 << __REQ_POWER_MANAGEMENT)
 
 #include <linux/elevator.h>
 

===== include/linux/ide.h 1.54 vs edited =====

include/linux/ide.h +41 -0

77 lines not on this page · raw message

#6 lore raw

Re: IDE Power Management (Was: software suspend in 2.5.70-mm3)

Patch 2.5.70-mm3 and compile with gcc295 OK

Bare multisuer with serial console,
no modules, network, usb, acpi .....

During suspend, after a while (some dots on the console) got the output below in an endless loop

Is there any debug or progress output in this version and how to use?

Regards
Michael

Call Trace:
 [<c011d958>] schedule+0x40/0x388
 [<c011eb02>] io_schedule+0xe/0x18
 [<c01384d5>] wait_on_page_bit_wq+0xc9/0xe4
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c01384fa>] wait_on_page_bit+0xa/0x10
 [<c014cc34>] rw_swap_page_sync+0x98/0xc6
 [<c0136afd>] write_suspend_image+0xf1/0x324
 [<c0246bdf>] device_resume+0x7f/0x88
 [<c01370e1>] drivers_unsuspend+0x11/0x18
 [<c013735e>] suspend_save_image+0x12/0x1c
 [<c013753f>] do_magic_suspend_2+0x17/0xa8
 [<c011ba9d>] do_magic+0x4d/0x130
 [<c013763b>] do_software_suspend+0x6b/0x90
 [<c0137695>] software_suspend+0x35/0x3c
 [<c012ba97>] sys_reboot+0x2df/0x36c
 [<c0143830>] unmap_page_range+0x38/0x5c
 [<c0143959>] unmap_vmas+0x105/0x208
 [<c01656e4>] dput+0x1c/0x204
 [<c01656e4>] dput+0x1c/0x204
 [<c015d367>] path_release+0xf/0x30
 [<c014fe69>] sys_chdir+0x5d/0x68
 [<c010af17>] syscall_call+0x7/0xb
Signature · 9 lines
Powered by linux-2.5.70-mm3
My current linux related activities in rough order of priority:
- Testing of 2.4/2.5 kernel interactivity
- Testing of Swsusp for 2.4
- Testing of Opera 7.11 emphasizing interactivity
- Research of NFS i/o errors during transfer 2.4>2.5
- Learning 2.5 series kernel debugging with kgdb
- Studying 2.5 series serial and ide drivers, ACPI, S3
* Input and feedback is always welcome *
#7 lore raw

Re: IDE Power Management (Was: software suspend in 2.5.70-mm3)

Quoted 10 lines · Michael Frank

Patch 2.5.70-mm3 and compile with gcc295 OK

Bare multisuer with serial console,
no modules, network, usb, acpi .....

During suspend, after a while (some dots on the console) got the output below in an endless loop

Is there any debug or progress output in this version and how to use?

I'm not sure how to interpret that call trace, was there any other message just before ? There is some debug output in the patch though it may have been lost at that point.

Ben.

Quoted 27 lines

Regards
Michael

Call Trace:
 [<c011d958>] schedule+0x40/0x388
 [<c011eb02>] io_schedule+0xe/0x18
 [<c01384d5>] wait_on_page_bit_wq+0xc9/0xe4
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c01384fa>] wait_on_page_bit+0xa/0x10
 [<c014cc34>] rw_swap_page_sync+0x98/0xc6
 [<c0136afd>] write_suspend_image+0xf1/0x324
 [<c0246bdf>] device_resume+0x7f/0x88
 [<c01370e1>] drivers_unsuspend+0x11/0x18
 [<c013735e>] suspend_save_image+0x12/0x1c
 [<c013753f>] do_magic_suspend_2+0x17/0xa8
 [<c011ba9d>] do_magic+0x4d/0x130
 [<c013763b>] do_software_suspend+0x6b/0x90
 [<c0137695>] software_suspend+0x35/0x3c
 [<c012ba97>] sys_reboot+0x2df/0x36c
 [<c0143830>] unmap_page_range+0x38/0x5c
 [<c0143959>] unmap_vmas+0x105/0x208
 [<c01656e4>] dput+0x1c/0x204
 [<c01656e4>] dput+0x1c/0x204
 [<c015d367>] path_release+0xf/0x30
 [<c014fe69>] sys_chdir+0x5d/0x68
 [<c010af17>] syscall_call+0x7/0xb
Signature · 1 line
Benjamin Herrenschmidt <[email protected]>
#8 lore raw

Re: IDE Power Management (Was: software suspend in 2.5.70-mm3)

In reply to Michael Frank

On Wednesday 04 June 2003 21:51, Michael Frank wrote:

Patch 2.5.70-mm3 and compile with gcc295 OK

Bare multisuer with serial console,
no modules, network, usb, acpi .....

Is there any debug or progress output in this version and how to use?

Regards
Michael

OK, made the history longer

Last login: Wed Jun 4 21:59:38 on tty2
[mhf@mhfl1 22:05:24 mhf]$ Stopping tasks: klogd entered refrigerator
=init entered refrigerator
=pdflush entered refrigerator
=pdflush entered refrigerator
=kswapd0 entered refrigerator
=kseriod entered refrigerator
=kjournald entered refrigerator
=syslogd entered refrigerator
=open entered refrigerator
=open entered refrigerator
=open entered refrigerator
=open entered refrigerator
=open entered refrigerator
=login entered refrigerator
=login entered refrigerator
=login entered refrigerator
=login entered refrigerator
=login entered refrigerator
=login entered refrigerator
=bash entered refrigerator
=bash entered refrigerator
=bash entered refrigerator
=bash entered refrigerator
=bash entered refrigerator
=bash entered refrigerator
=open entered refrigerator
=comr entered refrigerator
=sleep entered refrigerator
=tst entered refrigerator
=tstr entered refrigerator
=|
Freeing memory: ..................|
Syncing disks before copy
Suspending devices
Suspending devices
hda: start_power_step(susp: 1, step: 0)
hda: start_power_step(susp: 1, step: 1)
hda: start_power_step(susp: 1, step: 2)
hda: complete_power_step(susp: 1, step: 2, stat: 50, err: 0)
hda: completing PM request, suspend: 1
Suspending devices
/critical section: Counting pages to copy[nosave c03f7000] (pages needed: 2273+512=2785 free: 14110) Alloc pagedir
............
[nosave c03f7000]critical section/: done (2273 pages copied)
hda: Wakeup request inited, waiting for !BSY...
hda: start_power_step(susp: 0, step: 0)
hda: start_power_step(susp: 0, step: 101)
hda: completing PM request, suspend: 0
Devices Resumed
Devices Resumed
Writing data to swap (2273 pages): .<3>bad: scheduling while atomic!

Call Trace:
 [<c011d958>] schedule+0x40/0x388
 [<c011eb02>] io_schedule+0xe/0x18
 [<c01384d5>] wait_on_page_bit_wq+0xc9/0xe4
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c01384fa>] wait_on_page_bit+0xa/0x10
 [<c014cc34>] rw_swap_page_sync+0x98/0xc6
 [<c0136afd>] write_suspend_image+0xf1/0x324
 [<c0246bdf>] device_resume+0x7f/0x88
 [<c01370e1>] drivers_unsuspend+0x11/0x18
 [<c013735e>] suspend_save_image+0x12/0x1c
 [<c013753f>] do_magic_suspend_2+0x17/0xa8
 [<c011ba9d>] do_magic+0x4d/0x130
 [<c013763b>] do_software_suspend+0x6b/0x90
 [<c0137695>] software_suspend+0x35/0x3c
 [<c012ba97>] sys_reboot+0x2df/0x36c
 [<c0143830>] unmap_page_range+0x38/0x5c
 [<c0143959>] unmap_vmas+0x105/0x208
 [<c01656e4>] dput+0x1c/0x204
 [<c01656e4>] dput+0x1c/0x204
 [<c015d367>] path_release+0xf/0x30
 [<c014fe69>] sys_chdir+0x5d/0x68
 [<c010af17>] syscall_call+0x7/0xb

bad: scheduling while atomic!

Call Trace:
 [<c011d958>] schedule+0x40/0x388
 [<c011eb02>] io_schedule+0xe/0x18
 [<c01384d5>] wait_on_page_bit_wq+0xc9/0xe4
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c01384fa>] wait_on_page_bit+0xa/0x10
 [<c014cc34>] rw_swap_page_sync+0x98/0xc6
 [<c0136afd>] write_suspend_image+0xf1/0x324
 [<c0246bdf>] device_resume+0x7f/0x88
 [<c01370e1>] drivers_unsuspend+0x11/0x18
 [<c013735e>] suspend_save_image+0x12/0x1c
 [<c013753f>] do_magic_suspend_2+0x17/0xa8
 [<c011ba9d>] do_magic+0x4d/0x130
 [<c013763b>] do_software_suspend+0x6b/0x90
 [<c0137695>] software_suspend+0x35/0x3c
 [<c012ba97>] sys_reboot+0x2df/0x36c
 [<c0143830>] unmap_page_range+0x38/0x5c
 [<c0143959>] unmap_vmas+0x105/0x208
 [<c01656e4>] dput+0x1c/0x204
 [<c01656e4>] dput+0x1c/0x204
 [<c015d367>] path_release+0xf/0x30
 [<c014fe69>] sys_chdir+0x5d/0x68
 [<c010af17>] syscall_call+0x7/0xb
Signature · 9 lines
Powered by linux-2.5.70-mm3
My current linux related activities in rough order of priority:
- Testing of 2.4/2.5 kernel interactivity
- Testing of Swsusp for 2.4
- Testing of Opera 7.11 emphasizing interactivity
- Research of NFS i/o errors during transfer 2.4>2.5
- Learning 2.5 series kernel debugging with kgdb
- Studying 2.5 series serial and ide drivers, ACPI, S3
* Input and feedback is always welcome *
#9 lore raw

Re: IDE Power Management (Was: software suspend in 2.5.70-mm3)

Quoted 17 lines

hda: start_power_step(susp: 1, step: 0)
hda: start_power_step(susp: 1, step: 1)
hda: start_power_step(susp: 1, step: 2)
hda: complete_power_step(susp: 1, step: 2, stat: 50, err: 0)
hda: completing PM request, suspend: 1
Suspending devices
/critical section: Counting pages to copy[nosave c03f7000] (pages needed: 2273+512=2785 free: 14110) Alloc pagedir
............
[nosave c03f7000]critical section/: done (2273 pages copied)
hda: Wakeup request inited, waiting for !BSY...
hda: start_power_step(susp: 0, step: 0)
hda: start_power_step(susp: 0, step: 101)
hda: completing PM request, suspend: 0
Devices Resumed
Devices Resumed

Hrm... the joy if swsusp putting your disk to sleep just to wake it up right away... I need to check if I can differenciate suspend-to-disk from suspend-to-ram here to just not put the drive in STANDBY mode on suspend-to-disk (just freeze the queues)

Quoted 1 line

Writing data to swap (2273 pages): .<3>bad: scheduling while atomic!

Here's the real one. However, it doesn't look related to my sleep code, though I cannot guarantee this for sure right now, it _seems_ it's a swsusp bug you are hitting.

Quoted 24 lines
Call Trace:
 [<c011d958>] schedule+0x40/0x388
 [<c011eb02>] io_schedule+0xe/0x18
 [<c01384d5>] wait_on_page_bit_wq+0xc9/0xe4
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c011f320>] autoremove_wake_function+0x0/0x3c
 [<c01384fa>] wait_on_page_bit+0xa/0x10
 [<c014cc34>] rw_swap_page_sync+0x98/0xc6
 [<c0136afd>] write_suspend_image+0xf1/0x324
 [<c0246bdf>] device_resume+0x7f/0x88
 [<c01370e1>] drivers_unsuspend+0x11/0x18
 [<c013735e>] suspend_save_image+0x12/0x1c
 [<c013753f>] do_magic_suspend_2+0x17/0xa8
 [<c011ba9d>] do_magic+0x4d/0x130
 [<c013763b>] do_software_suspend+0x6b/0x90
 [<c0137695>] software_suspend+0x35/0x3c
 [<c012ba97>] sys_reboot+0x2df/0x36c
 [<c0143830>] unmap_page_range+0x38/0x5c
 [<c0143959>] unmap_vmas+0x105/0x208
 [<c01656e4>] dput+0x1c/0x204
 [<c01656e4>] dput+0x1c/0x204
 [<c015d367>] path_release+0xf/0x30
 [<c014fe69>] sys_chdir+0x5d/0x68
 [<c010af17>] syscall_call+0x7/0xb
#10 lore raw

Re: IDE Power Management (Was: software suspend in 2.5.70-mm3)

Quoted 17 lines · Benjamin Herrenschmidt
Quoted 8 lines

hda: start_power_step(susp: 1, step: 0)
hda: start_power_step(susp: 1, step: 1)
hda: start_power_step(susp: 1, step: 2)
hda: complete_power_step(susp: 1, step: 2, stat: 50, err: 0)
hda: completing PM request, suspend: 1
Suspending devices
/critical section: Counting pages to copy[nosave c03f7000] (pages needed:
2273+512=2785 free: 14110) Alloc pagedir

Quoted 8 lines

............
[nosave c03f7000]critical section/: done (2273 pages copied)
hda: Wakeup request inited, waiting for !BSY...
hda: start_power_step(susp: 0, step: 0)
hda: start_power_step(susp: 0, step: 101)
hda: completing PM request, suspend: 0
Devices Resumed
Devices Resumed

Quoted 4 lines

Hrm... the joy if swsusp putting your disk to sleep just to wake it up right away... I need to check if I can differenciate suspend-to-disk from suspend-to-ram here to just not put the drive in STANDBY mode on suspend-to-disk (just freeze the queues)

It did this also in 2.4 until Nigel Cunningham fixed it.

Quoted 6 lines
Quoted 2 lines

Writing data to swap (2273 pages): .<3>bad: scheduling while atomic!

Here's the real one. However, it doesn't look related to my sleep code, though I cannot guarantee this for sure right now, it _seems_ it's a swsusp bug you are hitting.

Well, awaiting the next patch...

Regards
Michael

Signature · 10 lines
Powered by linux-2.5.70-mm3
My current linux related activities in rough order of priority:
- Testing of 2.4/2.5 kernel interactivity
- Testing of Swsusp for 2.4
- Testing of Opera 7.11 emphasizing interactivity
- Research of NFS i/o errors during transfer 2.4>2.5
- Learning 2.5 series kernel debugging with kgdb - it's in the -mm tree
- Studying 2.5 series serial and ide drivers, ACPI, S3
* Input and feedback is always welcome *
Joke of the day: http://lwn.net/Articles/34848/
#11 lore raw

Re: IDE Power Management (Was: software suspend in 2.5.70-mm3)

In reply to Benjamin Herrenschmidt

Hi!

Quoted 9 lines
Quoted 8 lines

............
[nosave c03f7000]critical section/: done (2273 pages copied)
hda: Wakeup request inited, waiting for !BSY...
hda: start_power_step(susp: 0, step: 0)
hda: start_power_step(susp: 0, step: 101)
hda: completing PM request, suspend: 0
Devices Resumed
Devices Resumed

Quoted 4 lines

Hrm... the joy if swsusp putting your disk to sleep just to wake it up right away... I need to check if I can differenciate suspend-to-disk from suspend-to-ram here to just not put the drive in STANDBY mode on suspend-to-disk (just freeze the queues)

Why? Suspending then resuming it may take long but seems correct to me.

Quoted 5 lines
Quoted 1 line

Writing data to swap (2273 pages): .<3>bad: scheduling while atomic!

Here's the real one. However, it doesn't look related to my sleep code, though I cannot guarantee this for sure right now, it _seems_ it's a swsusp bug you are hitting.

Yes, it looks so.
Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#12 lore raw

Re: IDE Power Management (Was: software suspend in 2.5.70-mm3)

In reply to Benjamin Herrenschmidt

Hi!

Quoted 12 lines
Quoted 5 lines
Quoted 1 line

Still races. Ben's stuff is needed

I have it working with some fixes from what I sent earlier, I'll repost that tonight or tomorrow, I need to extract that from a half-broken tree ;)

Ok, here is it. It still need a bit of cleanup (removal of magic number for "steps" -> enum, etc...) and we may want to do more things on wakeup especially for ide-cd, Also I don't deal with ide-tape or ide-floppy in there and haven't fully studied the impact with ide-scsi....

Quoted 8 lines

So it's not meant to be merged as-is, though I'd appreciate to know if it helps for you.

Bartolomiej: Any comments appreciated, I won't do the ide-tape/floppy part as I don't know/own these, I think i'll let you decide if anything more is needed on the wakeup path for ide-cd... Once I have enough feedback, I'll send you a cleanified version as candidate for upstream merge.

Please send cleaned up version ASAP... Waiting will do no good. If it handles only ide-disks, that's okay, its still way better than whats in the tree.

Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
author
#14 lore raw
In reply to Pavel Machek
Quoted 2 lines · On Tue, 3 Jun 2003 20:55:51 +0200 Pavel Machek <[email protected]> wrote:

Locating Ben's patch and forward-porting
it would be way better...

I was tried Ben's patch, It's cool, Very stable in my laptop.

Here is two patch.
* suspend.c can swap more pages into swap space.
* vmscan.c can make swap faster.

kernel/suspend.c renamed from kernel/suspend.c.old +15 -6
@@ -621,9 +621,17 @@
  */
 static void free_some_memory(void)
 {
+	unsigned int count = 10;
+
 	printk("Freeing memory: ");
-	while (shrink_all_memory(10000))
+	while (count) {
+		unsigned int ret = shrink_all_memory(4 * 1024 * 1024 / PAGE_SIZE);
+		if (ret == 0) {
+			count--;
+			continue;
+		}
 		printk(".");
+	}
 	printk("|\n");
 }
--- linux-2.5.70/mm/vmscan.c.old	Sun Jun  8 11:08:27 2003
+++ linux-2.5.70/mm/vmscan.c	Sun Jun  8 11:02:27 2003
@@ -882,7 +882,8 @@
  * dead and from now on, only perform a short scan.  Basically we're polling
  * the zone for when the problem goes away.
  */
-static int balance_pgdat(pg_data_t *pgdat, int nr_pages, struct page_state *ps)
+static int balance_pgdat(pg_data_t *pgdat, int nr_pages,
+		struct page_state *ps, unsigned int time)
 {
 	int to_free = nr_pages;
 	int priority;
@@ -930,7 +931,7 @@
 		}
 		if (all_zones_ok)
 			break;
-		blk_congestion_wait(WRITE, HZ/10);
+		blk_congestion_wait(WRITE, HZ/time);
 	}
 	return nr_pages - to_free;
 }
@@ -984,7 +985,7 @@
 		schedule();
 		finish_wait(&pgdat->kswapd_wait, &wait);
 		get_page_state(&ps);
-		balance_pgdat(pgdat, 0, &ps);
+		balance_pgdat(pgdat, 0, &ps, 10);
 	}
 }
 
@@ -1020,7 +1021,7 @@
 		struct page_state ps;
 
 		get_page_state(&ps);
-		freed = balance_pgdat(pgdat, nr_to_free, &ps);
+		freed = balance_pgdat(pgdat, nr_to_free, &ps, 200);
 		ret += freed;
 		nr_to_free -= freed;
 		if (nr_to_free <= 0)
Signature · 6 lines
Hu Gang / Steve
Email        : [email protected], [email protected]
GPG FinePrint: 4099 3F1D AE01 1817 68F7  D499 A6C2 C418 86C8 610E
http://soulinfo.com/~hugang/HuGang.asc
ICQ#         : 205800361
Registered Linux User : 204016
author
#16 lore raw
In reply to Pavel Machek
Quoted 2 lines · On Tue, 3 Jun 2003 20:55:51 +0200 Pavel Machek <[email protected]> wrote:

Locating Ben's patch and forward-porting
it would be way better...

I was tried Ben's patch, It's cool, Very stable in my laptop.

Here is two patch.
* suspend.c can swap more pages into swap space.
* vmscan.c can make swap out faster.

kernel/suspend.c renamed from kernel/suspend.c.old +15 -6
@@ -621,9 +621,17 @@
  */
 static void free_some_memory(void)
 {
+	unsigned int count = 10;
+
 	printk("Freeing memory: ");
-	while (shrink_all_memory(10000))
+	while (count) {
+		unsigned int ret = shrink_all_memory(4 * 1024 * 1024 / PAGE_SIZE);
+		if (ret == 0) {
+			count--;
+			continue;
+		}
 		printk(".");
+	}
 	printk("|\n");
 }
--- linux-2.5.70/mm/vmscan.c.old	Sun Jun  8 11:08:27 2003
+++ linux-2.5.70/mm/vmscan.c	Sun Jun  8 11:02:27 2003
@@ -882,7 +882,8 @@
  * dead and from now on, only perform a short scan.  Basically we're polling
  * the zone for when the problem goes away.
  */
-static int balance_pgdat(pg_data_t *pgdat, int nr_pages, struct page_state *ps)
+static int balance_pgdat(pg_data_t *pgdat, int nr_pages,
+		struct page_state *ps, unsigned int time)
 {
 	int to_free = nr_pages;
 	int priority;
@@ -930,7 +931,7 @@
 		}
 		if (all_zones_ok)
 			break;
-		blk_congestion_wait(WRITE, HZ/10);
+		blk_congestion_wait(WRITE, HZ/time);
 	}
 	return nr_pages - to_free;
 }
@@ -984,7 +985,7 @@
 		schedule();
 		finish_wait(&pgdat->kswapd_wait, &wait);
 		get_page_state(&ps);
-		balance_pgdat(pgdat, 0, &ps);
+		balance_pgdat(pgdat, 0, &ps, 10);
 	}
 }
 
@@ -1020,7 +1021,7 @@
 		struct page_state ps;
 
 		get_page_state(&ps);
-		freed = balance_pgdat(pgdat, nr_to_free, &ps);
+		freed = balance_pgdat(pgdat, nr_to_free, &ps, 200);
 		ret += freed;
 		nr_to_free -= freed;
 		if (nr_to_free <= 0)
Signature · 6 lines
Hu Gang / Steve
Email        : [email protected], [email protected]
GPG FinePrint: 4099 3F1D AE01 1817 68F7  D499 A6C2 C418 86C8 610E
http://soulinfo.com/~hugang/HuGang.asc
ICQ#         : 205800361
Registered Linux User : 204016
#15 lore raw
In reply to hugang

Hi!

Quoted 19 lines
Quoted 2 lines

Locating Ben's patch and forward-porting
it would be way better...

I was tried Ben's patch, It's cool, Very stable in my laptop.

Here is two patch.
* suspend.c can swap more pages into swap space.
* vmscan.c can make swap faster.

kernel/suspend.c renamed from kernel/suspend.c.old +2 -1
@@ -621,9 +621,17 @@
  */
 static void free_some_memory(void)
 {
+	unsigned int count = 10;
+
 	printk("Freeing memory: ");
-	while (shrink_all_memory(10000))

kernel/suspend.c line 636

Quoted 10 lines
kernel/suspend.c renamed from kernel/suspend.c.old +7 -0
+	while (count) {
+		unsigned int ret = shrink_all_memory(4 * 1024 * 1024 / PAGE_SIZE);
+		if (ret == 0) {
+			count--;
+			continue;
+		}
 		printk(".");
+	}
 	printk("|\n");
 }

If this does something then... well... shrink_all_memory needs to be fixed.

Quoted 31 lines
mm/vmscan.c renamed from mm/vmscan.c.old +4 -3
@@ -882,7 +882,8 @@
  * dead and from now on, only perform a short scan.  Basically we're polling
  * the zone for when the problem goes away.
  */
-static int balance_pgdat(pg_data_t *pgdat, int nr_pages, struct page_state *ps)
+static int balance_pgdat(pg_data_t *pgdat, int nr_pages,
+		struct page_state *ps, unsigned int time)
 {
 	int to_free = nr_pages;
 	int priority;
@@ -930,7 +931,7 @@
 		}
 		if (all_zones_ok)
 			break;
-		blk_congestion_wait(WRITE, HZ/10);
+		blk_congestion_wait(WRITE, HZ/time);
 	}
 	return nr_pages - to_free;
 }
@@ -984,7 +985,7 @@
 		schedule();
 		finish_wait(&pgdat->kswapd_wait, &wait);
 		get_page_state(&ps);
-		balance_pgdat(pgdat, 0, &ps);
+		balance_pgdat(pgdat, 0, &ps, 10);
 	}
 }
 

mm/vmscan.c line 1027

Quoted 8 lines
mm/vmscan.c renamed from mm/vmscan.c.old +1 -1
@@ -1020,7 +1021,7 @@
 		struct page_state ps;
 
 		get_page_state(&ps);
-		freed = balance_pgdat(pgdat, nr_to_free, &ps);
+		freed = balance_pgdat(pgdat, nr_to_free, &ps, 200);
 		ret += freed;
 		nr_to_free -= freed;
 		if (nr_to_free <= 0)

Comment in balance_pgdat saying what the time means would be nice... And calling it time is pretty misleading: its frequency.

Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]