Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This module exposes the interface to kernel space for specifying |
| 3 | * QoS dependencies. It provides infrastructure for registration of: |
| 4 | * |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 5 | * Dependents on a QoS value : register requests |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 6 | * Watchers of QoS value : get notified when target QoS value changes |
| 7 | * |
| 8 | * This QoS design is best effort based. Dependents register their QoS needs. |
| 9 | * Watchers register to keep track of the current QoS needs of the system. |
| 10 | * |
| 11 | * There are 3 basic classes of QoS parameter: latency, timeout, throughput |
| 12 | * each have defined units: |
| 13 | * latency: usec |
| 14 | * timeout: usec <-- currently not used. |
| 15 | * throughput: kbs (kilo byte / sec) |
| 16 | * |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 17 | * There are lists of pm_qos_objects each one wrapping requests, notifiers |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 18 | * |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 19 | * User mode requests on a QOS parameter register themselves to the |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 20 | * subsystem by opening the device node /dev/... and writing there request to |
| 21 | * the node. As long as the process holds a file handle open to the node the |
| 22 | * client continues to be accounted for. Upon file release the usermode |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 23 | * request is removed and a new qos target is computed. This way when the |
| 24 | * request that the application has is cleaned up when closes the file |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 25 | * pointer or exits the pm_qos_object will get an opportunity to clean up. |
| 26 | * |
Richard Hughes | bf1db69 | 2008-08-05 13:01:35 -0700 | [diff] [blame] | 27 | * Mark Gross <mgross@linux.intel.com> |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 28 | */ |
| 29 | |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 30 | /*#define DEBUG*/ |
| 31 | |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 32 | #include <linux/pm_qos.h> |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 33 | #include <linux/sched.h> |
| 34 | #include <linux/spinlock.h> |
| 35 | #include <linux/slab.h> |
| 36 | #include <linux/time.h> |
| 37 | #include <linux/fs.h> |
| 38 | #include <linux/device.h> |
| 39 | #include <linux/miscdevice.h> |
| 40 | #include <linux/string.h> |
| 41 | #include <linux/platform_device.h> |
| 42 | #include <linux/init.h> |
Rafael J. Wysocki | 0775a60 | 2011-05-27 00:05:23 +0200 | [diff] [blame] | 43 | #include <linux/kernel.h> |
Nishanth Menon | f5f4eda | 2014-12-05 11:19:08 -0600 | [diff] [blame] | 44 | #include <linux/debugfs.h> |
| 45 | #include <linux/seq_file.h> |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 46 | #include <linux/irq.h> |
| 47 | #include <linux/irqdesc.h> |
Olav Haugan | 4970a4a | 2016-05-29 19:50:47 -0700 | [diff] [blame] | 48 | #include <linux/cpumask.h> |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 49 | |
| 50 | #include <linux/uaccess.h> |
Paul Gortmaker | 6e5fdee | 2011-05-26 16:00:52 -0400 | [diff] [blame] | 51 | #include <linux/export.h> |
Sahara | 247e9ee | 2013-06-21 11:12:28 +0900 | [diff] [blame] | 52 | #include <trace/events/power.h> |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 53 | |
| 54 | /* |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 55 | * locking rule: all changes to constraints or notifiers lists |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 56 | * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock |
| 57 | * held, taken with _irqsave. One lock to rule them all |
| 58 | */ |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 59 | struct pm_qos_object { |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 60 | struct pm_qos_constraints *constraints; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 61 | struct miscdevice pm_qos_power_miscdev; |
| 62 | char *name; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 63 | }; |
| 64 | |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 65 | static DEFINE_SPINLOCK(pm_qos_lock); |
| 66 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 67 | static struct pm_qos_object null_pm_qos; |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 68 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 69 | static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier); |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 70 | static struct pm_qos_constraints cpu_dma_constraints = { |
| 71 | .list = PLIST_HEAD_INIT(cpu_dma_constraints.list), |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 72 | .target_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE, |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 73 | .target_per_cpu = { [0 ... (NR_CPUS - 1)] = |
| 74 | PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE }, |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 75 | .default_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE, |
Rafael J. Wysocki | 327adae | 2014-02-11 00:35:29 +0100 | [diff] [blame] | 76 | .no_constraint_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE, |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 77 | .type = PM_QOS_MIN, |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 78 | .notifiers = &cpu_dma_lat_notifier, |
| 79 | }; |
| 80 | static struct pm_qos_object cpu_dma_pm_qos = { |
| 81 | .constraints = &cpu_dma_constraints, |
Dominik Brodowski | a6f05b97 | 2011-11-06 21:54:12 +0100 | [diff] [blame] | 82 | .name = "cpu_dma_latency", |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | static BLOCKING_NOTIFIER_HEAD(network_lat_notifier); |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 86 | static struct pm_qos_constraints network_lat_constraints = { |
| 87 | .list = PLIST_HEAD_INIT(network_lat_constraints.list), |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 88 | .target_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE, |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 89 | .target_per_cpu = { [0 ... (NR_CPUS - 1)] = |
| 90 | PM_QOS_NETWORK_LAT_DEFAULT_VALUE }, |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 91 | .default_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE, |
Rafael J. Wysocki | 327adae | 2014-02-11 00:35:29 +0100 | [diff] [blame] | 92 | .no_constraint_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE, |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 93 | .type = PM_QOS_MIN, |
| 94 | .notifiers = &network_lat_notifier, |
| 95 | }; |
| 96 | static struct pm_qos_object network_lat_pm_qos = { |
| 97 | .constraints = &network_lat_constraints, |
| 98 | .name = "network_latency", |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 99 | }; |
| 100 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 101 | static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier); |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 102 | static struct pm_qos_constraints network_tput_constraints = { |
| 103 | .list = PLIST_HEAD_INIT(network_tput_constraints.list), |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 104 | .target_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE, |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 105 | .target_per_cpu = { [0 ... (NR_CPUS - 1)] = |
| 106 | PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE }, |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 107 | .default_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE, |
Rafael J. Wysocki | 327adae | 2014-02-11 00:35:29 +0100 | [diff] [blame] | 108 | .no_constraint_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE, |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 109 | .type = PM_QOS_MAX, |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 110 | .notifiers = &network_throughput_notifier, |
| 111 | }; |
| 112 | static struct pm_qos_object network_throughput_pm_qos = { |
| 113 | .constraints = &network_tput_constraints, |
| 114 | .name = "network_throughput", |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | |
Tomeu Vizoso | 7990da7 | 2014-09-03 17:49:32 +0200 | [diff] [blame] | 118 | static BLOCKING_NOTIFIER_HEAD(memory_bandwidth_notifier); |
| 119 | static struct pm_qos_constraints memory_bw_constraints = { |
| 120 | .list = PLIST_HEAD_INIT(memory_bw_constraints.list), |
| 121 | .target_value = PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE, |
| 122 | .default_value = PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE, |
| 123 | .no_constraint_value = PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE, |
| 124 | .type = PM_QOS_SUM, |
| 125 | .notifiers = &memory_bandwidth_notifier, |
| 126 | }; |
| 127 | static struct pm_qos_object memory_bandwidth_pm_qos = { |
| 128 | .constraints = &memory_bw_constraints, |
| 129 | .name = "memory_bandwidth", |
| 130 | }; |
| 131 | |
| 132 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 133 | static struct pm_qos_object *pm_qos_array[] = { |
| 134 | &null_pm_qos, |
| 135 | &cpu_dma_pm_qos, |
| 136 | &network_lat_pm_qos, |
Tomeu Vizoso | 7990da7 | 2014-09-03 17:49:32 +0200 | [diff] [blame] | 137 | &network_throughput_pm_qos, |
| 138 | &memory_bandwidth_pm_qos, |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 139 | }; |
| 140 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 141 | static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, |
| 142 | size_t count, loff_t *f_pos); |
Thomas Renninger | f9b9e80 | 2011-02-28 22:06:34 +0100 | [diff] [blame] | 143 | static ssize_t pm_qos_power_read(struct file *filp, char __user *buf, |
| 144 | size_t count, loff_t *f_pos); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 145 | static int pm_qos_power_open(struct inode *inode, struct file *filp); |
| 146 | static int pm_qos_power_release(struct inode *inode, struct file *filp); |
| 147 | |
| 148 | static const struct file_operations pm_qos_power_fops = { |
| 149 | .write = pm_qos_power_write, |
Thomas Renninger | f9b9e80 | 2011-02-28 22:06:34 +0100 | [diff] [blame] | 150 | .read = pm_qos_power_read, |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 151 | .open = pm_qos_power_open, |
| 152 | .release = pm_qos_power_release, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 153 | .llseek = noop_llseek, |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 154 | }; |
| 155 | |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 156 | /* unlocked internal variant */ |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 157 | static inline int pm_qos_get_value(struct pm_qos_constraints *c) |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 158 | { |
Tomeu Vizoso | 7990da7 | 2014-09-03 17:49:32 +0200 | [diff] [blame] | 159 | struct plist_node *node; |
| 160 | int total_value = 0; |
| 161 | |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 162 | if (plist_head_empty(&c->list)) |
Rafael J. Wysocki | 327adae | 2014-02-11 00:35:29 +0100 | [diff] [blame] | 163 | return c->no_constraint_value; |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 164 | |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 165 | switch (c->type) { |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 166 | case PM_QOS_MIN: |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 167 | return plist_first(&c->list)->prio; |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 168 | |
| 169 | case PM_QOS_MAX: |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 170 | return plist_last(&c->list)->prio; |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 171 | |
Tomeu Vizoso | 7990da7 | 2014-09-03 17:49:32 +0200 | [diff] [blame] | 172 | case PM_QOS_SUM: |
| 173 | plist_for_each(node, &c->list) |
| 174 | total_value += node->prio; |
| 175 | |
| 176 | return total_value; |
| 177 | |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 178 | default: |
| 179 | /* runtime check for not using enum */ |
| 180 | BUG(); |
Luis Gonzalez Fernandez | c6a57bf | 2012-09-07 21:35:21 +0200 | [diff] [blame] | 181 | return PM_QOS_DEFAULT_VALUE; |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 182 | } |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 183 | } |
| 184 | |
Jean Pihet | b66213c | 2011-08-25 15:35:47 +0200 | [diff] [blame] | 185 | s32 pm_qos_read_value(struct pm_qos_constraints *c) |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 186 | { |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 187 | return c->target_value; |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 188 | } |
| 189 | |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 190 | static inline void pm_qos_set_value(struct pm_qos_constraints *c, s32 value) |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 191 | { |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 192 | c->target_value = value; |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 193 | } |
| 194 | |
Nishanth Menon | f5f4eda | 2014-12-05 11:19:08 -0600 | [diff] [blame] | 195 | static inline int pm_qos_get_value(struct pm_qos_constraints *c); |
| 196 | static int pm_qos_dbg_show_requests(struct seq_file *s, void *unused) |
| 197 | { |
| 198 | struct pm_qos_object *qos = (struct pm_qos_object *)s->private; |
| 199 | struct pm_qos_constraints *c; |
| 200 | struct pm_qos_request *req; |
| 201 | char *type; |
| 202 | unsigned long flags; |
| 203 | int tot_reqs = 0; |
| 204 | int active_reqs = 0; |
| 205 | |
| 206 | if (IS_ERR_OR_NULL(qos)) { |
| 207 | pr_err("%s: bad qos param!\n", __func__); |
| 208 | return -EINVAL; |
| 209 | } |
| 210 | c = qos->constraints; |
| 211 | if (IS_ERR_OR_NULL(c)) { |
| 212 | pr_err("%s: Bad constraints on qos?\n", __func__); |
| 213 | return -EINVAL; |
| 214 | } |
| 215 | |
| 216 | /* Lock to ensure we have a snapshot */ |
| 217 | spin_lock_irqsave(&pm_qos_lock, flags); |
| 218 | if (plist_head_empty(&c->list)) { |
| 219 | seq_puts(s, "Empty!\n"); |
| 220 | goto out; |
| 221 | } |
| 222 | |
| 223 | switch (c->type) { |
| 224 | case PM_QOS_MIN: |
| 225 | type = "Minimum"; |
| 226 | break; |
| 227 | case PM_QOS_MAX: |
| 228 | type = "Maximum"; |
| 229 | break; |
| 230 | case PM_QOS_SUM: |
| 231 | type = "Sum"; |
| 232 | break; |
| 233 | default: |
| 234 | type = "Unknown"; |
| 235 | } |
| 236 | |
| 237 | plist_for_each_entry(req, &c->list, node) { |
| 238 | char *state = "Default"; |
| 239 | |
| 240 | if ((req->node).prio != c->default_value) { |
| 241 | active_reqs++; |
| 242 | state = "Active"; |
| 243 | } |
| 244 | tot_reqs++; |
| 245 | seq_printf(s, "%d: %d: %s\n", tot_reqs, |
| 246 | (req->node).prio, state); |
| 247 | } |
| 248 | |
| 249 | seq_printf(s, "Type=%s, Value=%d, Requests: active=%d / total=%d\n", |
| 250 | type, pm_qos_get_value(c), active_reqs, tot_reqs); |
| 251 | |
| 252 | out: |
| 253 | spin_unlock_irqrestore(&pm_qos_lock, flags); |
| 254 | return 0; |
| 255 | } |
| 256 | |
| 257 | static int pm_qos_dbg_open(struct inode *inode, struct file *file) |
| 258 | { |
| 259 | return single_open(file, pm_qos_dbg_show_requests, |
| 260 | inode->i_private); |
| 261 | } |
| 262 | |
| 263 | static const struct file_operations pm_qos_debug_fops = { |
| 264 | .open = pm_qos_dbg_open, |
| 265 | .read = seq_read, |
| 266 | .llseek = seq_lseek, |
| 267 | .release = single_release, |
| 268 | }; |
| 269 | |
Maulik Shah | b4d6ca0 | 2019-10-11 12:36:34 +0530 | [diff] [blame] | 270 | static inline int pm_qos_set_value_for_cpus(struct pm_qos_constraints *c, |
Mahesh Sivasubramanian | 7ce01e7 | 2017-10-31 14:53:25 +0530 | [diff] [blame] | 271 | struct cpumask *cpus) |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 272 | { |
| 273 | struct pm_qos_request *req = NULL; |
| 274 | int cpu; |
| 275 | s32 qos_val[NR_CPUS] = { [0 ... (NR_CPUS - 1)] = c->default_value }; |
| 276 | |
Maulik Shah | b4d6ca0 | 2019-10-11 12:36:34 +0530 | [diff] [blame] | 277 | /* |
| 278 | * pm_qos_constraints can be from different classes, |
| 279 | * Update cpumask only only for CPU_DMA_LATENCY classes |
| 280 | */ |
| 281 | |
| 282 | if (c != pm_qos_array[PM_QOS_CPU_DMA_LATENCY]->constraints) |
| 283 | return -EINVAL; |
| 284 | |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 285 | plist_for_each_entry(req, &c->list, node) { |
| 286 | for_each_cpu(cpu, &req->cpus_affine) { |
| 287 | switch (c->type) { |
| 288 | case PM_QOS_MIN: |
| 289 | if (qos_val[cpu] > req->node.prio) |
| 290 | qos_val[cpu] = req->node.prio; |
| 291 | break; |
| 292 | case PM_QOS_MAX: |
| 293 | if (req->node.prio > qos_val[cpu]) |
| 294 | qos_val[cpu] = req->node.prio; |
| 295 | break; |
Archana Sathyakumar | dc7916f | 2017-06-29 14:10:41 -0600 | [diff] [blame] | 296 | case PM_QOS_SUM: |
| 297 | qos_val[cpu] += req->node.prio; |
| 298 | break; |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 299 | default: |
| 300 | BUG(); |
| 301 | break; |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
Mahesh Sivasubramanian | 7ce01e7 | 2017-10-31 14:53:25 +0530 | [diff] [blame] | 306 | for_each_possible_cpu(cpu) { |
| 307 | if (c->target_per_cpu[cpu] != qos_val[cpu]) |
| 308 | cpumask_set_cpu(cpu, cpus); |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 309 | c->target_per_cpu[cpu] = qos_val[cpu]; |
Mahesh Sivasubramanian | 7ce01e7 | 2017-10-31 14:53:25 +0530 | [diff] [blame] | 310 | } |
Maulik Shah | b4d6ca0 | 2019-10-11 12:36:34 +0530 | [diff] [blame] | 311 | |
| 312 | return 0; |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 313 | } |
| 314 | |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 315 | /** |
| 316 | * pm_qos_update_target - manages the constraints list and calls the notifiers |
| 317 | * if needed |
| 318 | * @c: constraints data struct |
Praveen Chidambaram | 4671010 | 2014-05-20 12:57:14 -0600 | [diff] [blame] | 319 | * @req: request to add to the list, to update or to remove |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 320 | * @action: action to take on the constraints list |
| 321 | * @value: value of the request to add or update |
| 322 | * |
| 323 | * This function returns 1 if the aggregated constraint value has changed, 0 |
| 324 | * otherwise. |
| 325 | */ |
Praveen Chidambaram | 4671010 | 2014-05-20 12:57:14 -0600 | [diff] [blame] | 326 | int pm_qos_update_target(struct pm_qos_constraints *c, |
| 327 | struct pm_qos_request *req, |
| 328 | enum pm_qos_req_action action, int value) |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 329 | { |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 330 | unsigned long flags; |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 331 | int prev_value, curr_value, new_value; |
Praveen Chidambaram | 4671010 | 2014-05-20 12:57:14 -0600 | [diff] [blame] | 332 | struct plist_node *node = &req->node; |
Mahesh Sivasubramanian | 7ce01e7 | 2017-10-31 14:53:25 +0530 | [diff] [blame] | 333 | struct cpumask cpus; |
Rafael J. Wysocki | 2d984ad | 2014-02-11 00:35:38 +0100 | [diff] [blame] | 334 | int ret; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 335 | |
| 336 | spin_lock_irqsave(&pm_qos_lock, flags); |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 337 | prev_value = pm_qos_get_value(c); |
| 338 | if (value == PM_QOS_DEFAULT_VALUE) |
| 339 | new_value = c->default_value; |
| 340 | else |
| 341 | new_value = value; |
| 342 | |
| 343 | switch (action) { |
| 344 | case PM_QOS_REMOVE_REQ: |
| 345 | plist_del(node, &c->list); |
| 346 | break; |
| 347 | case PM_QOS_UPDATE_REQ: |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 348 | /* |
| 349 | * to change the list, we atomically remove, reinit |
| 350 | * with new value and add, then see if the extremal |
| 351 | * changed |
| 352 | */ |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 353 | plist_del(node, &c->list); |
| 354 | case PM_QOS_ADD_REQ: |
| 355 | plist_node_init(node, new_value); |
| 356 | plist_add(node, &c->list); |
| 357 | break; |
| 358 | default: |
| 359 | /* no action */ |
| 360 | ; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 361 | } |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 362 | |
| 363 | curr_value = pm_qos_get_value(c); |
Mahesh Sivasubramanian | 7ce01e7 | 2017-10-31 14:53:25 +0530 | [diff] [blame] | 364 | cpumask_clear(&cpus); |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 365 | pm_qos_set_value(c, curr_value); |
Maulik Shah | b4d6ca0 | 2019-10-11 12:36:34 +0530 | [diff] [blame] | 366 | ret = pm_qos_set_value_for_cpus(c, &cpus); |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 367 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 368 | spin_unlock_irqrestore(&pm_qos_lock, flags); |
| 369 | |
Sahara | 247e9ee | 2013-06-21 11:12:28 +0900 | [diff] [blame] | 370 | trace_pm_qos_update_target(action, prev_value, curr_value); |
Mahesh Sivasubramanian | 7ce01e7 | 2017-10-31 14:53:25 +0530 | [diff] [blame] | 371 | |
| 372 | /* |
| 373 | * if cpu mask bits are set, call the notifier call chain |
| 374 | * to update the new qos restriction for the cores |
| 375 | */ |
| 376 | |
Maulik Shah | b4d6ca0 | 2019-10-11 12:36:34 +0530 | [diff] [blame] | 377 | if (!cpumask_empty(&cpus) || |
| 378 | (ret && prev_value != curr_value)) { |
Rafael J. Wysocki | 2d984ad | 2014-02-11 00:35:38 +0100 | [diff] [blame] | 379 | ret = 1; |
| 380 | if (c->notifiers) |
| 381 | blocking_notifier_call_chain(c->notifiers, |
Mahesh Sivasubramanian | 7ce01e7 | 2017-10-31 14:53:25 +0530 | [diff] [blame] | 382 | (unsigned long)curr_value, &cpus); |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 383 | } else { |
Rafael J. Wysocki | 2d984ad | 2014-02-11 00:35:38 +0100 | [diff] [blame] | 384 | ret = 0; |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 385 | } |
Rafael J. Wysocki | 2d984ad | 2014-02-11 00:35:38 +0100 | [diff] [blame] | 386 | return ret; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 387 | } |
| 388 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 389 | /** |
Rafael J. Wysocki | 5efbe42 | 2012-10-23 01:07:46 +0200 | [diff] [blame] | 390 | * pm_qos_flags_remove_req - Remove device PM QoS flags request. |
| 391 | * @pqf: Device PM QoS flags set to remove the request from. |
| 392 | * @req: Request to remove from the set. |
| 393 | */ |
| 394 | static void pm_qos_flags_remove_req(struct pm_qos_flags *pqf, |
| 395 | struct pm_qos_flags_request *req) |
| 396 | { |
| 397 | s32 val = 0; |
| 398 | |
| 399 | list_del(&req->node); |
| 400 | list_for_each_entry(req, &pqf->list, node) |
| 401 | val |= req->flags; |
| 402 | |
| 403 | pqf->effective_flags = val; |
| 404 | } |
| 405 | |
| 406 | /** |
| 407 | * pm_qos_update_flags - Update a set of PM QoS flags. |
| 408 | * @pqf: Set of flags to update. |
| 409 | * @req: Request to add to the set, to modify, or to remove from the set. |
| 410 | * @action: Action to take on the set. |
| 411 | * @val: Value of the request to add or modify. |
| 412 | * |
| 413 | * Update the given set of PM QoS flags and call notifiers if the aggregate |
| 414 | * value has changed. Returns 1 if the aggregate constraint value has changed, |
| 415 | * 0 otherwise. |
| 416 | */ |
| 417 | bool pm_qos_update_flags(struct pm_qos_flags *pqf, |
| 418 | struct pm_qos_flags_request *req, |
| 419 | enum pm_qos_req_action action, s32 val) |
| 420 | { |
| 421 | unsigned long irqflags; |
| 422 | s32 prev_value, curr_value; |
| 423 | |
| 424 | spin_lock_irqsave(&pm_qos_lock, irqflags); |
| 425 | |
| 426 | prev_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags; |
| 427 | |
| 428 | switch (action) { |
| 429 | case PM_QOS_REMOVE_REQ: |
| 430 | pm_qos_flags_remove_req(pqf, req); |
| 431 | break; |
| 432 | case PM_QOS_UPDATE_REQ: |
| 433 | pm_qos_flags_remove_req(pqf, req); |
| 434 | case PM_QOS_ADD_REQ: |
| 435 | req->flags = val; |
| 436 | INIT_LIST_HEAD(&req->node); |
| 437 | list_add_tail(&req->node, &pqf->list); |
| 438 | pqf->effective_flags |= val; |
| 439 | break; |
| 440 | default: |
| 441 | /* no action */ |
| 442 | ; |
| 443 | } |
| 444 | |
| 445 | curr_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags; |
| 446 | |
| 447 | spin_unlock_irqrestore(&pm_qos_lock, irqflags); |
| 448 | |
Sahara | 247e9ee | 2013-06-21 11:12:28 +0900 | [diff] [blame] | 449 | trace_pm_qos_update_flags(action, prev_value, curr_value); |
Rafael J. Wysocki | 5efbe42 | 2012-10-23 01:07:46 +0200 | [diff] [blame] | 450 | return prev_value != curr_value; |
| 451 | } |
| 452 | |
| 453 | /** |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 454 | * pm_qos_request - returns current system wide qos expectation |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 455 | * @pm_qos_class: identification of which qos value is requested |
| 456 | * |
Tim Chen | 333c5ae | 2011-02-11 12:49:04 -0800 | [diff] [blame] | 457 | * This function returns the current target value. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 458 | */ |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 459 | int pm_qos_request(int pm_qos_class) |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 460 | { |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 461 | return pm_qos_read_value(pm_qos_array[pm_qos_class]->constraints); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 462 | } |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 463 | EXPORT_SYMBOL_GPL(pm_qos_request); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 464 | |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 465 | int pm_qos_request_for_cpu(int pm_qos_class, int cpu) |
| 466 | { |
Olav Haugan | 4970a4a | 2016-05-29 19:50:47 -0700 | [diff] [blame] | 467 | if (cpu_isolated(cpu)) |
| 468 | return INT_MAX; |
| 469 | |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 470 | return pm_qos_array[pm_qos_class]->constraints->target_per_cpu[cpu]; |
| 471 | } |
| 472 | EXPORT_SYMBOL(pm_qos_request_for_cpu); |
| 473 | |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 474 | int pm_qos_request_active(struct pm_qos_request *req) |
James Bottomley | 82f6825 | 2010-07-05 22:53:06 +0200 | [diff] [blame] | 475 | { |
| 476 | return req->pm_qos_class != 0; |
| 477 | } |
| 478 | EXPORT_SYMBOL_GPL(pm_qos_request_active); |
| 479 | |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 480 | int pm_qos_request_for_cpumask(int pm_qos_class, struct cpumask *mask) |
| 481 | { |
| 482 | unsigned long irqflags; |
| 483 | int cpu; |
| 484 | struct pm_qos_constraints *c = NULL; |
| 485 | int val; |
| 486 | |
| 487 | spin_lock_irqsave(&pm_qos_lock, irqflags); |
| 488 | c = pm_qos_array[pm_qos_class]->constraints; |
| 489 | val = c->default_value; |
| 490 | |
| 491 | for_each_cpu(cpu, mask) { |
Olav Haugan | 4970a4a | 2016-05-29 19:50:47 -0700 | [diff] [blame] | 492 | |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 493 | switch (c->type) { |
| 494 | case PM_QOS_MIN: |
| 495 | if (c->target_per_cpu[cpu] < val) |
| 496 | val = c->target_per_cpu[cpu]; |
| 497 | break; |
| 498 | case PM_QOS_MAX: |
| 499 | if (c->target_per_cpu[cpu] > val) |
| 500 | val = c->target_per_cpu[cpu]; |
| 501 | break; |
| 502 | default: |
| 503 | BUG(); |
| 504 | break; |
| 505 | } |
| 506 | } |
| 507 | spin_unlock_irqrestore(&pm_qos_lock, irqflags); |
| 508 | |
| 509 | return val; |
| 510 | } |
| 511 | EXPORT_SYMBOL(pm_qos_request_for_cpumask); |
| 512 | |
Stephen Boyd | 40fea92f | 2013-08-13 14:12:40 -0700 | [diff] [blame] | 513 | static void __pm_qos_update_request(struct pm_qos_request *req, |
| 514 | s32 new_value) |
| 515 | { |
| 516 | trace_pm_qos_update_request(req->pm_qos_class, new_value); |
| 517 | |
| 518 | if (new_value != req->node.prio) |
| 519 | pm_qos_update_target( |
| 520 | pm_qos_array[req->pm_qos_class]->constraints, |
Praveen Chidambaram | 4671010 | 2014-05-20 12:57:14 -0600 | [diff] [blame] | 521 | req, PM_QOS_UPDATE_REQ, new_value); |
Stephen Boyd | 40fea92f | 2013-08-13 14:12:40 -0700 | [diff] [blame] | 522 | } |
| 523 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 524 | /** |
MyungJoo Ham | c4772d1 | 2012-03-28 23:31:24 +0200 | [diff] [blame] | 525 | * pm_qos_work_fn - the timeout handler of pm_qos_update_request_timeout |
| 526 | * @work: work struct for the delayed work (timeout) |
| 527 | * |
| 528 | * This cancels the timeout request by falling back to the default at timeout. |
| 529 | */ |
| 530 | static void pm_qos_work_fn(struct work_struct *work) |
| 531 | { |
| 532 | struct pm_qos_request *req = container_of(to_delayed_work(work), |
| 533 | struct pm_qos_request, |
| 534 | work); |
| 535 | |
Stephen Boyd | 40fea92f | 2013-08-13 14:12:40 -0700 | [diff] [blame] | 536 | __pm_qos_update_request(req, PM_QOS_DEFAULT_VALUE); |
MyungJoo Ham | c4772d1 | 2012-03-28 23:31:24 +0200 | [diff] [blame] | 537 | } |
| 538 | |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 539 | #ifdef CONFIG_SMP |
| 540 | static void pm_qos_irq_release(struct kref *ref) |
| 541 | { |
| 542 | unsigned long flags; |
| 543 | struct irq_affinity_notify *notify = container_of(ref, |
| 544 | struct irq_affinity_notify, kref); |
| 545 | struct pm_qos_request *req = container_of(notify, |
| 546 | struct pm_qos_request, irq_notify); |
| 547 | struct pm_qos_constraints *c = |
| 548 | pm_qos_array[req->pm_qos_class]->constraints; |
| 549 | |
| 550 | spin_lock_irqsave(&pm_qos_lock, flags); |
| 551 | cpumask_setall(&req->cpus_affine); |
| 552 | spin_unlock_irqrestore(&pm_qos_lock, flags); |
| 553 | |
| 554 | pm_qos_update_target(c, req, PM_QOS_UPDATE_REQ, c->default_value); |
| 555 | } |
| 556 | |
| 557 | static void pm_qos_irq_notify(struct irq_affinity_notify *notify, |
| 558 | const cpumask_t *mask) |
| 559 | { |
| 560 | unsigned long flags; |
| 561 | struct pm_qos_request *req = container_of(notify, |
| 562 | struct pm_qos_request, irq_notify); |
| 563 | struct pm_qos_constraints *c = |
| 564 | pm_qos_array[req->pm_qos_class]->constraints; |
| 565 | |
| 566 | spin_lock_irqsave(&pm_qos_lock, flags); |
| 567 | cpumask_copy(&req->cpus_affine, mask); |
| 568 | spin_unlock_irqrestore(&pm_qos_lock, flags); |
| 569 | |
| 570 | pm_qos_update_target(c, req, PM_QOS_UPDATE_REQ, req->node.prio); |
| 571 | } |
| 572 | #endif |
| 573 | |
MyungJoo Ham | c4772d1 | 2012-03-28 23:31:24 +0200 | [diff] [blame] | 574 | /** |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 575 | * pm_qos_add_request - inserts new qos request into the list |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 576 | * @req: pointer to a preallocated handle |
Saravana Kannan | 25cc69e | 2010-08-26 20:18:43 +0200 | [diff] [blame] | 577 | * @pm_qos_class: identifies which list of qos request to use |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 578 | * @value: defines the qos request |
| 579 | * |
| 580 | * This function inserts a new entry in the pm_qos_class list of requested qos |
Richard Hughes | bf1db69 | 2008-08-05 13:01:35 -0700 | [diff] [blame] | 581 | * performance characteristics. It recomputes the aggregate QoS expectations |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 582 | * for the pm_qos_class of parameters and initializes the pm_qos_request |
Saravana Kannan | 25cc69e | 2010-08-26 20:18:43 +0200 | [diff] [blame] | 583 | * handle. Caller needs to save this handle for later use in updates and |
| 584 | * removal. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 585 | */ |
Saravana Kannan | 25cc69e | 2010-08-26 20:18:43 +0200 | [diff] [blame] | 586 | |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 587 | void pm_qos_add_request(struct pm_qos_request *req, |
James Bottomley | 82f6825 | 2010-07-05 22:53:06 +0200 | [diff] [blame] | 588 | int pm_qos_class, s32 value) |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 589 | { |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 590 | if (!req) /*guard against callers passing in null */ |
| 591 | return; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 592 | |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 593 | if (pm_qos_request_active(req)) { |
James Bottomley | 82f6825 | 2010-07-05 22:53:06 +0200 | [diff] [blame] | 594 | WARN(1, KERN_ERR "pm_qos_add_request() called for already added request\n"); |
| 595 | return; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 596 | } |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 597 | |
| 598 | switch (req->type) { |
| 599 | case PM_QOS_REQ_AFFINE_CORES: |
| 600 | if (cpumask_empty(&req->cpus_affine)) { |
| 601 | req->type = PM_QOS_REQ_ALL_CORES; |
| 602 | cpumask_setall(&req->cpus_affine); |
| 603 | WARN(1, KERN_ERR "Affine cores not set for request with affinity flag\n"); |
| 604 | } |
| 605 | break; |
| 606 | #ifdef CONFIG_SMP |
| 607 | case PM_QOS_REQ_AFFINE_IRQ: |
| 608 | if (irq_can_set_affinity(req->irq)) { |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 609 | struct irq_desc *desc = irq_to_desc(req->irq); |
Lina Iyer | 1daba25 | 2017-07-17 11:52:22 -0600 | [diff] [blame] | 610 | struct cpumask *mask; |
| 611 | |
| 612 | if (!desc) |
Mahesh Sivasubramanian | 54aece5 | 2017-01-31 14:26:12 -0700 | [diff] [blame] | 613 | return; |
Lina Iyer | 1daba25 | 2017-07-17 11:52:22 -0600 | [diff] [blame] | 614 | |
| 615 | mask = desc->irq_data.common->affinity; |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 616 | |
| 617 | /* Get the current affinity */ |
| 618 | cpumask_copy(&req->cpus_affine, mask); |
| 619 | req->irq_notify.irq = req->irq; |
| 620 | req->irq_notify.notify = pm_qos_irq_notify; |
| 621 | req->irq_notify.release = pm_qos_irq_release; |
| 622 | |
Praveen Chidambaram | ba1ec85 | 2014-05-21 16:21:31 -0600 | [diff] [blame] | 623 | } else { |
| 624 | req->type = PM_QOS_REQ_ALL_CORES; |
| 625 | cpumask_setall(&req->cpus_affine); |
| 626 | WARN(1, KERN_ERR "IRQ-%d not set for request with affinity flag\n", |
| 627 | req->irq); |
| 628 | } |
| 629 | break; |
| 630 | #endif |
| 631 | default: |
| 632 | WARN(1, KERN_ERR "Unknown request type %d\n", req->type); |
| 633 | /* fall through */ |
| 634 | case PM_QOS_REQ_ALL_CORES: |
| 635 | cpumask_setall(&req->cpus_affine); |
| 636 | break; |
| 637 | } |
| 638 | |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 639 | req->pm_qos_class = pm_qos_class; |
MyungJoo Ham | c4772d1 | 2012-03-28 23:31:24 +0200 | [diff] [blame] | 640 | INIT_DELAYED_WORK(&req->work, pm_qos_work_fn); |
Sahara | ae8822b | 2013-06-21 11:12:29 +0900 | [diff] [blame] | 641 | trace_pm_qos_add_request(pm_qos_class, value); |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 642 | pm_qos_update_target(pm_qos_array[pm_qos_class]->constraints, |
Praveen Chidambaram | 4671010 | 2014-05-20 12:57:14 -0600 | [diff] [blame] | 643 | req, PM_QOS_ADD_REQ, value); |
Anil Kumar Mamidala | 471c3f2 | 2016-04-22 12:42:51 +0530 | [diff] [blame] | 644 | |
| 645 | #ifdef CONFIG_SMP |
| 646 | if (req->type == PM_QOS_REQ_AFFINE_IRQ && |
| 647 | irq_can_set_affinity(req->irq)) { |
| 648 | int ret = 0; |
| 649 | |
| 650 | ret = irq_set_affinity_notifier(req->irq, |
| 651 | &req->irq_notify); |
| 652 | if (ret) { |
| 653 | WARN(1, "IRQ affinity notify set failed\n"); |
| 654 | req->type = PM_QOS_REQ_ALL_CORES; |
| 655 | cpumask_setall(&req->cpus_affine); |
| 656 | pm_qos_update_target( |
| 657 | pm_qos_array[pm_qos_class]->constraints, |
| 658 | req, PM_QOS_UPDATE_REQ, value); |
| 659 | } |
| 660 | } |
| 661 | #endif |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 662 | } |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 663 | EXPORT_SYMBOL_GPL(pm_qos_add_request); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 664 | |
| 665 | /** |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 666 | * pm_qos_update_request - modifies an existing qos request |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 667 | * @req : handle to list element holding a pm_qos request to use |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 668 | * @value: defines the qos request |
| 669 | * |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 670 | * Updates an existing qos request for the pm_qos_class of parameters along |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 671 | * with updating the target pm_qos_class value. |
| 672 | * |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 673 | * Attempts are made to make this code callable on hot code paths. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 674 | */ |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 675 | void pm_qos_update_request(struct pm_qos_request *req, |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 676 | s32 new_value) |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 677 | { |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 678 | if (!req) /*guard against callers passing in null */ |
James Bottomley | 5f27984 | 2010-07-19 02:00:18 +0200 | [diff] [blame] | 679 | return; |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 680 | |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 681 | if (!pm_qos_request_active(req)) { |
James Bottomley | 82f6825 | 2010-07-05 22:53:06 +0200 | [diff] [blame] | 682 | WARN(1, KERN_ERR "pm_qos_update_request() called for unknown object\n"); |
| 683 | return; |
| 684 | } |
| 685 | |
Tejun Heo | c86d06b | 2016-09-05 08:38:13 -0400 | [diff] [blame] | 686 | /* |
| 687 | * This function may be called very early during boot, for example, |
| 688 | * from of_clk_init(), where irq needs to stay disabled. |
| 689 | * cancel_delayed_work_sync() assumes that irq is enabled on |
| 690 | * invocation and re-enables it on return. Avoid calling it until |
| 691 | * workqueue is initialized. |
| 692 | */ |
| 693 | if (keventd_up()) |
| 694 | cancel_delayed_work_sync(&req->work); |
| 695 | |
Stephen Boyd | 40fea92f | 2013-08-13 14:12:40 -0700 | [diff] [blame] | 696 | __pm_qos_update_request(req, new_value); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 697 | } |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 698 | EXPORT_SYMBOL_GPL(pm_qos_update_request); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 699 | |
| 700 | /** |
MyungJoo Ham | c4772d1 | 2012-03-28 23:31:24 +0200 | [diff] [blame] | 701 | * pm_qos_update_request_timeout - modifies an existing qos request temporarily. |
| 702 | * @req : handle to list element holding a pm_qos request to use |
| 703 | * @new_value: defines the temporal qos request |
| 704 | * @timeout_us: the effective duration of this qos request in usecs. |
| 705 | * |
| 706 | * After timeout_us, this qos request is cancelled automatically. |
| 707 | */ |
| 708 | void pm_qos_update_request_timeout(struct pm_qos_request *req, s32 new_value, |
| 709 | unsigned long timeout_us) |
| 710 | { |
| 711 | if (!req) |
| 712 | return; |
| 713 | if (WARN(!pm_qos_request_active(req), |
| 714 | "%s called for unknown object.", __func__)) |
| 715 | return; |
| 716 | |
Tejun Heo | ed1ac6e | 2013-01-11 13:37:33 +0100 | [diff] [blame] | 717 | cancel_delayed_work_sync(&req->work); |
MyungJoo Ham | c4772d1 | 2012-03-28 23:31:24 +0200 | [diff] [blame] | 718 | |
Sahara | ae8822b | 2013-06-21 11:12:29 +0900 | [diff] [blame] | 719 | trace_pm_qos_update_request_timeout(req->pm_qos_class, |
| 720 | new_value, timeout_us); |
MyungJoo Ham | c4772d1 | 2012-03-28 23:31:24 +0200 | [diff] [blame] | 721 | if (new_value != req->node.prio) |
| 722 | pm_qos_update_target( |
| 723 | pm_qos_array[req->pm_qos_class]->constraints, |
Praveen Chidambaram | 4671010 | 2014-05-20 12:57:14 -0600 | [diff] [blame] | 724 | req, PM_QOS_UPDATE_REQ, new_value); |
MyungJoo Ham | c4772d1 | 2012-03-28 23:31:24 +0200 | [diff] [blame] | 725 | |
| 726 | schedule_delayed_work(&req->work, usecs_to_jiffies(timeout_us)); |
| 727 | } |
| 728 | |
| 729 | /** |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 730 | * pm_qos_remove_request - modifies an existing qos request |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 731 | * @req: handle to request list element |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 732 | * |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 733 | * Will remove pm qos request from the list of constraints and |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 734 | * recompute the current target value for the pm_qos_class. Call this |
| 735 | * on slow code paths. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 736 | */ |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 737 | void pm_qos_remove_request(struct pm_qos_request *req) |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 738 | { |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 739 | if (!req) /*guard against callers passing in null */ |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 740 | return; |
| 741 | /* silent return to keep pcm code cleaner */ |
| 742 | |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 743 | if (!pm_qos_request_active(req)) { |
Srinivas Rao L | 8bcb8ea | 2016-01-12 15:40:25 +0530 | [diff] [blame] | 744 | WARN(1, "pm_qos_remove_request() called for unknown object\n"); |
James Bottomley | 82f6825 | 2010-07-05 22:53:06 +0200 | [diff] [blame] | 745 | return; |
| 746 | } |
| 747 | |
Tejun Heo | ed1ac6e | 2013-01-11 13:37:33 +0100 | [diff] [blame] | 748 | cancel_delayed_work_sync(&req->work); |
MyungJoo Ham | c4772d1 | 2012-03-28 23:31:24 +0200 | [diff] [blame] | 749 | |
Srinivas Rao L | 8bcb8ea | 2016-01-12 15:40:25 +0530 | [diff] [blame] | 750 | #ifdef CONFIG_SMP |
| 751 | if (req->type == PM_QOS_REQ_AFFINE_IRQ) { |
| 752 | int ret = 0; |
| 753 | /* Get the current affinity */ |
| 754 | ret = irq_set_affinity_notifier(req->irq, NULL); |
| 755 | if (ret) |
| 756 | WARN(1, "IRQ affinity notify set failed\n"); |
| 757 | } |
| 758 | #endif |
| 759 | |
Sahara | ae8822b | 2013-06-21 11:12:29 +0900 | [diff] [blame] | 760 | trace_pm_qos_remove_request(req->pm_qos_class, PM_QOS_DEFAULT_VALUE); |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 761 | pm_qos_update_target(pm_qos_array[req->pm_qos_class]->constraints, |
Praveen Chidambaram | 4671010 | 2014-05-20 12:57:14 -0600 | [diff] [blame] | 762 | req, PM_QOS_REMOVE_REQ, |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 763 | PM_QOS_DEFAULT_VALUE); |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 764 | memset(req, 0, sizeof(*req)); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 765 | } |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 766 | EXPORT_SYMBOL_GPL(pm_qos_remove_request); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 767 | |
| 768 | /** |
| 769 | * pm_qos_add_notifier - sets notification entry for changes to target value |
| 770 | * @pm_qos_class: identifies which qos target changes should be notified. |
| 771 | * @notifier: notifier block managed by caller. |
| 772 | * |
| 773 | * will register the notifier into a notification chain that gets called |
Richard Hughes | bf1db69 | 2008-08-05 13:01:35 -0700 | [diff] [blame] | 774 | * upon changes to the pm_qos_class target value. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 775 | */ |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 776 | int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier) |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 777 | { |
| 778 | int retval; |
| 779 | |
| 780 | retval = blocking_notifier_chain_register( |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 781 | pm_qos_array[pm_qos_class]->constraints->notifiers, |
| 782 | notifier); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 783 | |
| 784 | return retval; |
| 785 | } |
| 786 | EXPORT_SYMBOL_GPL(pm_qos_add_notifier); |
| 787 | |
| 788 | /** |
| 789 | * pm_qos_remove_notifier - deletes notification entry from chain. |
| 790 | * @pm_qos_class: identifies which qos target changes are notified. |
| 791 | * @notifier: notifier block to be removed. |
| 792 | * |
| 793 | * will remove the notifier from the notification chain that gets called |
Richard Hughes | bf1db69 | 2008-08-05 13:01:35 -0700 | [diff] [blame] | 794 | * upon changes to the pm_qos_class target value. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 795 | */ |
| 796 | int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) |
| 797 | { |
| 798 | int retval; |
| 799 | |
| 800 | retval = blocking_notifier_chain_unregister( |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame] | 801 | pm_qos_array[pm_qos_class]->constraints->notifiers, |
| 802 | notifier); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 803 | |
| 804 | return retval; |
| 805 | } |
| 806 | EXPORT_SYMBOL_GPL(pm_qos_remove_notifier); |
| 807 | |
Jean Pihet | 4a31a33 | 2011-08-25 15:35:20 +0200 | [diff] [blame] | 808 | /* User space interface to PM QoS classes via misc devices */ |
Nishanth Menon | f5f4eda | 2014-12-05 11:19:08 -0600 | [diff] [blame] | 809 | static int register_pm_qos_misc(struct pm_qos_object *qos, struct dentry *d) |
Jean Pihet | 4a31a33 | 2011-08-25 15:35:20 +0200 | [diff] [blame] | 810 | { |
| 811 | qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR; |
| 812 | qos->pm_qos_power_miscdev.name = qos->name; |
| 813 | qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; |
| 814 | |
Nishanth Menon | f5f4eda | 2014-12-05 11:19:08 -0600 | [diff] [blame] | 815 | if (d) { |
| 816 | (void)debugfs_create_file(qos->name, S_IRUGO, d, |
| 817 | (void *)qos, &pm_qos_debug_fops); |
| 818 | } |
| 819 | |
Jean Pihet | 4a31a33 | 2011-08-25 15:35:20 +0200 | [diff] [blame] | 820 | return misc_register(&qos->pm_qos_power_miscdev); |
| 821 | } |
| 822 | |
| 823 | static int find_pm_qos_object_by_minor(int minor) |
| 824 | { |
| 825 | int pm_qos_class; |
| 826 | |
Sahara | d24c2a4 | 2013-06-20 11:33:57 +0900 | [diff] [blame] | 827 | for (pm_qos_class = PM_QOS_CPU_DMA_LATENCY; |
Jean Pihet | 4a31a33 | 2011-08-25 15:35:20 +0200 | [diff] [blame] | 828 | pm_qos_class < PM_QOS_NUM_CLASSES; pm_qos_class++) { |
| 829 | if (minor == |
| 830 | pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) |
| 831 | return pm_qos_class; |
| 832 | } |
| 833 | return -1; |
| 834 | } |
| 835 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 836 | static int pm_qos_power_open(struct inode *inode, struct file *filp) |
| 837 | { |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 838 | long pm_qos_class; |
| 839 | |
| 840 | pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); |
Sahara | d24c2a4 | 2013-06-20 11:33:57 +0900 | [diff] [blame] | 841 | if (pm_qos_class >= PM_QOS_CPU_DMA_LATENCY) { |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 842 | struct pm_qos_request *req = kzalloc(sizeof(*req), GFP_KERNEL); |
James Bottomley | 82f6825 | 2010-07-05 22:53:06 +0200 | [diff] [blame] | 843 | if (!req) |
| 844 | return -ENOMEM; |
| 845 | |
| 846 | pm_qos_add_request(req, pm_qos_class, PM_QOS_DEFAULT_VALUE); |
| 847 | filp->private_data = req; |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 848 | |
Guennadi Liakhovetski | 6513fd6 | 2011-11-03 10:12:36 +0100 | [diff] [blame] | 849 | return 0; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 850 | } |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 851 | return -EPERM; |
| 852 | } |
| 853 | |
| 854 | static int pm_qos_power_release(struct inode *inode, struct file *filp) |
| 855 | { |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 856 | struct pm_qos_request *req; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 857 | |
James Bottomley | 82f6825 | 2010-07-05 22:53:06 +0200 | [diff] [blame] | 858 | req = filp->private_data; |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 859 | pm_qos_remove_request(req); |
James Bottomley | 82f6825 | 2010-07-05 22:53:06 +0200 | [diff] [blame] | 860 | kfree(req); |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 861 | |
| 862 | return 0; |
| 863 | } |
| 864 | |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 865 | |
Thomas Renninger | f9b9e80 | 2011-02-28 22:06:34 +0100 | [diff] [blame] | 866 | static ssize_t pm_qos_power_read(struct file *filp, char __user *buf, |
| 867 | size_t count, loff_t *f_pos) |
| 868 | { |
| 869 | s32 value; |
| 870 | unsigned long flags; |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 871 | struct pm_qos_request *req = filp->private_data; |
Thomas Renninger | f9b9e80 | 2011-02-28 22:06:34 +0100 | [diff] [blame] | 872 | |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 873 | if (!req) |
Thomas Renninger | f9b9e80 | 2011-02-28 22:06:34 +0100 | [diff] [blame] | 874 | return -EINVAL; |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 875 | if (!pm_qos_request_active(req)) |
Thomas Renninger | f9b9e80 | 2011-02-28 22:06:34 +0100 | [diff] [blame] | 876 | return -EINVAL; |
| 877 | |
Thomas Renninger | f9b9e80 | 2011-02-28 22:06:34 +0100 | [diff] [blame] | 878 | spin_lock_irqsave(&pm_qos_lock, flags); |
Jean Pihet | abe98ec | 2011-08-25 15:35:34 +0200 | [diff] [blame] | 879 | value = pm_qos_get_value(pm_qos_array[req->pm_qos_class]->constraints); |
Thomas Renninger | f9b9e80 | 2011-02-28 22:06:34 +0100 | [diff] [blame] | 880 | spin_unlock_irqrestore(&pm_qos_lock, flags); |
| 881 | |
| 882 | return simple_read_from_buffer(buf, count, f_pos, &value, sizeof(s32)); |
| 883 | } |
| 884 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 885 | static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, |
| 886 | size_t count, loff_t *f_pos) |
| 887 | { |
| 888 | s32 value; |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 889 | struct pm_qos_request *req; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 890 | |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 891 | if (count == sizeof(s32)) { |
| 892 | if (copy_from_user(&value, buf, sizeof(s32))) |
| 893 | return -EFAULT; |
Andy Shevchenko | d4f7ecf | 2013-09-11 17:02:38 +0300 | [diff] [blame] | 894 | } else { |
Rafael J. Wysocki | 0775a60 | 2011-05-27 00:05:23 +0200 | [diff] [blame] | 895 | int ret; |
| 896 | |
Andy Shevchenko | d4f7ecf | 2013-09-11 17:02:38 +0300 | [diff] [blame] | 897 | ret = kstrtos32_from_user(buf, count, 16, &value); |
| 898 | if (ret) |
| 899 | return ret; |
Rafael J. Wysocki | 0775a60 | 2011-05-27 00:05:23 +0200 | [diff] [blame] | 900 | } |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 901 | |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 902 | req = filp->private_data; |
| 903 | pm_qos_update_request(req, value); |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 904 | |
| 905 | return count; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | |
| 909 | static int __init pm_qos_power_init(void) |
| 910 | { |
| 911 | int ret = 0; |
Alex Frid | d031e1d | 2012-01-29 20:39:25 +0100 | [diff] [blame] | 912 | int i; |
Nishanth Menon | f5f4eda | 2014-12-05 11:19:08 -0600 | [diff] [blame] | 913 | struct dentry *d; |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 914 | |
Alex Frid | d031e1d | 2012-01-29 20:39:25 +0100 | [diff] [blame] | 915 | BUILD_BUG_ON(ARRAY_SIZE(pm_qos_array) != PM_QOS_NUM_CLASSES); |
| 916 | |
Nishanth Menon | f5f4eda | 2014-12-05 11:19:08 -0600 | [diff] [blame] | 917 | d = debugfs_create_dir("pm_qos", NULL); |
| 918 | if (IS_ERR_OR_NULL(d)) |
| 919 | d = NULL; |
| 920 | |
Sahara | d24c2a4 | 2013-06-20 11:33:57 +0900 | [diff] [blame] | 921 | for (i = PM_QOS_CPU_DMA_LATENCY; i < PM_QOS_NUM_CLASSES; i++) { |
Nishanth Menon | f5f4eda | 2014-12-05 11:19:08 -0600 | [diff] [blame] | 922 | ret = register_pm_qos_misc(pm_qos_array[i], d); |
Alex Frid | d031e1d | 2012-01-29 20:39:25 +0100 | [diff] [blame] | 923 | if (ret < 0) { |
| 924 | printk(KERN_ERR "pm_qos_param: %s setup failed\n", |
| 925 | pm_qos_array[i]->name); |
| 926 | return ret; |
| 927 | } |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 928 | } |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 929 | |
| 930 | return ret; |
| 931 | } |
| 932 | |
| 933 | late_initcall(pm_qos_power_init); |