Commit bed2b42d9f0b411f384c5619870ab0fea5dd116b
1 parent
e91c11b1a7
Exists in
master
and in
20 other branches
PM / Runtime: Allow helpers to be called by early platform drivers
Runtime PM helper functions, like pm_runtime_get_sync(), cannot be called by early platform device drivers, because the devices' power management locks are not initialized at that time. This is quite inconvenient, so modify early_platform_add_devices() to initialize the devices power management locks as appropriate and make sure that they won't be initialized more than once if an early platform device is going to be used as a regular one later. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Showing 3 changed files with 19 additions and 2 deletions Side-by-side Diff
drivers/base/platform.c
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | #include <linux/pm_runtime.h> |
23 | 23 | |
24 | 24 | #include "base.h" |
25 | +#include "power/power.h" | |
25 | 26 | |
26 | 27 | #define to_platform_driver(drv) (container_of((drv), struct platform_driver, \ |
27 | 28 | driver)) |
... | ... | @@ -948,6 +949,7 @@ |
948 | 949 | dev = &devs[i]->dev; |
949 | 950 | |
950 | 951 | if (!dev->devres_head.next) { |
952 | + pm_runtime_early_init(dev); | |
951 | 953 | INIT_LIST_HEAD(&dev->devres_head); |
952 | 954 | list_add_tail(&dev->devres_head, |
953 | 955 | &early_platform_device_list); |
drivers/base/power/power.h
... | ... | @@ -2,16 +2,30 @@ |
2 | 2 | |
3 | 3 | static inline void device_pm_init_common(struct device *dev) |
4 | 4 | { |
5 | - spin_lock_init(&dev->power.lock); | |
6 | - dev->power.power_state = PMSG_INVALID; | |
5 | + if (!dev->power.early_init) { | |
6 | + spin_lock_init(&dev->power.lock); | |
7 | + dev->power.power_state = PMSG_INVALID; | |
8 | + dev->power.early_init = true; | |
9 | + } | |
7 | 10 | } |
8 | 11 | |
9 | 12 | #ifdef CONFIG_PM_RUNTIME |
10 | 13 | |
14 | +static inline void pm_runtime_early_init(struct device *dev) | |
15 | +{ | |
16 | + dev->power.disable_depth = 1; | |
17 | + device_pm_init_common(dev); | |
18 | +} | |
19 | + | |
11 | 20 | extern void pm_runtime_init(struct device *dev); |
12 | 21 | extern void pm_runtime_remove(struct device *dev); |
13 | 22 | |
14 | 23 | #else /* !CONFIG_PM_RUNTIME */ |
24 | + | |
25 | +static inline void pm_runtime_early_init(struct device *dev) | |
26 | +{ | |
27 | + device_pm_init_common(dev); | |
28 | +} | |
15 | 29 | |
16 | 30 | static inline void pm_runtime_init(struct device *dev) {} |
17 | 31 | static inline void pm_runtime_remove(struct device *dev) {} |
include/linux/pm.h