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>
14 PM_QOS_CPU_DMA_LATENCY,
15 PM_QOS_NETWORK_LATENCY,
16 PM_QOS_NETWORK_THROUGHPUT,
17 PM_QOS_MIN_ONLINE_CPUS,
18 PM_QOS_MAX_ONLINE_CPUS,
22 /* insert new class ID */
27 #define PM_QOS_DEFAULT_VALUE -1
29 #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
30 #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
31 #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
32 #define PM_QOS_MIN_ONLINE_CPUS_DEFAULT_VALUE 0
33 #define PM_QOS_MAX_ONLINE_CPUS_DEFAULT_VALUE LONG_MAX
34 #define PM_QOS_CPU_FREQ_MIN_DEFAULT_VALUE 0
35 #define PM_QOS_CPU_FREQ_MAX_DEFAULT_VALUE LONG_MAX
36 #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0
38 struct pm_qos_request {
39 struct plist_node node;
43 struct dev_pm_qos_request {
44 struct plist_node node;
50 PM_QOS_MAX, /* return the largest value */
51 PM_QOS_MIN /* return the smallest value */
55 * Note: The lockless read path depends on the CPU accessing
56 * target_value atomically. Atomic access is only guaranteed on all CPU
57 * types linux supports for 32 bit quantites
59 struct pm_qos_constraints {
60 struct plist_head list;
61 s32 target_value; /* Do not change to 64 bit */
63 enum pm_qos_type type;
64 struct blocking_notifier_head *notifiers;
67 /* Action requested to pm_qos_update_target */
68 enum pm_qos_req_action {
69 PM_QOS_ADD_REQ, /* Add a new request */
70 PM_QOS_UPDATE_REQ, /* Update an existing request */
71 PM_QOS_REMOVE_REQ /* Remove an existing request */
74 static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req)
79 int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
80 enum pm_qos_req_action action, int value);
81 void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
83 void pm_qos_update_request(struct pm_qos_request *req,
85 void pm_qos_remove_request(struct pm_qos_request *req);
87 int pm_qos_request(int pm_qos_class);
88 int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
89 int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
90 int pm_qos_request_active(struct pm_qos_request *req);
91 s32 pm_qos_read_value(struct pm_qos_constraints *c);
94 s32 __dev_pm_qos_read_value(struct device *dev);
95 s32 dev_pm_qos_read_value(struct device *dev);
96 int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req,
98 int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value);
99 int dev_pm_qos_remove_request(struct dev_pm_qos_request *req);
100 int dev_pm_qos_add_notifier(struct device *dev,
101 struct notifier_block *notifier);
102 int dev_pm_qos_remove_notifier(struct device *dev,
103 struct notifier_block *notifier);
104 int dev_pm_qos_add_global_notifier(struct notifier_block *notifier);
105 int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier);
106 void dev_pm_qos_constraints_init(struct device *dev);
107 void dev_pm_qos_constraints_destroy(struct device *dev);
108 int dev_pm_qos_add_ancestor_request(struct device *dev,
109 struct dev_pm_qos_request *req, s32 value);
111 static inline s32 __dev_pm_qos_read_value(struct device *dev)
113 static inline s32 dev_pm_qos_read_value(struct device *dev)
115 static inline int dev_pm_qos_add_request(struct device *dev,
116 struct dev_pm_qos_request *req,
119 static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req,
122 static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req)
124 static inline int dev_pm_qos_add_notifier(struct device *dev,
125 struct notifier_block *notifier)
127 static inline int dev_pm_qos_remove_notifier(struct device *dev,
128 struct notifier_block *notifier)
130 static inline int dev_pm_qos_add_global_notifier(
131 struct notifier_block *notifier)
133 static inline int dev_pm_qos_remove_global_notifier(
134 struct notifier_block *notifier)
136 static inline void dev_pm_qos_constraints_init(struct device *dev)
138 dev->power.power_state = PMSG_ON;
140 static inline void dev_pm_qos_constraints_destroy(struct device *dev)
142 dev->power.power_state = PMSG_INVALID;
144 static inline int dev_pm_qos_add_ancestor_request(struct device *dev,
145 struct dev_pm_qos_request *req, s32 value)
149 #ifdef CONFIG_PM_RUNTIME
150 int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value);
151 void dev_pm_qos_hide_latency_limit(struct device *dev);
153 static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value)
155 static inline void dev_pm_qos_hide_latency_limit(struct device *dev) {}