Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit defc96f9 authored by Maulik Shah's avatar Maulik Shah Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarMaulik Shah <mkshah@codeaurora.org>
parent eca47d45
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -266,13 +266,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) {
@@ -295,6 +303,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;
}

/**
@@ -347,7 +357,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);

@@ -358,7 +368,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,