Skip to content

Commit 1476bb2

Browse files
committed
PM: runtime: Convert pm_runtime_blocked() to static inline
The comment in pm_runtime_blocked() is acutally wrong: power.last_status is not a bit field. Its data type is an enum and so one can reasonably assume that partial updates of it will not be observed. Accordingly, pm_runtime_blocked() can be converted to a static inline function and the related locking overhead can be eliminated, so long as it is only used in system suspend/resume code paths because power.last_status is not expected to be updated concurrently while that code is running. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://patch.msgid.link/1923449.tdWV9SEqCh@rjwysocki.net
1 parent cb88c22 commit 1476bb2

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

drivers/base/power/runtime.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,23 +1560,6 @@ void pm_runtime_enable(struct device *dev)
15601560
}
15611561
EXPORT_SYMBOL_GPL(pm_runtime_enable);
15621562

1563-
bool pm_runtime_blocked(struct device *dev)
1564-
{
1565-
bool ret;
1566-
1567-
/*
1568-
* dev->power.last_status is a bit field, so in case it is updated via
1569-
* RMW, read it under the spin lock.
1570-
*/
1571-
spin_lock_irq(&dev->power.lock);
1572-
1573-
ret = dev->power.last_status == RPM_BLOCKED;
1574-
1575-
spin_unlock_irq(&dev->power.lock);
1576-
1577-
return ret;
1578-
}
1579-
15801563
static void pm_runtime_disable_action(void *data)
15811564
{
15821565
pm_runtime_dont_use_autosuspend(data);

include/linux/pm_runtime.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ extern bool pm_runtime_block_if_disabled(struct device *dev);
8282
extern void pm_runtime_unblock(struct device *dev);
8383
extern void pm_runtime_enable(struct device *dev);
8484
extern void __pm_runtime_disable(struct device *dev, bool check_resume);
85-
extern bool pm_runtime_blocked(struct device *dev);
8685
extern void pm_runtime_allow(struct device *dev);
8786
extern void pm_runtime_forbid(struct device *dev);
8887
extern void pm_runtime_no_callbacks(struct device *dev);
@@ -200,6 +199,17 @@ static inline bool pm_runtime_enabled(struct device *dev)
200199
return !dev->power.disable_depth;
201200
}
202201

202+
/**
203+
* pm_runtime_blocked - Check if runtime PM enabling is blocked.
204+
* @dev: Target device.
205+
*
206+
* Do not call this function outside system suspend/resume code paths.
207+
*/
208+
static inline bool pm_runtime_blocked(struct device *dev)
209+
{
210+
return dev->power.last_status == RPM_BLOCKED;
211+
}
212+
203213
/**
204214
* pm_runtime_has_no_callbacks - Check if runtime PM callbacks may be present.
205215
* @dev: Target device.

0 commit comments

Comments
 (0)