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()
This commit is contained in:
@@ -393,11 +393,9 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
|
||||
if (unlikely(!genpd->set_performance_state))
|
||||
return -EINVAL;
|
||||
|
||||
if (unlikely(!dev->power.subsys_data ||
|
||||
!dev->power.subsys_data->domain_data)) {
|
||||
WARN_ON(1);
|
||||
if (WARN_ON(!dev->power.subsys_data ||
|
||||
!dev->power.subsys_data->domain_data))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
genpd_lock(genpd);
|
||||
|
||||
@@ -1398,8 +1396,7 @@ EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron);
|
||||
|
||||
#endif /* CONFIG_PM_SLEEP */
|
||||
|
||||
static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev,
|
||||
struct gpd_timing_data *td)
|
||||
static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev)
|
||||
{
|
||||
struct generic_pm_domain_data *gpd_data;
|
||||
int ret;
|
||||
@@ -1414,9 +1411,6 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev,
|
||||
goto err_put;
|
||||
}
|
||||
|
||||
if (td)
|
||||
gpd_data->td = *td;
|
||||
|
||||
gpd_data->base.dev = dev;
|
||||
gpd_data->td.constraint_changed = true;
|
||||
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,
|
||||
dev_pm_put_subsys_data(dev);
|
||||
}
|
||||
|
||||
static void __genpd_update_cpumask(struct generic_pm_domain *genpd,
|
||||
int cpu, bool set, unsigned int depth)
|
||||
static void genpd_update_cpumask(struct generic_pm_domain *genpd,
|
||||
int cpu, bool set, unsigned int depth)
|
||||
{
|
||||
struct gpd_link *link;
|
||||
|
||||
@@ -1468,7 +1462,7 @@ static void __genpd_update_cpumask(struct generic_pm_domain *genpd,
|
||||
struct generic_pm_domain *master = link->master;
|
||||
|
||||
genpd_lock_nested(master, depth + 1);
|
||||
__genpd_update_cpumask(master, cpu, set, depth + 1);
|
||||
genpd_update_cpumask(master, cpu, set, depth + 1);
|
||||
genpd_unlock(master);
|
||||
}
|
||||
|
||||
@@ -1478,36 +1472,35 @@ static void __genpd_update_cpumask(struct generic_pm_domain *genpd,
|
||||
cpumask_clear_cpu(cpu, genpd->cpus);
|
||||
}
|
||||
|
||||
static void genpd_update_cpumask(struct generic_pm_domain *genpd,
|
||||
struct device *dev, bool set)
|
||||
static void genpd_set_cpumask(struct generic_pm_domain *genpd, int cpu)
|
||||
{
|
||||
if (cpu >= 0)
|
||||
genpd_update_cpumask(genpd, cpu, true, 0);
|
||||
}
|
||||
|
||||
static void genpd_clear_cpumask(struct generic_pm_domain *genpd, int cpu)
|
||||
{
|
||||
if (cpu >= 0)
|
||||
genpd_update_cpumask(genpd, cpu, false, 0);
|
||||
}
|
||||
|
||||
static int genpd_get_cpu(struct generic_pm_domain *genpd, struct device *dev)
|
||||
{
|
||||
int cpu;
|
||||
|
||||
if (!genpd_is_cpu_domain(genpd))
|
||||
return;
|
||||
return -1;
|
||||
|
||||
for_each_possible_cpu(cpu) {
|
||||
if (get_cpu_device(cpu) == dev) {
|
||||
__genpd_update_cpumask(genpd, cpu, set, 0);
|
||||
return;
|
||||
}
|
||||
if (get_cpu_device(cpu) == dev)
|
||||
return cpu;
|
||||
}
|
||||
}
|
||||
|
||||
static void genpd_set_cpumask(struct generic_pm_domain *genpd,
|
||||
struct device *dev)
|
||||
{
|
||||
genpd_update_cpumask(genpd, dev, true);
|
||||
}
|
||||
|
||||
static void genpd_clear_cpumask(struct generic_pm_domain *genpd,
|
||||
struct device *dev)
|
||||
{
|
||||
genpd_update_cpumask(genpd, dev, false);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
|
||||
struct gpd_timing_data *td)
|
||||
struct device *base_dev)
|
||||
{
|
||||
struct generic_pm_domain_data *gpd_data;
|
||||
int ret;
|
||||
@@ -1517,17 +1510,19 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
|
||||
if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev))
|
||||
return -EINVAL;
|
||||
|
||||
gpd_data = genpd_alloc_dev_data(dev, td);
|
||||
gpd_data = genpd_alloc_dev_data(dev);
|
||||
if (IS_ERR(gpd_data))
|
||||
return PTR_ERR(gpd_data);
|
||||
|
||||
gpd_data->cpu = genpd_get_cpu(genpd, base_dev);
|
||||
|
||||
ret = genpd->attach_dev ? genpd->attach_dev(genpd, dev) : 0;
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
genpd_lock(genpd);
|
||||
|
||||
genpd_set_cpumask(genpd, dev);
|
||||
genpd_set_cpumask(genpd, gpd_data->cpu);
|
||||
dev_pm_domain_set(dev, &genpd->domain);
|
||||
|
||||
genpd->device_count++;
|
||||
@@ -1555,7 +1550,7 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
|
||||
int ret;
|
||||
|
||||
mutex_lock(&gpd_list_lock);
|
||||
ret = genpd_add_device(genpd, dev, NULL);
|
||||
ret = genpd_add_device(genpd, dev, dev);
|
||||
mutex_unlock(&gpd_list_lock);
|
||||
|
||||
return ret;
|
||||
@@ -1585,7 +1580,7 @@ static int genpd_remove_device(struct generic_pm_domain *genpd,
|
||||
genpd->device_count--;
|
||||
genpd->max_off_time_changed = true;
|
||||
|
||||
genpd_clear_cpumask(genpd, dev);
|
||||
genpd_clear_cpumask(genpd, gpd_data->cpu);
|
||||
dev_pm_domain_set(dev, NULL);
|
||||
|
||||
list_del_init(&pdd->list_node);
|
||||
@@ -2261,7 +2256,7 @@ int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = genpd_add_device(genpd, dev, NULL);
|
||||
ret = genpd_add_device(genpd, dev, dev);
|
||||
|
||||
out:
|
||||
mutex_unlock(&gpd_list_lock);
|
||||
@@ -2345,6 +2340,7 @@ EXPORT_SYMBOL_GPL(of_genpd_remove_last);
|
||||
|
||||
static void genpd_release_dev(struct device *dev)
|
||||
{
|
||||
of_node_put(dev->of_node);
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
@@ -2406,14 +2402,14 @@ static void genpd_dev_pm_sync(struct device *dev)
|
||||
genpd_queue_power_off_work(pd);
|
||||
}
|
||||
|
||||
static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
|
||||
static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
|
||||
unsigned int index, bool power_on)
|
||||
{
|
||||
struct of_phandle_args pd_args;
|
||||
struct generic_pm_domain *pd;
|
||||
int ret;
|
||||
|
||||
ret = of_parse_phandle_with_args(np, "power-domains",
|
||||
ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
|
||||
"#power-domain-cells", index, &pd_args);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@@ -2425,12 +2421,12 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
|
||||
mutex_unlock(&gpd_list_lock);
|
||||
dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
|
||||
__func__, PTR_ERR(pd));
|
||||
return driver_deferred_probe_check_state(dev);
|
||||
return driver_deferred_probe_check_state(base_dev);
|
||||
}
|
||||
|
||||
dev_dbg(dev, "adding to PM domain %s\n", pd->name);
|
||||
|
||||
ret = genpd_add_device(pd, dev, NULL);
|
||||
ret = genpd_add_device(pd, dev, base_dev);
|
||||
mutex_unlock(&gpd_list_lock);
|
||||
|
||||
if (ret < 0) {
|
||||
@@ -2481,7 +2477,7 @@ int genpd_dev_pm_attach(struct device *dev)
|
||||
"#power-domain-cells") != 1)
|
||||
return 0;
|
||||
|
||||
return __genpd_dev_pm_attach(dev, dev->of_node, 0, true);
|
||||
return __genpd_dev_pm_attach(dev, dev, 0, true);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
|
||||
|
||||
@@ -2511,10 +2507,10 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
|
||||
if (!dev->of_node)
|
||||
return NULL;
|
||||
|
||||
/* Deal only with devices using multiple PM domains. */
|
||||
/* Verify that the index is within a valid range. */
|
||||
num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
|
||||
"#power-domain-cells");
|
||||
if (num_domains < 2 || index >= num_domains)
|
||||
if (index >= num_domains)
|
||||
return NULL;
|
||||
|
||||
/* Allocate and register device on the genpd bus. */
|
||||
@@ -2525,15 +2521,16 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
|
||||
dev_set_name(virt_dev, "genpd:%u:%s", index, dev_name(dev));
|
||||
virt_dev->bus = &genpd_bus_type;
|
||||
virt_dev->release = genpd_release_dev;
|
||||
virt_dev->of_node = of_node_get(dev->of_node);
|
||||
|
||||
ret = device_register(virt_dev);
|
||||
if (ret) {
|
||||
kfree(virt_dev);
|
||||
put_device(virt_dev);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
/* Try to attach the device to the PM domain at the specified index. */
|
||||
ret = __genpd_dev_pm_attach(virt_dev, dev->of_node, index, false);
|
||||
ret = __genpd_dev_pm_attach(virt_dev, dev, index, false);
|
||||
if (ret < 1) {
|
||||
device_unregister(virt_dev);
|
||||
return ret ? ERR_PTR(ret) : NULL;
|
||||
|
مرجع در شماره جدید
Block a user