aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/sysfs.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-11-07 05:33:49 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-11-08 06:14:51 -0500
commit0759e80b84e34a84e7e46e2b1adb528c83d84a47 (patch)
treeffd28668a079d909242da53cdd4cc71855a0bb3e /drivers/base/power/sysfs.c
parent31f18230e480d6224e71910e9ab43a097d811fb0 (diff)
PM / QoS: Fix device resume latency framework
The special value of 0 for device resume latency PM QoS means "no restriction", but there are two problems with that. First, device resume latency PM QoS requests with 0 as the value are always put in front of requests with positive values in the priority lists used internally by the PM QoS framework, causing 0 to be chosen as an effective constraint value. However, that 0 is then interpreted as "no restriction" effectively overriding the other requests with specific restrictions which is incorrect. Second, the users of device resume latency PM QoS have no way to specify that *any* resume latency at all should be avoided, which is an artificial limitation in general. To address these issues, modify device resume latency PM QoS to use S32_MAX as the "no constraint" value and 0 as the "no latency at all" one and rework its users (the cpuidle menu governor, the genpd QoS governor and the runtime PM framework) to follow these changes. Also add a special "n/a" value to the corresponding user space I/F to allow user space to indicate that it cannot accept any resume latencies at all for the given device. Fixes: 85dc0b8a4019 (PM / QoS: Make it possible to expose PM QoS latency constraints) Link: https://bugzilla.kernel.org/show_bug.cgi?id=197323 Reported-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Reinette Chatre <reinette.chatre@intel.com> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Tero Kristo <t-kristo@ti.com> Reviewed-by: Ramesh Thomas <ramesh.thomas@intel.com>
Diffstat (limited to 'drivers/base/power/sysfs.c')
-rw-r--r--drivers/base/power/sysfs.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 29bf28fef136..e153e28b1857 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -218,7 +218,14 @@ static ssize_t pm_qos_resume_latency_show(struct device *dev,
218 struct device_attribute *attr, 218 struct device_attribute *attr,
219 char *buf) 219 char *buf)
220{ 220{
221 return sprintf(buf, "%d\n", dev_pm_qos_requested_resume_latency(dev)); 221 s32 value = dev_pm_qos_requested_resume_latency(dev);
222
223 if (value == 0)
224 return sprintf(buf, "n/a\n");
225 else if (value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
226 value = 0;
227
228 return sprintf(buf, "%d\n", value);
222} 229}
223 230
224static ssize_t pm_qos_resume_latency_store(struct device *dev, 231static ssize_t pm_qos_resume_latency_store(struct device *dev,
@@ -228,11 +235,21 @@ static ssize_t pm_qos_resume_latency_store(struct device *dev,
228 s32 value; 235 s32 value;
229 int ret; 236 int ret;
230 237
231 if (kstrtos32(buf, 0, &value)) 238 if (!kstrtos32(buf, 0, &value)) {
232 return -EINVAL; 239 /*
240 * Prevent users from writing negative or "no constraint" values
241 * directly.
242 */
243 if (value < 0 || value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
244 return -EINVAL;
233 245
234 if (value < 0) 246 if (value == 0)
247 value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
248 } else if (!strcmp(buf, "n/a") || !strcmp(buf, "n/a\n")) {
249 value = 0;
250 } else {
235 return -EINVAL; 251 return -EINVAL;
252 }
236 253
237 ret = dev_pm_qos_update_request(dev->power.qos->resume_latency_req, 254 ret = dev_pm_qos_update_request(dev->power.qos->resume_latency_req,
238 value); 255 value);