History

Merge branches 'pm-sleep', 'pm-domains', 'pm-opp' and 'powercap'

* pm-sleep: PM / wakeirq: remove unnecessary parentheses PM / core: Clean up some function headers in power.h PM / hibernate: memory_bm_find_bit(): Tighten node optimisation * pm-domains: PM / Domains: Convert to dev_to_genpd_safe() in genpd_syscore_switch() mmc: tmio: Avoid boilerplate code in ->runtime_suspend() PM / Domains: Implement the ->start() callback for genpd PM / Domains: Introduce dev_pm_domain_start() * pm-opp: PM / OPP: Support adjusting OPP voltages at runtime * powercap: powercap/intel_rapl: add support for Cometlake desktop powercap/intel_rapl: add support for CometLake Mobile

Rafael J. Wysocki committed 6 years ago

Commit 5a97aa55 parents fa6a599 01ca482 fe0c2ba 16c71c5 f84fdcb12 files · +157 −48Browse files

Unified · Split

12 files
  1. drivers/base/power/common.c +20 −0
  2. drivers/base/power/domain.c +20 −20
  3. drivers/base/power/power.h +12 −18
  4. drivers/base/power/wakeirq.c +2 −2
  5. drivers/mmc/host/tmio_mmc.h +0 −1
  6. drivers/mmc/host/tmio_mmc_core.c +4 −6
  7. drivers/opp/core.c +69 −0
  8. drivers/powercap/intel_rapl_common.c +2 −0
  9. include/linux/pm.h +2 −0
  10. include/linux/pm_domain.h +5 −0
  11. include/linux/pm_opp.h +13 −0
  12. kernel/power/snapshot.c +8 −1
