Skip to contentSkip to conversation

More updates for 2.6.25

PATCH In review Rafael J. Wysocki 3 participants 19 messages Jan 11, 2008 – Jan 23, 2008

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH 1/3 Suspend: Invoke suspend notifications after console switch

In reply to Rafael J. Wysocki

From: Johannes Berg <[email protected]>

In order to fix APM emulation it is necessary to enable apm-emulation notifications for suspends triggered in various ways via the suspend notifiers. However, this will cause the systems using APM emulation to lock up between X being needed to switch away from the VT and X already waiting for resume in the APM ioctl.

This patch moves the console switch (if enabled) before the suspend notification (and after the resume notification) to avoid this issue.

---
 kernel/power/main.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/power/main.c +4 -4
Index: linux-2.6/kernel/power/main.c
===================================================================
@@ -173,12 +173,12 @@ static int suspend_prepare(void)
 	if (!suspend_ops || !suspend_ops->enter)
 		return -EPERM;
 
+	pm_prepare_console();
+
 	error = pm_notifier_call_chain(PM_SUSPEND_PREPARE);
 	if (error)
 		goto Finish;
 
-	pm_prepare_console();
-
 	if (suspend_freeze_processes()) {
 		error = -EAGAIN;
 		goto Thaw;
@@ -198,9 +198,9 @@ static int suspend_prepare(void)
 
  Thaw:
 	suspend_thaw_processes();
-	pm_restore_console();
  Finish:
 	pm_notifier_call_chain(PM_POST_SUSPEND);
+	pm_restore_console();
 	return error;
 }
 
@@ -307,8 +307,8 @@ int suspend_devices_and_enter(suspend_st
 static void suspend_finish(void)
 {
 	suspend_thaw_processes();
-	pm_restore_console();
 	pm_notifier_call_chain(PM_POST_SUSPEND);
+	pm_restore_console();
 }
 
 
#3 lore raw

PATCH 2/3 Hibernation: Invoke suspend notifications after console switch

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Following the recent change in the suspend code path, switch consoles before calling PM notifiers during hibernation.

---
 kernel/power/disk.c |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
kernel/power/disk.c +7 -10
Index: linux-2.6/kernel/power/disk.c
===================================================================
@@ -458,20 +458,13 @@ static void power_down(void)
 	while(1);
 }
 
-static void unprepare_processes(void)
-{
-	thaw_processes();
-	pm_restore_console();
-}
-
 static int prepare_processes(void)
 {
 	int error = 0;
 
-	pm_prepare_console();
 	if (freeze_processes()) {
 		error = -EBUSY;
-		unprepare_processes();
+		thaw_processes();
 	}
 	return error;
 }
@@ -491,6 +484,7 @@ int hibernate(void)
 		goto Unlock;
 	}
 
+	pm_prepare_console();
 	error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
 	if (error)
 		goto Exit;
@@ -530,11 +524,12 @@ int hibernate(void)
 		swsusp_free();
 	}
  Thaw:
-	unprepare_processes();
+	thaw_processes();
  Finish:
 	free_basic_memory_bitmaps();
  Exit:
 	pm_notifier_call_chain(PM_POST_HIBERNATION);
+	pm_restore_console();
 	atomic_inc(&snapshot_device_available);
  Unlock:
 	mutex_unlock(&pm_mutex);
@@ -603,6 +598,7 @@ static int software_resume(void)
 		goto Unlock;
 	}
 
+	pm_prepare_console();
 	error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
 	if (error)
 		goto Finish;
@@ -626,11 +622,12 @@ static int software_resume(void)
 
 	printk(KERN_ERR "PM: Restore failed, recovering.\n");
 	swsusp_free();
-	unprepare_processes();
+	thaw_processes();
  Done:
 	free_basic_memory_bitmaps();
  Finish:
 	pm_notifier_call_chain(PM_POST_RESTORE);
+	pm_restore_console();
 	atomic_inc(&snapshot_device_available);
 	/* For success case, the suspend path will release the lock */
  Unlock:
#0 lore raw

cover More updates for 2.6.25

Len,

Please add the following three patches to the suspend branch.

Thanks,
Rafael

#4 lore raw

PATCH 2/3 Hibernation: Invoke suspend notifications after console switch

From: Rafael J. Wysocki <[email protected]>

Following the recent change in the suspend code path, switch consoles before calling PM notifiers during hibernation.

---
 kernel/power/disk.c |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
