aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-10-22 19:07:46 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-10-22 19:07:46 -0400
commit5efbe4279f959a3f5ed26adf5f05cb78dd1ffa7e (patch)
treeebc9bc44e7ac33b11c187850291114f30c39455a
parent5f986c590fcf4284924fcda991cf14ab32bff49f (diff)
PM / QoS: Introduce request and constraint data types for PM QoS flags
Introduce struct pm_qos_flags_request and struct pm_qos_flags representing PM QoS flags request type and PM QoS flags constraint type, respectively. With these definitions the data structures will be arranged so that the list member of a struct pm_qos_flags object will contain the head of a list of struct pm_qos_flags_request objects representing all of the "flags" requests present for the given device. Then, the effective_flags member of a struct pm_qos_flags object will contain the bitwise OR of the flags members of all the struct pm_qos_flags_request objects in the list. Additionally, introduce helper function pm_qos_update_flags() allowing the caller to manage the list of struct pm_qos_flags_request pointed to by the list member of struct pm_qos_flags. The flags are of type s32 so that the request's "value" field is always of the same type regardless of what kind of request it is (latency requests already have value fields of type s32). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Jean Pihet <j-pihet@ti.com> Acked-by: mark gross <markgross@thegnar.org>
-rw-r--r--include/linux/pm_qos.h17
-rw-r--r--kernel/power/qos.c63
2 files changed, 78 insertions, 2 deletions
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index 30e9ad72e797..413ada3c7c97 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -33,6 +33,11 @@ struct pm_qos_request {
33 struct delayed_work work; /* for pm_qos_update_request_timeout */ 33 struct delayed_work work; /* for pm_qos_update_request_timeout */
34}; 34};
35 35
36struct pm_qos_flags_request {
37 struct list_head node;
38 s32 flags; /* Do not change to 64 bit */
39};
40
36struct dev_pm_qos_request { 41struct dev_pm_qos_request {
37 struct plist_node node; 42 struct plist_node node;
38 struct device *dev; 43 struct device *dev;
@@ -45,8 +50,8 @@ enum pm_qos_type {
45}; 50};
46 51
47/* 52/*
48 * Note: The lockless read path depends on the CPU accessing 53 * Note: The lockless read path depends on the CPU accessing target_value
49 * target_value atomically. Atomic access is only guaranteed on all CPU 54 * or effective_flags atomically. Atomic access is only guaranteed on all CPU
50 * types linux supports for 32 bit quantites 55 * types linux supports for 32 bit quantites
51 */ 56 */
52struct pm_qos_constraints { 57struct pm_qos_constraints {
@@ -57,6 +62,11 @@ struct pm_qos_constraints {
57 struct blocking_notifier_head *notifiers; 62 struct blocking_notifier_head *notifiers;
58}; 63};
59 64
65struct pm_qos_flags {
66 struct list_head list;
67 s32 effective_flags; /* Do not change to 64 bit */
68};
69
60struct dev_pm_qos { 70struct dev_pm_qos {
61 struct pm_qos_constraints latency; 71 struct pm_qos_constraints latency;
62}; 72};
@@ -75,6 +85,9 @@ static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req)
75 85
76int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node, 86int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
77 enum pm_qos_req_action action, int value); 87 enum pm_qos_req_action action, int value);
88bool pm_qos_update_flags(struct pm_qos_flags *pqf,
89 struct pm_qos_flags_request *req,
90 enum pm_qos_req_action action, s32 val);
78void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class, 91void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
79 s32 value); 92 s32 value);
80void pm_qos_update_request(struct pm_qos_request *req, 93void pm_qos_update_request(struct pm_qos_request *req,
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 846bd42c7ed1..2ab2819aee65 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -213,6 +213,69 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
213} 213}
214 214
215/** 215/**
216 * pm_qos_flags_remove_req - Remove device PM QoS flags request.
217 * @pqf: Device PM QoS flags set to remove the request from.
218 * @req: Request to remove from the set.
219 */
220static void pm_qos_flags_remove_req(struct pm_qos_flags *pqf,
221 struct pm_qos_flags_request *req)
222{
223 s32 val = 0;
224
225 list_del(&req->node);
226 list_for_each_entry(req, &pqf->list, node)
227 val |= req->flags;
228
229 pqf->effective_flags = val;
230}
231
232/**
233 * pm_qos_update_flags - Update a set of PM QoS flags.
234 * @pqf: Set of flags to update.
235 * @req: Request to add to the set, to modify, or to remove from the set.
236 * @action: Action to take on the set.
237 * @val: Value of the request to add or modify.
238 *
239 * Update the given set of PM QoS flags and call notifiers if the aggregate
240 * value has changed. Returns 1 if the aggregate constraint value has changed,
241 * 0 otherwise.
242 */
243bool pm_qos_update_flags(struct pm_qos_flags *pqf,
244 struct pm_qos_flags_request *req,
245 enum pm_qos_req_action action, s32 val)
246{
247 unsigned long irqflags;
248 s32 prev_value, curr_value;
249
250 spin_lock_irqsave(&pm_qos_lock, irqflags);
251
252 prev_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags;
253
254 switch (action) {
255 case PM_QOS_REMOVE_REQ:
256 pm_qos_flags_remove_req(pqf, req);
257 break;
258 case PM_QOS_UPDATE_REQ:
259 pm_qos_flags_remove_req(pqf, req);
260 case PM_QOS_ADD_REQ:
261 req->flags = val;
262 INIT_LIST_HEAD(&req->node);
263 list_add_tail(&req->node, &pqf->list);
264 pqf->effective_flags |= val;
265 break;
266 default:
267 /* no action */
268 ;
269 }
270
271 curr_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags;
272
273 spin_unlock_irqrestore(&pm_qos_lock, irqflags);
274
275 return prev_value != curr_value;
276}
277
278/**
216 * pm_qos_request - returns current system wide qos expectation 279 * pm_qos_request - returns current system wide qos expectation
217 * @pm_qos_class: identification of which qos value is requested 280 * @pm_qos_class: identification of which qos value is requested
218 * 281 *