Skip to content

Commit 4eb2bd2

Browse files
committed
Merge tag 'pm-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "Fix the handling of block devices in the test_resume mode of hibernation (Chen Yu)" * tag 'pm-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PM: hibernate: Fix the exclusive get block device in test_resume mode PM: hibernate: Rename function parameter from snapshot_test to exclusive
2 parents e2dd7a1 + 148b6f4 commit 4eb2bd2

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

kernel/power/hibernate.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,9 @@ int hibernate(void)
786786
unlock_device_hotplug();
787787
if (snapshot_test) {
788788
pm_pr_dbg("Checking hibernation image\n");
789-
error = swsusp_check(snapshot_test);
789+
error = swsusp_check(false);
790790
if (!error)
791-
error = load_image_and_restore(snapshot_test);
791+
error = load_image_and_restore(false);
792792
}
793793
thaw_processes();
794794

@@ -945,14 +945,14 @@ static int software_resume(void)
945945
pm_pr_dbg("Looking for hibernation image.\n");
946946

947947
mutex_lock(&system_transition_mutex);
948-
error = swsusp_check(false);
948+
error = swsusp_check(true);
949949
if (error)
950950
goto Unlock;
951951

952952
/* The snapshot device should not be opened while we're running */
953953
if (!hibernate_acquire()) {
954954
error = -EBUSY;
955-
swsusp_close(false);
955+
swsusp_close(true);
956956
goto Unlock;
957957
}
958958

@@ -973,7 +973,7 @@ static int software_resume(void)
973973
goto Close_Finish;
974974
}
975975

976-
error = load_image_and_restore(false);
976+
error = load_image_and_restore(true);
977977
thaw_processes();
978978
Finish:
979979
pm_notifier_call_chain(PM_POST_RESTORE);
@@ -987,7 +987,7 @@ static int software_resume(void)
987987
pm_pr_dbg("Hibernation image not present or could not be loaded.\n");
988988
return error;
989989
Close_Finish:
990-
swsusp_close(false);
990+
swsusp_close(true);
991991
goto Finish;
992992
}
993993

kernel/power/power.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ extern int swsusp_swap_in_use(void);
168168
#define SF_HW_SIG 8
169169

170170
/* kernel/power/hibernate.c */
171-
int swsusp_check(bool snapshot_test);
171+
int swsusp_check(bool exclusive);
172172
extern void swsusp_free(void);
173173
extern int swsusp_read(unsigned int *flags_p);
174174
extern int swsusp_write(unsigned int flags);
175-
void swsusp_close(bool snapshot_test);
175+
void swsusp_close(bool exclusive);
176176
#ifdef CONFIG_SUSPEND
177177
extern int swsusp_unmark(void);
178178
#endif

kernel/power/swap.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,12 +1513,13 @@ int swsusp_read(unsigned int *flags_p)
15131513
static void *swsusp_holder;
15141514

15151515
/**
1516-
* swsusp_check - Check for swsusp signature in the resume device
1516+
* swsusp_check - Check for swsusp signature in the resume device
1517+
* @exclusive: Open the resume device exclusively.
15171518
*/
15181519

1519-
int swsusp_check(bool snapshot_test)
1520+
int swsusp_check(bool exclusive)
15201521
{
1521-
void *holder = snapshot_test ? &swsusp_holder : NULL;
1522+
void *holder = exclusive ? &swsusp_holder : NULL;
15221523
int error;
15231524

15241525
hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, BLK_OPEN_READ,
@@ -1563,17 +1564,18 @@ int swsusp_check(bool snapshot_test)
15631564
}
15641565

15651566
/**
1566-
* swsusp_close - close swap device.
1567+
* swsusp_close - close swap device.
1568+
* @exclusive: Close the resume device which is exclusively opened.
15671569
*/
15681570

1569-
void swsusp_close(bool snapshot_test)
1571+
void swsusp_close(bool exclusive)
15701572
{
15711573
if (IS_ERR(hib_resume_bdev)) {
15721574
pr_debug("Image device not initialised\n");
15731575
return;
15741576
}
15751577

1576-
blkdev_put(hib_resume_bdev, snapshot_test ? &swsusp_holder : NULL);
1578+
blkdev_put(hib_resume_bdev, exclusive ? &swsusp_holder : NULL);
15771579
}
15781580

15791581
/**

0 commit comments

Comments
 (0)