Skip to content

Commit e07095c

Browse files
committed
Merge branches 'pm-devfreq' and 'pm-domains'
* pm-devfreq: PM / devfreq: add tracing for scheduling work trace: events: add devfreq trace event file PM / devfreq: rk3399_dmc: Pass ODT and auto power down parameters to TF-A. PM / devfreq: rockchip-dfi: Move GRF definitions to a common place. PM / devfreq: exynos-bus: Suspend all devices on system shutdown PM / devfreq: Fix static checker warning in try_then_request_governor PM / devfreq: Restart previous governor if new governor fails to start PM / devfreq: tegra: remove unneeded variable PM / devfreq: rockchip-dfi: remove unneeded semicolon PM / devfreq: rk3399_dmc: remove unneeded semicolon PM / devfreq: consistent indentation PM / devfreq: fix missing check of return value in devfreq_add_device() PM / devfreq: fix mem leak in devfreq_add_device() PM / devfreq: Use of_node_name_eq for node name comparisons * pm-domains: PM / Domains: Allow to attach a CPU via genpd_dev_pm_attach_by_id|name() PM / Domains: Search for the CPU device outside the genpd lock PM / Domains: Drop unused in-parameter to some genpd functions PM / Domains: Use the base device for driver_deferred_probe_check_state() PM / Domains: Enable genpd_dev_pm_attach_by_id|name() for single PM domain PM / Domains: Allow OF lookup for multi PM domain case from ->attach_dev() PM / Domains: Don't kfree() the virtual device in the error path PM / Domains: remove unnecessary unlikely()
3 parents 7afc539 + e32d939 + f9ccd7c commit e07095c

File tree

13 files changed

+256
-102
lines changed

13 files changed

+256
-102
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4553,6 +4553,7 @@ S: Maintained
45534553
F: drivers/devfreq/
45544554
F: include/linux/devfreq.h
45554555
F: Documentation/devicetree/bindings/devfreq/
4556+
F: include/trace/events/devfreq.h
45564557

45574558
DEVICE FREQUENCY EVENT (DEVFREQ-EVENT)
45584559
M: Chanwoo Choi <[email protected]>

drivers/base/power/domain.c

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,9 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
393393
if (unlikely(!genpd->set_performance_state))
394394
return -EINVAL;
395395

396-
if (unlikely(!dev->power.subsys_data ||
397-
!dev->power.subsys_data->domain_data)) {
398-
WARN_ON(1);
396+
if (WARN_ON(!dev->power.subsys_data ||
397+
!dev->power.subsys_data->domain_data))
399398
return -EINVAL;
400-
}
401399

402400
genpd_lock(genpd);
403401

@@ -1398,8 +1396,7 @@ EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron);
13981396

13991397
#endif /* CONFIG_PM_SLEEP */
14001398

1401-
static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev,
1402-
struct gpd_timing_data *td)
1399+
static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev)
14031400
{
14041401
struct generic_pm_domain_data *gpd_data;
14051402
int ret;
@@ -1414,9 +1411,6 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev,
14141411
goto err_put;
14151412
}
14161413

1417-
if (td)
1418-
gpd_data->td = *td;
1419-
14201414
gpd_data->base.dev = dev;
14211415
gpd_data->td.constraint_changed = true;
14221416
gpd_data->td.effective_constraint_ns = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS;
@@ -1456,8 +1450,8 @@ static void genpd_free_dev_data(struct device *dev,
14561450
dev_pm_put_subsys_data(dev);
14571451
}
14581452

