Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 267083
b: refs/heads/master
c: 2aede85
h: refs/heads/master
i:
  267081: 5656c0a
  267079: af28ad1
v: v3
  • Loading branch information
Rafael J. Wysocki committed Oct 16, 2011
1 parent fcae448 commit d5102c5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8f88893c05f2f677f18f2ce5591b4bed5d4a7535
refs/heads/master: 2aede851ddf08666f68ffc17be446420e9d2a056
4 changes: 0 additions & 4 deletions trunk/Documentation/power/devices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ When the system goes into the standby or memory sleep state, the phases are:
time.) Unlike the other suspend-related phases, during the prepare
phase the device tree is traversed top-down.

In addition to that, if device drivers need to allocate additional
memory to be able to hadle device suspend correctly, that should be
done in the prepare phase.

After the prepare callback method returns, no new children may be
registered below the device. The method may also prepare the device or
driver in some way for the upcoming system power transition (for
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/linux/freezer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern int thaw_process(struct task_struct *p);

extern void refrigerator(void);
extern int freeze_processes(void);
extern int freeze_kernel_threads(void);
extern void thaw_processes(void);

static inline int try_to_freeze(void)
Expand Down Expand Up @@ -171,7 +172,8 @@ static inline void clear_freeze_flag(struct task_struct *p) {}
static inline int thaw_process(struct task_struct *p) { return 1; }

static inline void refrigerator(void) {}
static inline int freeze_processes(void) { BUG(); return 0; }
static inline int freeze_processes(void) { return -ENOSYS; }
static inline int freeze_kernel_threads(void) { return -ENOSYS; }
static inline void thaw_processes(void) {}

static inline int try_to_freeze(void) { return 0; }
Expand Down
12 changes: 8 additions & 4 deletions trunk/kernel/power/hibernate.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,16 @@ int hibernation_snapshot(int platform_mode)
if (error)
goto Close;

error = dpm_prepare(PMSG_FREEZE);
if (error)
goto Complete_devices;

/* Preallocate image memory before shutting down devices. */
error = hibernate_preallocate_memory();
if (error)
goto Close;

error = freeze_kernel_threads();
if (error)
goto Close;

error = dpm_prepare(PMSG_FREEZE);
if (error)
goto Complete_devices;

Expand Down
3 changes: 2 additions & 1 deletion trunk/kernel/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ extern int pm_test_level;
#ifdef CONFIG_SUSPEND_FREEZER
static inline int suspend_freeze_processes(void)
{
return freeze_processes();
int error = freeze_processes();
return error ? : freeze_kernel_threads();
}

static inline void suspend_thaw_processes(void)
Expand Down
30 changes: 20 additions & 10 deletions trunk/kernel/power/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,38 @@ static int try_to_freeze_tasks(bool sig_only)
}

/**
* freeze_processes - tell processes to enter the refrigerator
* freeze_processes - Signal user space processes to enter the refrigerator.
*/
int freeze_processes(void)
{
int error;

printk("Freezing user space processes ... ");
error = try_to_freeze_tasks(true);
if (error)
goto Exit;
printk("done.\n");
if (!error) {
printk("done.");
oom_killer_disable();
}
printk("\n");
BUG_ON(in_atomic());

return error;
}

/**
* freeze_kernel_threads - Make freezable kernel threads go to the refrigerator.
*/
int freeze_kernel_threads(void)
{
int error;

printk("Freezing remaining freezable tasks ... ");
error = try_to_freeze_tasks(false);
if (error)
goto Exit;
printk("done.");
if (!error)
printk("done.");

oom_killer_disable();
Exit:
BUG_ON(in_atomic());
printk("\n");
BUG_ON(in_atomic());

return error;
}
Expand Down

0 comments on commit d5102c5

Please sign in to comment.