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,
18 PM_QOS_MIN_ONLINE_CPUS,
19 PM_QOS_MAX_ONLINE_CPUS,
23 /* insert new class ID */
28 #define PM_QOS_DEFAULT_VALUE -1
30 #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
31 #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
32 #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
33 #define PM_QOS_MIN_ONLINE_CPUS_DEFAULT_VALUE 0
34 #define PM_QOS_MAX_ONLINE_CPUS_DEFAULT_VALUE LONG_MAX
35 #define PM_QOS_CPU_FREQ_MIN_DEFAULT_VALUE 0
36 #define PM_QOS_CPU_FREQ_MAX_DEFAULT_VALUE LONG_MAX
37 #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0
39 struct pm_qos_request {
40 struct plist_node node;
42 struct delayed_work work; /* for pm_qos_update_request_timeout */
45 struct dev_pm_qos_request {
46 struct plist_node node;
52 PM_QOS_MAX, /* return the largest value */
53 PM_QOS_MIN /* return the smallest value */
57 * Note: The lockless read path depends on the CPU accessing
58 * target_value atomically. Atomic access is only guaranteed on all CPU
59 * types linux supports for 32 bit quantites
61 struct pm_qos_constraints {
62 struct plist_head list;
63 s32 target_value; /* Do not change to 64 bit */
65 enum pm_qos_type type;
66 struct blocking_notifier_head *notifiers;
69 /* Action requested to pm_qos_update_target */
70 enum pm_qos_req_action {
71 PM_QOS_ADD_REQ, /* Add a new request */
72 PM_QOS_UPDATE_REQ, /* Update an existing request */
73 PM_QOS_REMOVE_REQ /* Remove an existing request */
76 static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req)
81 int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
82 enum pm_qos_req_action action, int value);
83 void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
85 void pm_qos_update_request(struct pm_qos_request *req,
87 void pm_qos_update_request_timeout(struct pm_qos_request *req,
88 s32 new_value, unsigned long timeout_us);
89 void pm_qos_remove_request(struct pm_qos_request *req);
91 int pm_qos_request(int pm_qos_class);
92 int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
93 int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
94 int pm_qos_request_active(struct pm_qos_request *req);
95 s32 pm_qos_read_value(struct pm_qos_constraints *c);
98 s32 __dev_pm_qos_read_value(struct device *dev);
99 s32 dev_pm_qos_read_value(struct device *dev);
100 int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req,
102 int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value);
103 int dev_pm_qos_remove_request(struct dev_pm_qos_request *req);
104 int dev_pm_qos_add_notifier(struct device *dev,
105 struct notifier_block *notifier);
106 int dev_pm_qos_remove_notifier(struct device *dev,
107 struct notifier_block *notifier);
108 int dev_pm_qos_add_global_notifier(struct notifier_block *notifier);
109 int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier);
110 void dev_pm_qos_constraints_init(struct device *dev);
111 void dev_pm_qos_constraints_destroy(struct device *dev);
112 int dev_pm_qos_add_ancestor_request(struct device *dev,
113 struct dev_pm_qos_request *req, s32 value);
115 static inline s32 __dev_pm_qos_read_value(struct device *dev)
117 static inline s32 dev_pm_qos_read_value(struct device *dev)
119 static inline int dev_pm_qos_add_request(struct device *dev,
120 struct dev_pm_qos_request *req,
123 static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req,
126 static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req)
128 static inline int dev_pm_qos_add_notifier(struct device *dev,
129 struct notifier_block *notifier)
131 static inline int dev_pm_qos_remove_notifier(struct device *dev,
132 struct notifier_block *notifier)
134 static inline int dev_pm_qos_add_global_notifier(
135 struct notifier_block *notifier)
137 static inline int dev_pm_qos_remove_global_notifier(
138 struct notifier_block *notifier)
140 static inline void dev_pm_qos_constraints_init(struct device *dev)
142 dev->power.power_state = PMSG_ON;
144 static inline void dev_pm_qos_constraints_destroy(struct device *dev)
146 dev->power.power_state = PMSG_INVALID;
148 static inline int dev_pm_qos_add_ancestor_request(struct device *dev,
149 struct dev_pm_qos_request *req, s32 value)
153 #ifdef CONFIG_PM_RUNTIME
154 int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value);
155 void dev_pm_qos_hide_latency_limit(struct device *dev);
157 static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value)
159 static inline void dev_pm_qos_hide_latency_limit(struct device *dev) {}