kernel/power/disk.c +7 -10
Index: linux-2.6/kernel/power/disk.c
===================================================================
@@ -458,20 +458,13 @@ static void power_down(void)
 	while(1);
 }
 
-static void unprepare_processes(void)
-{
-	thaw_processes();
-	pm_restore_console();
-}
-
 static int prepare_processes(void)
 {
 	int error = 0;
 
-	pm_prepare_console();
 	if (freeze_processes()) {
 		error = -EBUSY;
-		unprepare_processes();
+		thaw_processes();
 	}
 	return error;
 }
@@ -491,6 +484,7 @@ int hibernate(void)
 		goto Unlock;
 	}
 
+	pm_prepare_console();
 	error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
 	if (error)
 		goto Exit;
@@ -530,11 +524,12 @@ int hibernate(void)
 		swsusp_free();
 	}
  Thaw:
-	unprepare_processes();
+	thaw_processes();
  Finish:
 	free_basic_memory_bitmaps();
  Exit:
 	pm_notifier_call_chain(PM_POST_HIBERNATION);
+	pm_restore_console();
 	atomic_inc(&snapshot_device_available);
  Unlock:
 	mutex_unlock(&pm_mutex);
@@ -603,6 +598,7 @@ static int software_resume(void)
 		goto Unlock;
 	}
 
+	pm_prepare_console();
 	error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
 	if (error)
 		goto Finish;
@@ -626,11 +622,12 @@ static int software_resume(void)
 
 	printk(KERN_ERR "PM: Restore failed, recovering.\n");
 	swsusp_free();
-	unprepare_processes();
+	thaw_processes();
  Done:
 	free_basic_memory_bitmaps();
  Finish:
 	pm_notifier_call_chain(PM_POST_RESTORE);
+	pm_restore_console();
 	atomic_inc(&snapshot_device_available);
 	/* For success case, the suspend path will release the lock */
  Unlock:
#5 lore raw

PATCH 3/3 PM: Remove obsolete /sys/devices/.../power/state docs

In reply to Rafael J. Wysocki

From: David Brownell <[email protected]>

The /sys/devices/.../power/state files have been gone for a while now, but I just noticed some documentation that still refers to them. (Fortunately described as DEPRECATED and WILL REMOVE).

Time to remove that obsolete documentation too ...

---

 Documentation/power/devices.txt |   49 ----------------------------------------
 1 file changed, 49 deletions(-)
Documentation/power/devices.txt +0 -49
Index: linux-2.6/Documentation/power/devices.txt
===================================================================
@@ -502,52 +502,3 @@ If the CPU can have a "cpufreq" driver, 
 to shift to lower voltage settings and reduce the power cost of executing
 a given number of instructions.  (Without voltage adjustment, it's rare
 for cpufreq to save much power; the cost-per-instruction must go down.)
-
-
-/sys/devices/.../power/state files
-==================================
-For now you can also test some of this functionality using sysfs.
-
-	DEPRECATED:  USE "power/state" ONLY FOR DRIVER TESTING, AND
-	AVOID USING dev->power.power_state IN DRIVERS.
-
-	THESE WILL BE REMOVED.  IF THE "power/state" FILE GETS REPLACED,
-	IT WILL BECOME SOMETHING COUPLED TO THE BUS OR DRIVER.
-
-In each device's directory, there is a 'power' directory, which contains
-at least a 'state' file.  The value of this field is effectively boolean,
-PM_EVENT_ON or PM_EVENT_SUSPEND.
-
-   *	Reading from this file displays a value corresponding to
-	the power.power_state.event field.  All nonzero values are
-	displayed as "2", corresponding to a low power state; zero
-	is displayed as "0", corresponding to normal operation.
-
-   *	Writing to this file initiates a transition using the
-   	specified event code number; only '0', '2', and '3' are
-	accepted (without a newline); '2' and '3' are both
-	mapped to PM_EVENT_SUSPEND.
-
-On writes, the PM core relies on that recorded event code and the device/bus
-capabilities to determine whether it uses a partial suspend() or resume()
-sequence to change things so that the recorded event corresponds to the
-numeric parameter.
-
-   -	If the bus requires the irqs-disabled suspend_late()/resume_early()
-	phases, writes fail because those operations are not supported here.
-
-   -	If the recorded value is the expected value, nothing is done.
-
-   -	If the recorded value is nonzero, the device is partially resumed,
-	using the bus.resume() and/or class.resume() methods.
-
-   -	If the target value is nonzero, the device is partially suspended,
-	using the class.suspend() and/or bus.suspend() methods and the
-	PM_EVENT_SUSPEND message.
-
-Drivers have no way to tell whether their suspend() and resume() calls
-have come through the sysfs power/state file or as part of entering a
-system sleep state, except that when accessed through sysfs the normal
-parent/child sequencing rules are ignored.  Drivers (such as bus, bridge,
-or hub drivers) which expose child devices may need to enforce those rules
-on their own.
#2 lore raw

