Skip to content

Commit cd0c5bd

Browse files
committed
Merge branches 'pnp', 'powercap', 'pm-runtime' and 'pm-opp'
* pnp: MAINTAINERS: Remove Bjorn Helgaas as PNP maintainer PNP / resources: remove positive test on unsigned values * powercap: powercap / RAPL: add new CPU IDs powercap / RAPL: further relax energy counter checks * pm-runtime: PM / runtime: Update documentation to reflect the current code flow * pm-opp: PM / OPP: discard duplicate OPPs PM / OPP: Make OPP invisible to users in Kconfig PM / OPP: fix incorrect OPP count handling in of_init_opp_table
5 parents e81a0e7 + 1873696 + a97ac35 + 4ec6a9c + 64ce854 commit cd0c5bd

6 files changed

Lines changed: 52 additions & 40 deletions

File tree

‎Documentation/power/runtime_pm.txt‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -665,15 +665,17 @@ The PM core does its best to reduce the probability of race conditions between
665665
the runtime PM and system suspend/resume (and hibernation) callbacks by carrying
666666
out the following operations:
667667

668-
* During system suspend it calls pm_runtime_get_noresume() and
669-
pm_runtime_barrier() for every device right before executing the
670-
subsystem-level .suspend() callback for it. In addition to that it calls
671-
__pm_runtime_disable() with 'false' as the second argument for every device
672-
right before executing the subsystem-level .suspend_late() callback for it.
673-
674-
* During system resume it calls pm_runtime_enable() and pm_runtime_put()
675-
for every device right after executing the subsystem-level .resume_early()
676-
callback and right after executing the subsystem-level .resume() callback
668+
* During system suspend pm_runtime_get_noresume() is called for every device
669+
right before executing the subsystem-level .prepare() callback for it and
670+
pm_runtime_barrier() is called for every device right before executing the
671+
subsystem-level .suspend() callback for it. In addition to that the PM core
672+
calls __pm_runtime_disable() with 'false' as the second argument for every
673+
device right before executing the subsystem-level .suspend_late() callback
674+
for it.
675+
676+
* During system resume pm_runtime_enable() and pm_runtime_put() are called for
677+
every device right after executing the subsystem-level .resume_early()
678+
callback and right after executing the subsystem-level .complete() callback
677679
for it, respectively.
678680

679681
7. Generic subsystem callbacks

‎MAINTAINERS‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6938,7 +6938,6 @@ F: drivers/power/
69386938

69396939
PNP SUPPORT
69406940
M: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6941-
M: Bjorn Helgaas <bhelgaas@google.com>
69426941
S: Maintained
69436942
F: drivers/pnp/
69446943

‎drivers/base/power/opp.c‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,13 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor);
394394
* to keep the integrity of the internal data structures. Callers should ensure
395395
* that this function is *NOT* called under RCU protection or in contexts where
396396
* mutex cannot be locked.
397+
*
398+
* Return:
399+
* 0: On success OR
400+
* Duplicate OPPs (both freq and volt are same) and opp->available
401+
* -EEXIST: Freq are same and volt are different OR
402+
* Duplicate OPPs (both freq and volt are same) and !opp->available
403+
* -ENOMEM: Memory allocation failure
397404
*/
398405
int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
399406
{
@@ -443,15 +450,31 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
443450
new_opp->u_volt = u_volt;
444451
new_opp->available = true;
445452

446-
/* Insert new OPP in order of increasing frequency */
453+
/*
454+
* Insert new OPP in order of increasing frequency
455+
* and discard if already present
456+
*/
447457
head = &dev_opp->opp_list;
448458
list_for_each_entry_rcu(opp, &dev_opp->opp_list, node) {
449-
if (new_opp->rate < opp->rate)
459+
if (new_opp->rate <= opp->rate)
450460
break;
451461
else
452462
head = &opp->node;
453463
}
454464

465+
/* Duplicate OPPs ? */
466+
if (new_opp->rate == opp->rate) {
467+
int ret = opp->available && new_opp->u_volt == opp->u_volt ?
468+
0 : -EEXIST;
469+
470+
dev_warn(dev, "%s: duplicate OPPs detected. Existing: freq: %lu, volt: %lu, enabled: %d. New: freq: %lu, volt: %lu, enabled: %d\n",
471+
__func__, opp->rate, opp->u_volt, opp->available,
472+
new_opp->rate, new_opp->u_volt, new_opp->available);
473+
mutex_unlock(&dev_opp_list_lock);
474+
kfree(new_opp);
475+
return ret;
476+
}
477+
455478
list_add_rcu(&new_opp->node, head);
456479
mutex_unlock(&dev_opp_list_lock);
457480

@@ -734,11 +757,9 @@ int of_init_opp_table(struct device *dev)
734757
unsigned long freq = be32_to_cpup(val++) * 1000;
735758
unsigned long volt = be32_to_cpup(val++);
736759

737-
if (dev_pm_opp_add(dev, freq, volt)) {
760+
if (dev_pm_opp_add(dev, freq, volt))
738761
dev_warn(dev, "%s: Failed to add OPP %ld\n",
739762
__func__, freq);
740-
continue;
741-
}
742763
nr -= 2;
743764
}
744765