drivers/base/power/common.c+20−0
@@ -187,6 +187,26 @@ void dev_pm_domain_detach(struct device *dev, bool power_off) · 186 unmodified lines
187}187}
188EXPORT_SYMBOL_GPL(dev_pm_domain_detach);188EXPORT_SYMBOL_GPL(dev_pm_domain_detach);
189 189
190/**
191 * dev_pm_domain_start - Start the device through its PM domain.
192 * @dev: Device to start.
193 *
194 * This function should typically be called during probe by a subsystem/driver,
195 * when it needs to start its device from the PM domain's perspective. Note
196 * that, it's assumed that the PM domain is already powered on when this
197 * function is called.
198 *
199 * Returns 0 on success and negative error values on failures.
200 */
201int dev_pm_domain_start(struct device *dev)
202{
203 if (dev->pm_domain && dev->pm_domain->start)
204 return dev->pm_domain->start(dev);
205
206 return 0;
207}
208EXPORT_SYMBOL_GPL(dev_pm_domain_start);
209
190/**210/**
191 * dev_pm_domain_set - Set PM domain of a device.211 * dev_pm_domain_set - Set PM domain of a device.
192 * @dev: Device whose PM domain is to be set.212 * @dev: Device whose PM domain is to be set.
drivers/base/power/domain.c+20−20
@@ -634,6 +634,13 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth) · 633 unmodified lines
634 return ret;634 return ret;
635}635}
636 636
637static int genpd_dev_pm_start(struct device *dev)
638{
639 struct generic_pm_domain *genpd = dev_to_genpd(dev);
640
641 return genpd_start_dev(genpd, dev);
642}
643
637static int genpd_dev_pm_qos_notifier(struct notifier_block *nb,644static int genpd_dev_pm_qos_notifier(struct notifier_block *nb,
638 unsigned long val, void *ptr)645 unsigned long val, void *ptr)
639{646{
@@ -922,24 +929,6 @@ static int __init genpd_power_off_unused(void) · 282 unmodified lines
922}929}
923late_initcall(genpd_power_off_unused);930late_initcall(genpd_power_off_unused);
924 931
925#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_GENERIC_DOMAINS_OF)
926
927static bool genpd_present(const struct generic_pm_domain *genpd)
928{
929 const struct generic_pm_domain *gpd;
930
931 if (IS_ERR_OR_NULL(genpd))
932 return false;
933
934 list_for_each_entry(gpd, &gpd_list, gpd_list_node)
935 if (gpd == genpd)
936 return true;
937
938 return false;
939}
940
941#endif
942
943#ifdef CONFIG_PM_SLEEP932#ifdef CONFIG_PM_SLEEP
944 933
945/**934/**
@@ -1354,8 +1343,8 @@ static void genpd_syscore_switch(struct device *dev, bool suspend) · 408 unmodified lines
1354{1343{
1355 struct generic_pm_domain *genpd;1344 struct generic_pm_domain *genpd;
1356 1345
1357 genpd = dev_to_genpd(dev);1346 genpd = dev_to_genpd_safe(dev);
1358 if (!genpd_present(genpd))1347 if (!genpd)
1359 return;1348 return;
1360 1349
1361 if (suspend) {1350 if (suspend) {
@@ -1805,6 +1794,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd, · 443 unmodified lines
1805 genpd->domain.ops.poweroff_noirq = genpd_poweroff_noirq;1794 genpd->domain.ops.poweroff_noirq = genpd_poweroff_noirq;
1806 genpd->domain.ops.restore_noirq = genpd_restore_noirq;1795 genpd->domain.ops.restore_noirq = genpd_restore_noirq;
1807 genpd->domain.ops.complete = genpd_complete;1796 genpd->domain.ops.complete = genpd_complete;
1797 genpd->domain.start = genpd_dev_pm_start;
1808 1798
1809 if (genpd->flags & GENPD_FLAG_PM_CLK) {1799 if (genpd->flags & GENPD_FLAG_PM_CLK) {
1810 genpd->dev_ops.stop = pm_clk_suspend;1800 genpd->dev_ops.stop = pm_clk_suspend;
@@ -2020,6 +2010,16 @@ static int genpd_add_provider(struct device_node *np, genpd_xlate_t xlate, · 209 unmodified lines
2020 return 0;2010 return 0;
2021}2011}
2022 2012
2013static bool genpd_present(const struct generic_pm_domain *genpd)
2014{
2015 const struct generic_pm_domain *gpd;
2016
2017 list_for_each_entry(gpd, &gpd_list, gpd_list_node)
2018 if (gpd == genpd)
2019 return true;
2020 return false;
2021}
2022
2023/**2023/**
2024 * of_genpd_add_provider_simple() - Register a simple PM domain provider2024 * of_genpd_add_provider_simple() - Register a simple PM domain provider
2025 * @np: Device node pointer associated with the PM domain provider.2025 * @np: Device node pointer associated with the PM domain provider.
drivers/base/power/power.h+12−18
@@ -117,6 +117,13 @@ static inline bool device_pm_initialized(struct device *dev) · 116 unmodified lines
117 return dev->power.in_dpm_list;117 return dev->power.in_dpm_list;
118}118}
119 119
120/* drivers/base/power/wakeup_stats.c */
121extern int wakeup_source_sysfs_add(struct device *parent,
122 struct wakeup_source *ws);
123extern void wakeup_source_sysfs_remove(struct wakeup_source *ws);
124
125extern int pm_wakeup_source_sysfs_add(struct device *parent);
126
120#else /* !CONFIG_PM_SLEEP */127#else /* !CONFIG_PM_SLEEP */
121 128
122static inline void device_pm_sleep_init(struct device *dev) {}129static inline void device_pm_sleep_init(struct device *dev) {}
@@ -141,6 +148,11 @@ static inline bool device_pm_initialized(struct device *dev) · 18 unmodified lines
141 return device_is_registered(dev);148 return device_is_registered(dev);
142}149}
143 150
151static inline int pm_wakeup_source_sysfs_add(struct device *parent)
152{
153 return 0;
154}
155
144#endif /* !CONFIG_PM_SLEEP */156#endif /* !CONFIG_PM_SLEEP */
145 157
146static inline void device_pm_init(struct device *dev)158static inline void device_pm_init(struct device *dev)
@@ -149,21 +161,3 @@ static inline void device_pm_init(struct device *dev) · 2 unmodified lines
149 device_pm_sleep_init(dev);161 device_pm_sleep_init(dev);
150 pm_runtime_init(dev);162 pm_runtime_init(dev);
151}163}
152
153#ifdef CONFIG_PM_SLEEP
154
155/* drivers/base/power/wakeup_stats.c */
156extern int wakeup_source_sysfs_add(struct device *parent,
157 struct wakeup_source *ws);
158extern void wakeup_source_sysfs_remove(struct wakeup_source *ws);
159
160extern int pm_wakeup_source_sysfs_add(struct device *parent);
161
162#else /* !CONFIG_PM_SLEEP */
163
164static inline int pm_wakeup_source_sysfs_add(struct device *parent)
165{
166 return 0;
167}
168
169#endif /* CONFIG_PM_SLEEP */
drivers/base/power/wakeirq.c+2−2
@@ -272,7 +272,7 @@ void dev_pm_enable_wake_irq_check(struct device *dev, · 271 unmodified lines
272{272{
273 struct wake_irq *wirq = dev->power.wakeirq;273 struct wake_irq *wirq = dev->power.wakeirq;
274 274
275 if (!wirq || !((wirq->status & WAKE_IRQ_DEDICATED_MASK)))275 if (!wirq || !(wirq->status & WAKE_IRQ_DEDICATED_MASK))
276 return;276 return;
277 277
278 if (likely(wirq->status & WAKE_IRQ_DEDICATED_MANAGED)) {278 if (likely(wirq->status & WAKE_IRQ_DEDICATED_MANAGED)) {
@@ -299,7 +299,7 @@ void dev_pm_disable_wake_irq_check(struct device *dev) · 20 unmodified lines
299{299{
300 struct wake_irq *wirq = dev->power.wakeirq;300 struct wake_irq *wirq = dev->power.wakeirq;
301 301
302 if (!wirq || !((wirq->status & WAKE_IRQ_DEDICATED_MASK)))302 if (!wirq || !(wirq->status & WAKE_IRQ_DEDICATED_MASK))
303 return;303 return;
304 304
305 if (wirq->status & WAKE_IRQ_DEDICATED_MANAGED)305 if (wirq->status & WAKE_IRQ_DEDICATED_MANAGED)
drivers/mmc/host/tmio_mmc.h+0−1
@@ -163,7 +163,6 @@ struct tmio_mmc_host { · 162 unmodified lines
163 unsigned long last_req_ts;163 unsigned long last_req_ts;
164 struct mutex ios_lock; /* protect set_ios() context */164 struct mutex ios_lock; /* protect set_ios() context */
165 bool native_hotplug;165 bool native_hotplug;
166 bool runtime_synced;
167 bool sdio_irq_enabled;166 bool sdio_irq_enabled;
168 167
169 /* Mandatory callback */168 /* Mandatory callback */
drivers/mmc/host/tmio_mmc_core.c+4−6
@@ -39,6 +39,7 @@ · 38 unmodified lines
39#include <linux/module.h>39#include <linux/module.h>
40#include <linux/pagemap.h>40#include <linux/pagemap.h>
41#include <linux/platform_device.h>41#include <linux/platform_device.h>
42#include <linux/pm_domain.h>
42#include <linux/pm_qos.h>43#include <linux/pm_qos.h>
43#include <linux/pm_runtime.h>44#include <linux/pm_runtime.h>
44#include <linux/regulator/consumer.h>45#include <linux/regulator/consumer.h>
@@ -1248,10 +1249,12 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) · 1203 unmodified lines
1248 /* See if we also get DMA */1249 /* See if we also get DMA */
1249 tmio_mmc_request_dma(_host, pdata);1250 tmio_mmc_request_dma(_host, pdata);
1250 1251
1252 dev_pm_domain_start(&pdev->dev);
1253 pm_runtime_get_noresume(&pdev->dev);
1254 pm_runtime_set_active(&pdev->dev);
1251 pm_runtime_set_autosuspend_delay(&pdev->dev, 50);1255 pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
1252 pm_runtime_use_autosuspend(&pdev->dev);1256 pm_runtime_use_autosuspend(&pdev->dev);
1253 pm_runtime_enable(&pdev->dev);1257 pm_runtime_enable(&pdev->dev);
1254 pm_runtime_get_sync(&pdev->dev);
1255 1258
1256 ret = mmc_add_host(mmc);1259 ret = mmc_add_host(mmc);
1257 if (ret)1260 if (ret)
@@ -1333,11 +1336,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev) · 75 unmodified lines
1333{1336{
1334 struct tmio_mmc_host *host = dev_get_drvdata(dev);1337 struct tmio_mmc_host *host = dev_get_drvdata(dev);
1335 1338
1336 if (!host->runtime_synced) {
1337 host->runtime_synced = true;
1338 return 0;
1339 }
1340
1341 tmio_mmc_clk_enable(host);1339 tmio_mmc_clk_enable(host);
1342 tmio_mmc_hw_reset(host->mmc);1340 tmio_mmc_hw_reset(host->mmc);
1343 1341
drivers/opp/core.c+69−0
@@ -2102,6 +2102,75 @@ put_table: · 2101 unmodified lines
2102 return r;2102 return r;
2103}2103}
2104 2104
2105/**
2106 * dev_pm_opp_adjust_voltage() - helper to change the voltage of an OPP
2107 * @dev: device for which we do this operation
2108 * @freq: OPP frequency to adjust voltage of
2109 * @u_volt: new OPP target voltage
2110 * @u_volt_min: new OPP min voltage
2111 * @u_volt_max: new OPP max voltage
2112 *
2113 * Return: -EINVAL for bad pointers, -ENOMEM if no memory available for the
2114 * copy operation, returns 0 if no modifcation was done OR modification was
2115 * successful.
2116 */
2117int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq,
2118 unsigned long u_volt, unsigned long u_volt_min,
2119 unsigned long u_volt_max)
2120
2121{
2122 struct opp_table *opp_table;
2123 struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV);
2124 int r = 0;
2125
2126 /* Find the opp_table */
2127 opp_table = _find_opp_table(dev);
2128 if (IS_ERR(opp_table)) {
2129 r = PTR_ERR(opp_table);
2130 dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r);
2131 return r;
2132 }
2133
2134 mutex_lock(&opp_table->lock);
2135
2136 /* Do we have the frequency? */
2137 list_for_each_entry(tmp_opp, &opp_table->opp_list, node) {
2138 if (tmp_opp->rate == freq) {
2139 opp = tmp_opp;
2140 break;
2141 }
2142 }
2143
2144 if (IS_ERR(opp)) {
2145 r = PTR_ERR(opp);
2146 goto adjust_unlock;
2147 }
2148
2149 /* Is update really needed? */
2150 if (opp->supplies->u_volt == u_volt)
2151 goto adjust_unlock;
2152
2153 opp->supplies->u_volt = u_volt;
2154 opp->supplies->u_volt_min = u_volt_min;
2155 opp->supplies->u_volt_max = u_volt_max;
2156
2157 dev_pm_opp_get(opp);
2158 mutex_unlock(&opp_table->lock);
2159
2160 /* Notify the voltage change of the OPP */
2161 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADJUST_VOLTAGE,
2162 opp);
2163
2164 dev_pm_opp_put(opp);
2165 goto adjust_put_table;
2166
2167adjust_unlock:
2168 mutex_unlock(&opp_table->lock);
2169adjust_put_table:
2170 dev_pm_opp_put_opp_table(opp_table);
2171 return r;
2172}
2173
2105/**2174/**
2106 * dev_pm_opp_enable() - Enable a specific OPP2175 * dev_pm_opp_enable() - Enable a specific OPP
2107 * @dev: device for which we do this operation2176 * @dev: device for which we do this operation
drivers/powercap/intel_rapl_common.c+2−0
@@ -978,6 +978,8 @@ static const struct x86_cpu_id rapl_ids[] __initconst = { · 977 unmodified lines
978 INTEL_CPU_FAM6(ICELAKE_NNPI, rapl_defaults_core),978 INTEL_CPU_FAM6(ICELAKE_NNPI, rapl_defaults_core),
979 INTEL_CPU_FAM6(ICELAKE_X, rapl_defaults_hsw_server),979 INTEL_CPU_FAM6(ICELAKE_X, rapl_defaults_hsw_server),
980 INTEL_CPU_FAM6(ICELAKE_D, rapl_defaults_hsw_server),980 INTEL_CPU_FAM6(ICELAKE_D, rapl_defaults_hsw_server),
981 INTEL_CPU_FAM6(COMETLAKE_L, rapl_defaults_core),
982 INTEL_CPU_FAM6(COMETLAKE, rapl_defaults_core),
981 983
982 INTEL_CPU_FAM6(ATOM_SILVERMONT, rapl_defaults_byt),984 INTEL_CPU_FAM6(ATOM_SILVERMONT, rapl_defaults_byt),
983 INTEL_CPU_FAM6(ATOM_AIRMONT, rapl_defaults_cht),985 INTEL_CPU_FAM6(ATOM_AIRMONT, rapl_defaults_cht),
include/linux/pm.h+2−0
@@ -637,6 +637,7 @@ extern void dev_pm_put_subsys_data(struct device *dev); · 636 unmodified lines
637 * struct dev_pm_domain - power management domain representation.637 * struct dev_pm_domain - power management domain representation.
638 *638 *
639 * @ops: Power management operations associated with this domain.639 * @ops: Power management operations associated with this domain.
640 * @start: Called when a user needs to start the device via the domain.
640 * @detach: Called when removing a device from the domain.641 * @detach: Called when removing a device from the domain.
641 * @activate: Called before executing probe routines for bus types and drivers.642 * @activate: Called before executing probe routines for bus types and drivers.
642 * @sync: Called after successful driver probe.643 * @sync: Called after successful driver probe.
@@ -648,6 +649,7 @@ extern void dev_pm_put_subsys_data(struct device *dev); · 5 unmodified lines
648 */649 */
649struct dev_pm_domain {650struct dev_pm_domain {
650 struct dev_pm_ops ops;651 struct dev_pm_ops ops;
652 int (*start)(struct device *dev);
651 void (*detach)(struct device *dev, bool power_off);653 void (*detach)(struct device *dev, bool power_off);
652 int (*activate)(struct device *dev);654 int (*activate)(struct device *dev);
653 void (*sync)(struct device *dev);655 void (*sync)(struct device *dev);
include/linux/pm_domain.h+5−0
@@ -366,6 +366,7 @@ struct device *dev_pm_domain_attach_by_id(struct device *dev, · 365 unmodified lines
366struct device *dev_pm_domain_attach_by_name(struct device *dev,366struct device *dev_pm_domain_attach_by_name(struct device *dev,
367 const char *name);367 const char *name);
368void dev_pm_domain_detach(struct device *dev, bool power_off);368void dev_pm_domain_detach(struct device *dev, bool power_off);
369int dev_pm_domain_start(struct device *dev);
369void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd);370void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd);
370#else371#else
371static inline int dev_pm_domain_attach(struct device *dev, bool power_on)372static inline int dev_pm_domain_attach(struct device *dev, bool power_on)
@@ -383,6 +384,10 @@ static inline struct device *dev_pm_domain_attach_by_name(struct device *dev, · 11 unmodified lines
383 return NULL;384 return NULL;
384}385}
385static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {}386static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {}
387static inline int dev_pm_domain_start(struct device *dev)
388{
389 return 0;
390}
386static inline void dev_pm_domain_set(struct device *dev,391static inline void dev_pm_domain_set(struct device *dev,
387 struct dev_pm_domain *pd) {}392 struct dev_pm_domain *pd) {}
388#endif393#endif
include/linux/pm_opp.h+13−0
@@ -22,6 +22,7 @@ struct opp_table; · 21 unmodified lines
22 22
23enum dev_pm_opp_event {23enum dev_pm_opp_event {
24 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,24 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
25 OPP_EVENT_ADJUST_VOLTAGE,
25};26};
26 27
27/**28/**
@@ -113,6 +114,10 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, · 85 unmodified lines
113void dev_pm_opp_remove(struct device *dev, unsigned long freq);114void dev_pm_opp_remove(struct device *dev, unsigned long freq);
114void dev_pm_opp_remove_all_dynamic(struct device *dev);115void dev_pm_opp_remove_all_dynamic(struct device *dev);
115 116
117int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq,
118 unsigned long u_volt, unsigned long u_volt_min,
119 unsigned long u_volt_max);
120
116int dev_pm_opp_enable(struct device *dev, unsigned long freq);121int dev_pm_opp_enable(struct device *dev, unsigned long freq);
117 122
118int dev_pm_opp_disable(struct device *dev, unsigned long freq);123int dev_pm_opp_disable(struct device *dev, unsigned long freq);
@@ -242,6 +247,14 @@ static inline void dev_pm_opp_remove_all_dynamic(struct device *dev) · 123 unmodified lines
242{247{
243}248}
244 249
250static inline int
251dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq,
252 unsigned long u_volt, unsigned long u_volt_min,
253 unsigned long u_volt_max)
254{
255 return 0;
256}
257
245static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)258static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
246{259{
247 return 0;260 return 0;
kernel/power/snapshot.c+8−1
@@ -734,8 +734,15 @@ zone_found: · 733 unmodified lines
734 * We have found the zone. Now walk the radix tree to find the leaf node734 * We have found the zone. Now walk the radix tree to find the leaf node
735 * for our PFN.735 * for our PFN.
736 */736 */
737
738 /*
739 * If the zone we wish to scan is the the current zone and the
740 * pfn falls into the current node then we do not need to walk
741 * the tree.
742 */
737 node = bm->cur.node;743 node = bm->cur.node;
738 if (((pfn - zone->start_pfn) & ~BM_BLOCK_MASK) == bm->cur.node_pfn)744 if (zone == bm->cur.zone &&
745 ((pfn - zone->start_pfn) & ~BM_BLOCK_MASK) == bm->cur.node_pfn)
739 goto node_found;746 goto node_found;
740 747
741 node = zone->rtree;748 node = zone->rtree;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t