PATCH 1/3 Suspend: Invoke suspend notifications after console switch

In reply to Rafael J. Wysocki

From: Johannes Berg <[email protected]>

In order to fix APM emulation it is necessary to enable apm-emulation notifications for suspends triggered in various ways via the suspend notifiers. However, this will cause the systems using APM emulation to lock up between X being needed to switch away from the VT and X already waiting for resume in the APM ioctl.

This patch moves the console switch (if enabled) before the suspend notification (and after the resume notification) to avoid this issue.

---
 kernel/power/main.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/power/main.c +4 -4
Index: linux-2.6/kernel/power/main.c
===================================================================
@@ -173,12 +173,12 @@ static int suspend_prepare(void)
 	if (!suspend_ops || !suspend_ops->enter)
 		return -EPERM;
 
+	pm_prepare_console();
+
 	error = pm_notifier_call_chain(PM_SUSPEND_PREPARE);
 	if (error)
 		goto Finish;
 
-	pm_prepare_console();
-
 	if (suspend_freeze_processes()) {
 		error = -EAGAIN;
 		goto Thaw;
@@ -198,9 +198,9 @@ static int suspend_prepare(void)
 
  Thaw:
 	suspend_thaw_processes();
-	pm_restore_console();
  Finish:
 	pm_notifier_call_chain(PM_POST_SUSPEND);
+	pm_restore_console();
 	return error;
 }
 