‎drivers/pnp/resource.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
360360
return 1;
361361

362362
/* check if the resource is valid */
363-
if (*irq < 0 || *irq > 15)
363+
if (*irq > 15)
364364
return 0;
365365

366366
/* check if the resource is reserved */
@@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
424424
return 1;
425425

426426
/* check if the resource is valid */
427-
if (*dma < 0 || *dma == 4 || *dma > 7)
427+
if (*dma == 4 || *dma > 7)
428428
return 0;
429429

430430
/* check if the resource is reserved */

‎drivers/powercap/intel_rapl.c‎

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,9 @@ static const struct x86_cpu_id rapl_ids[] = {
951951
{ X86_VENDOR_INTEL, 6, 0x2d},/* Sandy Bridge EP */
952952
{ X86_VENDOR_INTEL, 6, 0x37},/* Valleyview */
953953
{ X86_VENDOR_INTEL, 6, 0x3a},/* Ivy Bridge */
954-
{ X86_VENDOR_INTEL, 6, 0x45},/* Haswell */
954+
{ X86_VENDOR_INTEL, 6, 0x3c},/* Haswell */
955+
{ X86_VENDOR_INTEL, 6, 0x3d},/* Broadwell */
956+
{ X86_VENDOR_INTEL, 6, 0x45},/* Haswell ULT */
955957
/* TODO: Add more CPU IDs after testing */
956958
{}
957959
};
@@ -1124,8 +1126,7 @@ static int rapl_register_powercap(void)
11241126
static int rapl_check_domain(int cpu, int domain)
11251127
{
11261128
unsigned msr;
1127-
u64 val1, val2 = 0;
1128-
int retry = 0;
1129+
u64 val = 0;
11291130

11301131
switch (domain) {
11311132
case RAPL_DOMAIN_PACKAGE:
@@ -1144,26 +1145,13 @@ static int rapl_check_domain(int cpu, int domain)
11441145
pr_err("invalid domain id %d\n", domain);
11451146
return -EINVAL;
11461147
}
1147-
if (rdmsrl_safe_on_cpu(cpu, msr, &val1))
1148-
return -ENODEV;
1149-
1150-
/* PP1/uncore/graphics domain may not be active at the time of
1151-
* driver loading. So skip further checks.
1148+
/* make sure domain counters are available and contains non-zero
1149+
* values, otherwise skip it.
11521150
*/
1153-
if (domain == RAPL_DOMAIN_PP1)
1154-
return 0;
1155-
/* energy counters roll slowly on some domains */
1156-
while (++retry < 10) {
1157-
usleep_range(10000, 15000);
1158-
rdmsrl_safe_on_cpu(cpu, msr, &val2);
1159-
if ((val1 & ENERGY_STATUS_MASK) != (val2 & ENERGY_STATUS_MASK))
1160-
return 0;
1161-
}
1162-
/* if energy counter does not change, report as bad domain */
1163-
pr_info("domain %s energy ctr %llu:%llu not working, skip\n",
1164-
rapl_domain_names[domain], val1, val2);
1151+
if (rdmsrl_safe_on_cpu(cpu, msr, &val) || !val)
1152+
return -ENODEV;
11651153

1166-
return -ENODEV;
1154+
return 0;
11671155
}
11681156

11691157
/* Detect active and valid domains for the given CPU, caller must
@@ -1180,6 +1168,9 @@ static int rapl_detect_domains(struct rapl_package *rp, int cpu)
11801168
/* use physical package id to read counters */
11811169
if (!rapl_check_domain(cpu, i))
11821170
rp->domain_map |= 1 << i;
1171+
else
1172+
pr_warn("RAPL domain %s detection failed\n",
1173+
rapl_domain_names[i]);
11831174
}
11841175
rp->nr_domains = bitmap_weight(&rp->domain_map, RAPL_DOMAIN_MAX);
11851176
if (!rp->nr_domains) {

‎kernel/power/Kconfig‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ config ARCH_HAS_OPP
257257
bool
258258

259259
config PM_OPP
260-
bool "Operating Performance Point (OPP) Layer library"
261-
depends on ARCH_HAS_OPP
260+
bool
262261
---help---
263262
SOCs have a standard set of tuples consisting of frequency and
264263
voltage pairs that the device will support per voltage domain. This

0 commit comments

Comments
 (0)