Skip to content

Commit

Permalink
PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl test path
Browse files Browse the repository at this point in the history
Commit 2aede85 (PM / Hibernate: Freeze
kernel threads after preallocating memory) moved the freezing of kernel
threads to hibernation_snapshot() function.

So now, if the call to hibernation_snapshot() returns early due to a
successful hibernation test, the caller has to thaw processes to ensure
that the system gets back to its original state.

But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw
processes in case hibernation_snapshot() returned due to a successful
freezer test. Fix this issue. But note we still send the value of 'in_suspend'
(which is now 0) to userspace, because we are not in an error path per-se,
and moreover, the value of in_suspend correctly depicts the situation here.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Srivatsa S. Bhat authored and Rafael J. Wysocki committed Dec 6, 2011
1 parent 0118521 commit 97819a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kernel/power/hibernate.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum {

static int hibernation_mode = HIBERNATION_SHUTDOWN;

static bool freezer_test_done;
bool freezer_test_done;

static const struct platform_hibernation_ops *hibernation_ops;

Expand Down
2 changes: 2 additions & 0 deletions kernel/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ static inline char *check_image_kernel(struct swsusp_info *info)
#define SPARE_PAGES ((1024 * 1024) >> PAGE_SHIFT)

/* kernel/power/hibernate.c */
extern bool freezer_test_done;

extern int hibernation_snapshot(int platform_mode);
extern int hibernation_restore(int platform_mode);
extern int hibernation_platform_enter(void);
Expand Down
11 changes: 8 additions & 3 deletions kernel/power/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,15 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
}
pm_restore_gfp_mask();
error = hibernation_snapshot(data->platform_support);
if (!error)
if (!error) {
error = put_user(in_suspend, (int __user *)arg);
if (!error)
data->ready = 1;
if (!error && !freezer_test_done)
data->ready = 1;
if (freezer_test_done) {
freezer_test_done = false;
thaw_processes();
}
}
break;

case SNAPSHOT_ATOMIC_RESTORE:
Expand Down

0 comments on commit 97819a2

Please sign in to comment.