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

Commit de52f151 authored by Benet Clark's avatar Benet Clark
Browse files

msm: mdss: Add missing locks in histogram collection for collect enable



The histogram state and collect enable need a spinlock around them when
being read or written to. There were a couple places where the spinlock
wasn't held when the variables were being checked. The number of spinlock
accesses has been reduced in collect as well.

Change-Id: Ic0369667b5b2bf83a19098f876f3ab48f9dcfbda
Signed-off-by: default avatarBenet Clark <benetc@codeaurora.org>
parent 2b979b24
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -3437,12 +3437,13 @@ static int pp_hist_collect(struct mdp_histogram_data *hist,
		return -EPERM;

	mutex_lock(&hist_info->hist_mutex);
	spin_lock_irqsave(&hist_info->hist_lock, flag);
	if ((hist_info->col_en == 0) ||
			(hist_info->col_state == HIST_UNKNOWN)) {
		ret = -EINVAL;
		spin_unlock_irqrestore(&hist_info->hist_lock, flag);
		goto hist_collect_exit;
	}
	spin_lock_irqsave(&hist_info->hist_lock, flag);
	/* wait for hist done if cache has no data */
	if (hist_info->col_state != HIST_READY) {
		spin_unlock_irqrestore(&hist_info->hist_lock, flag);
@@ -3458,9 +3459,9 @@ static int pp_hist_collect(struct mdp_histogram_data *hist,
				&(hist_info->comp), timeout);

		mutex_lock(&hist_info->hist_mutex);
		spin_lock_irqsave(&hist_info->hist_lock, flag);
		if (wait_ret == 0) {
			ret = -ETIMEDOUT;
			spin_lock_irqsave(&hist_info->hist_lock, flag);
			pr_debug("bin collection timedout, state %d",
					hist_info->col_state);
			/*
@@ -3475,26 +3476,22 @@ static int pp_hist_collect(struct mdp_histogram_data *hist,
			 */
			hist_info->hist_cnt_time++;
			hist_info->col_state = HIST_READY;
			spin_unlock_irqrestore(&hist_info->hist_lock, flag);
		} else if (wait_ret < 0) {
			ret = -EINTR;
			pr_debug("%s: bin collection interrupted",
					__func__);
			spin_unlock_irqrestore(&hist_info->hist_lock, flag);
			goto hist_collect_exit;
		}
		if (hist_info->col_state != HIST_READY) {
			ret = -ENODATA;
			spin_lock_irqsave(&hist_info->hist_lock, flag);
			hist_info->col_state = HIST_READY;
			spin_unlock_irqrestore(&hist_info->hist_lock, flag);
			pr_debug("%s: state is not ready: %d",
					__func__, hist_info->col_state);
		}
	} else {
		spin_unlock_irqrestore(&hist_info->hist_lock, flag);
	}
	spin_lock_irqsave(&hist_info->hist_lock, flag);
	if (hist_info->col_state == HIST_READY) {
		hist_info->col_state = HIST_IDLE;
		spin_unlock_irqrestore(&hist_info->hist_lock, flag);
		v_base = ctl_base + 0x1C;
		mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON, false);
@@ -3503,12 +3500,11 @@ static int pp_hist_collect(struct mdp_histogram_data *hist,
		if (is_hist_v2)
			writel_relaxed(0, ctl_base);
		mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF, false);
		spin_lock_irqsave(&hist_info->hist_lock, flag);
		if (expect_sum && sum != expect_sum)
			ret = -ENODATA;
		hist_info->col_state = HIST_IDLE;
	}
	} else {
		spin_unlock_irqrestore(&hist_info->hist_lock, flag);
	}
hist_collect_exit:
	mutex_unlock(&hist_info->hist_mutex);
	return ret;