Skip to content

Commit 5a97aa5

Browse files
committed
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
5 parents fa6a599 + 01ca482 + fe0c2ba + 16c71c5 + f84fdcb commit 5a97aa5

File tree

12 files changed

+157
-48
lines changed

12 files changed

+157
-48
lines changed

drivers/base/power/common.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,26 @@ void dev_pm_domain_detach(struct device *dev, bool power_off)
187187
}
188188
EXPORT_SYMBOL_GPL(dev_pm_domain_detach);
189189

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+
*/
201+
int 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+
}
208+
EXPORT_SYMBOL_GPL(dev_pm_domain_start);
209+
190210
/**
191211
* dev_pm_domain_set - Set PM domain of a device.
192212
* @dev: Device whose PM domain is to be set.

drivers/base/power/domain.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,13 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth)
634634
return ret;
635635
}
636636

637+
static 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+
637644
static int genpd_dev_pm_qos_notifier(struct notifier_block *nb,
638645
unsigned long val, void *ptr)
639646
{
@@ -922,24 +929,6 @@ static int __init genpd_power_off_unused(void)
922929
}
923930
late_initcall(genpd_power_off_unused);
924931

925-
#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_GENERIC_DOMAINS_OF)
926-
927-
static 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-
943932
#ifdef CONFIG_PM_SLEEP
944933

945934
/**
@@ -1354,8 +1343,8 @@ static void genpd_syscore_switch(struct device *dev, bool suspend)
13541343
{
13551344
struct generic_pm_domain *genpd;
13561345

1357-
genpd = dev_to_genpd(dev);
1358-
if (!genpd_present(genpd))
1346+
genpd = dev_to_genpd_safe(dev);
1347+
if (!genpd)
13591348
return;
13601349

13611350
if (suspend) {
@@ -1805,6 +1794,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
18051794
genpd->domain.ops.poweroff_noirq = genpd_poweroff_noirq;
18061795
genpd->domain.ops.restore_noirq = genpd_restore_noirq;
18071796
genpd->domain.ops.complete = genpd_complete;
1797+
genpd->domain.start = genpd_dev_pm_start;
18081798

18091799
if (genpd->flags & GENPD_FLAG_PM_CLK) {
18101800
genpd->dev_ops.stop = pm_clk_suspend;
@@ -2020,6 +2010,16 @@ static int genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
20202010
return 0;
20212011
}
20222012

2013+
static 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+
20232023
/**
20242024
* of_genpd_add_provider_simple() - Register a simple PM domain provider
20252025
* @np: Device node pointer associated with the PM domain provider.

drivers/base/power/power.h

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ static inline bool device_pm_initialized(struct device *dev)
117117
return dev->power.in_dpm_list;
118118
}
119119

120+
/* drivers/base/power/wakeup_stats.c */
121+
extern int wakeup_source_sysfs_add(struct device *parent,
122+
struct wakeup_source *ws);
123+
extern void wakeup_source_sysfs_remove(struct wakeup_source *ws);
124+
125+
extern int pm_wakeup_source_sysfs_add(struct device *parent);
126+
120127
#else /* !CONFIG_PM_SLEEP */
121128

122129
static inline void device_pm_sleep_init(struct device *dev) {}
@@ -141,6 +148,11 @@ static inline bool device_pm_initialized(struct device *dev)
141148
return device_is_registered(dev);
142149
}
143150

151+
static inline int pm_wakeup_source_sysfs_add(struct device *parent)
152+
{
153+
return 0;
154+
}
155+
144156
#endif /* !CONFIG_PM_SLEEP */
145157

