Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PM / QOS: Pass request type to dev_pm_qos_read_value()

In order to allow dev_pm_qos_read_value() to read values for different
QoS requests, pass request type as a parameter to these routines.

For now, it only supports resume-latency request type but will be
extended to frequency limit (min/max) constraints later on.

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Viresh Kumar and committed by
Rafael J. Wysocki
2a79ea5e 8262331e

+27 -10
+1 -1
Documentation/power/pm_qos_interface.txt
··· 123 123 call the notification trees if the target was changed as a result of removing 124 124 the request. 125 125 126 - s32 dev_pm_qos_read_value(device): 126 + s32 dev_pm_qos_read_value(device, type): 127 127 Returns the aggregated value for a given device's constraints list. 128 128 129 129 enum pm_qos_flags_status dev_pm_qos_flags(device, mask)
+1 -1
drivers/base/power/domain_governor.c
··· 33 33 * take its current PM QoS constraint (that's the only thing 34 34 * known at this point anyway). 35 35 */ 36 - constraint_ns = dev_pm_qos_read_value(dev); 36 + constraint_ns = dev_pm_qos_read_value(dev, DEV_PM_QOS_RESUME_LATENCY); 37 37 constraint_ns *= NSEC_PER_USEC; 38 38 } 39 39
+12 -5
drivers/base/power/qos.c
··· 105 105 /** 106 106 * dev_pm_qos_read_value - Get PM QoS constraint for a given device (locked). 107 107 * @dev: Device to get the PM QoS constraint value for. 108 + * @type: QoS request type. 108 109 */ 109 - s32 dev_pm_qos_read_value(struct device *dev) 110 + s32 dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type) 110 111 { 112 + struct dev_pm_qos *qos = dev->power.qos; 111 113 unsigned long flags; 112 114 s32 ret; 113 115 114 116 spin_lock_irqsave(&dev->power.lock, flags); 115 117 116 - if (IS_ERR_OR_NULL(dev->power.qos)) 117 - ret = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; 118 - else 119 - ret = pm_qos_read_value(&dev->power.qos->resume_latency); 118 + switch (type) { 119 + case DEV_PM_QOS_RESUME_LATENCY: 120 + ret = IS_ERR_OR_NULL(qos) ? PM_QOS_RESUME_LATENCY_NO_CONSTRAINT 121 + : pm_qos_read_value(&qos->resume_latency); 122 + break; 123 + default: 124 + WARN_ON(1); 125 + ret = 0; 126 + } 120 127 121 128 spin_unlock_irqrestore(&dev->power.lock, flags); 122 129
+13 -3
include/linux/pm_qos.h
··· 140 140 enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev, s32 mask); 141 141 enum pm_qos_flags_status dev_pm_qos_flags(struct device *dev, s32 mask); 142 142 s32 __dev_pm_qos_resume_latency(struct device *dev); 143 - s32 dev_pm_qos_read_value(struct device *dev); 143 + s32 dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type); 144 144 int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, 145 145 enum dev_pm_qos_req_type type, s32 value); 146 146 int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value); ··· 191 191 { return PM_QOS_FLAGS_UNDEFINED; } 192 192 static inline s32 __dev_pm_qos_resume_latency(struct device *dev) 193 193 { return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; } 194 - static inline s32 dev_pm_qos_read_value(struct device *dev) 195 - { return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; } 194 + static inline s32 dev_pm_qos_read_value(struct device *dev, 195 + enum dev_pm_qos_req_type type) 196 + { 197 + switch (type) { 198 + case DEV_PM_QOS_RESUME_LATENCY: 199 + return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; 200 + default: 201 + WARN_ON(1); 202 + return 0; 203 + } 204 + } 205 + 196 206 static inline int dev_pm_qos_add_request(struct device *dev, 197 207 struct dev_pm_qos_request *req, 198 208 enum dev_pm_qos_req_type type,