Skip to content

Commit 17bc343

Browse files
committed
Merge branches 'pm-core', 'pm-domains', 'pm-sleep', 'acpi-pm' and 'pm-cpuidle'
Merge changes in the PM core, system-wide PM infrastructure, generic power domains (genpd) framework, ACPI PM infrastructure and cpuidle for 4.19. * pm-core: driver core: Add flag to autoremove device link on supplier unbind driver core: Rename flag AUTOREMOVE to AUTOREMOVE_CONSUMER * pm-domains: PM / Domains: Introduce dev_pm_domain_attach_by_name() PM / Domains: Introduce option to attach a device by name to genpd PM / Domains: dt: Add a power-domain-names property * pm-sleep: PM / reboot: Eliminate race between reboot and suspend PM / hibernate: Mark expected switch fall-through x86/power/hibernate_64: Remove VLA usage PM / hibernate: cast PAGE_SIZE to int when comparing with error code * acpi-pm: ACPI / PM: save NVS memory for ASUS 1025C laptop ACPI / PM: Default to s2idle in all machines supporting LP S0 * pm-cpuidle: ARM: cpuidle: silence error on driver registration failure
6 parents 9b7c19e + 1689cac + 27dceb8 + 55f2503 + 231f941 + 818489e commit 17bc343

25 files changed

Lines changed: 186 additions & 89 deletions

File tree

‎Documentation/devicetree/bindings/power/power_domain.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,26 @@ Required properties:
114114
- power-domains : A list of PM domain specifiers, as defined by bindings of
115115
the power controller that is the PM domain provider.
116116

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+
117123
Example:
118124

119125
leaky-device@12350000 {
120126
compatible = "foo,i-leak-current";
121127
reg = <0x12350000 0x1000>;
122128
power-domains = <&power 0>;
129+
power-domain-names = "io";
123130
};
124131

125132
leaky-device@12351000 {
126133
compatible = "foo,i-leak-current";
127134
reg = <0x12351000 0x1000>;
128135
power-domains = <&power 0>, <&power 1> ;
136+
power-domain-names = "io", "clk";
129137
};
130138

131139
The first example above defines a typical PM domain consumer device, which is

‎Documentation/driver-api/device_link.rst‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ integration is desired.
8181
Two other flags are specifically targeted at use cases where the device
8282
link is added from the consumer's ``->probe`` callback: ``DL_FLAG_RPM_ACTIVE``
8383
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
85-
purged when the consumer fails to probe or later unbinds. This obviates
86-
the need to explicitly delete the link in the ``->remove`` callback or in
87-
the error path of the ``->probe`` callback.
84+
device link. ``DL_FLAG_AUTOREMOVE_CONSUMER`` causes the device link to be
85+
automatically purged when the consumer fails to probe or later unbinds.
86+
This obviates the need to explicitly delete the link in the ``->remove``
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.
8892

8993
Limitations
9094
===========

‎Documentation/power/freezing-of-tasks.txt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,26 +204,26 @@ VI. Are there any precautions to be taken to prevent freezing failures?
204204

205205
Yes, there are.
206206

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
208208
from system-wide sleep such as suspend/hibernation is not encouraged.
209209
If possible, that piece of code must instead hook onto the suspend/hibernation
210210
notifiers to achieve mutual exclusion. Look at the CPU-Hotplug code
211211
(kernel/cpu.c) for an example.
212212

213-
However, if that is not feasible, and grabbing 'pm_mutex' is deemed necessary,
214-
it is strongly discouraged to directly call mutex_[un]lock(&pm_mutex) since
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(&system_transition_mutex) since
215215
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
217217
to acquire the lock, then that task would get blocked in TASK_UNINTERRUPTIBLE
218218
state. As a consequence, the freezer would not be able to freeze that task,
219219
leading to freezing failure.
220220

221221
However, the [un]lock_system_sleep() APIs are safe to use in this scenario,
222222
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
224224
only after the entire suspend/hibernation sequence is complete.
225225
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.
227227

228228
V. Miscellaneous
229229
/sys/power/pm_freeze_timeout controls how long it will cost at most to freeze

‎Documentation/power/suspend-and-cpuhotplug.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ More details follow:
3232
sysfs file
3333
|
3434
v
35-
Acquire pm_mutex lock
35+
Acquire system_transition_mutex lock
3636
|
3737
v
3838
Send PM_SUSPEND_PREPARE
@@ -96,10 +96,10 @@ execution during resume):
9696

9797
* thaw tasks
9898
* send PM_POST_SUSPEND notifications
99-
* Release pm_mutex lock.
99+
* Release system_transition_mutex lock.
100100

101101

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
103103
beginning, when we are just starting out to suspend, and then released only
104104
after the entire cycle is complete (i.e., suspend + resume).
105105

‎arch/x86/power/hibernate_64.c‎

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -233,29 +233,35 @@ struct restore_data_record {
233233
*/
234234
static int get_e820_md5(struct e820_table *table, void *buf)
235235
{
236-
struct scatterlist sg;
237-
struct crypto_ahash *tfm;
236+
struct crypto_shash *tfm;
237+
struct shash_desc *desc;
238238
int size;
239239
int ret = 0;
240240

241-
tfm = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC);
241+
tfm = crypto_alloc_shash("md5", 0, 0);
242242
if (IS_ERR(tfm))
243243
return -ENOMEM;
244244

245-
{
246-
AHASH_REQUEST_ON_STACK(req, tfm);
247-
size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry) * table->nr_entries;
248-
ahash_request_set_tfm(req, tfm);
249-
sg_init_one(&sg, (u8 *)table, size);
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);
245+
desc = kmalloc(sizeof(struct shash_desc) + crypto_shash_descsize(tfm),
246+
GFP_KERNEL);
247+
if (!desc) {
248+
ret = -ENOMEM;
249+
goto free_tfm;
256250
}
257-
crypto_free_ahash(tfm);
258251

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);
259265
return ret;
260266
}
261267

