summaryrefslogtreecommitdiff
path: root/kernel/power/user.c
diff options
context:
space:
mode:
authorDomenico Andreoli <domenico.andreoli@linux.com>2020-05-07 10:19:52 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2020-05-19 18:48:08 +0300
commitab7e9b067f3d9cbec28cfca51d341efb421b7a51 (patch)
tree945ac12fc98f52d44b7f44bff01837cd62b9eb3e /kernel/power/user.c
parent3a4ccdb92e1e0f51844c8b60f2c0f48a4a620000 (diff)
downloadlinux-ab7e9b067f3d9cbec28cfca51d341efb421b7a51.tar.xz
PM: hibernate: Incorporate concurrency handling
Hibernation concurrency handling is currently delegated to user.c, where it's also used for regulating the access to the snapshot device. In the prospective of making user.c a separate configuration option, such mutual exclusion is brought into hibernate.c and made available through accessor helpers hereby introduced. Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/power/user.c')
-rw-r--r--kernel/power/user.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 7959449765d9..98548d1cf8a6 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -37,8 +37,6 @@ static struct snapshot_data {
bool free_bitmaps;
} snapshot_state;
-atomic_t snapshot_device_available = ATOMIC_INIT(1);
-
static int snapshot_open(struct inode *inode, struct file *filp)
{
struct snapshot_data *data;
@@ -49,13 +47,13 @@ static int snapshot_open(struct inode *inode, struct file *filp)
lock_system_sleep();
- if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
+ if (!hibernate_acquire()) {
error = -EBUSY;
goto Unlock;
}
if ((filp->f_flags & O_ACCMODE) == O_RDWR) {
- atomic_inc(&snapshot_device_available);
+ hibernate_release();
error = -ENOSYS;
goto Unlock;
}
@@ -92,7 +90,7 @@ static int snapshot_open(struct inode *inode, struct file *filp)
__pm_notifier_call_chain(PM_POST_RESTORE, nr_calls, NULL);
}
if (error)
- atomic_inc(&snapshot_device_available);
+ hibernate_release();
data->frozen = false;
data->ready = false;
@@ -122,7 +120,7 @@ static int snapshot_release(struct inode *inode, struct file *filp)
}
pm_notifier_call_chain(data->mode == O_RDONLY ?
PM_POST_HIBERNATION : PM_POST_RESTORE);
- atomic_inc(&snapshot_device_available);
+ hibernate_release();
unlock_system_sleep();