Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252751
b: refs/heads/master
c: 333c5ae
h: refs/heads/master
i:
  252749: f4525b7
  252747: 3d2746f
  252743: ee83f28
  252735: c729702
v: v3
  • Loading branch information
Tim Chen authored and Len Brown committed May 29, 2011
1 parent 4ebf73e commit a4c68ac
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7467571f4480b273007517b26297c07154c73924
refs/heads/master: 333c5ae9948194428fe6c5ef5c088304fc98263b
4 changes: 4 additions & 0 deletions trunk/include/linux/pm_qos_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#define PM_QOS_NUM_CLASSES 4
#define PM_QOS_DEFAULT_VALUE -1

#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0

struct pm_qos_request_list {
struct plist_node list;
int pm_qos_class;
Expand Down
37 changes: 25 additions & 12 deletions trunk/kernel/pm_qos_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ enum pm_qos_type {
PM_QOS_MIN /* return the smallest value */
};

/*
* Note: The lockless read path depends on the CPU accessing
* target_value atomically. Atomic access is only guaranteed on all CPU
* types linux supports for 32 bit quantites
*/
struct pm_qos_object {
struct plist_head requests;
struct blocking_notifier_head *notifiers;
struct miscdevice pm_qos_power_miscdev;
char *name;
s32 target_value; /* Do not change to 64 bit */
s32 default_value;
enum pm_qos_type type;
};
Expand All @@ -70,7 +76,8 @@ static struct pm_qos_object cpu_dma_pm_qos = {
.requests = PLIST_HEAD_INIT(cpu_dma_pm_qos.requests, pm_qos_lock),
.notifiers = &cpu_dma_lat_notifier,
.name = "cpu_dma_latency",
.default_value = 2000 * USEC_PER_SEC,
.target_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE,
.default_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE,
.type = PM_QOS_MIN,
};

Expand All @@ -79,7 +86,8 @@ static struct pm_qos_object network_lat_pm_qos = {
.requests = PLIST_HEAD_INIT(network_lat_pm_qos.requests, pm_qos_lock),
.notifiers = &network_lat_notifier,
.name = "network_latency",
.default_value = 2000 * USEC_PER_SEC,
.target_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE,
.default_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE,
.type = PM_QOS_MIN
};

Expand All @@ -89,7 +97,8 @@ static struct pm_qos_object network_throughput_pm_qos = {
.requests = PLIST_HEAD_INIT(network_throughput_pm_qos.requests, pm_qos_lock),
.notifiers = &network_throughput_notifier,
.name = "network_throughput",
.default_value = 0,
.target_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE,
.default_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE,
.type = PM_QOS_MAX,
};

Expand Down Expand Up @@ -132,6 +141,16 @@ static inline int pm_qos_get_value(struct pm_qos_object *o)
}
}

static inline s32 pm_qos_read_value(struct pm_qos_object *o)
{
return o->target_value;
}

static inline void pm_qos_set_value(struct pm_qos_object *o, s32 value)
{
o->target_value = value;
}

static void update_target(struct pm_qos_object *o, struct plist_node *node,
int del, int value)
{
Expand All @@ -156,6 +175,7 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,
plist_add(node, &o->requests);
}
curr_value = pm_qos_get_value(o);
pm_qos_set_value(o, curr_value);
spin_unlock_irqrestore(&pm_qos_lock, flags);

if (prev_value != curr_value)
Expand Down Expand Up @@ -190,18 +210,11 @@ static int find_pm_qos_object_by_minor(int minor)
* pm_qos_request - returns current system wide qos expectation
* @pm_qos_class: identification of which qos value is requested
*
* This function returns the current target value in an atomic manner.
* This function returns the current target value.
*/
int pm_qos_request(int pm_qos_class)
{
unsigned long flags;
int value;

spin_lock_irqsave(&pm_qos_lock, flags);
value = pm_qos_get_value(pm_qos_array[pm_qos_class]);
spin_unlock_irqrestore(&pm_qos_lock, flags);

return value;
return pm_qos_read_value(pm_qos_array[pm_qos_class]);
}
EXPORT_SYMBOL_GPL(pm_qos_request);

Expand Down

0 comments on commit a4c68ac

Please sign in to comment.