Skip to contentSkip to conversation

dev_pm_qos improvements

PATCH In review Andy Lutomirski 3 participants 6 messages Nov 30, 2016 – Dec 5, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover dev_pm_qos improvements

Hi Rafael-

Here are three minor dev_pm_qos improvements that make my upcoming nvme power management code work much better. Any chance you could take them for 4.10?

Thanks,
Andy

Andy Lutomirski (3):
dev_pm_qos: Improve sysfs pm_qos_latency_tolerance validation
dev_pm_qos: Fix writing 'auto' to pm_qos_latency_tolerance_us
dev_pm_qos: Export dev_pm_qos_update_user_latency_tolerance

 drivers/base/power/qos.c   | 6 +++++-
 drivers/base/power/sysfs.c | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/3 dev_pm_qos: Improve sysfs pm_qos_latency_tolerance validation

Negative values are special. Don't let users write them directly.

---
 drivers/base/power/sysfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/base/power/sysfs.c +5 -1
index a7b46798c81d..33b4b902741a 100644
@@ -263,7 +263,11 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
 	s32 value;
 	int ret;
 
-	if (kstrtos32(buf, 0, &value)) {
+	if (kstrtos32(buf, 0, &value) == 0) {
+		/* Users can't write negative values directly */
+		if (value < 0)
+			return -EINVAL;
+	} else {
 		if (!strcmp(buf, "auto") || !strcmp(buf, "auto\n"))
 			value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
 		else if (!strcmp(buf, "any") || !strcmp(buf, "any\n"))
Signature · 1 line
2.9.3
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] dev_pm_qos: Improve sysfs pm_qos_latency_tolerance validation

Quoted 3 lines · Andy Lutomirski

Negative values are special. Don't let users write them directly.

Quoted 15 lines
drivers/base/power/sysfs.c +5 -1
@@ -263,7 +263,11 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
 	s32 value;
 	int ret;
 
-	if (kstrtos32(buf, 0, &value)) {
+	if (kstrtos32(buf, 0, &value) == 0) {
+		/* Users can't write negative values directly */
+		if (value < 0)
+			return -EINVAL;
+	} else {
 		if (!strcmp(buf, "auto") || !strcmp(buf, "auto\n"))
 			value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
 		else if (!strcmp(buf, "any") || !strcmp(buf, "any\n"))
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw

PATCH 2/3 dev_pm_qos: Fix writing 'auto' to pm_qos_latency_tolerance_us

In reply to Andy Lutomirski

If it was already 'auto', then writing 'auto' again would incorrectly fail.

---
 drivers/base/power/qos.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/base/power/qos.c +4 -1
index 7f3646e459cb..6a1f2c7e01ea 100644
@@ -856,7 +856,10 @@ int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val)
 		struct dev_pm_qos_request *req;
 
 		if (val < 0) {
-			ret = -EINVAL;
+			if (val == PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT)
+				ret = 0;
+			else
+				ret = -EINVAL;
 			goto out;
 		}
 		req = kzalloc(sizeof(*req), GFP_KERNEL);
Signature · 1 line
2.9.3
#4 lore raw

PATCH 3/3 dev_pm_qos: Export dev_pm_qos_update_user_latency_tolerance

In reply to Andy Lutomirski

nvme wants a module parameter that overrides the default latency tolerance. This makes it easy for nvme to reflect that default in sysfs.

---
 drivers/base/power/qos.c | 1 +
 1 file changed, 1 insertion(+)
drivers/base/power/qos.c +1 -0
index 6a1f2c7e01ea..58fcc758334e 100644
@@ -886,6 +886,7 @@ int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val)
 	mutex_unlock(&dev_pm_qos_mtx);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(dev_pm_qos_update_user_latency_tolerance);
 
 /**
  * dev_pm_qos_expose_latency_tolerance - Expose latency tolerance to userspace
Signature · 1 line
2.9.3
#5 lore raw
In reply to Andy Lutomirski
Quoted 1 line · Andy Lutomirski

Hi Rafael-

Hi,

Quoted 3 lines

Here are three minor dev_pm_qos improvements that make my upcoming nvme power management code work much better. Any chance you could take them for 4.10?

Yup, all [1-3/3] applied.

Thanks,
Rafael