146158
static inline void device_pm_init(struct device *dev)
@@ -149,21 +161,3 @@ static inline void device_pm_init(struct device *dev)
149161
device_pm_sleep_init(dev);
150162
pm_runtime_init(dev);
151163
}
152-
153-
#ifdef CONFIG_PM_SLEEP
154-
155-
/* drivers/base/power/wakeup_stats.c */
156-
extern int wakeup_source_sysfs_add(struct device *parent,
157-
struct wakeup_source *ws);
158-
extern void wakeup_source_sysfs_remove(struct wakeup_source *ws);
159-
160-
extern int pm_wakeup_source_sysfs_add(struct device *parent);
161-
162-
#else /* !CONFIG_PM_SLEEP */
163-
164-
static 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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void dev_pm_enable_wake_irq_check(struct device *dev,
272272
{
273273
struct wake_irq *wirq = dev->power.wakeirq;
274274

275-
if (!wirq || !((wirq->status & WAKE_IRQ_DEDICATED_MASK)))
275+
if (!wirq || !(wirq->status & WAKE_IRQ_DEDICATED_MASK))
276276
return;
277277

278278
if (likely(wirq->status & WAKE_IRQ_DEDICATED_MANAGED)) {
@@ -299,7 +299,7 @@ void dev_pm_disable_wake_irq_check(struct device *dev)
299299
{
300300
struct wake_irq *wirq = dev->power.wakeirq;
301301

302-
if (!wirq || !((wirq->status & WAKE_IRQ_DEDICATED_MASK)))
302+
if (!wirq || !(wirq->status & WAKE_IRQ_DEDICATED_MASK))
303303
return;
304304

305305
if (wirq->status & WAKE_IRQ_DEDICATED_MANAGED)

drivers/mmc/host/tmio_mmc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ struct tmio_mmc_host {
163163
unsigned long last_req_ts;
164164
struct mutex ios_lock; /* protect set_ios() context */
165165
bool native_hotplug;
166-
bool runtime_synced;
167166
bool sdio_irq_enabled;
168167

169168
/* Mandatory callback */

drivers/mmc/host/tmio_mmc_core.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <linux/module.h>
4040
#include <linux/pagemap.h>
4141
#include <linux/platform_device.h>
42+
#include <linux/pm_domain.h>
4243
#include <linux/pm_qos.h>
4344
#include <linux/pm_runtime.h>
4445
#include <linux/regulator/consumer.h>
@@ -1248,10 +1249,12 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
12481249
/* See if we also get DMA */
12491250
tmio_mmc_request_dma(_host, pdata);
12501251

1252+
dev_pm_domain_start(&pdev->dev);
1253+
pm_runtime_get_noresume(&pdev->dev);
1254+
pm_runtime_set_active(&pdev->dev);
12511255
pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
12521256
pm_runtime_use_autosuspend(&pdev->dev);
12531257
pm_runtime_enable(&pdev->dev);
1254-
pm_runtime_get_sync(&pdev->dev);
12551258

12561259
ret = mmc_add_host(mmc);
12571260
if (ret)
@@ -1333,11 +1336,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
13331336
{
13341337
struct tmio_mmc_host *host = dev_get_drvdata(dev);
13351338

1336-
if (!host->runtime_synced) {
1337-
host->runtime_synced = true;
1338-
return 0;
1339-
}
1340-
13411339
tmio_mmc_clk_enable(host);
13421340
tmio_mmc_hw_reset(host->mmc);
13431341

drivers/opp/core.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,75 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,
21022102
return r;
21032103
}
21042104

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+
*/
2117+
int 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+
2167+
adjust_unlock:
2168+
mutex_unlock(&opp_table->lock);
2169+
adjust_put_table:
2170+
dev_pm_opp_put_opp_table(opp_table);
2171+
return r;
2172+
}
2173+
21052174
/**
21062175
* dev_pm_opp_enable() - Enable a specific OPP
21072176
* @dev: device for which we do this operation

drivers/powercap/intel_rapl_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,8 @@ static const struct x86_cpu_id rapl_ids[] __initconst = {
978978
INTEL_CPU_FAM6(ICELAKE_NNPI, rapl_defaults_core),
979979
INTEL_CPU_FAM6(ICELAKE_X, rapl_defaults_hsw_server),
980980
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),
981983

982984
INTEL_CPU_FAM6(ATOM_SILVERMONT, rapl_defaults_byt),
983985
INTEL_CPU_FAM6(ATOM_AIRMONT, rapl_defaults_cht),

include/linux/pm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ extern void dev_pm_put_subsys_data(struct device *dev);
637637
* struct dev_pm_domain - power management domain representation.
638638
*
639639
* @ops: Power management operations associated with this domain.
640+
* @start: Called when a user needs to start the device via the domain.
640641
* @detach: Called when removing a device from the domain.
641642
* @activate: Called before executing probe routines for bus types and drivers.
642643
* @sync: Called after successful driver probe.
@@ -648,6 +649,7 @@ extern void dev_pm_put_subsys_data(struct device *dev);
648649
*/
649650
struct dev_pm_domain {
650651
struct dev_pm_ops ops;
652+
int (*start)(struct device *dev);
651653
void (*detach)(struct device *dev, bool power_off);
652654
int (*activate)(struct device *dev);
653655
void (*sync)(struct device *dev);

include/linux/pm_domain.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ struct device *dev_pm_domain_attach_by_id(struct device *dev,
366366
struct device *dev_pm_domain_attach_by_name(struct device *dev,
367367
const char *name);
368368
void dev_pm_domain_detach(struct device *dev, bool power_off);
369+
int dev_pm_domain_start(struct device *dev);
369370
void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd);
370371
#else
371372
static 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,
383384
return NULL;
384385
}
385386
static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {}
387+
static inline int dev_pm_domain_start(struct device *dev)
388+
{
389+
return 0;
390+
}
386391
static inline void dev_pm_domain_set(struct device *dev,
387392
struct dev_pm_domain *pd) {}
388393
#endif

0 commit comments

Comments
 (0)