Skip to content

Commit

Permalink
PM: hibernate: Turn snapshot_test into global variable
Browse files Browse the repository at this point in the history
[ Upstream commit 08169a1 ]

There is need to check snapshot_test and open block device
in different mode, so as to avoid the race condition.

No functional changes intended.

Suggested-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Stable-dep-of: 5904de0 ("PM: hibernate: Do not get block device exclusively in test_resume mode")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
yu-chen-surf authored and gregkh committed May 11, 2023
1 parent cdd3fa5 commit d331f2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel/power/hibernate.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ enum {
static int hibernation_mode = HIBERNATION_SHUTDOWN;

bool freezer_test_done;
bool snapshot_test;

static const struct platform_hibernation_ops *hibernation_ops;

Expand Down Expand Up @@ -716,7 +717,6 @@ static int load_image_and_restore(void)
*/
int hibernate(void)
{
bool snapshot_test = false;
unsigned int sleep_flags;
int error;

Expand Down Expand Up @@ -744,6 +744,9 @@ int hibernate(void)
if (error)
goto Exit;

/* protected by system_transition_mutex */
snapshot_test = false;

lock_device_hotplug();
/* Allocate memory management structures */
error = create_basic_memory_bitmaps();
Expand Down Expand Up @@ -940,6 +943,8 @@ static int software_resume(void)
*/
mutex_lock_nested(&system_transition_mutex, SINGLE_DEPTH_NESTING);

snapshot_test = false;

if (swsusp_resume_device)
goto Check_image;

Expand Down
1 change: 1 addition & 0 deletions kernel/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ asmlinkage int swsusp_save(void);

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

extern int hibernation_snapshot(int platform_mode);
extern int hibernation_restore(int platform_mode);
Expand Down

0 comments on commit d331f2a

Please sign in to comment.