Skip to content

Commit 1396651

Browse files
Ulf Hanssonrafaeljw
authored andcommitted
PM: runtime: Allow to call __pm_runtime_set_status() from atomic context
The only two users of __pm_runtime_set_status() are pm_runtime_set_active() and pm_runtime_set_suspended(). These are widely used and should be called from non-atomic context to work as expected. However, it would be convenient to allow them be called from atomic context too, as shown from a subsequent change, so let's add support for this. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Maulik Shah <quic_mkshah@quicinc.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent e5a3b0c commit 1396651

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drivers/base/power/runtime.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,12 +1210,13 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
12101210
{
12111211
struct device *parent = dev->parent;
12121212
bool notify_parent = false;
1213+
unsigned long flags;
12131214
int error = 0;
12141215

12151216
if (status != RPM_ACTIVE && status != RPM_SUSPENDED)
12161217
return -EINVAL;
12171218

1218-
spin_lock_irq(&dev->power.lock);
1219+
spin_lock_irqsave(&dev->power.lock, flags);
12191220

12201221
/*
12211222
* Prevent PM-runtime from being enabled for the device or return an
@@ -1226,7 +1227,7 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
12261227
else
12271228
error = -EAGAIN;
12281229

1229-
spin_unlock_irq(&dev->power.lock);
1230+
spin_unlock_irqrestore(&dev->power.lock, flags);
12301231

12311232
if (error)
12321233
return error;
@@ -1247,7 +1248,7 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
12471248
device_links_read_unlock(idx);
12481249
}
12491250

1250-
spin_lock_irq(&dev->power.lock);
1251+
spin_lock_irqsave(&dev->power.lock, flags);
12511252

12521253
if (dev->power.runtime_status == status || !parent)
12531254
goto out_set;
@@ -1288,7 +1289,7 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
12881289
dev->power.runtime_error = 0;
12891290

12901291
out:
1291-
spin_unlock_irq(&dev->power.lock);
1292+
spin_unlock_irqrestore(&dev->power.lock, flags);
12921293

12931294
if (notify_parent)
12941295
pm_request_idle(parent);

0 commit comments

Comments
 (0)