power: qos: Fix accessing pm_qos_request struct

Constraints added using dev_pm_qos_add_request are not member
of pm_qos_request struct.

Only those constraints that are added using pm_qos_add_request
are member of pm_qos_request struct and can be accessed as CPU DMA
latency constraints while updating the cpumask for which latency
has been updated.

Add a check if constraint is of CPU DMA latency class before
accessing.

Change-Id: I809b8fc46379311902cd3eea4e55f753e9002c69
Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
This commit is contained in:
Maulik Shah 2019-10-11 12:36:34 +05:30
parent 02645d3a5c
commit 562330a441

View File

@ -267,13 +267,21 @@ static const struct file_operations pm_qos_debug_fops = {
.release = single_release,
};
static inline void pm_qos_set_value_for_cpus(struct pm_qos_constraints *c,
static inline int pm_qos_set_value_for_cpus(struct pm_qos_constraints *c,
struct cpumask *cpus)
{
struct pm_qos_request *req = NULL;
int cpu;
s32 qos_val[NR_CPUS] = { [0 ... (NR_CPUS - 1)] = c->default_value };
/*
* pm_qos_constraints can be from different classes,
* Update cpumask only only for CPU_DMA_LATENCY classes
*/
if (c != pm_qos_array[PM_QOS_CPU_DMA_LATENCY]->constraints)
return -EINVAL;
plist_for_each_entry(req, &c->list, node) {
for_each_cpu(cpu, &req->cpus_affine) {
switch (c->type) {
@ -299,6 +307,8 @@ static inline void pm_qos_set_value_for_cpus(struct pm_qos_constraints *c,
cpumask_set_cpu(cpu, cpus);
c->target_per_cpu[cpu] = qos_val[cpu];
}
return 0;
}
/**
@ -350,7 +360,7 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
curr_value = pm_qos_get_value(c);
cpumask_clear(&cpus);
pm_qos_set_value(c, curr_value);
pm_qos_set_value_for_cpus(c, &cpus);
ret = pm_qos_set_value_for_cpus(c, &cpus);
spin_unlock_irqrestore(&pm_qos_lock, flags);
@ -361,7 +371,8 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
* to update the new qos restriction for the cores
*/
if (!cpumask_empty(&cpus)) {
if (!cpumask_empty(&cpus) ||
(ret && prev_value != curr_value)) {
ret = 1;
if (c->notifiers)
blocking_notifier_call_chain(c->notifiers,