diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-10-07 17:17:07 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-10-07 17:17:07 -0400 |
commit | 9696cc90071e3660ec02a3728acdedb68afdce4c (patch) | |
tree | 99783d31dd42262c29346c92760f7896c3d81cb6 /include | |
parent | c28b56b1d46b1bbb1be33c8f2632a88b0de1ef68 (diff) | |
parent | e3cba3243eb853a052613c804dea033bc4c9cf2d (diff) |
Merge branch 'pm-qos' into pm-for-linus
* pm-qos:
PM / QoS: Update Documentation for the pm_qos and dev_pm_qos frameworks
PM / QoS: Add function dev_pm_qos_read_value() (v3)
PM QoS: Add global notification mechanism for device constraints
PM QoS: Implement per-device PM QoS constraints
PM QoS: Generalize and export constraints management code
PM QoS: Reorganize data structs
PM QoS: Code reorganization
PM QoS: Minor clean-ups
PM QoS: Move and rename the implementation files
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netdevice.h | 4 | ||||
-rw-r--r-- | include/linux/pm.h | 3 | ||||
-rw-r--r-- | include/linux/pm_qos.h | 155 | ||||
-rw-r--r-- | include/linux/pm_qos_params.h | 38 | ||||
-rw-r--r-- | include/sound/pcm.h | 4 |
5 files changed, 162 insertions, 42 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ddee79bb8f15..f38ab5b7e768 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/if_link.h> | 31 | #include <linux/if_link.h> |
32 | 32 | ||
33 | #ifdef __KERNEL__ | 33 | #ifdef __KERNEL__ |
34 | #include <linux/pm_qos_params.h> | 34 | #include <linux/pm_qos.h> |
35 | #include <linux/timer.h> | 35 | #include <linux/timer.h> |
36 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
37 | #include <linux/atomic.h> | 37 | #include <linux/atomic.h> |
@@ -964,7 +964,7 @@ struct net_device { | |||
964 | */ | 964 | */ |
965 | char name[IFNAMSIZ]; | 965 | char name[IFNAMSIZ]; |
966 | 966 | ||
967 | struct pm_qos_request_list pm_qos_req; | 967 | struct pm_qos_request pm_qos_req; |
968 | 968 | ||
969 | /* device name hash chain */ | 969 | /* device name hash chain */ |
970 | struct hlist_node name_hlist; | 970 | struct hlist_node name_hlist; |
diff --git a/include/linux/pm.h b/include/linux/pm.h index f497ed06ee15..91f248bbe4fe 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
@@ -326,6 +326,7 @@ extern struct dev_pm_ops generic_subsys_pm_ops; | |||
326 | * requested by a driver. | 326 | * requested by a driver. |
327 | */ | 327 | */ |
328 | 328 | ||
329 | #define PM_EVENT_INVALID (-1) | ||
329 | #define PM_EVENT_ON 0x0000 | 330 | #define PM_EVENT_ON 0x0000 |
330 | #define PM_EVENT_FREEZE 0x0001 | 331 | #define PM_EVENT_FREEZE 0x0001 |
331 | #define PM_EVENT_SUSPEND 0x0002 | 332 | #define PM_EVENT_SUSPEND 0x0002 |
@@ -346,6 +347,7 @@ extern struct dev_pm_ops generic_subsys_pm_ops; | |||
346 | #define PM_EVENT_AUTO_SUSPEND (PM_EVENT_AUTO | PM_EVENT_SUSPEND) | 347 | #define PM_EVENT_AUTO_SUSPEND (PM_EVENT_AUTO | PM_EVENT_SUSPEND) |
347 | #define PM_EVENT_AUTO_RESUME (PM_EVENT_AUTO | PM_EVENT_RESUME) | 348 | #define PM_EVENT_AUTO_RESUME (PM_EVENT_AUTO | PM_EVENT_RESUME) |
348 | 349 | ||
350 | #define PMSG_INVALID ((struct pm_message){ .event = PM_EVENT_INVALID, }) | ||
349 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) | 351 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) |
350 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) | 352 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) |
351 | #define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, }) | 353 | #define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, }) |
@@ -481,6 +483,7 @@ struct dev_pm_info { | |||
481 | unsigned long accounting_timestamp; | 483 | unsigned long accounting_timestamp; |
482 | #endif | 484 | #endif |
483 | struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ | 485 | struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ |
486 | struct pm_qos_constraints *constraints; | ||
484 | }; | 487 | }; |
485 | 488 | ||
486 | extern void update_pm_runtime_accounting(struct device *dev); | 489 | extern void update_pm_runtime_accounting(struct device *dev); |
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h new file mode 100644 index 000000000000..83b0ea302a80 --- /dev/null +++ b/include/linux/pm_qos.h | |||
@@ -0,0 +1,155 @@ | |||
1 | #ifndef _LINUX_PM_QOS_H | ||
2 | #define _LINUX_PM_QOS_H | ||
3 | /* interface for the pm_qos_power infrastructure of the linux kernel. | ||
4 | * | ||
5 | * Mark Gross <mgross@linux.intel.com> | ||
6 | */ | ||
7 | #include <linux/plist.h> | ||
8 | #include <linux/notifier.h> | ||
9 | #include <linux/miscdevice.h> | ||
10 | #include <linux/device.h> | ||
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 | |||
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 | ||
23 | #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 | ||
24 | |||
25 | struct pm_qos_request { | ||
26 | struct plist_node node; | ||
27 | int pm_qos_class; | ||
28 | }; | ||
29 | |||
30 | struct dev_pm_qos_request { | ||
31 | struct plist_node node; | ||
32 | struct device *dev; | ||
33 | }; | ||
34 | |||
35 | enum 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 | */ | ||
46 | struct 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 | |||
54 | /* Action requested to pm_qos_update_target */ | ||
55 | enum 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 | |||
61 | static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req) | ||
62 | { | ||
63 | return req->dev != 0; | ||
64 | } | ||
65 | |||
66 | #ifdef CONFIG_PM | ||
67 | int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node, | ||
68 | enum pm_qos_req_action action, int value); | ||
69 | void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class, | ||
70 | s32 value); | ||
71 | void pm_qos_update_request(struct pm_qos_request *req, | ||
72 | s32 new_value); | ||
73 | void pm_qos_remove_request(struct pm_qos_request *req); | ||
74 | |||
75 | int pm_qos_request(int pm_qos_class); | ||
76 | int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier); | ||
77 | int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier); | ||
78 | int pm_qos_request_active(struct pm_qos_request *req); | ||
79 | s32 pm_qos_read_value(struct pm_qos_constraints *c); | ||
80 | |||
81 | s32 dev_pm_qos_read_value(struct device *dev); | ||
82 | int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, | ||
83 | s32 value); | ||
84 | int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value); | ||
85 | int dev_pm_qos_remove_request(struct dev_pm_qos_request *req); | ||
86 | int dev_pm_qos_add_notifier(struct device *dev, | ||
87 | struct notifier_block *notifier); | ||
88 | int dev_pm_qos_remove_notifier(struct device *dev, | ||
89 | struct notifier_block *notifier); | ||
90 | int dev_pm_qos_add_global_notifier(struct notifier_block *notifier); | ||
91 | int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier); | ||
92 | void dev_pm_qos_constraints_init(struct device *dev); | ||
93 | void dev_pm_qos_constraints_destroy(struct device *dev); | ||
94 | #else | ||
95 | static inline int pm_qos_update_target(struct pm_qos_constraints *c, | ||
96 | struct plist_node *node, | ||
97 | enum pm_qos_req_action action, | ||
98 | int value) | ||
99 | { return 0; } | ||
100 | static inline void pm_qos_add_request(struct pm_qos_request *req, | ||
101 | int pm_qos_class, s32 value) | ||
102 | { return; } | ||
103 | static inline void pm_qos_update_request(struct pm_qos_request *req, | ||
104 | s32 new_value) | ||
105 | { return; } | ||
106 | static inline void pm_qos_remove_request(struct pm_qos_request *req) | ||
107 | { return; } | ||
108 | |||
109 | static inline int pm_qos_request(int pm_qos_class) | ||
110 | { return 0; } | ||
111 | static inline int pm_qos_add_notifier(int pm_qos_class, | ||
112 | struct notifier_block *notifier) | ||
113 | { return 0; } | ||
114 | static inline int pm_qos_remove_notifier(int pm_qos_class, | ||
115 | struct notifier_block *notifier) | ||
116 | { return 0; } | ||
117 | static inline int pm_qos_request_active(struct pm_qos_request *req) | ||
118 | { return 0; } | ||
119 | static inline s32 pm_qos_read_value(struct pm_qos_constraints *c) | ||
120 | { return 0; } | ||
121 | |||
122 | static inline s32 dev_pm_qos_read_value(struct device *dev) | ||
123 | { return 0; } | ||
124 | static inline int dev_pm_qos_add_request(struct device *dev, | ||
125 | struct dev_pm_qos_request *req, | ||
126 | s32 value) | ||
127 | { return 0; } | ||
128 | static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req, | ||
129 | s32 new_value) | ||
130 | { return 0; } | ||
131 | static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req) | ||
132 | { return 0; } | ||
133 | static inline int dev_pm_qos_add_notifier(struct device *dev, | ||
134 | struct notifier_block *notifier) | ||
135 | { return 0; } | ||
136 | static inline int dev_pm_qos_remove_notifier(struct device *dev, | ||
137 | struct notifier_block *notifier) | ||
138 | { return 0; } | ||
139 | static inline int dev_pm_qos_add_global_notifier( | ||
140 | struct notifier_block *notifier) | ||
141 | { return 0; } | ||
142 | static inline int dev_pm_qos_remove_global_notifier( | ||
143 | struct notifier_block *notifier) | ||
144 | { return 0; } | ||
145 | static inline void dev_pm_qos_constraints_init(struct device *dev) | ||
146 | { | ||
147 | dev->power.power_state = PMSG_ON; | ||
148 | } | ||
149 | static inline void dev_pm_qos_constraints_destroy(struct device *dev) | ||
150 | { | ||
151 | dev->power.power_state = PMSG_INVALID; | ||
152 | } | ||
153 | #endif | ||
154 | |||
155 | #endif | ||
diff --git a/include/linux/pm_qos_params.h b/include/linux/pm_qos_params.h deleted file mode 100644 index a7d87f911cab..000000000000 --- a/include/linux/pm_qos_params.h +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | #ifndef _LINUX_PM_QOS_PARAMS_H | ||
2 | #define _LINUX_PM_QOS_PARAMS_H | ||
3 | /* interface for the pm_qos_power infrastructure of the linux kernel. | ||
4 | * | ||
5 | * Mark Gross <mgross@linux.intel.com> | ||
6 | */ | ||
7 | #include <linux/plist.h> | ||
8 | #include <linux/notifier.h> | ||
9 | #include <linux/miscdevice.h> | ||
10 | |||
11 | #define PM_QOS_RESERVED 0 | ||
12 | #define PM_QOS_CPU_DMA_LATENCY 1 | ||
13 | #define PM_QOS_NETWORK_LATENCY 2 | ||
14 | #define PM_QOS_NETWORK_THROUGHPUT 3 | ||
15 | |||
16 | #define PM_QOS_NUM_CLASSES 4 | ||
17 | #define PM_QOS_DEFAULT_VALUE -1 | ||
18 | |||
19 | #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | ||
20 | #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | ||
21 | #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 | ||
22 | |||
23 | struct pm_qos_request_list { | ||
24 | struct plist_node list; | ||
25 | int pm_qos_class; | ||
26 | }; | ||
27 | |||
28 | void pm_qos_add_request(struct pm_qos_request_list *l, int pm_qos_class, s32 value); | ||
29 | void pm_qos_update_request(struct pm_qos_request_list *pm_qos_req, | ||
30 | s32 new_value); | ||
31 | void pm_qos_remove_request(struct pm_qos_request_list *pm_qos_req); | ||
32 | |||
33 | int pm_qos_request(int pm_qos_class); | ||
34 | int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier); | ||
35 | int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier); | ||
36 | int pm_qos_request_active(struct pm_qos_request_list *req); | ||
37 | |||
38 | #endif | ||
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 57e71fa33f7c..54cb079b7bf1 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/poll.h> | 29 | #include <linux/poll.h> |
30 | #include <linux/mm.h> | 30 | #include <linux/mm.h> |
31 | #include <linux/bitops.h> | 31 | #include <linux/bitops.h> |
32 | #include <linux/pm_qos_params.h> | 32 | #include <linux/pm_qos.h> |
33 | 33 | ||
34 | #define snd_pcm_substream_chip(substream) ((substream)->private_data) | 34 | #define snd_pcm_substream_chip(substream) ((substream)->private_data) |
35 | #define snd_pcm_chip(pcm) ((pcm)->private_data) | 35 | #define snd_pcm_chip(pcm) ((pcm)->private_data) |
@@ -373,7 +373,7 @@ struct snd_pcm_substream { | |||
373 | int number; | 373 | int number; |
374 | char name[32]; /* substream name */ | 374 | char name[32]; /* substream name */ |
375 | int stream; /* stream (direction) */ | 375 | int stream; /* stream (direction) */ |
376 | struct pm_qos_request_list latency_pm_qos_req; /* pm_qos request */ | 376 | struct pm_qos_request latency_pm_qos_req; /* pm_qos request */ |
377 | size_t buffer_bytes_max; /* limit ring buffer size */ | 377 | size_t buffer_bytes_max; /* limit ring buffer size */ |
378 | struct snd_dma_buffer dma_buffer; | 378 | struct snd_dma_buffer dma_buffer; |
379 | unsigned int dma_buf_id; | 379 | unsigned int dma_buf_id; |