1 #ifndef _LINUX_PM_QOS_H
2 #define _LINUX_PM_QOS_H
3 /* interface for the pm_qos_power infrastructure of the linux kernel.
5 * Mark Gross <mgross@linux.intel.com>
7 #include <linux/plist.h>
8 #include <linux/notifier.h>
9 #include <linux/miscdevice.h>
10 #include <linux/device.h>
11 #include <linux/workqueue.h>
15 PM_QOS_CPU_DMA_LATENCY
,
16 PM_QOS_NETWORK_LATENCY
,
17 PM_QOS_NETWORK_THROUGHPUT
,
19 /* insert new class ID */
23 enum pm_qos_flags_status
{
24 PM_QOS_FLAGS_UNDEFINED
= -1,
30 #define PM_QOS_DEFAULT_VALUE -1
32 #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
33 #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
34 #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
35 #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0
37 struct pm_qos_request
{
38 struct plist_node node
;
40 struct delayed_work work
; /* for pm_qos_update_request_timeout */
43 struct pm_qos_flags_request
{
44 struct list_head node
;
45 s32 flags
; /* Do not change to 64 bit */
48 enum dev_pm_qos_req_type
{
49 DEV_PM_QOS_LATENCY
= 1,
53 struct dev_pm_qos_request
{
54 enum dev_pm_qos_req_type type
;
56 struct plist_node pnode
;
57 struct pm_qos_flags_request flr
;
64 PM_QOS_MAX
, /* return the largest value */
65 PM_QOS_MIN
/* return the smallest value */
69 * Note: The lockless read path depends on the CPU accessing target_value
70 * or effective_flags atomically. Atomic access is only guaranteed on all CPU
71 * types linux supports for 32 bit quantites
73 struct pm_qos_constraints
{
74 struct plist_head list
;
75 s32 target_value
; /* Do not change to 64 bit */
77 enum pm_qos_type type
;
78 struct blocking_notifier_head
*notifiers
;
82 struct list_head list
;
83 s32 effective_flags
; /* Do not change to 64 bit */
87 struct pm_qos_constraints latency
;
88 struct pm_qos_flags flags
;
91 /* Action requested to pm_qos_update_target */
92 enum pm_qos_req_action
{
93 PM_QOS_ADD_REQ
, /* Add a new request */
94 PM_QOS_UPDATE_REQ
, /* Update an existing request */
95 PM_QOS_REMOVE_REQ
/* Remove an existing request */
98 static inline int dev_pm_qos_request_active(struct dev_pm_qos_request
*req
)
100 return req
->dev
!= NULL
;
103 int pm_qos_update_target(struct pm_qos_constraints
*c
, struct plist_node
*node
,
104 enum pm_qos_req_action action
, int value
);
105 bool pm_qos_update_flags(struct pm_qos_flags
*pqf
,
106 struct pm_qos_flags_request
*req
,
107 enum pm_qos_req_action action
, s32 val
);
108 void pm_qos_add_request(struct pm_qos_request
*req
, int pm_qos_class
,
110 void pm_qos_update_request(struct pm_qos_request
*req
,
112 void pm_qos_update_request_timeout(struct pm_qos_request
*req
,
113 s32 new_value
, unsigned long timeout_us
);
114 void pm_qos_remove_request(struct pm_qos_request
*req
);
116 int pm_qos_request(int pm_qos_class
);
117 int pm_qos_add_notifier(int pm_qos_class
, struct notifier_block
*notifier
);
118 int pm_qos_remove_notifier(int pm_qos_class
, struct notifier_block
*notifier
);
119 int pm_qos_request_active(struct pm_qos_request
*req
);
120 s32
pm_qos_read_value(struct pm_qos_constraints
*c
);
123 enum pm_qos_flags_status
__dev_pm_qos_flags(struct device
*dev
, s32 mask
);
124 enum pm_qos_flags_status
dev_pm_qos_flags(struct device
*dev
, s32 mask
);
125 s32
__dev_pm_qos_read_value(struct device
*dev
);
126 s32
dev_pm_qos_read_value(struct device
*dev
);
127 int dev_pm_qos_add_request(struct device
*dev
, struct dev_pm_qos_request
*req
,
128 enum dev_pm_qos_req_type type
, s32 value
);
129 int dev_pm_qos_update_request(struct dev_pm_qos_request
*req
, s32 new_value
);
130 int dev_pm_qos_remove_request(struct dev_pm_qos_request
*req
);
131 int dev_pm_qos_add_notifier(struct device
*dev
,
132 struct notifier_block
*notifier
);
133 int dev_pm_qos_remove_notifier(struct device
*dev
,
134 struct notifier_block
*notifier
);
135 int dev_pm_qos_add_global_notifier(struct notifier_block
*notifier
);
136 int dev_pm_qos_remove_global_notifier(struct notifier_block
*notifier
);
137 void dev_pm_qos_constraints_init(struct device
*dev
);
138 void dev_pm_qos_constraints_destroy(struct device
*dev
);
139 int dev_pm_qos_add_ancestor_request(struct device
*dev
,
140 struct dev_pm_qos_request
*req
, s32 value
);
142 static inline enum pm_qos_flags_status
__dev_pm_qos_flags(struct device
*dev
,
144 { return PM_QOS_FLAGS_UNDEFINED
; }
145 static inline enum pm_qos_flags_status
dev_pm_qos_flags(struct device
*dev
,
147 { return PM_QOS_FLAGS_UNDEFINED
; }
148 static inline s32
__dev_pm_qos_read_value(struct device
*dev
)
150 static inline s32
dev_pm_qos_read_value(struct device
*dev
)
152 static inline int dev_pm_qos_add_request(struct device
*dev
,
153 struct dev_pm_qos_request
*req
,
154 enum dev_pm_qos_req_type type
,
157 static inline int dev_pm_qos_update_request(struct dev_pm_qos_request
*req
,
160 static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request
*req
)
162 static inline int dev_pm_qos_add_notifier(struct device
*dev
,
163 struct notifier_block
*notifier
)
165 static inline int dev_pm_qos_remove_notifier(struct device
*dev
,
166 struct notifier_block
*notifier
)
168 static inline int dev_pm_qos_add_global_notifier(
169 struct notifier_block
*notifier
)
171 static inline int dev_pm_qos_remove_global_notifier(
172 struct notifier_block
*notifier
)
174 static inline void dev_pm_qos_constraints_init(struct device
*dev
)
176 dev
->power
.power_state
= PMSG_ON
;
178 static inline void dev_pm_qos_constraints_destroy(struct device
*dev
)
180 dev
->power
.power_state
= PMSG_INVALID
;
182 static inline int dev_pm_qos_add_ancestor_request(struct device
*dev
,
183 struct dev_pm_qos_request
*req
, s32 value
)
187 #ifdef CONFIG_PM_RUNTIME
188 int dev_pm_qos_expose_latency_limit(struct device
*dev
, s32 value
);
189 void dev_pm_qos_hide_latency_limit(struct device
*dev
);
191 static inline int dev_pm_qos_expose_latency_limit(struct device
*dev
, s32 value
)
193 static inline void dev_pm_qos_hide_latency_limit(struct device
*dev
) {}