From b4d6ca0fd62bb351ea196a643a495f6ea9b8ed63 Mon Sep 17 00:00:00 2001 From: Maulik Shah Date: Fri, 11 Oct 2019 12:36:34 +0530 Subject: [PATCH] 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 --- kernel/power/qos.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/kernel/power/qos.c b/kernel/power/qos.c index d6a0b0ffffb1..5009fc932c0f 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -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) { @@ -300,6 +308,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; } /** @@ -353,7 +363,7 @@ int pm_qos_update_target(struct pm_qos_constraints *c, 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); @@ -364,7 +374,8 @@ int pm_qos_update_target(struct pm_qos_constraints *c, * 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,