PM / QoS: CPU C-state breakage with PM Qos change
[deliverable/linux.git] / include / linux / pm_qos.h
CommitLineData
e8db0be1
JP
1#ifndef _LINUX_PM_QOS_H
2#define _LINUX_PM_QOS_H
d82b3518
MG
3/* interface for the pm_qos_power infrastructure of the linux kernel.
4 *
bf1db69f 5 * Mark Gross <mgross@linux.intel.com>
d82b3518 6 */
82f68251 7#include <linux/plist.h>
d82b3518
MG
8#include <linux/notifier.h>
9#include <linux/miscdevice.h>
1a9a9152 10#include <linux/device.h>
d82b3518
MG
11
12#define PM_QOS_RESERVED 0
13#define PM_QOS_CPU_DMA_LATENCY 1
14#define PM_QOS_NETWORK_LATENCY 2
15#define PM_QOS_NETWORK_THROUGHPUT 3
16
17#define PM_QOS_NUM_CLASSES 4
18#define PM_QOS_DEFAULT_VALUE -1
19
333c5ae9
TC
20#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
21#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
22#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
91ff4cb8 23#define PM_QOS_DEV_LAT_DEFAULT_VALUE 0
333c5ae9 24
cc749986
JP
25struct pm_qos_request {
26 struct plist_node node;
82f68251
JB
27 int pm_qos_class;
28};
d82b3518 29
91ff4cb8
JP
30struct dev_pm_qos_request {
31 struct plist_node node;
32 struct device *dev;
33};
34
4e1779ba
JP
35enum pm_qos_type {
36 PM_QOS_UNITIALIZED,
37 PM_QOS_MAX, /* return the largest value */
38 PM_QOS_MIN /* return the smallest value */
39};
40
41/*
42 * Note: The lockless read path depends on the CPU accessing
43 * target_value atomically. Atomic access is only guaranteed on all CPU
44 * types linux supports for 32 bit quantites
45 */
46struct pm_qos_constraints {
47 struct plist_head list;
48 s32 target_value; /* Do not change to 64 bit */
49 s32 default_value;
50 enum pm_qos_type type;
51 struct blocking_notifier_head *notifiers;
52};
53
abe98ec2
JP
54/* Action requested to pm_qos_update_target */
55enum pm_qos_req_action {
56 PM_QOS_ADD_REQ, /* Add a new request */
57 PM_QOS_UPDATE_REQ, /* Update an existing request */
58 PM_QOS_REMOVE_REQ /* Remove an existing request */
59};
60
91ff4cb8
JP
61static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req)
62{
63 return req->dev != 0;
64}
65
e8db0be1 66#ifdef CONFIG_PM
abe98ec2
JP
67int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
68 enum pm_qos_req_action action, int value);
cc749986
JP
69void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
70 s32 value);
71void pm_qos_update_request(struct pm_qos_request *req,
e8db0be1 72 s32 new_value);
cc749986 73void pm_qos_remove_request(struct pm_qos_request *req);
d82b3518 74
ed77134b
MG
75int pm_qos_request(int pm_qos_class);
76int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
77int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
cc749986 78int pm_qos_request_active(struct pm_qos_request *req);
b66213cd 79s32 pm_qos_read_value(struct pm_qos_constraints *c);
91ff4cb8 80
00dc9ad1 81s32 __dev_pm_qos_read_value(struct device *dev);
1a9a9152 82s32 dev_pm_qos_read_value(struct device *dev);
91ff4cb8
JP
83int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req,
84 s32 value);
85int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value);
86int dev_pm_qos_remove_request(struct dev_pm_qos_request *req);
87int dev_pm_qos_add_notifier(struct device *dev,
88 struct notifier_block *notifier);
89int dev_pm_qos_remove_notifier(struct device *dev,
90 struct notifier_block *notifier);
b66213cd
JP
91int dev_pm_qos_add_global_notifier(struct notifier_block *notifier);
92int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier);
91ff4cb8
JP
93void dev_pm_qos_constraints_init(struct device *dev);
94void dev_pm_qos_constraints_destroy(struct device *dev);
40a5f8be
RW
95int dev_pm_qos_add_ancestor_request(struct device *dev,
96 struct dev_pm_qos_request *req, s32 value);
e8db0be1 97#else
abe98ec2
JP
98static inline int pm_qos_update_target(struct pm_qos_constraints *c,
99 struct plist_node *node,
100 enum pm_qos_req_action action,
101 int value)
102 { return 0; }
cc749986 103static inline void pm_qos_add_request(struct pm_qos_request *req,
e8db0be1
JP
104 int pm_qos_class, s32 value)
105 { return; }
cc749986 106static inline void pm_qos_update_request(struct pm_qos_request *req,
e8db0be1
JP
107 s32 new_value)
108 { return; }
cc749986 109static inline void pm_qos_remove_request(struct pm_qos_request *req)
e8db0be1
JP
110 { return; }
111
112static inline int pm_qos_request(int pm_qos_class)
d020283d
VP
113{
114 switch (pm_qos_class) {
115 case PM_QOS_CPU_DMA_LATENCY:
116 return PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE;
117 case PM_QOS_NETWORK_LATENCY:
118 return PM_QOS_NETWORK_LAT_DEFAULT_VALUE;
119 case PM_QOS_NETWORK_THROUGHPUT:
120 return PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE;
121 default:
122 return PM_QOS_DEFAULT_VALUE;
123 }
124}
125
e8db0be1
JP
126static inline int pm_qos_add_notifier(int pm_qos_class,
127 struct notifier_block *notifier)
128 { return 0; }
129static inline int pm_qos_remove_notifier(int pm_qos_class,
130 struct notifier_block *notifier)
131 { return 0; }
cc749986 132static inline int pm_qos_request_active(struct pm_qos_request *req)
e8db0be1 133 { return 0; }
b66213cd
JP
134static inline s32 pm_qos_read_value(struct pm_qos_constraints *c)
135 { return 0; }
91ff4cb8 136
00dc9ad1
RW
137static inline s32 __dev_pm_qos_read_value(struct device *dev)
138 { return 0; }
1a9a9152
RW
139static inline s32 dev_pm_qos_read_value(struct device *dev)
140 { return 0; }
91ff4cb8
JP
141static inline int dev_pm_qos_add_request(struct device *dev,
142 struct dev_pm_qos_request *req,
143 s32 value)
144 { return 0; }
145static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req,
146 s32 new_value)
147 { return 0; }
148static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req)
149 { return 0; }
150static inline int dev_pm_qos_add_notifier(struct device *dev,
151 struct notifier_block *notifier)
152 { return 0; }
153static inline int dev_pm_qos_remove_notifier(struct device *dev,
154 struct notifier_block *notifier)
155 { return 0; }
b66213cd
JP
156static inline int dev_pm_qos_add_global_notifier(
157 struct notifier_block *notifier)
158 { return 0; }
159static inline int dev_pm_qos_remove_global_notifier(
160 struct notifier_block *notifier)
161 { return 0; }
91ff4cb8 162static inline void dev_pm_qos_constraints_init(struct device *dev)
1a9a9152
RW
163{
164 dev->power.power_state = PMSG_ON;
165}
91ff4cb8 166static inline void dev_pm_qos_constraints_destroy(struct device *dev)
1a9a9152
RW
167{
168 dev->power.power_state = PMSG_INVALID;
169}
40a5f8be
RW
170static inline int dev_pm_qos_add_ancestor_request(struct device *dev,
171 struct dev_pm_qos_request *req, s32 value)
172 { return 0; }
e8db0be1 173#endif
d82b3518 174
82f68251 175#endif
This page took 0.498204 seconds and 5 git commands to generate.