1459-
static void __genpd_update_cpumask(struct generic_pm_domain *genpd,
1460-
int cpu, bool set, unsigned int depth)
1453+
static void genpd_update_cpumask(struct generic_pm_domain *genpd,
1454+
int cpu, bool set, unsigned int depth)
14611455
{
14621456
struct gpd_link *link;
14631457

@@ -1468,7 +1462,7 @@ static void __genpd_update_cpumask(struct generic_pm_domain *genpd,
14681462
struct generic_pm_domain *master = link->master;
14691463

14701464
genpd_lock_nested(master, depth + 1);
1471-
__genpd_update_cpumask(master, cpu, set, depth + 1);
1465+
genpd_update_cpumask(master, cpu, set, depth + 1);
14721466
genpd_unlock(master);
14731467
}
14741468

@@ -1478,36 +1472,35 @@ static void __genpd_update_cpumask(struct generic_pm_domain *genpd,
14781472
cpumask_clear_cpu(cpu, genpd->cpus);
14791473
}
14801474

1481-
static void genpd_update_cpumask(struct generic_pm_domain *genpd,
1482-
struct device *dev, bool set)
1475+
static void genpd_set_cpumask(struct generic_pm_domain *genpd, int cpu)
1476+
{
1477+
if (cpu >= 0)
1478+
genpd_update_cpumask(genpd, cpu, true, 0);
1479+
}
1480+
1481+
static void genpd_clear_cpumask(struct generic_pm_domain *genpd, int cpu)
1482+
{
1483+
if (cpu >= 0)
1484+
genpd_update_cpumask(genpd, cpu, false, 0);
1485+
}
1486+
1487+
static int genpd_get_cpu(struct generic_pm_domain *genpd, struct device *dev)
14831488
{
14841489
int cpu;
14851490

14861491
if (!genpd_is_cpu_domain(genpd))
1487-
return;
1492+
return -1;
14881493

14891494
for_each_possible_cpu(cpu) {
1490-
if (get_cpu_device(cpu) == dev) {
1491-
__genpd_update_cpumask(genpd, cpu, set, 0);
1492-
return;
1493-
}
1495+
if (get_cpu_device(cpu) == dev)
1496+
return cpu;
14941497
}
1495-
}
14961498

1497-
static void genpd_set_cpumask(struct generic_pm_domain *genpd,
1498-
struct device *dev)
1499-
{
1500-
genpd_update_cpumask(genpd, dev, true);
1501-
}
1502-
1503-
static void genpd_clear_cpumask(struct generic_pm_domain *genpd,
1504-
struct device *dev)
1505-
{
1506-
genpd_update_cpumask(genpd, dev, false);
1499+
return -1;
15071500
}
15081501

15091502
static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
1510-
struct gpd_timing_data *td)
1503+
struct device *base_dev)
15111504
{
15121505
struct generic_pm_domain_data *gpd_data;
15131506
int ret;
@@ -1517,17 +1510,19 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
15171510
if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev))
15181511
return -EINVAL;
15191512

1520-
gpd_data = genpd_alloc_dev_data(dev, td);
1513+
gpd_data = genpd_alloc_dev_data(dev);
15211514
if (IS_ERR(gpd_data))
15221515
return PTR_ERR(gpd_data);
15231516

1517+
gpd_data->cpu = genpd_get_cpu(genpd, base_dev);
1518+
15241519
ret = genpd->attach_dev ? genpd->attach_dev(genpd, dev) : 0;
15251520
if (ret)
15261521
goto out;
15271522

15281523
genpd_lock(genpd);
15291524

1530-
genpd_set_cpumask(genpd, dev);
1525+
genpd_set_cpumask(genpd, gpd_data->cpu);
15311526
dev_pm_domain_set(dev, &genpd->domain);
15321527

15331528
genpd->device_count++;
@@ -1555,7 +1550,7 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
15551550
int ret;
15561551

15571552
mutex_lock(&gpd_list_lock);
1558-
ret = genpd_add_device(genpd, dev, NULL);
1553+
ret = genpd_add_device(genpd, dev, dev);
15591554
mutex_unlock(&gpd_list_lock);
15601555

15611556
return ret;
@@ -1585,7 +1580,7 @@ static int genpd_remove_device(struct generic_pm_domain *genpd,
15851580
genpd->device_count--;
15861581
genpd->max_off_time_changed = true;
15871582

1588-
genpd_clear_cpumask(genpd, dev);
1583+
genpd_clear_cpumask(genpd, gpd_data->cpu);
15891584
dev_pm_domain_set(dev, NULL);
15901585

15911586
list_del_init(&pdd->list_node);
@@ -2261,7 +2256,7 @@ int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev)
22612256
goto out;
22622257
}
22632258

