* [PATCH 1/9] Consolidate driver_probe_done() loops into one place
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
@ 2009-02-14 0:59 ` Rafael J. Wysocki
2009-02-14 1:47 ` Greg KH
2009-02-14 1:00 ` [PATCH 2/9] PM/resume: wait for device probing to finish Rafael J. Wysocki
` (8 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-14 0:59 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
From: Arjan van de Ven <arjan@linux.intel.com>
there's a few places that currently loop over driver_probe_done(), and
I'm about to add another one. This patch abstracts it into a helper
to reduce duplication.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
drivers/base/dd.c | 17 +++++++++++++++++
include/linux/device.h | 2 ++
init/do_mounts.c | 13 +++++++++----
init/do_mounts_md.c | 5 +++--
4 files changed, 31 insertions(+), 6 deletions(-)
Index: linux-2.6/drivers/base/dd.c
===================================================================
--- linux-2.6.orig/drivers/base/dd.c
+++ linux-2.6/drivers/base/dd.c
@@ -18,9 +18,11 @@
*/
#include <linux/device.h>
+#include <linux/delay.h>
#include <linux/module.h>
#include <linux/kthread.h>
#include <linux/wait.h>
+#include <linux/async.h>
#include "base.h"
#include "power/power.h"
@@ -168,6 +170,21 @@ int driver_probe_done(void)
}
/**
+ * wait_for_device_probe
+ * Wait for device probing to be completed.
+ *
+ * Note: this function polls at 100 msec intervals.
+ */
+int wait_for_device_probe(void)
+{
+ /* wait for the known devices to complete their probing */
+ while (driver_probe_done() != 0)
+ msleep(100);
+ async_synchronize_full();
+ return 0;
+}
+
+/**
* driver_probe_device - attempt to bind device & driver together
* @drv: driver to bind a device to
* @dev: device to try to bind to the driver
Index: linux-2.6/include/linux/device.h
===================================================================
--- linux-2.6.orig/include/linux/device.h
+++ linux-2.6/include/linux/device.h
@@ -147,6 +147,8 @@ extern void put_driver(struct device_dri
extern struct device_driver *driver_find(const char *name,
struct bus_type *bus);
extern int driver_probe_done(void);
+extern int wait_for_device_probe(void);
+
/* sysfs interface for exporting driver attributes */
Index: linux-2.6/init/do_mounts.c
===================================================================
--- linux-2.6.orig/init/do_mounts.c
+++ linux-2.6/init/do_mounts.c
@@ -370,10 +370,14 @@ void __init prepare_namespace(void)
ssleep(root_delay);
}
- /* wait for the known devices to complete their probing */
- while (driver_probe_done() != 0)
- msleep(100);
- async_synchronize_full();
+ /*
+ * wait for the known devices to complete their probing
+ *
+ * Note: this is a potential source of long boot delays.
+ * For example, it is not atypical to wait 5 seconds here
+ * for the touchpad of a laptop to initialize.
+ */
+ wait_for_device_probe();
md_run_setup();
@@ -399,6 +403,7 @@ void __init prepare_namespace(void)
while (driver_probe_done() != 0 ||
(ROOT_DEV = name_to_dev_t(saved_root_name)) == 0)
msleep(100);
+ async_synchronize_full();
}
is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
Index: linux-2.6/init/do_mounts_md.c
===================================================================
--- linux-2.6.orig/init/do_mounts_md.c
+++ linux-2.6/init/do_mounts_md.c
@@ -281,8 +281,9 @@ static void __init autodetect_raid(void)
*/
printk(KERN_INFO "md: Waiting for all devices to be available before autodetect\n");
printk(KERN_INFO "md: If you don't use raid, use raid=noautodetect\n");
- while (driver_probe_done() < 0)
- msleep(100);
+
+ wait_for_device_probe();
+
fd = sys_open("/dev/md0", 0, 0);
if (fd >= 0) {
sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 1/9] Consolidate driver_probe_done() loops into one place
2009-02-14 0:59 ` [PATCH 1/9] Consolidate driver_probe_done() loops into one place Rafael J. Wysocki
@ 2009-02-14 1:47 ` Greg KH
0 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2009-02-14 1:47 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Len Brown, Andrew Morton, Arve Hjønnevåg, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
On Sat, Feb 14, 2009 at 01:59:06AM +0100, Rafael J. Wysocki wrote:
> From: Arjan van de Ven <arjan@linux.intel.com>
>
> there's a few places that currently loop over driver_probe_done(), and
> I'm about to add another one. This patch abstracts it into a helper
> to reduce duplication.
>
> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Fine with me if this goes through Len's tree.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 2/9] PM/resume: wait for device probing to finish
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
2009-02-14 0:59 ` [PATCH 1/9] Consolidate driver_probe_done() loops into one place Rafael J. Wysocki
@ 2009-02-14 1:00 ` Rafael J. Wysocki
2009-02-14 1:48 ` Greg KH
2009-02-14 1:01 ` [PATCH 3/9] PM/hibernate: fix "swap breaks after hibernation failures" Rafael J. Wysocki
` (7 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-14 1:00 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
From: Arjan van de Ven <arjan@linux.intel.com>
the resume code does not currently wait for device probing to finish.
Even without async function calls this is dicey and not correct,
but with async function calls during the boot sequence this is going
to get hit more...
This patch adds the synchronization using the newly introduced helper.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
kernel/power/disk.c | 11 +++++++++++
1 file changed, 11 insertions(+)
Index: linux-2.6/kernel/power/disk.c
===================================================================
--- linux-2.6.orig/kernel/power/disk.c
+++ linux-2.6/kernel/power/disk.c
@@ -595,6 +595,12 @@ static int software_resume(void)
unsigned int flags;
/*
+ * If the user said "noresume".. bail out early.
+ */
+ if (noresume)
+ return 0;
+
+ /*
* name_to_dev_t() below takes a sysfs buffer mutex when sysfs
* is configured into the kernel. Since the regular hibernate
* trigger path is via sysfs which takes a buffer mutex before
@@ -610,6 +616,11 @@ static int software_resume(void)
mutex_unlock(&pm_mutex);
return -ENOENT;
}
+ /*
+ * Some device discovery might still be in progress; we need
+ * to wait for this to finish.
+ */
+ wait_for_device_probe();
swsusp_resume_device = name_to_dev_t(resume_file);
pr_debug("PM: Resume from partition %s\n", resume_file);
} else {
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 2/9] PM/resume: wait for device probing to finish
2009-02-14 1:00 ` [PATCH 2/9] PM/resume: wait for device probing to finish Rafael J. Wysocki
@ 2009-02-14 1:48 ` Greg KH
0 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2009-02-14 1:48 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Len Brown, Andrew Morton, Arve Hjønnevåg, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
On Sat, Feb 14, 2009 at 02:00:19AM +0100, Rafael J. Wysocki wrote:
> From: Arjan van de Ven <arjan@linux.intel.com>
>
> the resume code does not currently wait for device probing to finish.
> Even without async function calls this is dicey and not correct,
> but with async function calls during the boot sequence this is going
> to get hit more...
>
> This patch adds the synchronization using the newly introduced helper.
>
> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Fine with me if this goes through Len's tree.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 3/9] PM/hibernate: fix "swap breaks after hibernation failures"
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
2009-02-14 0:59 ` [PATCH 1/9] Consolidate driver_probe_done() loops into one place Rafael J. Wysocki
2009-02-14 1:00 ` [PATCH 2/9] PM/resume: wait for device probing to finish Rafael J. Wysocki
@ 2009-02-14 1:01 ` Rafael J. Wysocki
2009-02-14 1:02 ` [PATCH 4/9] PM: fix build for CONFIG_PM unset Rafael J. Wysocki
` (6 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-14 1:01 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
http://bugzilla.kernel.org/show_bug.cgi?id=12239
The image writing code dropped a reference to the current swap device.
This doesn't show up if the hibernation succeeds - because it doesn't
affect the image which gets resumed. But it means multiple _failed_
hibernations end up freeing the swap device while it is still use!
swsusp_write() finds the block device for the swap file using swap_type_of().
It then uses blkdev_get() / blkdev_put() to open and close the block device.
Unfortunately, blkdev_get() assumes ownership of the inode of the block_device
passed to it. So blkdev_put() calls iput() on the inode. This is by design
and other callers expect this behaviour. The fix is for swap_type_of() to take
a reference on the inode using bdget().
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
mm/swapfile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6/mm/swapfile.c
===================================================================
--- linux-2.6.orig/mm/swapfile.c
+++ linux-2.6/mm/swapfile.c
@@ -635,7 +635,7 @@ int swap_type_of(dev_t device, sector_t
if (!bdev) {
if (bdev_p)
- *bdev_p = sis->bdev;
+ *bdev_p = bdget(sis->bdev->bd_dev);
spin_unlock(&swap_lock);
return i;
@@ -647,7 +647,7 @@ int swap_type_of(dev_t device, sector_t
struct swap_extent, list);
if (se->start_block == offset) {
if (bdev_p)
- *bdev_p = sis->bdev;
+ *bdev_p = bdget(sis->bdev->bd_dev);
spin_unlock(&swap_lock);
bdput(bdev);
^ permalink raw reply [flat|nested] 20+ messages in thread* [PATCH 4/9] PM: fix build for CONFIG_PM unset
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
` (2 preceding siblings ...)
2009-02-14 1:01 ` [PATCH 3/9] PM/hibernate: fix "swap breaks after hibernation failures" Rafael J. Wysocki
@ 2009-02-14 1:02 ` Rafael J. Wysocki
2009-02-14 1:03 ` [PATCH 5/9] swsusp: dont fiddle with swappiness Rafael J. Wysocki
` (5 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-14 1:02 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
From: Rafael J. Wysocki <rjw@sisk.pl>
Compilation of kprobes.c with CONFIG_PM unset is broken due to some broken
config dependncies. Fix that.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Reported-by: Ingo Molnar <mingo@elte.hu>
Tested-by: Masami Hiramatsu <mhiramat@redhat.com>
---
kernel/Makefile | 1 +
kernel/power/Makefile | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
Index: linux-2.6/kernel/Makefile
===================================================================
--- linux-2.6.orig/kernel/Makefile
+++ linux-2.6/kernel/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_UID16) += uid16.o
obj-$(CONFIG_MODULES) += module.o
obj-$(CONFIG_KALLSYMS) += kallsyms.o
obj-$(CONFIG_PM) += power/
+obj-$(CONFIG_FREEZER) += power/
obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
obj-$(CONFIG_KEXEC) += kexec.o
obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
Index: linux-2.6/kernel/power/Makefile
===================================================================
--- linux-2.6.orig/kernel/power/Makefile
+++ linux-2.6/kernel/power/Makefile
@@ -3,7 +3,7 @@ ifeq ($(CONFIG_PM_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
-obj-y := main.o
+obj-$(CONFIG_PM) += main.o
obj-$(CONFIG_PM_SLEEP) += console.o
obj-$(CONFIG_FREEZER) += process.o
obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o
^ permalink raw reply [flat|nested] 20+ messages in thread* [PATCH 5/9] swsusp: dont fiddle with swappiness
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
` (3 preceding siblings ...)
2009-02-14 1:02 ` [PATCH 4/9] PM: fix build for CONFIG_PM unset Rafael J. Wysocki
@ 2009-02-14 1:03 ` Rafael J. Wysocki
2009-02-14 1:04 ` [PATCH 6/9] swsusp: clean up shrink_all_zones() Rafael J. Wysocki
` (4 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-14 1:03 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
From: Johannes Weiner <hannes@cmpxchg.org>
sc.swappiness is not used in the swsusp memory shrinking path, do not
set it.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
mm/vmscan.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
Index: linux-2.6/mm/vmscan.c
===================================================================
--- linux-2.6.orig/mm/vmscan.c
+++ linux-2.6/mm/vmscan.c
@@ -2112,7 +2112,6 @@ unsigned long shrink_all_memory(unsigned
.may_swap = 0,
.swap_cluster_max = nr_pages,
.may_writepage = 1,
- .swappiness = vm_swappiness,
.isolate_pages = isolate_pages_global,
};
@@ -2146,10 +2145,8 @@ unsigned long shrink_all_memory(unsigned
int prio;
/* Force reclaiming mapped pages in the passes #3 and #4 */
- if (pass > 2) {
+ if (pass > 2)
sc.may_swap = 1;
- sc.swappiness = 100;
- }
for (prio = DEF_PRIORITY; prio >= 0; prio--) {
unsigned long nr_to_scan = nr_pages - ret;
^ permalink raw reply [flat|nested] 20+ messages in thread* [PATCH 6/9] swsusp: clean up shrink_all_zones()
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
` (4 preceding siblings ...)
2009-02-14 1:03 ` [PATCH 5/9] swsusp: dont fiddle with swappiness Rafael J. Wysocki
@ 2009-02-14 1:04 ` Rafael J. Wysocki
2009-02-14 1:05 ` [PATCH 7/9] PM: Fix pm_notifiers during user mode hibernation Rafael J. Wysocki
` (3 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-14 1:04 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
From: Johannes Weiner <hannes@cmpxchg.org>
Move local variables to innermost possible scopes and use local
variables to cache calculations/reads done more than once.
No change in functionality (intended).
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
mm/vmscan.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
Index: linux-2.6/mm/vmscan.c
===================================================================
--- linux-2.6.orig/mm/vmscan.c
+++ linux-2.6/mm/vmscan.c
@@ -2057,31 +2057,31 @@ static unsigned long shrink_all_zones(un
int pass, struct scan_control *sc)
{
struct zone *zone;
- unsigned long nr_to_scan, ret = 0;
- enum lru_list l;
+ unsigned long ret = 0;
for_each_zone(zone) {
+ enum lru_list l;
if (!populated_zone(zone))
continue;
-
if (zone_is_all_unreclaimable(zone) && prio != DEF_PRIORITY)
continue;
for_each_evictable_lru(l) {
+ enum zone_stat_item ls = NR_LRU_BASE + l;
+ unsigned long lru_pages = zone_page_state(zone, ls);
+
/* For pass = 0, we don't shrink the active list */
- if (pass == 0 &&
- (l == LRU_ACTIVE || l == LRU_ACTIVE_FILE))
+ if (pass == 0 && (l == LRU_ACTIVE_ANON ||
+ l == LRU_ACTIVE_FILE))
continue;
- zone->lru[l].nr_scan +=
- (zone_page_state(zone, NR_LRU_BASE + l)
- >> prio) + 1;
+ zone->lru[l].nr_scan += (lru_pages >> prio) + 1;
if (zone->lru[l].nr_scan >= nr_pages || pass > 3) {
+ unsigned long nr_to_scan;
+
zone->lru[l].nr_scan = 0;
- nr_to_scan = min(nr_pages,
- zone_page_state(zone,
- NR_LRU_BASE + l));
+ nr_to_scan = min(nr_pages, lru_pages);
ret += shrink_list(l, nr_to_scan, zone,
sc, prio);
if (ret >= nr_pages)
@@ -2089,7 +2089,6 @@ static unsigned long shrink_all_zones(un
}
}
}
-
return ret;
}
^ permalink raw reply [flat|nested] 20+ messages in thread* [PATCH 7/9] PM: Fix pm_notifiers during user mode hibernation
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
` (5 preceding siblings ...)
2009-02-14 1:04 ` [PATCH 6/9] swsusp: clean up shrink_all_zones() Rafael J. Wysocki
@ 2009-02-14 1:05 ` Rafael J. Wysocki
2009-02-14 1:06 ` [PATCH 8/9] PM: Wait for console in resume Rafael J. Wysocki
` (2 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-14 1:05 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
From: Andrey Borzenkov <arvidjaar@mail.ru>
Snapshot device is opened with O_RDONLY during suspend and O_WRONLY durig
resume. Make sure we also call notifiers with correct parameter telling
them what we are really doing.
Signed-off-by: Andrey Borzenkov <arvidjaar@mail.ru>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
kernel/power/user.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6/kernel/power/user.c
===================================================================
--- linux-2.6.orig/kernel/power/user.c
+++ linux-2.6/kernel/power/user.c
@@ -95,15 +95,15 @@ static int snapshot_open(struct inode *i
data->swap = swsusp_resume_device ?
swap_type_of(swsusp_resume_device, 0, NULL) : -1;
data->mode = O_RDONLY;
- error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
+ error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
if (error)
- pm_notifier_call_chain(PM_POST_RESTORE);
+ pm_notifier_call_chain(PM_POST_HIBERNATION);
} else {
data->swap = -1;
data->mode = O_WRONLY;
- error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
+ error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
if (error)
- pm_notifier_call_chain(PM_POST_HIBERNATION);
+ pm_notifier_call_chain(PM_POST_RESTORE);
}
if (error)
atomic_inc(&snapshot_device_available);
^ permalink raw reply [flat|nested] 20+ messages in thread* [PATCH 8/9] PM: Wait for console in resume
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
` (6 preceding siblings ...)
2009-02-14 1:05 ` [PATCH 7/9] PM: Fix pm_notifiers during user mode hibernation Rafael J. Wysocki
@ 2009-02-14 1:06 ` Rafael J. Wysocki
2009-02-14 1:07 ` [PATCH 9/9] PM: Fix suspend_console and resume_console to use only one semaphore Rafael J. Wysocki
2009-02-21 4:41 ` [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Len Brown
9 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-14 1:06 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
From: Arve Hjønnevåg <arve@android.com>
Avoids later waking up to a blinking cursor if the device woke up and
returned to sleep before the console switch happened.
Signed-off-by: Brian Swetland <swetland@google.com>
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
kernel/power/console.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: linux-2.6/kernel/power/console.c
===================================================================
--- linux-2.6.orig/kernel/power/console.c
+++ linux-2.6/kernel/power/console.c
@@ -78,6 +78,12 @@ void pm_restore_console(void)
}
set_console(orig_fgconsole);
release_console_sem();
+
+ if (vt_waitactive(orig_fgconsole)) {
+ pr_debug("Resume: Can't switch VCs.");
+ return;
+ }
+
kmsg_redirect = orig_kmsg;
}
#endif
^ permalink raw reply [flat|nested] 20+ messages in thread* [PATCH 9/9] PM: Fix suspend_console and resume_console to use only one semaphore
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
` (7 preceding siblings ...)
2009-02-14 1:06 ` [PATCH 8/9] PM: Wait for console in resume Rafael J. Wysocki
@ 2009-02-14 1:07 ` Rafael J. Wysocki
2009-02-21 4:41 ` [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Len Brown
9 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-14 1:07 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
From: Arve Hjønnevåg <arve@android.com>
This fixes a race where a thread acquires the console while the
console is suspended, and the console is resumed before this
thread releases it. In this case, the secondary console
semaphore would be left locked, and the primary semaphore would
be released twice. This in turn would cause the console switch
on suspend or resume to hang forever.
Note that suspend_console does not actually lock the console
for clients that use acquire_console_sem, it only locks it for
clients that use try_acquire_console_sem. If we change
suspend_console to fully lock the console, then the kernel
may deadlock on suspend. One client of try_acquire_console_sem
is acquire_console_semaphore_for_printk, which uses it to
prevent printk from using the console while it is suspended.
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
kernel/printk.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
Index: linux-2.6/kernel/printk.c
===================================================================
--- linux-2.6.orig/kernel/printk.c
+++ linux-2.6/kernel/printk.c
@@ -73,7 +73,6 @@ EXPORT_SYMBOL(oops_in_progress);
* driver system.
*/
static DECLARE_MUTEX(console_sem);
-static DECLARE_MUTEX(secondary_console_sem);
struct console *console_drivers;
EXPORT_SYMBOL_GPL(console_drivers);
@@ -891,12 +890,14 @@ void suspend_console(void)
printk("Suspending console(s) (use no_console_suspend to debug)\n");
acquire_console_sem();
console_suspended = 1;
+ up(&console_sem);
}
void resume_console(void)
{
if (!console_suspend_enabled)
return;
+ down(&console_sem);
console_suspended = 0;
release_console_sem();
}
@@ -912,11 +913,9 @@ void resume_console(void)
void acquire_console_sem(void)
{
BUG_ON(in_interrupt());
- if (console_suspended) {
- down(&secondary_console_sem);
- return;
- }
down(&console_sem);
+ if (console_suspended)
+ return;
console_locked = 1;
console_may_schedule = 1;
}
@@ -926,6 +925,10 @@ int try_acquire_console_sem(void)
{
if (down_trylock(&console_sem))
return -1;
+ if (console_suspended) {
+ up(&console_sem);
+ return -1;
+ }
console_locked = 1;
console_may_schedule = 0;
return 0;
@@ -979,7 +982,7 @@ void release_console_sem(void)
unsigned wake_klogd = 0;
if (console_suspended) {
- up(&secondary_console_sem);
+ up(&console_sem);
return;
}
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
` (8 preceding siblings ...)
2009-02-14 1:07 ` [PATCH 9/9] PM: Fix suspend_console and resume_console to use only one semaphore Rafael J. Wysocki
@ 2009-02-21 4:41 ` Len Brown
2009-02-21 9:38 ` Rafael J. Wysocki
9 siblings, 1 reply; 20+ messages in thread
From: Len Brown @ 2009-02-21 4:41 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Andrew Morton, Arve Hjønnevåg, Greg KH, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
On Sat, 14 Feb 2009, Rafael J. Wysocki wrote:
> Hi Len,
>
> The following are fixes related to suspend and hibernation I have collected
> over the last couple of weeks. Some of them are in -mm. I think they all are
> 2.6.29 material.
>
> 1/9 and 2/9 fix hibernation regression caused by the async boot changes,
> I hope Greg will not object if they go through your tree.
>
> 3/9 fixes a long-standing hibernation issue that cause the resume partition
> to become unuseable after two consecutive failing attempts to hibernate.
>
> 4/9 fixes build of kprobes.c with CONFIG_PM unset.
looks like this one added power/ twice --
and looks like akpm sent a fixed version of this to linus already?
> 5/9 and 6/9 clean up memory freeing code used during hibernation.
>
> 7/9 fixes a bug related to the use of PM notifiers during hibernation with
> the help of the user land interface.
>
> 8/9 and 9/9 fix the handling of consoles during suspend/hibernation.
>
> Please add these patches to the suspend branch and push to Linus for 2.6.29.
All except #4 are now on the suspend branch.
thanks,
--
Len Brown, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29
2009-02-21 4:41 ` [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Len Brown
@ 2009-02-21 9:38 ` Rafael J. Wysocki
2009-02-21 18:29 ` Greg KH
0 siblings, 1 reply; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-21 9:38 UTC (permalink / raw)
To: Len Brown, Greg KH
Cc: Andrew Morton, Arve Hjønnevåg, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
On Saturday 21 February 2009, Len Brown wrote:
>
> On Sat, 14 Feb 2009, Rafael J. Wysocki wrote:
>
> > Hi Len,
> >
> > The following are fixes related to suspend and hibernation I have collected
> > over the last couple of weeks. Some of them are in -mm. I think they all are
> > 2.6.29 material.
> >
> > 1/9 and 2/9 fix hibernation regression caused by the async boot changes,
> > I hope Greg will not object if they go through your tree.
> >
> > 3/9 fixes a long-standing hibernation issue that cause the resume partition
> > to become unuseable after two consecutive failing attempts to hibernate.
> >
> > 4/9 fixes build of kprobes.c with CONFIG_PM unset.
>
> looks like this one added power/ twice --
That was on purpose.
> and looks like akpm sent a fixed version of this to linus already?
Yes, he did.
> > 5/9 and 6/9 clean up memory freeing code used during hibernation.
> >
> > 7/9 fixes a bug related to the use of PM notifiers during hibernation with
> > the help of the user land interface.
> >
> > 8/9 and 9/9 fix the handling of consoles during suspend/hibernation.
> >
> > Please add these patches to the suspend branch and push to Linus for 2.6.29.
>
> All except #4 are now on the suspend branch.
1/9 and 2/9 are also in the Greg's tree, AFAICS.
Greg, do you intend to push them to Linus? In that case I think it's better if
Len drops them.
Rafael
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29
2009-02-21 9:38 ` Rafael J. Wysocki
@ 2009-02-21 18:29 ` Greg KH
2009-02-21 19:32 ` Arjan van de Ven
0 siblings, 1 reply; 20+ messages in thread
From: Greg KH @ 2009-02-21 18:29 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Len Brown, Andrew Morton, Arve Hjønnevåg, Ingo Molnar,
Johannes Weiner, KOSAKI Motohiro, LKML, Linus Torvalds,
Pavel Machek, pm list, Arjan van de Ven, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
On Sat, Feb 21, 2009 at 10:38:40AM +0100, Rafael J. Wysocki wrote:
> On Saturday 21 February 2009, Len Brown wrote:
> >
> > On Sat, 14 Feb 2009, Rafael J. Wysocki wrote:
> >
> > > Hi Len,
> > >
> > > The following are fixes related to suspend and hibernation I have collected
> > > over the last couple of weeks. Some of them are in -mm. I think they all are
> > > 2.6.29 material.
> > >
> > > 1/9 and 2/9 fix hibernation regression caused by the async boot changes,
> > > I hope Greg will not object if they go through your tree.
> > >
> > > 3/9 fixes a long-standing hibernation issue that cause the resume partition
> > > to become unuseable after two consecutive failing attempts to hibernate.
> > >
> > > 4/9 fixes build of kprobes.c with CONFIG_PM unset.
> >
> > looks like this one added power/ twice --
>
> That was on purpose.
>
> > and looks like akpm sent a fixed version of this to linus already?
>
> Yes, he did.
>
> > > 5/9 and 6/9 clean up memory freeing code used during hibernation.
> > >
> > > 7/9 fixes a bug related to the use of PM notifiers during hibernation with
> > > the help of the user land interface.
> > >
> > > 8/9 and 9/9 fix the handling of consoles during suspend/hibernation.
> > >
> > > Please add these patches to the suspend branch and push to Linus for 2.6.29.
> >
> > All except #4 are now on the suspend branch.
>
> 1/9 and 2/9 are also in the Greg's tree, AFAICS.
>
> Greg, do you intend to push them to Linus? In that case I think it's better if
> Len drops them.
I was not planning to send them for .29, sorry I got confused. I'll
drop them from my tree and Len can send them all to Linus now.
Is that ok?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29
2009-02-21 18:29 ` Greg KH
@ 2009-02-21 19:32 ` Arjan van de Ven
2009-02-21 19:48 ` Greg KH
0 siblings, 1 reply; 20+ messages in thread
From: Arjan van de Ven @ 2009-02-21 19:32 UTC (permalink / raw)
To: Greg KH
Cc: Rafael J. Wysocki, Len Brown, Andrew Morton,
Arve Hjønnevåg, Ingo Molnar, Johannes Weiner,
KOSAKI Motohiro, LKML, Linus Torvalds, Pavel Machek, pm list,
Alan Jenkins, Masami Hiramatsu, Andrey Borzenkov
Greg KH wrote:
> I was not planning to send them for .29, sorry I got confused. I'll
> drop them from my tree and Len can send them all to Linus now.
>
they really really need to go into .29, they are a fix for a regression.
This patch exists for 6 weeks now as a fix for the regression.. why is it so
hard to get it sent to Linus???
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29
2009-02-21 19:32 ` Arjan van de Ven
@ 2009-02-21 19:48 ` Greg KH
2009-02-21 22:18 ` Linus Torvalds
0 siblings, 1 reply; 20+ messages in thread
From: Greg KH @ 2009-02-21 19:48 UTC (permalink / raw)
To: Arjan van de Ven
Cc: Rafael J. Wysocki, Len Brown, Andrew Morton,
Arve Hjønnevåg, Ingo Molnar, Johannes Weiner,
KOSAKI Motohiro, LKML, Linus Torvalds, Pavel Machek, pm list,
Alan Jenkins, Masami Hiramatsu, Andrey Borzenkov
On Sat, Feb 21, 2009 at 11:32:37AM -0800, Arjan van de Ven wrote:
> Greg KH wrote:
>> I was not planning to send them for .29, sorry I got confused. I'll
>> drop them from my tree and Len can send them all to Linus now.
>
> they really really need to go into .29, they are a fix for a regression.
>
> This patch exists for 6 weeks now as a fix for the regression.. why is it
> so hard to get it sent to Linus???
I think it's because both of us (Len and I) think the other is doing it
:(
Ok, so, Len, are you willing to send these to Linus this week?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29
2009-02-21 19:48 ` Greg KH
@ 2009-02-21 22:18 ` Linus Torvalds
2009-02-22 2:47 ` Len Brown
2009-02-22 10:07 ` Rafael J. Wysocki
0 siblings, 2 replies; 20+ messages in thread
From: Linus Torvalds @ 2009-02-21 22:18 UTC (permalink / raw)
To: Greg KH
Cc: Arjan van de Ven, Rafael J. Wysocki, Len Brown, Andrew Morton,
Arve Hjønnevåg, Ingo Molnar, Johannes Weiner,
KOSAKI Motohiro, LKML, Pavel Machek, pm list, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
On Sat, 21 Feb 2009, Greg KH wrote:
>
> Ok, so, Len, are you willing to send these to Linus this week?
I took them all, and added both of you to the cc, so if/when things break
and get bisected to this series, both of you should be cc'd on the
discussion.
Linus
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29
2009-02-21 22:18 ` Linus Torvalds
@ 2009-02-22 2:47 ` Len Brown
2009-02-22 10:07 ` Rafael J. Wysocki
1 sibling, 0 replies; 20+ messages in thread
From: Len Brown @ 2009-02-22 2:47 UTC (permalink / raw)
To: Linus Torvalds
Cc: Greg KH, Arjan van de Ven, Rafael J. Wysocki, Andrew Morton,
Arve Hjønnevåg, Ingo Molnar, Johannes Weiner,
KOSAKI Motohiro, LKML, Pavel Machek, pm list, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
> I took them all, and added both of you to the cc, so if/when things break
> and get bisected to this series, both of you should be cc'd on the
> discussion.
Okay, I'll delete them from my suspend branch.
thanks,
-Len
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29
2009-02-21 22:18 ` Linus Torvalds
2009-02-22 2:47 ` Len Brown
@ 2009-02-22 10:07 ` Rafael J. Wysocki
1 sibling, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2009-02-22 10:07 UTC (permalink / raw)
To: Linus Torvalds
Cc: Greg KH, Arjan van de Ven, Len Brown, Andrew Morton,
Arve Hjønnevåg, Ingo Molnar, Johannes Weiner,
KOSAKI Motohiro, LKML, Pavel Machek, pm list, Alan Jenkins,
Masami Hiramatsu, Andrey Borzenkov
On Saturday 21 February 2009, Linus Torvalds wrote:
>
> On Sat, 21 Feb 2009, Greg KH wrote:
> >
> > Ok, so, Len, are you willing to send these to Linus this week?
>
> I took them all, and added both of you to the cc, so if/when things break
> and get bisected to this series, both of you should be cc'd on the
> discussion.
Thanks Linus! :-)
Rafael
^ permalink raw reply [flat|nested] 20+ messages in thread