‎drivers/acpi/sleep.c‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ static const struct dmi_system_id acpisleep_dmi_table[] __initconst = {
338338
DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"),
339339
},
340340
},
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+
},
341349
/*
342350
* https://bugzilla.kernel.org/show_bug.cgi?id=189431
343351
* 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[] = {
718726
#define ACPI_LPS0_ENTRY 5
719727
#define ACPI_LPS0_EXIT 6
720728

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-
724729
static acpi_handle lps0_device_handle;
725730
static guid_t lps0_dsm_guid;
726731
static char lps0_dsm_func_mask;
@@ -924,17 +929,14 @@ static int lps0_device_attach(struct acpi_device *adev,
924929
if (out_obj && out_obj->type == ACPI_TYPE_BUFFER) {
925930
char bitmask = *(char *)out_obj->buffer.pointer;
926931

927-
if ((bitmask & ACPI_LPS0_PLATFORM_MASK) == ACPI_LPS0_PLATFORM_MASK ||
928-
(bitmask & ACPI_LPS0_SCREEN_MASK) == ACPI_LPS0_SCREEN_MASK) {
929-
lps0_dsm_func_mask = bitmask;
930-
lps0_device_handle = adev->handle;
931-
/*
932-
* Use suspend-to-idle by default if the default
933-
* suspend mode was not set from the command line.
934-
*/
935-
if (mem_sleep_default > PM_SUSPEND_MEM)
936-
mem_sleep_current = PM_SUSPEND_TO_IDLE;
937-
}
932+
lps0_dsm_func_mask = bitmask;
933+
lps0_device_handle = adev->handle;
934+
/*
935+
* Use suspend-to-idle by default if the default
936+
* suspend mode was not set from the command line.
937+
*/
938+
if (mem_sleep_default > PM_SUSPEND_MEM)
939+
mem_sleep_current = PM_SUSPEND_TO_IDLE;
938940

939941
acpi_handle_debug(adev->handle, "_DSM function mask: 0x%x\n",
940942
bitmask);

‎drivers/base/core.c‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ void device_pm_move_to_tail(struct device *dev)
178178
* of the link. If DL_FLAG_PM_RUNTIME is not set, DL_FLAG_RPM_ACTIVE will be
179179
* ignored.
180180
*
181-
* If the DL_FLAG_AUTOREMOVE is set, the link will be removed automatically
182-
* when the consumer device driver unbinds from it. The combination of both
183-
* DL_FLAG_AUTOREMOVE and DL_FLAG_STATELESS set is invalid and will cause NULL
184-
* to be returned.
181+
* If the DL_FLAG_AUTOREMOVE_CONSUMER is set, the link will be removed
182+
* automatically when the consumer device driver unbinds from it.
183+
* The combination of both DL_FLAG_AUTOREMOVE_CONSUMER and DL_FLAG_STATELESS
184+
* set is invalid and will cause NULL to be returned.
185185
*
186186
* A side effect of the link creation is re-ordering of dpm_list and the
187187
* 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,
198198
struct device_link *link;
199199

200200
if (!consumer || !supplier ||
201-
((flags & DL_FLAG_STATELESS) && (flags & DL_FLAG_AUTOREMOVE)))
201+
((flags & DL_FLAG_STATELESS) &&
202+
(flags & DL_FLAG_AUTOREMOVE_CONSUMER)))
202203
return NULL;
203204

204205
device_links_write_lock();
@@ -479,7 +480,7 @@ static void __device_links_no_driver(struct device *dev)
479480
if (link->flags & DL_FLAG_STATELESS)
480481
continue;
481482

482-
if (link->flags & DL_FLAG_AUTOREMOVE)
483+
if (link->flags & DL_FLAG_AUTOREMOVE_CONSUMER)
483484
kref_put(&link->kref, __device_link_del);
484485
else if (link->status != DL_STATE_SUPPLIER_UNBIND)
485486
WRITE_ONCE(link->status, DL_STATE_AVAILABLE);
@@ -515,8 +516,18 @@ void device_links_driver_cleanup(struct device *dev)
515516
if (link->flags & DL_FLAG_STATELESS)
516517
continue;
517518

518-
WARN_ON(link->flags & DL_FLAG_AUTOREMOVE);
519+
WARN_ON(link->flags & DL_FLAG_AUTOREMOVE_CONSUMER);
519520
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+
520531
WRITE_ONCE(link->status, DL_STATE_DORMANT);
521532
}
522533

‎drivers/base/power/common.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,23 @@ struct device *dev_pm_domain_attach_by_id(struct device *dev,
152152
}
153153
EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id);
154154

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+
155172
/**
156173
* dev_pm_domain_detach - Detach a device from its PM domain.
157174
* @dev: Device to detach.

‎drivers/base/power/domain.c‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,30 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
23742374
}
23752375
EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id);
23762376

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+
23772401
static const struct of_device_id idle_state_match[] = {
23782402
{ .compatible = "domain-idle-state", },
23792403
{ }

‎drivers/cpuidle/cpuidle-arm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ static int __init arm_idle_init_cpu(int cpu)
105105

106106
ret = cpuidle_register_driver(drv);
107107
if (ret) {
108-
pr_err("Failed to register cpuidle driver\n");
108+
if (ret != -EBUSY)
109+
pr_err("Failed to register cpuidle driver\n");
109110
goto out_kfree_drv;
110111
}
111112

0 commit comments

Comments
 (0)