diff options
author | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
commit | 62b8c978ee6b8d135d9e7953221de58000dba986 (patch) | |
tree | 683b04b2e627f6710c22c151b23c8cc9a165315e /drivers/base/power | |
parent | 78fd82238d0e5716578c326404184a27ba67fd6e (diff) | |
download | linux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz |
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'drivers/base/power')
-rw-r--r-- | drivers/base/power/main.c | 80 | ||||
-rw-r--r-- | drivers/base/power/opp.c | 115 | ||||
-rw-r--r-- | drivers/base/power/runtime.c | 5 |
3 files changed, 60 insertions, 140 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 1b41fca..9f098a8 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -30,8 +30,6 @@ #include <linux/suspend.h> #include <trace/events/power.h> #include <linux/cpuidle.h> -#include <linux/timer.h> - #include "../base.h" #include "power.h" @@ -392,71 +390,6 @@ static int dpm_run_callback(pm_callback_t cb, struct device *dev, return error; } -#ifdef CONFIG_DPM_WATCHDOG -struct dpm_watchdog { - struct device *dev; - struct task_struct *tsk; - struct timer_list timer; -}; - -#define DECLARE_DPM_WATCHDOG_ON_STACK(wd) \ - struct dpm_watchdog wd - -/** - * dpm_watchdog_handler - Driver suspend / resume watchdog handler. - * @data: Watchdog object address. - * - * Called when a driver has timed out suspending or resuming. - * There's not much we can do here to recover so panic() to - * capture a crash-dump in pstore. - */ -static void dpm_watchdog_handler(unsigned long data) -{ - struct dpm_watchdog *wd = (void *)data; - - dev_emerg(wd->dev, "**** DPM device timeout ****\n"); - show_stack(wd->tsk, NULL); - panic("%s %s: unrecoverable failure\n", - dev_driver_string(wd->dev), dev_name(wd->dev)); -} - -/** - * dpm_watchdog_set - Enable pm watchdog for given device. - * @wd: Watchdog. Must be allocated on the stack. - * @dev: Device to handle. - */ -static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev) -{ - struct timer_list *timer = &wd->timer; - - wd->dev = dev; - wd->tsk = current; - - init_timer_on_stack(timer); - /* use same timeout value for both suspend and resume */ - timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_TIMEOUT; - timer->function = dpm_watchdog_handler; - timer->data = (unsigned long)wd; - add_timer(timer); -} - -/** - * dpm_watchdog_clear - Disable suspend/resume watchdog. - * @wd: Watchdog to disable. - */ -static void dpm_watchdog_clear(struct dpm_watchdog *wd) -{ - struct timer_list *timer = &wd->timer; - - del_timer_sync(timer); - destroy_timer_on_stack(timer); -} -#else -#define DECLARE_DPM_WATCHDOG_ON_STACK(wd) -#define dpm_watchdog_set(x, y) -#define dpm_watchdog_clear(x) -#endif - /*------------------------- Resume routines -------------------------*/ /** @@ -643,7 +576,6 @@ static int device_resume(struct device *dev, pm_message_t state, bool async) pm_callback_t callback = NULL; char *info = NULL; int error = 0; - DECLARE_DPM_WATCHDOG_ON_STACK(wd); TRACE_DEVICE(dev); TRACE_RESUME(0); @@ -652,7 +584,6 @@ static int device_resume(struct device *dev, pm_message_t state, bool async) goto Complete; dpm_wait(dev->parent, async); - dpm_watchdog_set(&wd, dev); device_lock(dev); /* @@ -711,7 +642,6 @@ static int device_resume(struct device *dev, pm_message_t state, bool async) Unlock: device_unlock(dev); - dpm_watchdog_clear(&wd); Complete: complete_all(&dev->power.completion); @@ -757,7 +687,7 @@ void dpm_resume(pm_message_t state) async_error = 0; list_for_each_entry(dev, &dpm_suspended_list, power.entry) { - reinit_completion(&dev->power.completion); + INIT_COMPLETION(dev->power.completion); if (is_async(dev)) { get_device(dev); async_schedule(async_resume, dev); @@ -1130,7 +1060,6 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) pm_callback_t callback = NULL; char *info = NULL; int error = 0; - DECLARE_DPM_WATCHDOG_ON_STACK(wd); dpm_wait_for_children(dev, async); @@ -1154,7 +1083,6 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) if (dev->power.syscore) goto Complete; - dpm_watchdog_set(&wd, dev); device_lock(dev); if (dev->pm_domain) { @@ -1211,7 +1139,6 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) } device_unlock(dev); - dpm_watchdog_clear(&wd); Complete: complete_all(&dev->power.completion); @@ -1237,7 +1164,7 @@ static void async_suspend(void *data, async_cookie_t cookie) static int device_suspend(struct device *dev) { - reinit_completion(&dev->power.completion); + INIT_COMPLETION(dev->power.completion); if (pm_async_enabled && dev->power.async_suspend) { get_device(dev); @@ -1350,9 +1277,6 @@ static int device_prepare(struct device *dev, pm_message_t state) device_unlock(dev); - if (error) - pm_runtime_put(dev); - return error; } diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index fa41874..ef89897 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -21,7 +21,7 @@ #include <linux/list.h> #include <linux/rculist.h> #include <linux/rcupdate.h> -#include <linux/pm_opp.h> +#include <linux/opp.h> #include <linux/of.h> #include <linux/export.h> @@ -42,7 +42,7 @@ */ /** - * struct dev_pm_opp - Generic OPP description structure + * struct opp - Generic OPP description structure * @node: opp list node. The nodes are maintained throughout the lifetime * of boot. It is expected only an optimal set of OPPs are * added to the library by the SoC framework. @@ -59,7 +59,7 @@ * * This structure stores the OPP information for a given device. */ -struct dev_pm_opp { +struct opp { struct list_head node; bool available; @@ -136,7 +136,7 @@ static struct device_opp *find_device_opp(struct device *dev) } /** - * dev_pm_opp_get_voltage() - Gets the voltage corresponding to an available opp + * opp_get_voltage() - Gets the voltage corresponding to an available opp * @opp: opp for which voltage has to be returned for * * Return voltage in micro volt corresponding to the opp, else @@ -150,9 +150,9 @@ static struct device_opp *find_device_opp(struct device *dev) * prior to unlocking with rcu_read_unlock() to maintain the integrity of the * pointer. */ -unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) +unsigned long opp_get_voltage(struct opp *opp) { - struct dev_pm_opp *tmp_opp; + struct opp *tmp_opp; unsigned long v = 0; tmp_opp = rcu_dereference(opp); @@ -163,10 +163,10 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) return v; } -EXPORT_SYMBOL_GPL(dev_pm_opp_get_voltage); +EXPORT_SYMBOL_GPL(opp_get_voltage); /** - * dev_pm_opp_get_freq() - Gets the frequency corresponding to an available opp + * opp_get_freq() - Gets the frequency corresponding to an available opp * @opp: opp for which frequency has to be returned for * * Return frequency in hertz corresponding to the opp, else @@ -180,9 +180,9 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_voltage); * prior to unlocking with rcu_read_unlock() to maintain the integrity of the * pointer. */ -unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) +unsigned long opp_get_freq(struct opp *opp) { - struct dev_pm_opp *tmp_opp; + struct opp *tmp_opp; unsigned long f = 0; tmp_opp = rcu_dereference(opp); @@ -193,10 +193,10 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) return f; } -EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); +EXPORT_SYMBOL_GPL(opp_get_freq); /** - * dev_pm_opp_get_opp_count() - Get number of opps available in the opp list + * opp_get_opp_count() - Get number of opps available in the opp list * @dev: device for which we do this operation * * This function returns the number of available opps if there are any, @@ -206,10 +206,10 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); * internally references two RCU protected structures: device_opp and opp which * are safe as long as we are under a common RCU locked section. */ -int dev_pm_opp_get_opp_count(struct device *dev) +int opp_get_opp_count(struct device *dev) { struct device_opp *dev_opp; - struct dev_pm_opp *temp_opp; + struct opp *temp_opp; int count = 0; dev_opp = find_device_opp(dev); @@ -226,10 +226,10 @@ int dev_pm_opp_get_opp_count(struct device *dev) return count; } -EXPORT_SYMBOL_GPL(dev_pm_opp_get_opp_count); +EXPORT_SYMBOL_GPL(opp_get_opp_count); /** - * dev_pm_opp_find_freq_exact() - search for an exact frequency + * opp_find_freq_exact() - search for an exact frequency * @dev: device for which we do this operation * @freq: frequency to search for * @available: true/false - match for available opp @@ -254,12 +254,11 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_opp_count); * under the locked area. The pointer returned must be used prior to unlocking * with rcu_read_unlock() to maintain the integrity of the pointer. */ -struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, - unsigned long freq, - bool available) +struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq, + bool available) { struct device_opp *dev_opp; - struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); + struct opp *temp_opp, *opp = ERR_PTR(-ERANGE); dev_opp = find_device_opp(dev); if (IS_ERR(dev_opp)) { @@ -278,10 +277,10 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, return opp; } -EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact); +EXPORT_SYMBOL_GPL(opp_find_freq_exact); /** - * dev_pm_opp_find_freq_ceil() - Search for an rounded ceil freq + * opp_find_freq_ceil() - Search for an rounded ceil freq * @dev: device for which we do this operation * @freq: Start frequency * @@ -301,11 +300,10 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact); * under the locked area. The pointer returned must be used prior to unlocking * with rcu_read_unlock() to maintain the integrity of the pointer. */ -struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, - unsigned long *freq) +struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq) { struct device_opp *dev_opp; - struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); + struct opp *temp_opp, *opp = ERR_PTR(-ERANGE); if (!dev || !freq) { dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq); @@ -326,10 +324,10 @@ struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, return opp; } -EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil); +EXPORT_SYMBOL_GPL(opp_find_freq_ceil); /** - * dev_pm_opp_find_freq_floor() - Search for a rounded floor freq + * opp_find_freq_floor() - Search for a rounded floor freq * @dev: device for which we do this operation * @freq: Start frequency * @@ -349,11 +347,10 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil); * under the locked area. The pointer returned must be used prior to unlocking * with rcu_read_unlock() to maintain the integrity of the pointer. */ -struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, - unsigned long *freq) +struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq) { struct device_opp *dev_opp; - struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); + struct opp *temp_opp, *opp = ERR_PTR(-ERANGE); if (!dev || !freq) { dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq); @@ -378,17 +375,17 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, return opp; } -EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); +EXPORT_SYMBOL_GPL(opp_find_freq_floor); /** - * dev_pm_opp_add() - Add an OPP table from a table definitions + * opp_add() - Add an OPP table from a table definitions * @dev: device for which we do this operation * @freq: Frequency in Hz for this OPP * @u_volt: Voltage in uVolts for this OPP * * This function adds an opp definition to the opp list and returns status. * The opp is made available by default and it can be controlled using - * dev_pm_opp_enable/disable functions. + * opp_enable/disable functions. * * Locking: The internal device_opp and opp structures are RCU protected. * Hence this function internally uses RCU updater strategy with mutex locks @@ -396,14 +393,14 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); * that this function is *NOT* called under RCU protection or in contexts where * mutex cannot be locked. */ -int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) +int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) { struct device_opp *dev_opp = NULL; - struct dev_pm_opp *opp, *new_opp; + struct opp *opp, *new_opp; struct list_head *head; /* allocate new OPP node */ - new_opp = kzalloc(sizeof(*new_opp), GFP_KERNEL); + new_opp = kzalloc(sizeof(struct opp), GFP_KERNEL); if (!new_opp) { dev_warn(dev, "%s: Unable to create new OPP node\n", __func__); return -ENOMEM; @@ -463,7 +460,7 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ADD, new_opp); return 0; } -EXPORT_SYMBOL_GPL(dev_pm_opp_add); +EXPORT_SYMBOL_GPL(opp_add); /** * opp_set_availability() - helper to set the availability of an opp @@ -488,11 +485,11 @@ static int opp_set_availability(struct device *dev, unsigned long freq, bool availability_req) { struct device_opp *tmp_dev_opp, *dev_opp = ERR_PTR(-ENODEV); - struct dev_pm_opp *new_opp, *tmp_opp, *opp = ERR_PTR(-ENODEV); + struct opp *new_opp, *tmp_opp, *opp = ERR_PTR(-ENODEV); int r = 0; /* keep the node allocated */ - new_opp = kmalloc(sizeof(*new_opp), GFP_KERNEL); + new_opp = kmalloc(sizeof(struct opp), GFP_KERNEL); if (!new_opp) { dev_warn(dev, "%s: Unable to create OPP\n", __func__); return -ENOMEM; @@ -555,13 +552,13 @@ unlock: } /** - * dev_pm_opp_enable() - Enable a specific OPP + * opp_enable() - Enable a specific OPP * @dev: device for which we do this operation * @freq: OPP frequency to enable * * Enables a provided opp. If the operation is valid, this returns 0, else the * corresponding error value. It is meant to be used for users an OPP available - * after being temporarily made unavailable with dev_pm_opp_disable. + * after being temporarily made unavailable with opp_disable. * * Locking: The internal device_opp and opp structures are RCU protected. * Hence this function indirectly uses RCU and mutex locks to keep the @@ -569,21 +566,21 @@ unlock: * this function is *NOT* called under RCU protection or in contexts where * mutex locking or synchronize_rcu() blocking calls cannot be used. */ -int dev_pm_opp_enable(struct device *dev, unsigned long freq) +int opp_enable(struct device *dev, unsigned long freq) { return opp_set_availability(dev, freq, true); } -EXPORT_SYMBOL_GPL(dev_pm_opp_enable); +EXPORT_SYMBOL_GPL(opp_enable); /** - * dev_pm_opp_disable() - Disable a specific OPP + * opp_disable() - Disable a specific OPP * @dev: device for which we do this operation * @freq: OPP frequency to disable * * Disables a provided opp. If the operation is valid, this returns * 0, else the corresponding error value. It is meant to be a temporary * control by users to make this OPP not available until the circumstances are - * right to make it available again (with a call to dev_pm_opp_enable). + * right to make it available again (with a call to opp_enable). * * Locking: The internal device_opp and opp structures are RCU protected. * Hence this function indirectly uses RCU and mutex locks to keep the @@ -591,15 +588,15 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_enable); * this function is *NOT* called under RCU protection or in contexts where * mutex locking or synchronize_rcu() blocking calls cannot be used. */ -int dev_pm_opp_disable(struct device *dev, unsigned long freq) +int opp_disable(struct device *dev, unsigned long freq) { return opp_set_availability(dev, freq, false); } -EXPORT_SYMBOL_GPL(dev_pm_opp_disable); +EXPORT_SYMBOL_GPL(opp_disable); #ifdef CONFIG_CPU_FREQ /** - * dev_pm_opp_init_cpufreq_table() - create a cpufreq table for a device + * opp_init_cpufreq_table() - create a cpufreq table for a device * @dev: device for which we do this operation * @table: Cpufreq table returned back to caller * @@ -622,11 +619,11 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_disable); * Callers should ensure that this function is *NOT* called under RCU protection * or in contexts where mutex locking cannot be used. */ -int dev_pm_opp_init_cpufreq_table(struct device *dev, +int opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table) { struct device_opp *dev_opp; - struct dev_pm_opp *opp; + struct opp *opp; struct cpufreq_frequency_table *freq_table; int i = 0; @@ -642,7 +639,7 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, } freq_table = kzalloc(sizeof(struct cpufreq_frequency_table) * - (dev_pm_opp_get_opp_count(dev) + 1), GFP_KERNEL); + (opp_get_opp_count(dev) + 1), GFP_KERNEL); if (!freq_table) { mutex_unlock(&dev_opp_list_lock); dev_warn(dev, "%s: Unable to allocate frequency table\n", @@ -666,16 +663,16 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, return 0; } -EXPORT_SYMBOL_GPL(dev_pm_opp_init_cpufreq_table); +EXPORT_SYMBOL_GPL(opp_init_cpufreq_table); /** - * dev_pm_opp_free_cpufreq_table() - free the cpufreq table + * opp_free_cpufreq_table() - free the cpufreq table * @dev: device for which we do this operation * @table: table to free * - * Free up the table allocated by dev_pm_opp_init_cpufreq_table + * Free up the table allocated by opp_init_cpufreq_table */ -void dev_pm_opp_free_cpufreq_table(struct device *dev, +void opp_free_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table) { if (!table) @@ -684,14 +681,14 @@ void dev_pm_opp_free_cpufreq_table(struct device *dev, kfree(*table); *table = NULL; } -EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); +EXPORT_SYMBOL_GPL(opp_free_cpufreq_table); #endif /* CONFIG_CPU_FREQ */ /** - * dev_pm_opp_get_notifier() - find notifier_head of the device with opp + * opp_get_notifier() - find notifier_head of the device with opp * @dev: device pointer used to lookup device OPPs. */ -struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev) +struct srcu_notifier_head *opp_get_notifier(struct device *dev) { struct device_opp *dev_opp = find_device_opp(dev); @@ -735,7 +732,7 @@ int of_init_opp_table(struct device *dev) unsigned long freq = be32_to_cpup(val++) * 1000; unsigned long volt = be32_to_cpup(val++); - if (dev_pm_opp_add(dev, freq, volt)) { + if (opp_add(dev, freq, volt)) { dev_warn(dev, "%s: Failed to add OPP %ld\n", __func__, freq); continue; diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 72e00e6..268a350 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -258,8 +258,7 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev) * Check if the device's runtime PM status allows it to be suspended. If * another idle notification has been started earlier, return immediately. If * the RPM_ASYNC flag is set then queue an idle-notification request; otherwise - * run the ->runtime_idle() callback directly. If the ->runtime_idle callback - * doesn't exist or if it returns 0, call rpm_suspend with the RPM_AUTO flag. + * run the ->runtime_idle() callback directly. * * This function must be called under dev->power.lock with interrupts disabled. */ @@ -332,7 +331,7 @@ static int rpm_idle(struct device *dev, int rpmflags) out: trace_rpm_return_int(dev, _THIS_IP_, retval); - return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO); + return retval ? retval : rpm_suspend(dev, rpmflags); } /** |