diff options
-rw-r--r-- | Documentation/devicetree/bindings/power/power_domain.txt | 8 | ||||
-rw-r--r-- | Documentation/driver-api/device_link.rst | 12 | ||||
-rw-r--r-- | Documentation/power/freezing-of-tasks.txt | 12 | ||||
-rw-r--r-- | Documentation/power/suspend-and-cpuhotplug.txt | 6 | ||||
-rw-r--r-- | arch/x86/power/hibernate_64.c | 36 | ||||
-rw-r--r-- | drivers/acpi/sleep.c | 30 | ||||
-rw-r--r-- | drivers/base/core.c | 25 | ||||
-rw-r--r-- | drivers/base/power/common.c | 17 | ||||
-rw-r--r-- | drivers/base/power/domain.c | 24 | ||||
-rw-r--r-- | drivers/cpuidle/cpuidle-arm.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/tegra/dc.c | 2 | ||||
-rw-r--r-- | drivers/gpu/ipu-v3/ipu-pre.c | 3 | ||||
-rw-r--r-- | drivers/gpu/ipu-v3/ipu-prg.c | 3 | ||||
-rw-r--r-- | drivers/soc/imx/gpc.c | 2 | ||||
-rw-r--r-- | include/linux/device.h | 14 | ||||
-rw-r--r-- | include/linux/pm_domain.h | 15 | ||||
-rw-r--r-- | include/linux/suspend.h | 2 | ||||
-rw-r--r-- | kernel/freezer.c | 4 | ||||
-rw-r--r-- | kernel/power/hibernate.c | 16 | ||||
-rw-r--r-- | kernel/power/main.c | 12 | ||||
-rw-r--r-- | kernel/power/suspend.c | 4 | ||||
-rw-r--r-- | kernel/power/swap.c | 4 | ||||
-rw-r--r-- | kernel/power/user.c | 4 | ||||
-rw-r--r-- | kernel/reboot.c | 6 | ||||
-rw-r--r-- | mm/page_alloc.c | 11 |
25 files changed, 186 insertions, 89 deletions
diff --git a/Documentation/devicetree/bindings/power/power_domain.txt b/Documentation/devicetree/bindings/power/power_domain.txt index 7dec508987c7..8f8b25a24b8f 100644 --- a/Documentation/devicetree/bindings/power/power_domain.txt +++ b/Documentation/devicetree/bindings/power/power_domain.txt | |||
@@ -114,18 +114,26 @@ Required properties: | |||
114 | - power-domains : A list of PM domain specifiers, as defined by bindings of | 114 | - power-domains : A list of PM domain specifiers, as defined by bindings of |
115 | the power controller that is the PM domain provider. | 115 | the power controller that is the PM domain provider. |
116 | 116 | ||
117 | Optional properties: | ||
118 | - power-domain-names : A list of power domain name strings sorted in the same | ||
119 | order as the power-domains property. Consumers drivers will use | ||
120 | power-domain-names to match power domains with power-domains | ||
121 | specifiers. | ||
122 | |||
117 | Example: | 123 | Example: |
118 | 124 | ||
119 | leaky-device@12350000 { | 125 | leaky-device@12350000 { |
120 | compatible = "foo,i-leak-current"; | 126 | compatible = "foo,i-leak-current"; |
121 | reg = <0x12350000 0x1000>; | 127 | reg = <0x12350000 0x1000>; |
122 | power-domains = <&power 0>; | 128 | power-domains = <&power 0>; |
129 | power-domain-names = "io"; | ||
123 | }; | 130 | }; |
124 | 131 | ||
125 | leaky-device@12351000 { | 132 | leaky-device@12351000 { |
126 | compatible = "foo,i-leak-current"; | 133 | compatible = "foo,i-leak-current"; |
127 | reg = <0x12351000 0x1000>; | 134 | reg = <0x12351000 0x1000>; |
128 | power-domains = <&power 0>, <&power 1> ; | 135 | power-domains = <&power 0>, <&power 1> ; |
136 | power-domain-names = "io", "clk"; | ||
129 | }; | 137 | }; |
130 | 138 | ||
131 | The first example above defines a typical PM domain consumer device, which is | 139 | The first example above defines a typical PM domain consumer device, which is |
diff --git a/Documentation/driver-api/device_link.rst b/Documentation/driver-api/device_link.rst index 70e328e16aad..d6763272e747 100644 --- a/Documentation/driver-api/device_link.rst +++ b/Documentation/driver-api/device_link.rst | |||
@@ -81,10 +81,14 @@ integration is desired. | |||
81 | Two other flags are specifically targeted at use cases where the device | 81 | Two other flags are specifically targeted at use cases where the device |
82 | link is added from the consumer's ``->probe`` callback: ``DL_FLAG_RPM_ACTIVE`` | 82 | link is added from the consumer's ``->probe`` callback: ``DL_FLAG_RPM_ACTIVE`` |
83 | can be specified to runtime resume the supplier upon addition of the | 83 | can be specified to runtime resume the supplier upon addition of the |
84 | device link. ``DL_FLAG_AUTOREMOVE`` causes the device link to be automatically | 84 | device link. ``DL_FLAG_AUTOREMOVE_CONSUMER`` causes the device link to be |
85 | purged when the consumer fails to probe or later unbinds. This obviates | 85 | automatically purged when the consumer fails to probe or later unbinds. |
86 | the need to explicitly delete the link in the ``->remove`` callback or in | 86 | This obviates the need to explicitly delete the link in the ``->remove`` |
87 | the error path of the ``->probe`` callback. | 87 | callback or in the error path of the ``->probe`` callback. |
88 | |||
89 | Similarly, when the device link is added from supplier's ``->probe`` callback, | ||
90 | ``DL_FLAG_AUTOREMOVE_SUPPLIER`` causes the device link to be automatically | ||
91 | purged when the supplier fails to probe or later unbinds. | ||
88 | 92 | ||
89 | Limitations | 93 | Limitations |
90 | =========== | 94 | =========== |
diff --git a/Documentation/power/freezing-of-tasks.txt b/Documentation/power/freezing-of-tasks.txt index af005770e767..cd283190855a 100644 --- a/Documentation/power/freezing-of-tasks.txt +++ b/Documentation/power/freezing-of-tasks.txt | |||
@@ -204,26 +204,26 @@ VI. Are there any precautions to be taken to prevent freezing failures? | |||
204 | 204 | ||
205 | Yes, there are. | 205 | Yes, there are. |
206 | 206 | ||
207 | First of all, grabbing the 'pm_mutex' lock to mutually exclude a piece of code | 207 | First of all, grabbing the 'system_transition_mutex' lock to mutually exclude a piece of code |
208 | from system-wide sleep such as suspend/hibernation is not encouraged. | 208 | from system-wide sleep such as suspend/hibernation is not encouraged. |
209 | If possible, that piece of code must instead hook onto the suspend/hibernation | 209 | If possible, that piece of code must instead hook onto the suspend/hibernation |
210 | notifiers to achieve mutual exclusion. Look at the CPU-Hotplug code | 210 | notifiers to achieve mutual exclusion. Look at the CPU-Hotplug code |
211 | (kernel/cpu.c) for an example. | 211 | (kernel/cpu.c) for an example. |
212 | 212 | ||
213 | However, if that is not feasible, and grabbing 'pm_mutex' is deemed necessary, | 213 | However, if that is not feasible, and grabbing 'system_transition_mutex' is deemed necessary, |
214 | it is strongly discouraged to directly call mutex_[un]lock(&pm_mutex) since | 214 | it is strongly discouraged to directly call mutex_[un]lock(&system_transition_mutex) since |
215 | that could lead to freezing failures, because if the suspend/hibernate code | 215 | that could lead to freezing failures, because if the suspend/hibernate code |
216 | successfully acquired the 'pm_mutex' lock, and hence that other entity failed | 216 | successfully acquired the 'system_transition_mutex' lock, and hence that other entity failed |
217 | to acquire the lock, then that task would get blocked in TASK_UNINTERRUPTIBLE | 217 | to acquire the lock, then that task would get blocked in TASK_UNINTERRUPTIBLE |
218 | state. As a consequence, the freezer would not be able to freeze that task, | 218 | state. As a consequence, the freezer would not be able to freeze that task, |
219 | leading to freezing failure. | 219 | leading to freezing failure. |
220 | 220 | ||
221 | However, the [un]lock_system_sleep() APIs are safe to use in this scenario, | 221 | However, the [un]lock_system_sleep() APIs are safe to use in this scenario, |
222 | since they ask the freezer to skip freezing this task, since it is anyway | 222 | since they ask the freezer to skip freezing this task, since it is anyway |
223 | "frozen enough" as it is blocked on 'pm_mutex', which will be released | 223 | "frozen enough" as it is blocked on 'system_transition_mutex', which will be released |
224 | only after the entire suspend/hibernation sequence is complete. | 224 | only after the entire suspend/hibernation sequence is complete. |
225 | So, to summarize, use [un]lock_system_sleep() instead of directly using | 225 | So, to summarize, use [un]lock_system_sleep() instead of directly using |
226 | mutex_[un]lock(&pm_mutex). That would prevent freezing failures. | 226 | mutex_[un]lock(&system_transition_mutex). That would prevent freezing failures. |
227 | 227 | ||
228 | V. Miscellaneous | 228 | V. Miscellaneous |
229 | /sys/power/pm_freeze_timeout controls how long it will cost at most to freeze | 229 | /sys/power/pm_freeze_timeout controls how long it will cost at most to freeze |
diff --git a/Documentation/power/suspend-and-cpuhotplug.txt b/Documentation/power/suspend-and-cpuhotplug.txt index 6f55eb960a6d..a8751b8df10e 100644 --- a/Documentation/power/suspend-and-cpuhotplug.txt +++ b/Documentation/power/suspend-and-cpuhotplug.txt | |||
@@ -32,7 +32,7 @@ More details follow: | |||
32 | sysfs file | 32 | sysfs file |
33 | | | 33 | | |
34 | v | 34 | v |
35 | Acquire pm_mutex lock | 35 | Acquire system_transition_mutex lock |
36 | | | 36 | | |
37 | v | 37 | v |
38 | Send PM_SUSPEND_PREPARE | 38 | Send PM_SUSPEND_PREPARE |
@@ -96,10 +96,10 @@ execution during resume): | |||
96 | 96 | ||
97 | * thaw tasks | 97 | * thaw tasks |
98 | * send PM_POST_SUSPEND notifications | 98 | * send PM_POST_SUSPEND notifications |
99 | * Release pm_mutex lock. | 99 | * Release system_transition_mutex lock. |
100 | 100 | ||
101 | 101 | ||
102 | It is to be noted here that the pm_mutex lock is acquired at the very | 102 | It is to be noted here that the system_transition_mutex lock is acquired at the very |
103 | beginning, when we are just starting out to suspend, and then released only | 103 | beginning, when we are just starting out to suspend, and then released only |
104 | after the entire cycle is complete (i.e., suspend + resume). | 104 | after the entire cycle is complete (i.e., suspend + resume). |
105 | 105 | ||
diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c index 67ccf64c8bd8..f8e3b668d20b 100644 --- a/arch/x86/power/hibernate_64.c +++ b/arch/x86/power/hibernate_64.c | |||
@@ -233,29 +233,35 @@ struct restore_data_record { | |||
233 | */ | 233 | */ |
234 | static int get_e820_md5(struct e820_table *table, void *buf) | 234 | static int get_e820_md5(struct e820_table *table, void *buf) |
235 | { | 235 | { |
236 | struct scatterlist sg; | 236 | struct crypto_shash *tfm; |
237 | struct crypto_ahash *tfm; | 237 | struct shash_desc *desc; |
238 | int size; | 238 | int size; |
239 | int ret = 0; | 239 | int ret = 0; |
240 | 240 | ||
241 | tfm = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC); | 241 | tfm = crypto_alloc_shash("md5", 0, 0); |
242 | if (IS_ERR(tfm)) | 242 | if (IS_ERR(tfm)) |
243 | return -ENOMEM; | 243 | return -ENOMEM; |
244 | 244 | ||
245 | { | 245 | desc = kmalloc(sizeof(struct shash_desc) + crypto_shash_descsize(tfm), |
246 | AHASH_REQUEST_ON_STACK(req, tfm); | 246 | GFP_KERNEL); |
247 | size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry) * table->nr_entries; | 247 | if (!desc) { |
248 | ahash_request_set_tfm(req, tfm); | 248 | ret = -ENOMEM; |
249 | sg_init_one(&sg, (u8 *)table, size); | 249 | goto free_tfm; |
250 | ahash_request_set_callback(req, 0, NULL, NULL); | ||
251 | ahash_request_set_crypt(req, &sg, buf, size); | ||
252 | |||
253 | if (crypto_ahash_digest(req)) | ||
254 | ret = -EINVAL; | ||
255 | ahash_request_zero(req); | ||
256 | } | 250 | } |
257 | crypto_free_ahash(tfm); | ||
258 | 251 | ||
252 | desc->tfm = tfm; | ||
253 | desc->flags = 0; | ||
254 | |||
255 | size = offsetof(struct e820_table, entries) + | ||
256 | sizeof(struct e820_entry) * table->nr_entries; | ||
257 | |||
258 | if (crypto_shash_digest(desc, (u8 *)table, size, buf)) | ||
259 | ret = -EINVAL; | ||
260 | |||
261 | kzfree(desc); | ||
262 | |||
263 | free_tfm: | ||
264 | crypto_free_shash(tfm); | ||
259 | return ret; | 265 | return ret; |
260 | } | 266 | } |
261 | 267 | ||
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 5d0486f1cfcd..754d59f95500 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -338,6 +338,14 @@ static const struct dmi_system_id acpisleep_dmi_table[] __initconst = { | |||
338 | DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"), | 338 | DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"), |
339 | }, | 339 | }, |
340 | }, | 340 | }, |
341 | { | ||
342 | .callback = init_nvs_save_s3, | ||
343 | .ident = "Asus 1025C", | ||
344 | .matches = { | ||
345 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), | ||
346 | DMI_MATCH(DMI_PRODUCT_NAME, "1025C"), | ||
347 | }, | ||
348 | }, | ||
341 | /* | 349 | /* |
342 | * https://bugzilla.kernel.org/show_bug.cgi?id=189431 | 350 | * https://bugzilla.kernel.org/show_bug.cgi?id=189431 |
343 | * Lenovo G50-45 is a platform later than 2012, but needs nvs memory | 351 | * Lenovo G50-45 is a platform later than 2012, but needs nvs memory |
@@ -718,9 +726,6 @@ static const struct acpi_device_id lps0_device_ids[] = { | |||
718 | #define ACPI_LPS0_ENTRY 5 | 726 | #define ACPI_LPS0_ENTRY 5 |
719 | #define ACPI_LPS0_EXIT 6 | 727 | #define ACPI_LPS0_EXIT 6 |
720 | 728 | ||
721 | #define ACPI_LPS0_SCREEN_MASK ((1 << ACPI_LPS0_SCREEN_OFF) | (1 << ACPI_LPS0_SCREEN_ON)) | ||
722 | #define ACPI_LPS0_PLATFORM_MASK ((1 << ACPI_LPS0_ENTRY) | (1 << ACPI_LPS0_EXIT)) | ||
723 | |||
724 | static acpi_handle lps0_device_handle; | 729 | static acpi_handle lps0_device_handle; |
725 | static guid_t lps0_dsm_guid; | 730 | static guid_t lps0_dsm_guid; |
726 | static char lps0_dsm_func_mask; | 731 | static char lps0_dsm_func_mask; |
@@ -924,17 +929,14 @@ static int lps0_device_attach(struct acpi_device *adev, | |||
924 | if (out_obj && out_obj->type == ACPI_TYPE_BUFFER) { | 929 | if (out_obj && out_obj->type == ACPI_TYPE_BUFFER) { |
925 | char bitmask = *(char *)out_obj->buffer.pointer; | 930 | char bitmask = *(char *)out_obj->buffer.pointer; |
926 | 931 | ||
927 | if ((bitmask & ACPI_LPS0_PLATFORM_MASK) == ACPI_LPS0_PLATFORM_MASK || | 932 | lps0_dsm_func_mask = bitmask; |
928 | (bitmask & ACPI_LPS0_SCREEN_MASK) == ACPI_LPS0_SCREEN_MASK) { | 933 | lps0_device_handle = adev->handle; |
929 | lps0_dsm_func_mask = bitmask; | 934 | /* |
930 | lps0_device_handle = adev->handle; | 935 | * Use suspend-to-idle by default if the default |
931 | /* | 936 | * suspend mode was not set from the command line. |
932 | * Use suspend-to-idle by default if the default | 937 | */ |
933 | * suspend mode was not set from the command line. | 938 | if (mem_sleep_default > PM_SUSPEND_MEM) |
934 | */ | 939 | mem_sleep_current = PM_SUSPEND_TO_IDLE; |
935 | if (mem_sleep_default > PM_SUSPEND_MEM) | ||
936 | mem_sleep_current = PM_SUSPEND_TO_IDLE; | ||
937 | } | ||
938 | 940 | ||
939 | acpi_handle_debug(adev->handle, "_DSM function mask: 0x%x\n", | 941 | acpi_handle_debug(adev->handle, "_DSM function mask: 0x%x\n", |
940 | bitmask); | 942 | bitmask); |
diff --git a/drivers/base/core.c b/drivers/base/core.c index df3e1a44707a..e721218bf352 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -178,10 +178,10 @@ void device_pm_move_to_tail(struct device *dev) | |||
178 | * of the link. If DL_FLAG_PM_RUNTIME is not set, DL_FLAG_RPM_ACTIVE will be | 178 | * of the link. If DL_FLAG_PM_RUNTIME is not set, DL_FLAG_RPM_ACTIVE will be |
179 | * ignored. | 179 | * ignored. |
180 | * | 180 | * |
181 | * If the DL_FLAG_AUTOREMOVE is set, the link will be removed automatically | 181 | * If the DL_FLAG_AUTOREMOVE_CONSUMER is set, the link will be removed |
182 | * when the consumer device driver unbinds from it. The combination of both | 182 | * automatically when the consumer device driver unbinds from it. |
183 | * DL_FLAG_AUTOREMOVE and DL_FLAG_STATELESS set is invalid and will cause NULL | 183 | * The combination of both DL_FLAG_AUTOREMOVE_CONSUMER and DL_FLAG_STATELESS |
184 | * to be returned. | 184 | * set is invalid and will cause NULL to be returned. |
185 | * | 185 | * |
186 | * A side effect of the link creation is re-ordering of dpm_list and the | 186 | * A side effect of the link creation is re-ordering of dpm_list and the |
187 | * devices_kset list by moving the consumer device and all devices depending | 187 | * devices_kset list by moving the consumer device and all devices depending |
@@ -198,7 +198,8 @@ struct device_link *device_link_add(struct device *consumer, | |||
198 | struct device_link *link; | 198 | struct device_link *link; |
199 | 199 | ||
200 | if (!consumer || !supplier || | 200 | if (!consumer || !supplier || |
201 | ((flags & DL_FLAG_STATELESS) && (flags & DL_FLAG_AUTOREMOVE))) | 201 | ((flags & DL_FLAG_STATELESS) && |
202 | (flags & DL_FLAG_AUTOREMOVE_CONSUMER))) | ||
202 | return NULL; | 203 | return NULL; |
203 | 204 | ||
204 | device_links_write_lock(); | 205 | device_links_write_lock(); |
@@ -479,7 +480,7 @@ static void __device_links_no_driver(struct device *dev) | |||
479 | if (link->flags & DL_FLAG_STATELESS) | 480 | if (link->flags & DL_FLAG_STATELESS) |
480 | continue; | 481 | continue; |
481 | 482 | ||
482 | if (link->flags & DL_FLAG_AUTOREMOVE) | 483 | if (link->flags & DL_FLAG_AUTOREMOVE_CONSUMER) |
483 | kref_put(&link->kref, __device_link_del); | 484 | kref_put(&link->kref, __device_link_del); |
484 | else if (link->status != DL_STATE_SUPPLIER_UNBIND) | 485 | else if (link->status != DL_STATE_SUPPLIER_UNBIND) |
485 | WRITE_ONCE(link->status, DL_STATE_AVAILABLE); | 486 | WRITE_ONCE(link->status, DL_STATE_AVAILABLE); |
@@ -515,8 +516,18 @@ void device_links_driver_cleanup(struct device *dev) | |||
515 | if (link->flags & DL_FLAG_STATELESS) | 516 | if (link->flags & DL_FLAG_STATELESS) |
516 | continue; | 517 | continue; |
517 | 518 | ||
518 | WARN_ON(link->flags & DL_FLAG_AUTOREMOVE); | 519 | WARN_ON(link->flags & DL_FLAG_AUTOREMOVE_CONSUMER); |
519 | WARN_ON(link->status != DL_STATE_SUPPLIER_UNBIND); | 520 | WARN_ON(link->status != DL_STATE_SUPPLIER_UNBIND); |
521 | |||
522 | /* | ||
523 | * autoremove the links between this @dev and its consumer | ||
524 | * devices that are not active, i.e. where the link state | ||
525 | * has moved to DL_STATE_SUPPLIER_UNBIND. | ||
526 | */ | ||
527 | if (link->status == DL_STATE_SUPPLIER_UNBIND && | ||
528 | link->flags & DL_FLAG_AUTOREMOVE_SUPPLIER) | ||
529 | kref_put(&link->kref, __device_link_del); | ||
530 | |||
520 | WRITE_ONCE(link->status, DL_STATE_DORMANT); | 531 | WRITE_ONCE(link->status, DL_STATE_DORMANT); |
521 | } | 532 | } |
522 | 533 | ||
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index df41b4780b3b..b413951c6abc 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c | |||
@@ -153,6 +153,23 @@ struct device *dev_pm_domain_attach_by_id(struct device *dev, | |||
153 | EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id); | 153 | EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * dev_pm_domain_attach_by_name - Associate a device with one of its PM domains. | ||
157 | * @dev: The device used to lookup the PM domain. | ||
158 | * @name: The name of the PM domain. | ||
159 | * | ||
160 | * For a detailed function description, see dev_pm_domain_attach_by_id(). | ||
161 | */ | ||
162 | struct device *dev_pm_domain_attach_by_name(struct device *dev, | ||
163 | char *name) | ||
164 | { | ||
165 | if (dev->pm_domain) | ||
166 | return ERR_PTR(-EEXIST); | ||
167 | |||
168 | return genpd_dev_pm_attach_by_name(dev, name); | ||
169 | } | ||
170 | EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_name); | ||
171 | |||
172 | /** | ||
156 | * dev_pm_domain_detach - Detach a device from its PM domain. | 173 | * dev_pm_domain_detach - Detach a device from its PM domain. |
157 | * @dev: Device to detach. | 174 | * @dev: Device to detach. |
158 | * @power_off: Used to indicate whether we should power off the device. | 175 | * @power_off: Used to indicate whether we should power off the device. |
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 9e8484189034..79bdca70a81a 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c | |||
@@ -2374,6 +2374,30 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, | |||
2374 | } | 2374 | } |
2375 | EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id); | 2375 | EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id); |
2376 | 2376 | ||
2377 | /** | ||
2378 | * genpd_dev_pm_attach_by_name - Associate a device with one of its PM domains. | ||
2379 | * @dev: The device used to lookup the PM domain. | ||
2380 | * @name: The name of the PM domain. | ||
2381 | * | ||
2382 | * Parse device's OF node to find a PM domain specifier using the | ||
2383 | * power-domain-names DT property. For further description see | ||
2384 | * genpd_dev_pm_attach_by_id(). | ||
2385 | */ | ||
2386 | struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name) | ||
2387 | { | ||
2388 | int index; | ||
2389 | |||
2390 | if (!dev->of_node) | ||
2391 | return NULL; | ||
2392 | |||
2393 | index = of_property_match_string(dev->of_node, "power-domain-names", | ||
2394 | name); | ||
2395 | if (index < 0) | ||
2396 | return NULL; | ||
2397 | |||
2398 | return genpd_dev_pm_attach_by_id(dev, index); | ||
2399 | } | ||
2400 | |||
2377 | static const struct of_device_id idle_state_match[] = { | 2401 | static const struct of_device_id idle_state_match[] = { |
2378 | { .compatible = "domain-idle-state", }, | 2402 | { .compatible = "domain-idle-state", }, |
2379 | { } | 2403 | { } |
diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index e07bc7ace774..073557f433eb 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c | |||
@@ -105,7 +105,8 @@ static int __init arm_idle_init_cpu(int cpu) | |||
105 | 105 | ||
106 | ret = cpuidle_register_driver(drv); | 106 | ret = cpuidle_register_driver(drv); |
107 | if (ret) { | 107 | if (ret) { |
108 | pr_err("Failed to register cpuidle driver\n"); | 108 | if (ret != -EBUSY) |
109 | pr_err("Failed to register cpuidle driver\n"); | ||
109 | goto out_kfree_drv; | 110 | goto out_kfree_drv; |
110 | } | 111 | } |
111 | 112 | ||
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index c3afe7b2237e..965088afcfad 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c | |||
@@ -2312,7 +2312,7 @@ static int tegra_dc_couple(struct tegra_dc *dc) | |||
2312 | * POWER_CONTROL registers during CRTC enabling. | 2312 | * POWER_CONTROL registers during CRTC enabling. |
2313 | */ | 2313 | */ |
2314 | if (dc->soc->coupled_pm && dc->pipe == 1) { | 2314 | if (dc->soc->coupled_pm && dc->pipe == 1) { |
2315 | u32 flags = DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE; | 2315 | u32 flags = DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_CONSUMER; |
2316 | struct device_link *link; | 2316 | struct device_link *link; |
2317 | struct device *partner; | 2317 | struct device *partner; |
2318 | 2318 | ||
diff --git a/drivers/gpu/ipu-v3/ipu-pre.c b/drivers/gpu/ipu-v3/ipu-pre.c index 0f70e8847540..2f8db9d62551 100644 --- a/drivers/gpu/ipu-v3/ipu-pre.c +++ b/drivers/gpu/ipu-v3/ipu-pre.c | |||
@@ -128,7 +128,8 @@ ipu_pre_lookup_by_phandle(struct device *dev, const char *name, int index) | |||
128 | list_for_each_entry(pre, &ipu_pre_list, list) { | 128 | list_for_each_entry(pre, &ipu_pre_list, list) { |
129 | if (pre_node == pre->dev->of_node) { | 129 | if (pre_node == pre->dev->of_node) { |
130 | mutex_unlock(&ipu_pre_list_mutex); | 130 | mutex_unlock(&ipu_pre_list_mutex); |
131 | device_link_add(dev, pre->dev, DL_FLAG_AUTOREMOVE); | 131 | device_link_add(dev, pre->dev, |
132 | DL_FLAG_AUTOREMOVE_CONSUMER); | ||
132 | of_node_put(pre_node); | 133 | of_node_put(pre_node); |
133 | return pre; | 134 | return pre; |
134 | } | 135 | } |
diff --git a/drivers/gpu/ipu-v3/ipu-prg.c b/drivers/gpu/ipu-v3/ipu-prg.c index 83f9dd934a5d..38a3a9764e49 100644 --- a/drivers/gpu/ipu-v3/ipu-prg.c +++ b/drivers/gpu/ipu-v3/ipu-prg.c | |||
@@ -100,7 +100,8 @@ ipu_prg_lookup_by_phandle(struct device *dev, const char *name, int ipu_id) | |||
100 | list_for_each_entry(prg, &ipu_prg_list, list) { | 100 | list_for_each_entry(prg, &ipu_prg_list, list) { |
101 | if (prg_node == prg->dev->of_node) { | 101 | if (prg_node == prg->dev->of_node) { |
102 | mutex_unlock(&ipu_prg_list_mutex); | 102 | mutex_unlock(&ipu_prg_list_mutex); |
103 | device_link_add(dev, prg->dev, DL_FLAG_AUTOREMOVE); | 103 | device_link_add(dev, prg->dev, |
104 | DL_FLAG_AUTOREMOVE_CONSUMER); | ||
104 | prg->id = ipu_id; | 105 | prg->id = ipu_id; |
105 | of_node_put(prg_node); | 106 | of_node_put(prg_node); |
106 | return prg; | 107 | return prg; |
diff --git a/drivers/soc/imx/gpc.c b/drivers/soc/imx/gpc.c index 0097a939487f..546960a18d60 100644 --- a/drivers/soc/imx/gpc.c +++ b/drivers/soc/imx/gpc.c | |||
@@ -209,7 +209,7 @@ static int imx_pgc_power_domain_probe(struct platform_device *pdev) | |||
209 | goto genpd_err; | 209 | goto genpd_err; |
210 | } | 210 | } |
211 | 211 | ||
212 | device_link_add(dev, dev->parent, DL_FLAG_AUTOREMOVE); | 212 | device_link_add(dev, dev->parent, DL_FLAG_AUTOREMOVE_CONSUMER); |
213 | 213 | ||
214 | return 0; | 214 | return 0; |
215 | 215 | ||
diff --git a/include/linux/device.h b/include/linux/device.h index 055a69dbcd18..e80920452b49 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -90,7 +90,7 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | |||
90 | * @num_vf: Called to find out how many virtual functions a device on this | 90 | * @num_vf: Called to find out how many virtual functions a device on this |
91 | * bus supports. | 91 | * bus supports. |
92 | * @dma_configure: Called to setup DMA configuration on a device on | 92 | * @dma_configure: Called to setup DMA configuration on a device on |
93 | this bus. | 93 | * this bus. |
94 | * @pm: Power management operations of this bus, callback the specific | 94 | * @pm: Power management operations of this bus, callback the specific |
95 | * device driver's pm-ops. | 95 | * device driver's pm-ops. |
96 | * @iommu_ops: IOMMU specific operations for this bus, used to attach IOMMU | 96 | * @iommu_ops: IOMMU specific operations for this bus, used to attach IOMMU |
@@ -784,14 +784,16 @@ enum device_link_state { | |||
784 | * Device link flags. | 784 | * Device link flags. |
785 | * | 785 | * |
786 | * STATELESS: The core won't track the presence of supplier/consumer drivers. | 786 | * STATELESS: The core won't track the presence of supplier/consumer drivers. |
787 | * AUTOREMOVE: Remove this link automatically on consumer driver unbind. | 787 | * AUTOREMOVE_CONSUMER: Remove the link automatically on consumer driver unbind. |
788 | * PM_RUNTIME: If set, the runtime PM framework will use this link. | 788 | * PM_RUNTIME: If set, the runtime PM framework will use this link. |
789 | * RPM_ACTIVE: Run pm_runtime_get_sync() on the supplier during link creation. | 789 | * RPM_ACTIVE: Run pm_runtime_get_sync() on the supplier during link creation. |
790 | * AUTOREMOVE_SUPPLIER: Remove the link automatically on supplier driver unbind. | ||
790 | */ | 791 | */ |
791 | #define DL_FLAG_STATELESS BIT(0) | 792 | #define DL_FLAG_STATELESS BIT(0) |
792 | #define DL_FLAG_AUTOREMOVE BIT(1) | 793 | #define DL_FLAG_AUTOREMOVE_CONSUMER BIT(1) |
793 | #define DL_FLAG_PM_RUNTIME BIT(2) | 794 | #define DL_FLAG_PM_RUNTIME BIT(2) |
794 | #define DL_FLAG_RPM_ACTIVE BIT(3) | 795 | #define DL_FLAG_RPM_ACTIVE BIT(3) |
796 | #define DL_FLAG_AUTOREMOVE_SUPPLIER BIT(4) | ||
795 | 797 | ||
796 | /** | 798 | /** |
797 | * struct device_link - Device link representation. | 799 | * struct device_link - Device link representation. |
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index cb8d84090cfb..776c546d581a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h | |||
@@ -239,6 +239,8 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev, | |||
239 | int genpd_dev_pm_attach(struct device *dev); | 239 | int genpd_dev_pm_attach(struct device *dev); |
240 | struct device *genpd_dev_pm_attach_by_id(struct device *dev, | 240 | struct device *genpd_dev_pm_attach_by_id(struct device *dev, |
241 | unsigned int index); | 241 | unsigned int index); |
242 | struct device *genpd_dev_pm_attach_by_name(struct device *dev, | ||
243 | char *name); | ||
242 | #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ | 244 | #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ |
243 | static inline int of_genpd_add_provider_simple(struct device_node *np, | 245 | static inline int of_genpd_add_provider_simple(struct device_node *np, |
244 | struct generic_pm_domain *genpd) | 246 | struct generic_pm_domain *genpd) |
@@ -290,6 +292,12 @@ static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev, | |||
290 | return NULL; | 292 | return NULL; |
291 | } | 293 | } |
292 | 294 | ||
295 | static inline struct device *genpd_dev_pm_attach_by_name(struct device *dev, | ||
296 | char *name) | ||
297 | { | ||
298 | return NULL; | ||
299 | } | ||
300 | |||
293 | static inline | 301 | static inline |
294 | struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) | 302 | struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) |
295 | { | 303 | { |
@@ -301,6 +309,8 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) | |||
301 | int dev_pm_domain_attach(struct device *dev, bool power_on); | 309 | int dev_pm_domain_attach(struct device *dev, bool power_on); |
302 | struct device *dev_pm_domain_attach_by_id(struct device *dev, | 310 | struct device *dev_pm_domain_attach_by_id(struct device *dev, |
303 | unsigned int index); | 311 | unsigned int index); |
312 | struct device *dev_pm_domain_attach_by_name(struct device *dev, | ||
313 | char *name); | ||
304 | void dev_pm_domain_detach(struct device *dev, bool power_off); | 314 | void dev_pm_domain_detach(struct device *dev, bool power_off); |
305 | void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); | 315 | void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); |
306 | #else | 316 | #else |
@@ -313,6 +323,11 @@ static inline struct device *dev_pm_domain_attach_by_id(struct device *dev, | |||
313 | { | 323 | { |
314 | return NULL; | 324 | return NULL; |
315 | } | 325 | } |
326 | static inline struct device *dev_pm_domain_attach_by_name(struct device *dev, | ||
327 | char *name) | ||
328 | { | ||
329 | return NULL; | ||
330 | } | ||
316 | static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {} | 331 | static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {} |
317 | static inline void dev_pm_domain_set(struct device *dev, | 332 | static inline void dev_pm_domain_set(struct device *dev, |
318 | struct dev_pm_domain *pd) {} | 333 | struct dev_pm_domain *pd) {} |
diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 440b62f7502e..5a28ac9284f0 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
@@ -414,7 +414,7 @@ static inline bool hibernation_available(void) { return false; } | |||
414 | #define PM_RESTORE_PREPARE 0x0005 /* Going to restore a saved image */ | 414 | #define PM_RESTORE_PREPARE 0x0005 /* Going to restore a saved image */ |
415 | #define PM_POST_RESTORE 0x0006 /* Restore failed */ | 415 | #define PM_POST_RESTORE 0x0006 /* Restore failed */ |
416 | 416 | ||
417 | extern struct mutex pm_mutex; | 417 | extern struct mutex system_transition_mutex; |
418 | 418 | ||
419 | #ifdef CONFIG_PM_SLEEP | 419 | #ifdef CONFIG_PM_SLEEP |
420 | void save_processor_state(void); | 420 | void save_processor_state(void); |
diff --git a/kernel/freezer.c b/kernel/freezer.c index 6f56a9e219fa..b162b74611e4 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c | |||
@@ -15,7 +15,9 @@ | |||
15 | atomic_t system_freezing_cnt = ATOMIC_INIT(0); | 15 | atomic_t system_freezing_cnt = ATOMIC_INIT(0); |
16 | EXPORT_SYMBOL(system_freezing_cnt); | 16 | EXPORT_SYMBOL(system_freezing_cnt); |
17 | 17 | ||
18 | /* indicate whether PM freezing is in effect, protected by pm_mutex */ | 18 | /* indicate whether PM freezing is in effect, protected by |
19 | * system_transition_mutex | ||
20 | */ | ||
19 | bool pm_freezing; | 21 | bool pm_freezing; |
20 | bool pm_nosig_freezing; | 22 | bool pm_nosig_freezing; |
21 | 23 | ||
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 9c85c7822383..abef759de7c8 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
@@ -338,7 +338,7 @@ static int create_image(int platform_mode) | |||
338 | * hibernation_snapshot - Quiesce devices and create a hibernation image. | 338 | * hibernation_snapshot - Quiesce devices and create a hibernation image. |
339 | * @platform_mode: If set, use platform driver to prepare for the transition. | 339 | * @platform_mode: If set, use platform driver to prepare for the transition. |
340 | * | 340 | * |
341 | * This routine must be called with pm_mutex held. | 341 | * This routine must be called with system_transition_mutex held. |
342 | */ | 342 | */ |
343 | int hibernation_snapshot(int platform_mode) | 343 | int hibernation_snapshot(int platform_mode) |
344 | { | 344 | { |
@@ -500,8 +500,9 @@ static int resume_target_kernel(bool platform_mode) | |||
500 | * hibernation_restore - Quiesce devices and restore from a hibernation image. | 500 | * hibernation_restore - Quiesce devices and restore from a hibernation image. |
501 | * @platform_mode: If set, use platform driver to prepare for the transition. | 501 | * @platform_mode: If set, use platform driver to prepare for the transition. |
502 | * | 502 | * |
503 | * This routine must be called with pm_mutex held. If it is successful, control | 503 | * This routine must be called with system_transition_mutex held. If it is |
504 | * reappears in the restored target kernel in hibernation_snapshot(). | 504 | * successful, control reappears in the restored target kernel in |
505 | * hibernation_snapshot(). | ||
505 | */ | 506 | */ |
506 | int hibernation_restore(int platform_mode) | 507 | int hibernation_restore(int platform_mode) |
507 | { | 508 | { |
@@ -638,6 +639,7 @@ static void power_down(void) | |||
638 | break; | 639 | break; |
639 | case HIBERNATION_PLATFORM: | 640 | case HIBERNATION_PLATFORM: |
640 | hibernation_platform_enter(); | 641 | hibernation_platform_enter(); |
642 | /* Fall through */ | ||
641 | case HIBERNATION_SHUTDOWN: | 643 | case HIBERNATION_SHUTDOWN: |
642 | if (pm_power_off) | 644 | if (pm_power_off) |
643 | kernel_power_off(); | 645 | kernel_power_off(); |
@@ -805,13 +807,13 @@ static int software_resume(void) | |||
805 | * name_to_dev_t() below takes a sysfs buffer mutex when sysfs | 807 | * name_to_dev_t() below takes a sysfs buffer mutex when sysfs |
806 | * is configured into the kernel. Since the regular hibernate | 808 | * is configured into the kernel. Since the regular hibernate |
807 | * trigger path is via sysfs which takes a buffer mutex before | 809 | * trigger path is via sysfs which takes a buffer mutex before |
808 | * calling hibernate functions (which take pm_mutex) this can | 810 | * calling hibernate functions (which take system_transition_mutex) |
809 | * cause lockdep to complain about a possible ABBA deadlock | 811 | * this can cause lockdep to complain about a possible ABBA deadlock |
810 | * which cannot happen since we're in the boot code here and | 812 | * which cannot happen since we're in the boot code here and |
811 | * sysfs can't be invoked yet. Therefore, we use a subclass | 813 | * sysfs can't be invoked yet. Therefore, we use a subclass |
812 | * here to avoid lockdep complaining. | 814 | * here to avoid lockdep complaining. |
813 | */ | 815 | */ |
814 | mutex_lock_nested(&pm_mutex, SINGLE_DEPTH_NESTING); | 816 | mutex_lock_nested(&system_transition_mutex, SINGLE_DEPTH_NESTING); |
815 | 817 | ||
816 | if (swsusp_resume_device) | 818 | if (swsusp_resume_device) |
817 | goto Check_image; | 819 | goto Check_image; |
@@ -899,7 +901,7 @@ static int software_resume(void) | |||
899 | atomic_inc(&snapshot_device_available); | 901 | atomic_inc(&snapshot_device_available); |
900 | /* For success case, the suspend path will release the lock */ | 902 | /* For success case, the suspend path will release the lock */ |
901 | Unlock: | 903 | Unlock: |
902 | mutex_unlock(&pm_mutex); | 904 | mutex_unlock(&system_transition_mutex); |
903 | pm_pr_dbg("Hibernation image not present or could not be loaded.\n"); | 905 | pm_pr_dbg("Hibernation image not present or could not be loaded.\n"); |
904 | return error; | 906 | return error; |
905 | Close_Finish: | 907 | Close_Finish: |
diff --git a/kernel/power/main.c b/kernel/power/main.c index d9706da10930..35b50823d83b 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -15,17 +15,16 @@ | |||
15 | #include <linux/workqueue.h> | 15 | #include <linux/workqueue.h> |
16 | #include <linux/debugfs.h> | 16 | #include <linux/debugfs.h> |
17 | #include <linux/seq_file.h> | 17 | #include <linux/seq_file.h> |
18 | #include <linux/suspend.h> | ||
18 | 19 | ||
19 | #include "power.h" | 20 | #include "power.h" |
20 | 21 | ||
21 | DEFINE_MUTEX(pm_mutex); | ||
22 | |||
23 | #ifdef CONFIG_PM_SLEEP | 22 | #ifdef CONFIG_PM_SLEEP |
24 | 23 | ||
25 | void lock_system_sleep(void) | 24 | void lock_system_sleep(void) |
26 | { | 25 | { |
27 | current->flags |= PF_FREEZER_SKIP; | 26 | current->flags |= PF_FREEZER_SKIP; |
28 | mutex_lock(&pm_mutex); | 27 | mutex_lock(&system_transition_mutex); |
29 | } | 28 | } |
30 | EXPORT_SYMBOL_GPL(lock_system_sleep); | 29 | EXPORT_SYMBOL_GPL(lock_system_sleep); |
31 | 30 | ||
@@ -37,8 +36,9 @@ void unlock_system_sleep(void) | |||
37 | * | 36 | * |
38 | * Reason: | 37 | * Reason: |
39 | * Fundamentally, we just don't need it, because freezing condition | 38 | * Fundamentally, we just don't need it, because freezing condition |
40 | * doesn't come into effect until we release the pm_mutex lock, | 39 | * doesn't come into effect until we release the |
41 | * since the freezer always works with pm_mutex held. | 40 | * system_transition_mutex lock, since the freezer always works with |
41 | * system_transition_mutex held. | ||
42 | * | 42 | * |
43 | * More importantly, in the case of hibernation, | 43 | * More importantly, in the case of hibernation, |
44 | * unlock_system_sleep() gets called in snapshot_read() and | 44 | * unlock_system_sleep() gets called in snapshot_read() and |
@@ -47,7 +47,7 @@ void unlock_system_sleep(void) | |||
47 | * enter the refrigerator, thus causing hibernation to lockup. | 47 | * enter the refrigerator, thus causing hibernation to lockup. |
48 | */ | 48 | */ |
49 | current->flags &= ~PF_FREEZER_SKIP; | 49 | current->flags &= ~PF_FREEZER_SKIP; |
50 | mutex_unlock(&pm_mutex); | 50 | mutex_unlock(&system_transition_mutex); |
51 | } | 51 | } |
52 | EXPORT_SYMBOL_GPL(unlock_system_sleep); | 52 | EXPORT_SYMBOL_GPL(unlock_system_sleep); |
53 | 53 | ||
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 87331565e505..9e13afe65a14 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
@@ -556,7 +556,7 @@ static int enter_state(suspend_state_t state) | |||
556 | } else if (!valid_state(state)) { | 556 | } else if (!valid_state(state)) { |
557 | return -EINVAL; | 557 | return -EINVAL; |
558 | } | 558 | } |
559 | if (!mutex_trylock(&pm_mutex)) | 559 | if (!mutex_trylock(&system_transition_mutex)) |
560 | return -EBUSY; | 560 | return -EBUSY; |
561 | 561 | ||
562 | if (state == PM_SUSPEND_TO_IDLE) | 562 | if (state == PM_SUSPEND_TO_IDLE) |
@@ -590,7 +590,7 @@ static int enter_state(suspend_state_t state) | |||
590 | pm_pr_dbg("Finishing wakeup.\n"); | 590 | pm_pr_dbg("Finishing wakeup.\n"); |
591 | suspend_finish(); | 591 | suspend_finish(); |
592 | Unlock: | 592 | Unlock: |
593 | mutex_unlock(&pm_mutex); | 593 | mutex_unlock(&system_transition_mutex); |
594 | return error; | 594 | return error; |
595 | } | 595 | } |
596 | 596 | ||
diff --git a/kernel/power/swap.c b/kernel/power/swap.c index c2bcf97d24c8..d7f6c1a288d3 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c | |||
@@ -923,7 +923,7 @@ int swsusp_write(unsigned int flags) | |||
923 | } | 923 | } |
924 | memset(&snapshot, 0, sizeof(struct snapshot_handle)); | 924 | memset(&snapshot, 0, sizeof(struct snapshot_handle)); |
925 | error = snapshot_read_next(&snapshot); | 925 | error = snapshot_read_next(&snapshot); |
926 | if (error < PAGE_SIZE) { | 926 | if (error < (int)PAGE_SIZE) { |
927 | if (error >= 0) | 927 | if (error >= 0) |
928 | error = -EFAULT; | 928 | error = -EFAULT; |
929 | 929 | ||
@@ -1483,7 +1483,7 @@ int swsusp_read(unsigned int *flags_p) | |||
1483 | 1483 | ||
1484 | memset(&snapshot, 0, sizeof(struct snapshot_handle)); | 1484 | memset(&snapshot, 0, sizeof(struct snapshot_handle)); |
1485 | error = snapshot_write_next(&snapshot); | 1485 | error = snapshot_write_next(&snapshot); |
1486 | if (error < PAGE_SIZE) | 1486 | if (error < (int)PAGE_SIZE) |
1487 | return error < 0 ? error : -EFAULT; | 1487 | return error < 0 ? error : -EFAULT; |
1488 | header = (struct swsusp_info *)data_of(snapshot); | 1488 | header = (struct swsusp_info *)data_of(snapshot); |
1489 | error = get_swap_reader(&handle, flags_p); | 1489 | error = get_swap_reader(&handle, flags_p); |
diff --git a/kernel/power/user.c b/kernel/power/user.c index abd225550271..2d8b60a3c86b 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -216,7 +216,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
216 | if (!capable(CAP_SYS_ADMIN)) | 216 | if (!capable(CAP_SYS_ADMIN)) |
217 | return -EPERM; | 217 | return -EPERM; |
218 | 218 | ||
219 | if (!mutex_trylock(&pm_mutex)) | 219 | if (!mutex_trylock(&system_transition_mutex)) |
220 | return -EBUSY; | 220 | return -EBUSY; |
221 | 221 | ||
222 | lock_device_hotplug(); | 222 | lock_device_hotplug(); |
@@ -394,7 +394,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
394 | } | 394 | } |
395 | 395 | ||
396 | unlock_device_hotplug(); | 396 | unlock_device_hotplug(); |
397 | mutex_unlock(&pm_mutex); | 397 | mutex_unlock(&system_transition_mutex); |
398 | 398 | ||
399 | return error; | 399 | return error; |
400 | } | 400 | } |
diff --git a/kernel/reboot.c b/kernel/reboot.c index e4ced883d8de..8fb44dec9ad7 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c | |||
@@ -294,7 +294,7 @@ void kernel_power_off(void) | |||
294 | } | 294 | } |
295 | EXPORT_SYMBOL_GPL(kernel_power_off); | 295 | EXPORT_SYMBOL_GPL(kernel_power_off); |
296 | 296 | ||
297 | static DEFINE_MUTEX(reboot_mutex); | 297 | DEFINE_MUTEX(system_transition_mutex); |
298 | 298 | ||
299 | /* | 299 | /* |
300 | * Reboot system call: for obvious reasons only root may call it, | 300 | * Reboot system call: for obvious reasons only root may call it, |
@@ -338,7 +338,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, | |||
338 | if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) | 338 | if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) |
339 | cmd = LINUX_REBOOT_CMD_HALT; | 339 | cmd = LINUX_REBOOT_CMD_HALT; |
340 | 340 | ||
341 | mutex_lock(&reboot_mutex); | 341 | mutex_lock(&system_transition_mutex); |
342 | switch (cmd) { | 342 | switch (cmd) { |
343 | case LINUX_REBOOT_CMD_RESTART: | 343 | case LINUX_REBOOT_CMD_RESTART: |
344 | kernel_restart(NULL); | 344 | kernel_restart(NULL); |
@@ -389,7 +389,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, | |||
389 | ret = -EINVAL; | 389 | ret = -EINVAL; |
390 | break; | 390 | break; |
391 | } | 391 | } |
392 | mutex_unlock(&reboot_mutex); | 392 | mutex_unlock(&system_transition_mutex); |
393 | return ret; | 393 | return ret; |
394 | } | 394 | } |
395 | 395 | ||
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a790ef4be74e..3674e42e3620 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -155,16 +155,17 @@ static inline void set_pcppage_migratetype(struct page *page, int migratetype) | |||
155 | * The following functions are used by the suspend/hibernate code to temporarily | 155 | * The following functions are used by the suspend/hibernate code to temporarily |
156 | * change gfp_allowed_mask in order to avoid using I/O during memory allocations | 156 | * change gfp_allowed_mask in order to avoid using I/O during memory allocations |
157 | * while devices are suspended. To avoid races with the suspend/hibernate code, | 157 | * while devices are suspended. To avoid races with the suspend/hibernate code, |
158 | * they should always be called with pm_mutex held (gfp_allowed_mask also should | 158 | * they should always be called with system_transition_mutex held |
159 | * only be modified with pm_mutex held, unless the suspend/hibernate code is | 159 | * (gfp_allowed_mask also should only be modified with system_transition_mutex |
160 | * guaranteed not to run in parallel with that modification). | 160 | * held, unless the suspend/hibernate code is guaranteed not to run in parallel |
161 | * with that modification). | ||
161 | */ | 162 | */ |
162 | 163 | ||
163 | static gfp_t saved_gfp_mask; | 164 | static gfp_t saved_gfp_mask; |
164 | 165 | ||
165 | void pm_restore_gfp_mask(void) | 166 | void pm_restore_gfp_mask(void) |
166 | { | 167 | { |
167 | WARN_ON(!mutex_is_locked(&pm_mutex)); | 168 | WARN_ON(!mutex_is_locked(&system_transition_mutex)); |
168 | if (saved_gfp_mask) { | 169 | if (saved_gfp_mask) { |
169 | gfp_allowed_mask = saved_gfp_mask; | 170 | gfp_allowed_mask = saved_gfp_mask; |
170 | saved_gfp_mask = 0; | 171 | saved_gfp_mask = 0; |
@@ -173,7 +174,7 @@ void pm_restore_gfp_mask(void) | |||
173 | 174 | ||
174 | void pm_restrict_gfp_mask(void) | 175 | void pm_restrict_gfp_mask(void) |
175 | { | 176 | { |
176 | WARN_ON(!mutex_is_locked(&pm_mutex)); | 177 | WARN_ON(!mutex_is_locked(&system_transition_mutex)); |
177 | WARN_ON(saved_gfp_mask); | 178 | WARN_ON(saved_gfp_mask); |
178 | saved_gfp_mask = gfp_allowed_mask; | 179 | saved_gfp_mask = gfp_allowed_mask; |
179 | gfp_allowed_mask &= ~(__GFP_IO | __GFP_FS); | 180 | gfp_allowed_mask &= ~(__GFP_IO | __GFP_FS); |