Skip to content

Commit 08169a1

Browse files
yu-chen-surfrafaeljw
authored andcommitted
PM: hibernate: Turn snapshot_test into global variable
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>
1 parent 0cfd870 commit 08169a1

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

kernel/power/hibernate.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ enum {
6464
static int hibernation_mode = HIBERNATION_SHUTDOWN;
6565

6666
bool freezer_test_done;
67+
bool snapshot_test;
6768

6869
static const struct platform_hibernation_ops *hibernation_ops;
6970

@@ -716,7 +717,6 @@ static int load_image_and_restore(void)
716717
*/
717718
int hibernate(void)
718719
{
719-
bool snapshot_test = false;
720720
unsigned int sleep_flags;
721721
int error;
722722

@@ -744,6 +744,9 @@ int hibernate(void)
744744
if (error)
745745
goto Exit;
746746

747+
/* protected by system_transition_mutex */
748+
snapshot_test = false;
749+
747750
lock_device_hotplug();
748751
/* Allocate memory management structures */
749752
error = create_basic_memory_bitmaps();
@@ -940,6 +943,8 @@ static int software_resume(void)
940943
*/
941944
mutex_lock_nested(&system_transition_mutex, SINGLE_DEPTH_NESTING);
942945

946+
snapshot_test = false;
947+
943948
if (swsusp_resume_device)
944949
goto Check_image;
945950

kernel/power/power.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ asmlinkage int swsusp_save(void);
5959

6060
/* kernel/power/hibernate.c */
6161
extern bool freezer_test_done;
62+
extern bool snapshot_test;
6263

6364
extern int hibernation_snapshot(int platform_mode);
6465
extern int hibernation_restore(int platform_mode);

0 commit comments

Comments
 (0)