33 #include <linux/sched.h>
35 #include <linux/slab.h>
36 #include <linux/time.h>
38 #include <linux/device.h>
40 #include <linux/string.h>
43 #include <linux/kernel.h>
46 #include <linux/export.h>
69 .notifiers = &cpu_dma_lat_notifier,
72 .constraints = &cpu_dma_constraints,
73 .name =
"cpu_dma_latency",
82 .notifiers = &network_lat_notifier,
85 .constraints = &network_lat_constraints,
86 .name =
"network_latency",
96 .notifiers = &network_throughput_notifier,
99 .constraints = &network_tput_constraints,
100 .name =
"network_throughput",
108 &network_throughput_pm_qos
111 static ssize_t pm_qos_power_write(
struct file *filp,
const char __user *
buf,
112 size_t count, loff_t *f_pos);
113 static ssize_t pm_qos_power_read(
struct file *filp,
char __user *
buf,
114 size_t count, loff_t *f_pos);
115 static int pm_qos_power_open(
struct inode *
inode,
struct file *filp);
116 static int pm_qos_power_release(
struct inode *
inode,
struct file *filp);
119 .write = pm_qos_power_write,
120 .read = pm_qos_power_read,
121 .open = pm_qos_power_open,
122 .release = pm_qos_power_release,
129 if (plist_head_empty(&c->
list))
134 return plist_first(&c->
list)->prio;
137 return plist_last(&c->
list)->prio;
171 int prev_value, curr_value, new_value;
174 prev_value = pm_qos_get_value(c);
192 plist_node_init(node, new_value);
200 curr_value = pm_qos_get_value(c);
201 pm_qos_set_value(c, curr_value);
203 spin_unlock_irqrestore(&pm_qos_lock, flags);
205 if (prev_value != curr_value) {
207 (
unsigned long)curr_value,
268 WARN(1,
KERN_ERR "pm_qos_add_request() called for already added request\n");
295 WARN(1,
KERN_ERR "pm_qos_update_request() called for unknown object\n");
302 if (new_value != req->
node.prio)
318 unsigned long timeout_us)
323 "%s called for unknown object.", __func__))
329 if (new_value != req->
node.prio)
352 WARN(1,
KERN_ERR "pm_qos_remove_request() called for unknown object\n");
362 memset(req, 0,
sizeof(*req));
379 pm_qos_array[pm_qos_class]->constraints->notifiers,
399 pm_qos_array[pm_qos_class]->constraints->notifiers,
416 static int find_pm_qos_object_by_minor(
int minor)
420 for (pm_qos_class = 0;
423 pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor)
429 static int pm_qos_power_open(
struct inode *
inode,
struct file *filp)
433 pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
434 if (pm_qos_class >= 0) {
447 static int pm_qos_power_release(
struct inode *inode,
struct file *filp)
459 static ssize_t pm_qos_power_read(
struct file *filp,
char __user *
buf,
460 size_t count, loff_t *f_pos)
473 spin_unlock_irqrestore(&pm_qos_lock, flags);
478 static ssize_t pm_qos_power_write(
struct file *filp,
const char __user *buf,
479 size_t count, loff_t *f_pos)
484 if (count ==
sizeof(
s32)) {
487 }
else if (count <= 11) {
488 char ascii_value[11];
489 unsigned long int ulval;
496 if (ascii_value[10] ==
'\n')
497 ascii_value[10] =
'\0';
501 ascii_value[
count] =
'\0';
505 pr_debug(
"%s, 0x%lx, 0x%x\n", ascii_value, ulval, ret);
520 static int __init pm_qos_power_init(
void)
528 ret = register_pm_qos_misc(pm_qos_array[i]);
531 pm_qos_array[i]->
name);