blob: 68df076fec5d045f4f3dab02696fb4c9429a1e00 [file] [log] [blame]
Mark Grossd82b3512008-02-04 22:30:08 -08001/*
2 * This module exposes the interface to kernel space for specifying
3 * QoS dependencies. It provides infrastructure for registration of:
4 *
Mark Grossed771342010-05-06 01:59:26 +02005 * Dependents on a QoS value : register requests
Mark Grossd82b3512008-02-04 22:30:08 -08006 * 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 Grossed771342010-05-06 01:59:26 +020017 * There are lists of pm_qos_objects each one wrapping requests, notifiers
Mark Grossd82b3512008-02-04 22:30:08 -080018 *
Mark Grossed771342010-05-06 01:59:26 +020019 * User mode requests on a QOS parameter register themselves to the
Mark Grossd82b3512008-02-04 22:30:08 -080020 * 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 Grossed771342010-05-06 01:59:26 +020023 * 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 Grossd82b3512008-02-04 22:30:08 -080025 * pointer or exits the pm_qos_object will get an opportunity to clean up.
26 *
Richard Hughesbf1db692008-08-05 13:01:35 -070027 * Mark Gross <mgross@linux.intel.com>
Mark Grossd82b3512008-02-04 22:30:08 -080028 */
29
Mark Grossed771342010-05-06 01:59:26 +020030/*#define DEBUG*/
31
Mark Grossd82b3512008-02-04 22:30:08 -080032#include <linux/pm_qos_params.h>
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. Wysocki0775a602011-05-27 00:05:23 +020043#include <linux/kernel.h>
Mark Grossd82b3512008-02-04 22:30:08 -080044
45#include <linux/uaccess.h>
46
47/*
Mark Grossed771342010-05-06 01:59:26 +020048 * locking rule: all changes to requests or notifiers lists
Mark Grossd82b3512008-02-04 22:30:08 -080049 * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock
50 * held, taken with _irqsave. One lock to rule them all
51 */
James Bottomley5f279842010-07-19 02:00:18 +020052enum pm_qos_type {
53 PM_QOS_MAX, /* return the largest value */
54 PM_QOS_MIN /* return the smallest value */
55};
Mark Grossd82b3512008-02-04 22:30:08 -080056
57struct pm_qos_object {
James Bottomley5f279842010-07-19 02:00:18 +020058 struct plist_head requests;
Mark Grossd82b3512008-02-04 22:30:08 -080059 struct blocking_notifier_head *notifiers;
60 struct miscdevice pm_qos_power_miscdev;
61 char *name;
62 s32 default_value;
James Bottomley5f279842010-07-19 02:00:18 +020063 enum pm_qos_type type;
Mark Grossd82b3512008-02-04 22:30:08 -080064};
65
James Bottomley5f279842010-07-19 02:00:18 +020066static DEFINE_SPINLOCK(pm_qos_lock);
67
Mark Grossd82b3512008-02-04 22:30:08 -080068static struct pm_qos_object null_pm_qos;
69static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier);
70static struct pm_qos_object cpu_dma_pm_qos = {
James Bottomley5f279842010-07-19 02:00:18 +020071 .requests = PLIST_HEAD_INIT(cpu_dma_pm_qos.requests, pm_qos_lock),
Mark Grossd82b3512008-02-04 22:30:08 -080072 .notifiers = &cpu_dma_lat_notifier,
73 .name = "cpu_dma_latency",
74 .default_value = 2000 * USEC_PER_SEC,
James Bottomley5f279842010-07-19 02:00:18 +020075 .type = PM_QOS_MIN,
Mark Grossd82b3512008-02-04 22:30:08 -080076};
77
78static BLOCKING_NOTIFIER_HEAD(network_lat_notifier);
79static struct pm_qos_object network_lat_pm_qos = {
James Bottomley5f279842010-07-19 02:00:18 +020080 .requests = PLIST_HEAD_INIT(network_lat_pm_qos.requests, pm_qos_lock),
Mark Grossd82b3512008-02-04 22:30:08 -080081 .notifiers = &network_lat_notifier,
82 .name = "network_latency",
83 .default_value = 2000 * USEC_PER_SEC,
James Bottomley5f279842010-07-19 02:00:18 +020084 .type = PM_QOS_MIN
Mark Grossd82b3512008-02-04 22:30:08 -080085};
86
87
88static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier);
89static struct pm_qos_object network_throughput_pm_qos = {
James Bottomley5f279842010-07-19 02:00:18 +020090 .requests = PLIST_HEAD_INIT(network_throughput_pm_qos.requests, pm_qos_lock),
Mark Grossd82b3512008-02-04 22:30:08 -080091 .notifiers = &network_throughput_notifier,
92 .name = "network_throughput",
93 .default_value = 0,
James Bottomley5f279842010-07-19 02:00:18 +020094 .type = PM_QOS_MAX,
Mark Grossd82b3512008-02-04 22:30:08 -080095};
96
97
98static struct pm_qos_object *pm_qos_array[] = {
99 &null_pm_qos,
100 &cpu_dma_pm_qos,
101 &network_lat_pm_qos,
102 &network_throughput_pm_qos
103};
104
Mark Grossd82b3512008-02-04 22:30:08 -0800105static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
106 size_t count, loff_t *f_pos);
Thomas Renningerf9b9e802011-02-28 22:06:34 +0100107static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,
108 size_t count, loff_t *f_pos);
Mark Grossd82b3512008-02-04 22:30:08 -0800109static int pm_qos_power_open(struct inode *inode, struct file *filp);
110static int pm_qos_power_release(struct inode *inode, struct file *filp);
111
112static const struct file_operations pm_qos_power_fops = {
113 .write = pm_qos_power_write,
Thomas Renningerf9b9e802011-02-28 22:06:34 +0100114 .read = pm_qos_power_read,
Mark Grossd82b3512008-02-04 22:30:08 -0800115 .open = pm_qos_power_open,
116 .release = pm_qos_power_release,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200117 .llseek = noop_llseek,
Mark Grossd82b3512008-02-04 22:30:08 -0800118};
119
James Bottomley5f279842010-07-19 02:00:18 +0200120/* unlocked internal variant */
121static inline int pm_qos_get_value(struct pm_qos_object *o)
Mark Grossd82b3512008-02-04 22:30:08 -0800122{
James Bottomley5f279842010-07-19 02:00:18 +0200123 if (plist_head_empty(&o->requests))
124 return o->default_value;
125
126 switch (o->type) {
127 case PM_QOS_MIN:
Colin Cross00fafcd2010-11-15 22:45:22 +0100128 return plist_first(&o->requests)->prio;
James Bottomley5f279842010-07-19 02:00:18 +0200129
130 case PM_QOS_MAX:
Colin Cross00fafcd2010-11-15 22:45:22 +0100131 return plist_last(&o->requests)->prio;
James Bottomley5f279842010-07-19 02:00:18 +0200132
133 default:
134 /* runtime check for not using enum */
135 BUG();
136 }
Mark Grossd82b3512008-02-04 22:30:08 -0800137}
138
James Bottomley5f279842010-07-19 02:00:18 +0200139static void update_target(struct pm_qos_object *o, struct plist_node *node,
140 int del, int value)
Mark Grossd82b3512008-02-04 22:30:08 -0800141{
Mark Grossd82b3512008-02-04 22:30:08 -0800142 unsigned long flags;
James Bottomley5f279842010-07-19 02:00:18 +0200143 int prev_value, curr_value;
Mark Grossd82b3512008-02-04 22:30:08 -0800144
145 spin_lock_irqsave(&pm_qos_lock, flags);
James Bottomley5f279842010-07-19 02:00:18 +0200146 prev_value = pm_qos_get_value(o);
147 /* PM_QOS_DEFAULT_VALUE is a signal that the value is unchanged */
148 if (value != PM_QOS_DEFAULT_VALUE) {
149 /*
150 * to change the list, we atomically remove, reinit
151 * with new value and add, then see if the extremal
152 * changed
153 */
154 plist_del(node, &o->requests);
155 plist_node_init(node, value);
156 plist_add(node, &o->requests);
157 } else if (del) {
158 plist_del(node, &o->requests);
159 } else {
160 plist_add(node, &o->requests);
Mark Grossd82b3512008-02-04 22:30:08 -0800161 }
James Bottomley5f279842010-07-19 02:00:18 +0200162 curr_value = pm_qos_get_value(o);
Mark Grossd82b3512008-02-04 22:30:08 -0800163 spin_unlock_irqrestore(&pm_qos_lock, flags);
164
James Bottomley5f279842010-07-19 02:00:18 +0200165 if (prev_value != curr_value)
166 blocking_notifier_call_chain(o->notifiers,
167 (unsigned long)curr_value,
168 NULL);
Mark Grossd82b3512008-02-04 22:30:08 -0800169}
170
171static int register_pm_qos_misc(struct pm_qos_object *qos)
172{
173 qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR;
174 qos->pm_qos_power_miscdev.name = qos->name;
175 qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops;
176
177 return misc_register(&qos->pm_qos_power_miscdev);
178}
179
180static int find_pm_qos_object_by_minor(int minor)
181{
182 int pm_qos_class;
183
184 for (pm_qos_class = 0;
185 pm_qos_class < PM_QOS_NUM_CLASSES; pm_qos_class++) {
186 if (minor ==
187 pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor)
188 return pm_qos_class;
189 }
190 return -1;
191}
192
193/**
Mark Grossed771342010-05-06 01:59:26 +0200194 * pm_qos_request - returns current system wide qos expectation
Mark Grossd82b3512008-02-04 22:30:08 -0800195 * @pm_qos_class: identification of which qos value is requested
196 *
197 * This function returns the current target value in an atomic manner.
198 */
Mark Grossed771342010-05-06 01:59:26 +0200199int pm_qos_request(int pm_qos_class)
Mark Grossd82b3512008-02-04 22:30:08 -0800200{
James Bottomley5f279842010-07-19 02:00:18 +0200201 unsigned long flags;
202 int value;
203
204 spin_lock_irqsave(&pm_qos_lock, flags);
205 value = pm_qos_get_value(pm_qos_array[pm_qos_class]);
206 spin_unlock_irqrestore(&pm_qos_lock, flags);
207
208 return value;
Mark Grossd82b3512008-02-04 22:30:08 -0800209}
Mark Grossed771342010-05-06 01:59:26 +0200210EXPORT_SYMBOL_GPL(pm_qos_request);
Mark Grossd82b3512008-02-04 22:30:08 -0800211
James Bottomley82f68252010-07-05 22:53:06 +0200212int pm_qos_request_active(struct pm_qos_request_list *req)
213{
214 return req->pm_qos_class != 0;
215}
216EXPORT_SYMBOL_GPL(pm_qos_request_active);
217
Mark Grossd82b3512008-02-04 22:30:08 -0800218/**
Mark Grossed771342010-05-06 01:59:26 +0200219 * pm_qos_add_request - inserts new qos request into the list
Saravana Kannan25cc69e2010-08-26 20:18:43 +0200220 * @dep: pointer to a preallocated handle
221 * @pm_qos_class: identifies which list of qos request to use
Mark Grossd82b3512008-02-04 22:30:08 -0800222 * @value: defines the qos request
223 *
224 * This function inserts a new entry in the pm_qos_class list of requested qos
Richard Hughesbf1db692008-08-05 13:01:35 -0700225 * performance characteristics. It recomputes the aggregate QoS expectations
Saravana Kannan25cc69e2010-08-26 20:18:43 +0200226 * for the pm_qos_class of parameters and initializes the pm_qos_request_list
227 * handle. Caller needs to save this handle for later use in updates and
228 * removal.
Mark Grossd82b3512008-02-04 22:30:08 -0800229 */
Saravana Kannan25cc69e2010-08-26 20:18:43 +0200230
James Bottomley82f68252010-07-05 22:53:06 +0200231void pm_qos_add_request(struct pm_qos_request_list *dep,
232 int pm_qos_class, s32 value)
Mark Grossd82b3512008-02-04 22:30:08 -0800233{
James Bottomley82f68252010-07-05 22:53:06 +0200234 struct pm_qos_object *o = pm_qos_array[pm_qos_class];
235 int new_value;
Mark Grossd82b3512008-02-04 22:30:08 -0800236
James Bottomley82f68252010-07-05 22:53:06 +0200237 if (pm_qos_request_active(dep)) {
238 WARN(1, KERN_ERR "pm_qos_add_request() called for already added request\n");
239 return;
Mark Grossd82b3512008-02-04 22:30:08 -0800240 }
James Bottomley82f68252010-07-05 22:53:06 +0200241 if (value == PM_QOS_DEFAULT_VALUE)
242 new_value = o->default_value;
243 else
244 new_value = value;
245 plist_node_init(&dep->list, new_value);
246 dep->pm_qos_class = pm_qos_class;
247 update_target(o, &dep->list, 0, PM_QOS_DEFAULT_VALUE);
Mark Grossd82b3512008-02-04 22:30:08 -0800248}
Mark Grossed771342010-05-06 01:59:26 +0200249EXPORT_SYMBOL_GPL(pm_qos_add_request);
Mark Grossd82b3512008-02-04 22:30:08 -0800250
251/**
Mark Grossed771342010-05-06 01:59:26 +0200252 * pm_qos_update_request - modifies an existing qos request
253 * @pm_qos_req : handle to list element holding a pm_qos request to use
Mark Grossd82b3512008-02-04 22:30:08 -0800254 * @value: defines the qos request
255 *
Mark Grossed771342010-05-06 01:59:26 +0200256 * Updates an existing qos request for the pm_qos_class of parameters along
Mark Grossd82b3512008-02-04 22:30:08 -0800257 * with updating the target pm_qos_class value.
258 *
Mark Grossed771342010-05-06 01:59:26 +0200259 * Attempts are made to make this code callable on hot code paths.
Mark Grossd82b3512008-02-04 22:30:08 -0800260 */
Mark Grossed771342010-05-06 01:59:26 +0200261void pm_qos_update_request(struct pm_qos_request_list *pm_qos_req,
James Bottomley5f279842010-07-19 02:00:18 +0200262 s32 new_value)
Mark Grossd82b3512008-02-04 22:30:08 -0800263{
Mark Grossed771342010-05-06 01:59:26 +0200264 s32 temp;
James Bottomley5f279842010-07-19 02:00:18 +0200265 struct pm_qos_object *o;
Mark Grossd82b3512008-02-04 22:30:08 -0800266
James Bottomley5f279842010-07-19 02:00:18 +0200267 if (!pm_qos_req) /*guard against callers passing in null */
268 return;
Mark Grossed771342010-05-06 01:59:26 +0200269
James Bottomley82f68252010-07-05 22:53:06 +0200270 if (!pm_qos_request_active(pm_qos_req)) {
271 WARN(1, KERN_ERR "pm_qos_update_request() called for unknown object\n");
272 return;
273 }
274
James Bottomley5f279842010-07-19 02:00:18 +0200275 o = pm_qos_array[pm_qos_req->pm_qos_class];
276
277 if (new_value == PM_QOS_DEFAULT_VALUE)
278 temp = o->default_value;
279 else
280 temp = new_value;
281
282 if (temp != pm_qos_req->list.prio)
283 update_target(o, &pm_qos_req->list, 0, temp);
Mark Grossd82b3512008-02-04 22:30:08 -0800284}
Mark Grossed771342010-05-06 01:59:26 +0200285EXPORT_SYMBOL_GPL(pm_qos_update_request);
Mark Grossd82b3512008-02-04 22:30:08 -0800286
287/**
Mark Grossed771342010-05-06 01:59:26 +0200288 * pm_qos_remove_request - modifies an existing qos request
289 * @pm_qos_req: handle to request list element
Mark Grossd82b3512008-02-04 22:30:08 -0800290 *
Mark Grossed771342010-05-06 01:59:26 +0200291 * Will remove pm qos request from the list of requests and
292 * recompute the current target value for the pm_qos_class. Call this
293 * on slow code paths.
Mark Grossd82b3512008-02-04 22:30:08 -0800294 */
Mark Grossed771342010-05-06 01:59:26 +0200295void pm_qos_remove_request(struct pm_qos_request_list *pm_qos_req)
Mark Grossd82b3512008-02-04 22:30:08 -0800296{
James Bottomley5f279842010-07-19 02:00:18 +0200297 struct pm_qos_object *o;
Mark Grossd82b3512008-02-04 22:30:08 -0800298
Mark Grossed771342010-05-06 01:59:26 +0200299 if (pm_qos_req == NULL)
300 return;
301 /* silent return to keep pcm code cleaner */
302
James Bottomley82f68252010-07-05 22:53:06 +0200303 if (!pm_qos_request_active(pm_qos_req)) {
304 WARN(1, KERN_ERR "pm_qos_remove_request() called for unknown object\n");
305 return;
306 }
307
James Bottomley5f279842010-07-19 02:00:18 +0200308 o = pm_qos_array[pm_qos_req->pm_qos_class];
309 update_target(o, &pm_qos_req->list, 1, PM_QOS_DEFAULT_VALUE);
James Bottomley82f68252010-07-05 22:53:06 +0200310 memset(pm_qos_req, 0, sizeof(*pm_qos_req));
Mark Grossd82b3512008-02-04 22:30:08 -0800311}
Mark Grossed771342010-05-06 01:59:26 +0200312EXPORT_SYMBOL_GPL(pm_qos_remove_request);
Mark Grossd82b3512008-02-04 22:30:08 -0800313
314/**
315 * pm_qos_add_notifier - sets notification entry for changes to target value
316 * @pm_qos_class: identifies which qos target changes should be notified.
317 * @notifier: notifier block managed by caller.
318 *
319 * will register the notifier into a notification chain that gets called
Richard Hughesbf1db692008-08-05 13:01:35 -0700320 * upon changes to the pm_qos_class target value.
Mark Grossd82b3512008-02-04 22:30:08 -0800321 */
Mark Grossed771342010-05-06 01:59:26 +0200322int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier)
Mark Grossd82b3512008-02-04 22:30:08 -0800323{
324 int retval;
325
326 retval = blocking_notifier_chain_register(
327 pm_qos_array[pm_qos_class]->notifiers, notifier);
328
329 return retval;
330}
331EXPORT_SYMBOL_GPL(pm_qos_add_notifier);
332
333/**
334 * pm_qos_remove_notifier - deletes notification entry from chain.
335 * @pm_qos_class: identifies which qos target changes are notified.
336 * @notifier: notifier block to be removed.
337 *
338 * will remove the notifier from the notification chain that gets called
Richard Hughesbf1db692008-08-05 13:01:35 -0700339 * upon changes to the pm_qos_class target value.
Mark Grossd82b3512008-02-04 22:30:08 -0800340 */
341int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier)
342{
343 int retval;
344
345 retval = blocking_notifier_chain_unregister(
346 pm_qos_array[pm_qos_class]->notifiers, notifier);
347
348 return retval;
349}
350EXPORT_SYMBOL_GPL(pm_qos_remove_notifier);
351
Mark Grossd82b3512008-02-04 22:30:08 -0800352static int pm_qos_power_open(struct inode *inode, struct file *filp)
353{
Mark Grossd82b3512008-02-04 22:30:08 -0800354 long pm_qos_class;
355
356 pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
357 if (pm_qos_class >= 0) {
David Alan Gilbertbac1e742010-08-24 20:22:18 +0200358 struct pm_qos_request_list *req = kzalloc(sizeof(*req), GFP_KERNEL);
James Bottomley82f68252010-07-05 22:53:06 +0200359 if (!req)
360 return -ENOMEM;
361
362 pm_qos_add_request(req, pm_qos_class, PM_QOS_DEFAULT_VALUE);
363 filp->private_data = req;
Mark Grossed771342010-05-06 01:59:26 +0200364
365 if (filp->private_data)
Mark Grossd82b3512008-02-04 22:30:08 -0800366 return 0;
367 }
Mark Grossd82b3512008-02-04 22:30:08 -0800368 return -EPERM;
369}
370
371static int pm_qos_power_release(struct inode *inode, struct file *filp)
372{
Mark Grossed771342010-05-06 01:59:26 +0200373 struct pm_qos_request_list *req;
Mark Grossd82b3512008-02-04 22:30:08 -0800374
James Bottomley82f68252010-07-05 22:53:06 +0200375 req = filp->private_data;
Mark Grossed771342010-05-06 01:59:26 +0200376 pm_qos_remove_request(req);
James Bottomley82f68252010-07-05 22:53:06 +0200377 kfree(req);
Mark Grossd82b3512008-02-04 22:30:08 -0800378
379 return 0;
380}
381
Mark Grossed771342010-05-06 01:59:26 +0200382
Thomas Renningerf9b9e802011-02-28 22:06:34 +0100383static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,
384 size_t count, loff_t *f_pos)
385{
386 s32 value;
387 unsigned long flags;
388 struct pm_qos_object *o;
389 struct pm_qos_request_list *pm_qos_req = filp->private_data;;
390
391 if (!pm_qos_req)
392 return -EINVAL;
393 if (!pm_qos_request_active(pm_qos_req))
394 return -EINVAL;
395
396 o = pm_qos_array[pm_qos_req->pm_qos_class];
397 spin_lock_irqsave(&pm_qos_lock, flags);
398 value = pm_qos_get_value(o);
399 spin_unlock_irqrestore(&pm_qos_lock, flags);
400
401 return simple_read_from_buffer(buf, count, f_pos, &value, sizeof(s32));
402}
403
Mark Grossd82b3512008-02-04 22:30:08 -0800404static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
405 size_t count, loff_t *f_pos)
406{
407 s32 value;
Mark Grossed771342010-05-06 01:59:26 +0200408 struct pm_qos_request_list *pm_qos_req;
Mark Grossd82b3512008-02-04 22:30:08 -0800409
Mark Grossed771342010-05-06 01:59:26 +0200410 if (count == sizeof(s32)) {
411 if (copy_from_user(&value, buf, sizeof(s32)))
412 return -EFAULT;
Rafael J. Wysocki0775a602011-05-27 00:05:23 +0200413 } else if (count <= 11) { /* ASCII perhaps? */
414 char ascii_value[11];
415 unsigned long int ulval;
416 int ret;
417
418 if (copy_from_user(ascii_value, buf, count))
Mark Grossed771342010-05-06 01:59:26 +0200419 return -EFAULT;
Rafael J. Wysocki0775a602011-05-27 00:05:23 +0200420
421 if (count > 10) {
422 if (ascii_value[10] == '\n')
423 ascii_value[10] = '\0';
424 else
425 return -EINVAL;
426 } else {
427 ascii_value[count] = '\0';
428 }
429 ret = strict_strtoul(ascii_value, 16, &ulval);
430 if (ret) {
431 pr_debug("%s, 0x%lx, 0x%x\n", ascii_value, ulval, ret);
mark gross0109c2c2010-09-09 23:20:09 +0200432 return -EINVAL;
Rafael J. Wysocki0775a602011-05-27 00:05:23 +0200433 }
434 value = (s32)lower_32_bits(ulval);
435 } else {
Mark Grossd82b3512008-02-04 22:30:08 -0800436 return -EINVAL;
Rafael J. Wysocki0775a602011-05-27 00:05:23 +0200437 }
Mark Grossd82b3512008-02-04 22:30:08 -0800438
Joe Perches99a51792010-09-04 18:52:50 -0700439 pm_qos_req = filp->private_data;
Mark Grossed771342010-05-06 01:59:26 +0200440 pm_qos_update_request(pm_qos_req, value);
441
442 return count;
Mark Grossd82b3512008-02-04 22:30:08 -0800443}
444
445
446static int __init pm_qos_power_init(void)
447{
448 int ret = 0;
449
450 ret = register_pm_qos_misc(&cpu_dma_pm_qos);
451 if (ret < 0) {
452 printk(KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n");
453 return ret;
454 }
455 ret = register_pm_qos_misc(&network_lat_pm_qos);
456 if (ret < 0) {
457 printk(KERN_ERR "pm_qos_param: network_latency setup failed\n");
458 return ret;
459 }
460 ret = register_pm_qos_misc(&network_throughput_pm_qos);
461 if (ret < 0)
462 printk(KERN_ERR
463 "pm_qos_param: network_throughput setup failed\n");
464
465 return ret;
466}
467
468late_initcall(pm_qos_power_init);