2264-
ret = genpd_add_device(genpd, dev, NULL);
2259+
ret = genpd_add_device(genpd, dev, dev);
22652260

22662261
out:
22672262
mutex_unlock(&gpd_list_lock);
@@ -2345,6 +2340,7 @@ EXPORT_SYMBOL_GPL(of_genpd_remove_last);
23452340

23462341
static void genpd_release_dev(struct device *dev)
23472342
{
2343+
of_node_put(dev->of_node);
23482344
kfree(dev);
23492345
}
23502346

@@ -2406,14 +2402,14 @@ static void genpd_dev_pm_sync(struct device *dev)
24062402
genpd_queue_power_off_work(pd);
24072403
}
24082404

2409-
static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
2405+
static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
24102406
unsigned int index, bool power_on)
24112407
{
24122408
struct of_phandle_args pd_args;
24132409
struct generic_pm_domain *pd;
24142410
int ret;
24152411

2416-
ret = of_parse_phandle_with_args(np, "power-domains",
2412+
ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
24172413
"#power-domain-cells", index, &pd_args);
24182414
if (ret < 0)
24192415
return ret;
@@ -2425,12 +2421,12 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
24252421
mutex_unlock(&gpd_list_lock);
24262422
dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
24272423
__func__, PTR_ERR(pd));
2428-
return driver_deferred_probe_check_state(dev);
2424+
return driver_deferred_probe_check_state(base_dev);
24292425
}
24302426

24312427
dev_dbg(dev, "adding to PM domain %s\n", pd->name);
24322428

2433-
ret = genpd_add_device(pd, dev, NULL);
2429+
ret = genpd_add_device(pd, dev, base_dev);
24342430
mutex_unlock(&gpd_list_lock);
24352431

24362432
if (ret < 0) {
@@ -2481,7 +2477,7 @@ int genpd_dev_pm_attach(struct device *dev)
24812477
"#power-domain-cells") != 1)
24822478
return 0;
24832479

2484-
return __genpd_dev_pm_attach(dev, dev->of_node, 0, true);
2480+
return __genpd_dev_pm_attach(dev, dev, 0, true);
24852481
}
24862482
EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
24872483

@@ -2511,10 +2507,10 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
25112507
if (!dev->of_node)
25122508
return NULL;
25132509

2514-
/* Deal only with devices using multiple PM domains. */
2510+
/* Verify that the index is within a valid range. */
25152511
num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
25162512
"#power-domain-cells");
2517-
if (num_domains < 2 || index >= num_domains)
2513+
if (index >= num_domains)
25182514
return NULL;
25192515

25202516
/* Allocate and register device on the genpd bus. */
@@ -2525,15 +2521,16 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
25252521
dev_set_name(virt_dev, "genpd:%u:%s", index, dev_name(dev));
25262522
virt_dev->bus = &genpd_bus_type;
25272523
virt_dev->release = genpd_release_dev;
2524+
virt_dev->of_node = of_node_get(dev->of_node);
25282525

25292526
ret = device_register(virt_dev);
25302527
if (ret) {
2531-
kfree(virt_dev);
2528+
put_device(virt_dev);
25322529
return ERR_PTR(ret);
25332530
}
25342531

25352532
/* Try to attach the device to the PM domain at the specified index. */
2536-
ret = __genpd_dev_pm_attach(virt_dev, dev->of_node, index, false);
2533+
ret = __genpd_dev_pm_attach(virt_dev, dev, index, false);
25372534
if (ret < 1) {
25382535
device_unregister(virt_dev);
25392536
return ret ? ERR_PTR(ret) : NULL;

drivers/devfreq/devfreq-event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev,
240240
}
241241

242242
list_for_each_entry(edev, &devfreq_event_list, node) {
243-
if (!strcmp(edev->desc->name, node->name))
243+
if (of_node_name_eq(node, edev->desc->name))
244244
goto out;
245245
}
246246
edev = NULL;

0 commit comments

Comments
 (0)