aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/sysfs.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-03-12 20:01:39 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-03-13 17:37:14 -0400
commit85dc0b8a4019e38ad4fd0c008f89a5c241805ac2 (patch)
treea73c5864d8ce4a6845e616ade7b8107e181279b6 /drivers/base/power/sysfs.c
parenta9b542ee607a8afafa9447292394959fc84ea650 (diff)
PM / QoS: Make it possible to expose PM QoS latency constraints
A runtime suspend of a device (e.g. an MMC controller) belonging to a power domain or, in a more complicated scenario, a runtime suspend of another device in the same power domain, may cause power to be removed from the entire domain. In that case, the amount of time necessary to runtime-resume the given device (e.g. the MMC controller) is often substantially greater than the time needed to run its driver's runtime resume callback. That may hurt performance in some situations, because user data may need to wait for the device to become operational, so we should make it possible to prevent that from happening. For this reason, introduce a new sysfs attribute for devices, power/pm_qos_resume_latency_us, allowing user space to specify the upper bound of the time necessary to bring the (runtime-suspended) device up after the resume of it has been requested. However, make that attribute appear only for the devices whose drivers declare support for it by calling the (new) dev_pm_qos_expose_latency_limit() helper function with the appropriate initial value of the attribute. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Reviewed-by: Kevin Hilman <khilman@ti.com> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/base/power/sysfs.c')
-rw-r--r--drivers/base/power/sysfs.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index adf41be0ea66..95c12f6cb5b9 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -5,6 +5,7 @@
5#include <linux/device.h> 5#include <linux/device.h>
6#include <linux/string.h> 6#include <linux/string.h>
7#include <linux/export.h> 7#include <linux/export.h>
8#include <linux/pm_qos.h>
8#include <linux/pm_runtime.h> 9#include <linux/pm_runtime.h>
9#include <linux/atomic.h> 10#include <linux/atomic.h>
10#include <linux/jiffies.h> 11#include <linux/jiffies.h>
@@ -217,6 +218,31 @@ static ssize_t autosuspend_delay_ms_store(struct device *dev,
217static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show, 218static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show,
218 autosuspend_delay_ms_store); 219 autosuspend_delay_ms_store);
219 220
221static ssize_t pm_qos_latency_show(struct device *dev,
222 struct device_attribute *attr, char *buf)
223{
224 return sprintf(buf, "%d\n", dev->power.pq_req->node.prio);
225}
226
227static ssize_t pm_qos_latency_store(struct device *dev,
228 struct device_attribute *attr,
229 const char *buf, size_t n)
230{
231 s32 value;
232 int ret;
233
234 if (kstrtos32(buf, 0, &value))
235 return -EINVAL;
236
237 if (value < 0)
238 return -EINVAL;
239
240 ret = dev_pm_qos_update_request(dev->power.pq_req, value);
241 return ret < 0 ? ret : n;
242}
243
244static DEVICE_ATTR(pm_qos_resume_latency_us, 0644,
245 pm_qos_latency_show, pm_qos_latency_store);
220#endif /* CONFIG_PM_RUNTIME */ 246#endif /* CONFIG_PM_RUNTIME */
221 247
222#ifdef CONFIG_PM_SLEEP 248#ifdef CONFIG_PM_SLEEP
@@ -490,6 +516,17 @@ static struct attribute_group pm_runtime_attr_group = {
490 .attrs = runtime_attrs, 516 .attrs = runtime_attrs,
491}; 517};
492 518
519static struct attribute *pm_qos_attrs[] = {
520#ifdef CONFIG_PM_RUNTIME
521 &dev_attr_pm_qos_resume_latency_us.attr,
522#endif /* CONFIG_PM_RUNTIME */
523 NULL,
524};
525static struct attribute_group pm_qos_attr_group = {
526 .name = power_group_name,
527 .attrs = pm_qos_attrs,
528};
529
493int dpm_sysfs_add(struct device *dev) 530int dpm_sysfs_add(struct device *dev)
494{ 531{
495 int rc; 532 int rc;
@@ -530,6 +567,16 @@ void wakeup_sysfs_remove(struct device *dev)
530 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); 567 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
531} 568}
532 569
570int pm_qos_sysfs_add(struct device *dev)
571{
572 return sysfs_merge_group(&dev->kobj, &pm_qos_attr_group);
573}
574
575void pm_qos_sysfs_remove(struct device *dev)
576{
577 sysfs_unmerge_group(&dev->kobj, &pm_qos_attr_group);
578}
579
533void rpm_sysfs_remove(struct device *dev) 580void rpm_sysfs_remove(struct device *dev)
534{ 581{
535 sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group); 582 sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group);