Commit 31689497d90e589d7050fc7bc850b4b46e632bfc
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
Merge branches 'pm-domains', 'pm-sleep' and 'pm-cpufreq'
* pm-domains: PM / Domains: Fix initial default state of the need_restore flag PM / Domains: Change prototype for the attach and detach callbacks * pm-sleep: PM / sleep: Fix entering suspend-to-IDLE if no freeze_oops is set * pm-cpufreq: cpufreq: Avoid crash in resume on SMP without OPP cpufreq: cpufreq-dt: Fix arguments in clock failure error message
Showing 5 changed files Side-by-side Diff
drivers/base/power/domain.c
... | ... | @@ -361,9 +361,19 @@ |
361 | 361 | struct device *dev = pdd->dev; |
362 | 362 | int ret = 0; |
363 | 363 | |
364 | - if (gpd_data->need_restore) | |
364 | + if (gpd_data->need_restore > 0) | |
365 | 365 | return 0; |
366 | 366 | |
367 | + /* | |
368 | + * If the value of the need_restore flag is still unknown at this point, | |
369 | + * we trust that pm_genpd_poweroff() has verified that the device is | |
370 | + * already runtime PM suspended. | |
371 | + */ | |
372 | + if (gpd_data->need_restore < 0) { | |
373 | + gpd_data->need_restore = 1; | |
374 | + return 0; | |
375 | + } | |
376 | + | |
367 | 377 | mutex_unlock(&genpd->lock); |
368 | 378 | |
369 | 379 | genpd_start_dev(genpd, dev); |
... | ... | @@ -373,7 +383,7 @@ |
373 | 383 | mutex_lock(&genpd->lock); |
374 | 384 | |
375 | 385 | if (!ret) |
376 | - gpd_data->need_restore = true; | |
386 | + gpd_data->need_restore = 1; | |
377 | 387 | |
378 | 388 | return ret; |
379 | 389 | } |
380 | 390 | |
381 | 391 | |
... | ... | @@ -389,12 +399,17 @@ |
389 | 399 | { |
390 | 400 | struct generic_pm_domain_data *gpd_data = to_gpd_data(pdd); |
391 | 401 | struct device *dev = pdd->dev; |
392 | - bool need_restore = gpd_data->need_restore; | |
402 | + int need_restore = gpd_data->need_restore; | |
393 | 403 | |
394 | - gpd_data->need_restore = false; | |
404 | + gpd_data->need_restore = 0; | |
395 | 405 | mutex_unlock(&genpd->lock); |
396 | 406 | |
397 | 407 | genpd_start_dev(genpd, dev); |
408 | + | |
409 | + /* | |
410 | + * Call genpd_restore_dev() for recently added devices too (need_restore | |
411 | + * is negative then). | |
412 | + */ | |
398 | 413 | if (need_restore) |
399 | 414 | genpd_restore_dev(genpd, dev); |
400 | 415 | |
... | ... | @@ -603,6 +618,7 @@ |
603 | 618 | static int pm_genpd_runtime_suspend(struct device *dev) |
604 | 619 | { |
605 | 620 | struct generic_pm_domain *genpd; |
621 | + struct generic_pm_domain_data *gpd_data; | |
606 | 622 | bool (*stop_ok)(struct device *__dev); |
607 | 623 | int ret; |
608 | 624 | |
... | ... | @@ -628,6 +644,16 @@ |
628 | 644 | return 0; |
629 | 645 | |
630 | 646 | mutex_lock(&genpd->lock); |
647 | + | |
648 | + /* | |
649 | + * If we have an unknown state of the need_restore flag, it means none | |
650 | + * of the runtime PM callbacks has been invoked yet. Let's update the | |
651 | + * flag to reflect that the current state is active. | |
652 | + */ | |
653 | + gpd_data = to_gpd_data(dev->power.subsys_data->domain_data); | |
654 | + if (gpd_data->need_restore < 0) | |
655 | + gpd_data->need_restore = 0; | |
656 | + | |
631 | 657 | genpd->in_progress++; |
632 | 658 | pm_genpd_poweroff(genpd); |
633 | 659 | genpd->in_progress--; |
634 | 660 | |
... | ... | @@ -1437,12 +1463,12 @@ |
1437 | 1463 | spin_unlock_irq(&dev->power.lock); |
1438 | 1464 | |
1439 | 1465 | if (genpd->attach_dev) |
1440 | - genpd->attach_dev(dev); | |
1466 | + genpd->attach_dev(genpd, dev); | |
1441 | 1467 | |
1442 | 1468 | mutex_lock(&gpd_data->lock); |
1443 | 1469 | gpd_data->base.dev = dev; |
1444 | 1470 | list_add_tail(&gpd_data->base.list_node, &genpd->dev_list); |
1445 | - gpd_data->need_restore = genpd->status == GPD_STATE_POWER_OFF; | |
1471 | + gpd_data->need_restore = -1; | |
1446 | 1472 | gpd_data->td.constraint_changed = true; |
1447 | 1473 | gpd_data->td.effective_constraint_ns = -1; |
1448 | 1474 | mutex_unlock(&gpd_data->lock); |
... | ... | @@ -1499,7 +1525,7 @@ |
1499 | 1525 | genpd->max_off_time_changed = true; |
1500 | 1526 | |
1501 | 1527 | if (genpd->detach_dev) |
1502 | - genpd->detach_dev(dev); | |
1528 | + genpd->detach_dev(genpd, dev); | |
1503 | 1529 | |
1504 | 1530 | spin_lock_irq(&dev->power.lock); |
1505 | 1531 | |
... | ... | @@ -1546,7 +1572,7 @@ |
1546 | 1572 | |
1547 | 1573 | psd = dev_to_psd(dev); |
1548 | 1574 | if (psd && psd->domain_data) |
1549 | - to_gpd_data(psd->domain_data)->need_restore = val; | |
1575 | + to_gpd_data(psd->domain_data)->need_restore = val ? 1 : 0; | |
1550 | 1576 | |
1551 | 1577 | spin_unlock_irqrestore(&dev->power.lock, flags); |
1552 | 1578 | } |
drivers/cpufreq/cpufreq-dt.c
... | ... | @@ -166,8 +166,8 @@ |
166 | 166 | if (ret == -EPROBE_DEFER) |
167 | 167 | dev_dbg(cpu_dev, "cpu%d clock not ready, retry\n", cpu); |
168 | 168 | else |
169 | - dev_err(cpu_dev, "failed to get cpu%d clock: %d\n", ret, | |
170 | - cpu); | |
169 | + dev_err(cpu_dev, "failed to get cpu%d clock: %d\n", cpu, | |
170 | + ret); | |
171 | 171 | } else { |
172 | 172 | *cdev = cpu_dev; |
173 | 173 | *creg = cpu_reg; |
drivers/cpufreq/cpufreq.c
include/linux/pm_domain.h
... | ... | @@ -72,8 +72,10 @@ |
72 | 72 | bool max_off_time_changed; |
73 | 73 | bool cached_power_down_ok; |
74 | 74 | struct gpd_cpuidle_data *cpuidle_data; |
75 | - void (*attach_dev)(struct device *dev); | |
76 | - void (*detach_dev)(struct device *dev); | |
75 | + int (*attach_dev)(struct generic_pm_domain *domain, | |
76 | + struct device *dev); | |
77 | + void (*detach_dev)(struct generic_pm_domain *domain, | |
78 | + struct device *dev); | |
77 | 79 | }; |
78 | 80 | |
79 | 81 | static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd) |
... | ... | @@ -104,7 +106,7 @@ |
104 | 106 | struct notifier_block nb; |
105 | 107 | struct mutex lock; |
106 | 108 | unsigned int refcount; |
107 | - bool need_restore; | |
109 | + int need_restore; | |
108 | 110 | }; |
109 | 111 | |
110 | 112 | #ifdef CONFIG_PM_GENERIC_DOMAINS |
kernel/power/suspend.c
... | ... | @@ -146,7 +146,7 @@ |
146 | 146 | |
147 | 147 | static int platform_suspend_prepare_late(suspend_state_t state) |
148 | 148 | { |
149 | - return state == PM_SUSPEND_FREEZE && freeze_ops->prepare ? | |
149 | + return state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->prepare ? | |
150 | 150 | freeze_ops->prepare() : 0; |
151 | 151 | } |
152 | 152 | |
... | ... | @@ -164,7 +164,7 @@ |
164 | 164 | |
165 | 165 | static void platform_resume_early(suspend_state_t state) |
166 | 166 | { |
167 | - if (state == PM_SUSPEND_FREEZE && freeze_ops->restore) | |
167 | + if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->restore) | |
168 | 168 | freeze_ops->restore(); |
169 | 169 | } |
170 | 170 |
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013
-
mentioned in commit 03e013