@@ -307,8 +307,8 @@ int suspend_devices_and_enter(suspend_st
 static void suspend_finish(void)
 {
 	suspend_thaw_processes();
-	pm_restore_console();
 	pm_notifier_call_chain(PM_POST_SUSPEND);
+	pm_restore_console();
 }
 
 
#6 lore raw

PATCH 3/3 PM: Remove obsolete /sys/devices/.../power/state docs

In reply to Rafael J. Wysocki

From: David Brownell <[email protected]>

The /sys/devices/.../power/state files have been gone for a while now, but I just noticed some documentation that still refers to them. (Fortunately described as DEPRECATED and WILL REMOVE).

Time to remove that obsolete documentation too ...

---

 Documentation/power/devices.txt |   49 ----------------------------------------
 1 file changed, 49 deletions(-)
Documentation/power/devices.txt +0 -49
Index: linux-2.6/Documentation/power/devices.txt
===================================================================
@@ -502,52 +502,3 @@ If the CPU can have a "cpufreq" driver, 
 to shift to lower voltage settings and reduce the power cost of executing
 a given number of instructions.  (Without voltage adjustment, it's rare
 for cpufreq to save much power; the cost-per-instruction must go down.)
-
-
-/sys/devices/.../power/state files
-==================================
-For now you can also test some of this functionality using sysfs.
-
-	DEPRECATED:  USE "power/state" ONLY FOR DRIVER TESTING, AND
-	AVOID USING dev->power.power_state IN DRIVERS.
-
-	THESE WILL BE REMOVED.  IF THE "power/state" FILE GETS REPLACED,
-	IT WILL BECOME SOMETHING COUPLED TO THE BUS OR DRIVER.
-
-In each device's directory, there is a 'power' directory, which contains
-at least a 'state' file.  The value of this field is effectively boolean,
-PM_EVENT_ON or PM_EVENT_SUSPEND.
-
-   *	Reading from this file displays a value corresponding to
-	the power.power_state.event field.  All nonzero values are
-	displayed as "2", corresponding to a low power state; zero
-	is displayed as "0", corresponding to normal operation.
-
-   *	Writing to this file initiates a transition using the
-   	specified event code number; only '0', '2', and '3' are
-	accepted (without a newline); '2' and '3' are both
-	mapped to PM_EVENT_SUSPEND.
-
-On writes, the PM core relies on that recorded event code and the device/bus
-capabilities to determine whether it uses a partial suspend() or resume()
-sequence to change things so that the recorded event corresponds to the
-numeric parameter.
-
-   -	If the bus requires the irqs-disabled suspend_late()/resume_early()
-	phases, writes fail because those operations are not supported here.
-
-   -	If the recorded value is the expected value, nothing is done.
-
-   -	If the recorded value is nonzero, the device is partially resumed,
-	using the bus.resume() and/or class.resume() methods.
-
-   -	If the target value is nonzero, the device is partially suspended,
-	using the class.suspend() and/or bus.suspend() methods and the
-	PM_EVENT_SUSPEND message.
-
-Drivers have no way to tell whether their suspend() and resume() calls
-have come through the sysfs power/state file or as part of entering a
-system sleep state, except that when accessed through sysfs the normal
-parent/child sequencing rules are ignored.  Drivers (such as bus, bridge,
-or hub drivers) which expose child devices may need to enforce those rules
-on their own.
reviewer
#7 lore raw
In reply to Rafael J. Wysocki
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

thanks,
-Len

reviewer
#8 lore raw
In reply to Rafael J. Wysocki
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

thanks,
-Len

#9 lore raw
Quoted 6 lines · Len Brown
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#18 lore raw
In reply to Len Brown
Quoted 6 lines · Len Brown
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#10 lore raw
In reply to Pavel Machek
Quoted 10 lines · Pavel Machek
Quoted 6 lines · Len Brown
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?

Yes, plus the docs update from Dave Brownell.

Greetings,
Rafael

#17 lore raw
In reply to Pavel Machek
Quoted 10 lines · Pavel Machek
Quoted 6 lines · Len Brown
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?

Yes, plus the docs update from Dave Brownell.

Greetings,
Rafael

#11 lore raw
In reply to Rafael J. Wysocki
Quoted 5 lines · Rafael J. Wysocki
Quoted 4 lines · Pavel Machek
Quoted 3 lines · Len Brown
Quoted 2 lines · Rafael J. Wysocki

Len,

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?

Yes, plus the docs update from Dave Brownell.

Can we stop that reordering? I do not think it is such a good idea.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#12 lore raw
In reply to Rafael J. Wysocki
Quoted 5 lines · Rafael J. Wysocki
Quoted 4 lines · Pavel Machek
Quoted 3 lines · Len Brown
Quoted 2 lines · Rafael J. Wysocki

Len,

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?

Yes, plus the docs update from Dave Brownell.

Can we stop that reordering? I do not think it is such a good idea.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#13 lore raw
Quoted 8 lines · Pavel Machek
Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Len Brown
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?

Yes, plus the docs update from Dave Brownell.

Can we stop that reordering? I do not think it is such a good idea.

In this particular case it's needed to unbreak the APM emulation and it certainly is not a good idea to have two different orderings of the notifiers vs the freezer (hence the second patch in the series).

Thanks,
Rafael

#14 lore raw
In reply to Pavel Machek
Quoted 8 lines · Pavel Machek
Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Len Brown
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?

Yes, plus the docs update from Dave Brownell.

Can we stop that reordering? I do not think it is such a good idea.

In this particular case it's needed to unbreak the APM emulation and it certainly is not a good idea to have two different orderings of the notifiers vs the freezer (hence the second patch in the series).

Thanks,
Rafael

#15 lore raw
Quoted 14 lines · Rafael J. Wysocki
Quoted 13 lines · Pavel Machek
Quoted 12 lines · Rafael J. Wysocki
Quoted 10 lines · Pavel Machek
Quoted 6 lines · Len Brown
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Yes, plus the docs update from Dave Brownell.

Can we stop that reordering? I do not think it is such a good idea.

In this particular case it's needed to unbreak the APM emulation and it certainly is not a good idea to have two different orderings of the notifiers vs the freezer

Sorry, s/notifiers vs the freezer/console switch vs the notifiers/

Quoted 1 line

(hence the second patch in the series).

#16 lore raw
In reply to Rafael J. Wysocki
Quoted 14 lines · Rafael J. Wysocki
Quoted 13 lines · Pavel Machek
Quoted 12 lines · Rafael J. Wysocki
Quoted 10 lines · Pavel Machek
Quoted 6 lines · Len Brown
Quoted 3 lines · Rafael J. Wysocki

Len,

Please add the following three patches to the suspend branch.

Applied (and suspend branch has been re-based to latest linus tree)

Was that "lets reorder notifications, old order was more logical, but it fixes apm?" series?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Yes, plus the docs update from Dave Brownell.

Can we stop that reordering? I do not think it is such a good idea.

In this particular case it's needed to unbreak the APM emulation and it certainly is not a good idea to have two different orderings of the notifiers vs the freezer

Sorry, s/notifiers vs the freezer/console switch vs the notifiers/

Quoted 1 line

(hence the second patch in the series).