Commit 4e1779ba authored by Jean Pihet's avatar Jean Pihet Committed by Rafael J. Wysocki

PM QoS: Reorganize data structs

In preparation for the per-device constratins support, re-organize
the data strctures:
 - add a struct pm_qos_constraints which contains the constraints
 related data
 - update struct pm_qos_object contents to the PM QoS internal object
 data. Add a pointer to struct pm_qos_constraints
 - update the internal code to use the new data structs.
Signed-off-by: default avatarJean Pihet <j-pihet@ti.com>
Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent 4a31a334
...@@ -25,6 +25,25 @@ struct pm_qos_request { ...@@ -25,6 +25,25 @@ struct pm_qos_request {
int pm_qos_class; int pm_qos_class;
}; };
enum pm_qos_type {
PM_QOS_UNITIALIZED,
PM_QOS_MAX, /* return the largest value */
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_constraints {
struct plist_head list;
s32 target_value; /* Do not change to 64 bit */
s32 default_value;
enum pm_qos_type type;
struct blocking_notifier_head *notifiers;
};
#ifdef CONFIG_PM #ifdef CONFIG_PM
void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class, void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
s32 value); s32 value);
......
...@@ -49,58 +49,53 @@ ...@@ -49,58 +49,53 @@
* or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock
* held, taken with _irqsave. One lock to rule them all * held, taken with _irqsave. One lock to rule them all
*/ */
enum pm_qos_type {
PM_QOS_MAX, /* return the largest value */
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 pm_qos_object {
struct plist_head constraints; struct pm_qos_constraints *constraints;
struct blocking_notifier_head *notifiers;
struct miscdevice pm_qos_power_miscdev; struct miscdevice pm_qos_power_miscdev;
char *name; char *name;
s32 target_value; /* Do not change to 64 bit */
s32 default_value;
enum pm_qos_type type;
}; };
static DEFINE_SPINLOCK(pm_qos_lock); static DEFINE_SPINLOCK(pm_qos_lock);
static struct pm_qos_object null_pm_qos; static struct pm_qos_object null_pm_qos;
static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier); static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier);
static struct pm_qos_object cpu_dma_pm_qos = { static struct pm_qos_constraints cpu_dma_constraints = {
.constraints = PLIST_HEAD_INIT(cpu_dma_pm_qos.constraints), .list = PLIST_HEAD_INIT(cpu_dma_constraints.list),
.notifiers = &cpu_dma_lat_notifier,
.name = "cpu_dma_latency",
.target_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE, .target_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE,
.default_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE, .default_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE,
.type = PM_QOS_MIN, .type = PM_QOS_MIN,
.notifiers = &cpu_dma_lat_notifier,
};
static struct pm_qos_object cpu_dma_pm_qos = {
.constraints = &cpu_dma_constraints,
}; };
static BLOCKING_NOTIFIER_HEAD(network_lat_notifier); static BLOCKING_NOTIFIER_HEAD(network_lat_notifier);
static struct pm_qos_object network_lat_pm_qos = { static struct pm_qos_constraints network_lat_constraints = {
.constraints = PLIST_HEAD_INIT(network_lat_pm_qos.constraints), .list = PLIST_HEAD_INIT(network_lat_constraints.list),
.notifiers = &network_lat_notifier,
.name = "network_latency",
.target_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE, .target_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE,
.default_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE, .default_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE,
.type = PM_QOS_MIN .type = PM_QOS_MIN,
.notifiers = &network_lat_notifier,
};
static struct pm_qos_object network_lat_pm_qos = {
.constraints = &network_lat_constraints,
.name = "network_latency",
}; };
static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier); static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier);
static struct pm_qos_object network_throughput_pm_qos = { static struct pm_qos_constraints network_tput_constraints = {
.constraints = PLIST_HEAD_INIT(network_throughput_pm_qos.constraints), .list = PLIST_HEAD_INIT(network_tput_constraints.list),
.notifiers = &network_throughput_notifier,
.name = "network_throughput",
.target_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE, .target_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE,
.default_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE, .default_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE,
.type = PM_QOS_MAX, .type = PM_QOS_MAX,
.notifiers = &network_throughput_notifier,
};
static struct pm_qos_object network_throughput_pm_qos = {
.constraints = &network_tput_constraints,
.name = "network_throughput",
}; };
...@@ -129,15 +124,15 @@ static const struct file_operations pm_qos_power_fops = { ...@@ -129,15 +124,15 @@ static const struct file_operations pm_qos_power_fops = {
/* unlocked internal variant */ /* unlocked internal variant */
static inline int pm_qos_get_value(struct pm_qos_object *o) static inline int pm_qos_get_value(struct pm_qos_object *o)
{ {
if (plist_head_empty(&o->constraints)) if (plist_head_empty(&o->constraints->list))
return o->default_value; return o->constraints->default_value;
switch (o->type) { switch (o->constraints->type) {
case PM_QOS_MIN: case PM_QOS_MIN:
return plist_first(&o->constraints)->prio; return plist_first(&o->constraints->list)->prio;
case PM_QOS_MAX: case PM_QOS_MAX:
return plist_last(&o->constraints)->prio; return plist_last(&o->constraints->list)->prio;
default: default:
/* runtime check for not using enum */ /* runtime check for not using enum */
...@@ -147,12 +142,12 @@ static inline int pm_qos_get_value(struct pm_qos_object *o) ...@@ -147,12 +142,12 @@ static inline int pm_qos_get_value(struct pm_qos_object *o)
static inline s32 pm_qos_read_value(struct pm_qos_object *o) static inline s32 pm_qos_read_value(struct pm_qos_object *o)
{ {
return o->target_value; return o->constraints->target_value;
} }
static inline void pm_qos_set_value(struct pm_qos_object *o, s32 value) static inline void pm_qos_set_value(struct pm_qos_object *o, s32 value)
{ {
o->target_value = value; o->constraints->target_value = value;
} }
static void update_target(struct pm_qos_object *o, struct plist_node *node, static void update_target(struct pm_qos_object *o, struct plist_node *node,
...@@ -170,20 +165,20 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node, ...@@ -170,20 +165,20 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,
* with new value and add, then see if the extremal * with new value and add, then see if the extremal
* changed * changed
*/ */
plist_del(node, &o->constraints); plist_del(node, &o->constraints->list);
plist_node_init(node, value); plist_node_init(node, value);
plist_add(node, &o->constraints); plist_add(node, &o->constraints->list);
} else if (del) { } else if (del) {
plist_del(node, &o->constraints); plist_del(node, &o->constraints->list);
} else { } else {
plist_add(node, &o->constraints); plist_add(node, &o->constraints->list);
} }
curr_value = pm_qos_get_value(o); curr_value = pm_qos_get_value(o);
pm_qos_set_value(o, curr_value); pm_qos_set_value(o, curr_value);
spin_unlock_irqrestore(&pm_qos_lock, flags); spin_unlock_irqrestore(&pm_qos_lock, flags);
if (prev_value != curr_value) if (prev_value != curr_value)
blocking_notifier_call_chain(o->notifiers, blocking_notifier_call_chain(o->constraints->notifiers,
(unsigned long)curr_value, (unsigned long)curr_value,
NULL); NULL);
} }
...@@ -230,7 +225,7 @@ void pm_qos_add_request(struct pm_qos_request *req, ...@@ -230,7 +225,7 @@ void pm_qos_add_request(struct pm_qos_request *req,
return; return;
} }
if (value == PM_QOS_DEFAULT_VALUE) if (value == PM_QOS_DEFAULT_VALUE)
new_value = o->default_value; new_value = o->constraints->default_value;
else else
new_value = value; new_value = value;
plist_node_init(&req->node, new_value); plist_node_init(&req->node, new_value);
...@@ -266,7 +261,7 @@ void pm_qos_update_request(struct pm_qos_request *req, ...@@ -266,7 +261,7 @@ void pm_qos_update_request(struct pm_qos_request *req,
o = pm_qos_array[req->pm_qos_class]; o = pm_qos_array[req->pm_qos_class];
if (new_value == PM_QOS_DEFAULT_VALUE) if (new_value == PM_QOS_DEFAULT_VALUE)
temp = o->default_value; temp = o->constraints->default_value;
else else
temp = new_value; temp = new_value;
...@@ -315,7 +310,8 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier) ...@@ -315,7 +310,8 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier)
int retval; int retval;
retval = blocking_notifier_chain_register( retval = blocking_notifier_chain_register(
pm_qos_array[pm_qos_class]->notifiers, notifier); pm_qos_array[pm_qos_class]->constraints->notifiers,
notifier);
return retval; return retval;
} }
...@@ -334,7 +330,8 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) ...@@ -334,7 +330,8 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier)
int retval; int retval;
retval = blocking_notifier_chain_unregister( retval = blocking_notifier_chain_unregister(
pm_qos_array[pm_qos_class]->notifiers, notifier); pm_qos_array[pm_qos_class]->constraints->notifiers,
notifier);
return retval; return retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment