Commit 4614e0cc authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branches 'pm-cpu', 'pm-cpuidle' and 'pm-domains'

* pm-cpu:
  kernel/cpu_pm: fix cpu_cluster_pm_exit comment

* pm-cpuidle:
  cpuidle/coupled: Add sanity check for safe_state_index

* pm-domains:
  staging: board: Migrate away from __pm_genpd_name_add_device()
  PM / Domains: Ensure subdomain is not in use before removing
  PM / Domains: Try power off masters in error path of __pm_genpd_poweron()
...@@ -212,6 +212,18 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool timed) ...@@ -212,6 +212,18 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool timed)
return ret; return ret;
} }
/**
* genpd_queue_power_off_work - Queue up the execution of pm_genpd_poweroff().
* @genpd: PM domait to power off.
*
* Queue up the execution of pm_genpd_poweroff() unless it's already been done
* before.
*/
static void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
{
queue_work(pm_wq, &genpd->power_off_work);
}
/** /**
* __pm_genpd_poweron - Restore power to a given PM domain and its masters. * __pm_genpd_poweron - Restore power to a given PM domain and its masters.
* @genpd: PM domain to power up. * @genpd: PM domain to power up.
...@@ -259,8 +271,12 @@ static int __pm_genpd_poweron(struct generic_pm_domain *genpd) ...@@ -259,8 +271,12 @@ static int __pm_genpd_poweron(struct generic_pm_domain *genpd)
return 0; return 0;
err: err:
list_for_each_entry_continue_reverse(link, &genpd->slave_links, slave_node) list_for_each_entry_continue_reverse(link,
&genpd->slave_links,
slave_node) {
genpd_sd_counter_dec(link->master); genpd_sd_counter_dec(link->master);
genpd_queue_power_off_work(link->master);
}
return ret; return ret;
} }
...@@ -348,18 +364,6 @@ static int genpd_dev_pm_qos_notifier(struct notifier_block *nb, ...@@ -348,18 +364,6 @@ static int genpd_dev_pm_qos_notifier(struct notifier_block *nb,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
/**
* genpd_queue_power_off_work - Queue up the execution of pm_genpd_poweroff().
* @genpd: PM domait to power off.
*
* Queue up the execution of pm_genpd_poweroff() unless it's already been done
* before.
*/
static void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
{
queue_work(pm_wq, &genpd->power_off_work);
}
/** /**
* pm_genpd_poweroff - Remove power from a given PM domain. * pm_genpd_poweroff - Remove power from a given PM domain.
* @genpd: PM domain to power down. * @genpd: PM domain to power down.
...@@ -1469,6 +1473,13 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, ...@@ -1469,6 +1473,13 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
mutex_lock(&genpd->lock); mutex_lock(&genpd->lock);
if (!list_empty(&subdomain->slave_links) || subdomain->device_count) {
pr_warn("%s: unable to remove subdomain %s\n", genpd->name,
subdomain->name);
ret = -EBUSY;
goto out;
}
list_for_each_entry(link, &genpd->master_links, master_node) { list_for_each_entry(link, &genpd->master_links, master_node) {
if (link->slave != subdomain) if (link->slave != subdomain)
continue; continue;
...@@ -1487,6 +1498,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, ...@@ -1487,6 +1498,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
break; break;
} }
out:
mutex_unlock(&genpd->lock); mutex_unlock(&genpd->lock);
return ret; return ret;
......
...@@ -186,6 +186,28 @@ bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state) ...@@ -186,6 +186,28 @@ bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state)
return drv->states[state].flags & CPUIDLE_FLAG_COUPLED; return drv->states[state].flags & CPUIDLE_FLAG_COUPLED;
} }
/**
* cpuidle_coupled_state_verify - check if the coupled states are correctly set.
* @drv: struct cpuidle_driver for the platform
*
* Returns 0 for valid state values, a negative error code otherwise:
* * -EINVAL if any coupled state(safe_state_index) is wrongly set.
*/
int cpuidle_coupled_state_verify(struct cpuidle_driver *drv)
{
int i;
for (i = drv->state_count - 1; i >= 0; i--) {
if (cpuidle_state_is_coupled(drv, i) &&
(drv->safe_state_index == i ||
drv->safe_state_index < 0 ||
drv->safe_state_index >= drv->state_count))
return -EINVAL;
}
return 0;
}
/** /**
* cpuidle_coupled_set_ready - mark a cpu as ready * cpuidle_coupled_set_ready - mark a cpu as ready
* @coupled: the struct coupled that contains the current cpu * @coupled: the struct coupled that contains the current cpu
......
...@@ -35,6 +35,7 @@ extern void cpuidle_remove_sysfs(struct cpuidle_device *dev); ...@@ -35,6 +35,7 @@ extern void cpuidle_remove_sysfs(struct cpuidle_device *dev);
#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state); bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state);
int cpuidle_coupled_state_verify(struct cpuidle_driver *drv);
int cpuidle_enter_state_coupled(struct cpuidle_device *dev, int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int next_state); struct cpuidle_driver *drv, int next_state);
int cpuidle_coupled_register_device(struct cpuidle_device *dev); int cpuidle_coupled_register_device(struct cpuidle_device *dev);
...@@ -46,6 +47,11 @@ bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state) ...@@ -46,6 +47,11 @@ bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state)
return false; return false;
} }
static inline int cpuidle_coupled_state_verify(struct cpuidle_driver *drv)
{
return 0;
}
static inline int cpuidle_enter_state_coupled(struct cpuidle_device *dev, static inline int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int next_state) struct cpuidle_driver *drv, int next_state)
{ {
......
...@@ -227,6 +227,10 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv) ...@@ -227,6 +227,10 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv)
if (!drv || !drv->state_count) if (!drv || !drv->state_count)
return -EINVAL; return -EINVAL;
ret = cpuidle_coupled_state_verify(drv);
if (ret)
return ret;
if (cpuidle_disabled()) if (cpuidle_disabled())
return -ENODEV; return -ENODEV;
......
...@@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = { ...@@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
.pdev = &lcdc0_device, .pdev = &lcdc0_device,
.clocks = lcdc0_clocks, .clocks = lcdc0_clocks,
.nclocks = ARRAY_SIZE(lcdc0_clocks), .nclocks = ARRAY_SIZE(lcdc0_clocks),
.domain = "a4lc", .domain = "/system-controller@e6180000/pm-domains/c5/a4lc@1"
}, },
}; };
......
...@@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc) ...@@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
return error; return error;
} }
#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
static int board_staging_add_dev_domain(struct platform_device *pdev,
const char *domain)
{
struct of_phandle_args pd_args;
struct generic_pm_domain *pd;
struct device_node *np;
np = of_find_node_by_path(domain);
if (!np) {
pr_err("Cannot find domain node %s\n", domain);
return -ENOENT;
}
pd_args.np = np;
pd_args.args_count = 0;
pd = of_genpd_get_from_provider(&pd_args);
if (IS_ERR(pd)) {
pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
return PTR_ERR(pd);
}
pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
return pm_genpd_add_device(pd, &pdev->dev);
}
#else
static inline int board_staging_add_dev_domain(struct platform_device *pdev,
const char *domain)
{
return 0;
}
#endif
int __init board_staging_register_device(const struct board_staging_dev *dev) int __init board_staging_register_device(const struct board_staging_dev *dev)
{ {
struct platform_device *pdev = dev->pdev; struct platform_device *pdev = dev->pdev;
...@@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev) ...@@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
} }
if (dev->domain) if (dev->domain)
__pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL); board_staging_add_dev_domain(pdev, dev->domain);
return error; return error;
} }
......
...@@ -180,7 +180,7 @@ EXPORT_SYMBOL_GPL(cpu_cluster_pm_enter); ...@@ -180,7 +180,7 @@ EXPORT_SYMBOL_GPL(cpu_cluster_pm_enter);
* low power state that may have caused some blocks in the same power domain * low power state that may have caused some blocks in the same power domain
* to reset. * to reset.
* *
* Must be called after cpu_pm_exit has been called on all cpus in the power * Must be called after cpu_cluster_pm_enter has been called for the power
* domain, and before cpu_pm_exit has been called on any cpu in the power * domain, and before cpu_pm_exit has been called on any cpu in the power
* domain. Notified drivers can include VFP co-processor, interrupt controller * domain. Notified drivers can include VFP co-processor, interrupt controller
* and its PM extensions, local CPU timers context save/restore which * and its PM extensions, local CPU timers context save/restore which
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment