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

Commit d1885ab5 authored by Rama Aparna Mallavarapu's avatar Rama Aparna Mallavarapu
Browse files

devfreq: update mon status when updating the polling interval



When handling the polling interval update, ensure to set the
mon_started to false since the hwmon would be suspended anyway. This
would prevent unclocked access of BWMON when update_devfreq races
with the polling interval update. Also set the mon_started to true
as soon as the interval update and hwmon resume are completed.
This patch fixes the following race condition that could happen.
devfreq_bw_hwmon_ev_handler {		update_devfreq {
    ....			    	   get_target_freq
    ....				   devfreq_bw_hwmon_get_freq {
    hw->suspend_hwmon(hw);			....
    devfreq_interval_update(df, &sample_ms);	__bw_hwmon_hw_sample_end {
    ret = hw->resume_hwmon(hw);			hwmon->get_bytes_and_clear
    ....					....

Change-Id: I4cdab066ff184891aaeb22cb8b3af31213015ff1
Signed-off-by: default avatarRama Aparna Mallavarapu <aparnam@codeaurora.org>
parent 30d171ac
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -832,6 +832,11 @@ static int devfreq_bw_hwmon_ev_handler(struct devfreq *df,
		 */
		node = df->data;
		hw = node->hw;

		mutex_lock(&node->mon_lock);
		node->mon_started = false;
		mutex_unlock(&node->mon_lock);

		hw->suspend_hwmon(hw);
		devfreq_interval_update(df, &sample_ms);
		ret = hw->resume_hwmon(hw);
@@ -840,6 +845,9 @@ static int devfreq_bw_hwmon_ev_handler(struct devfreq *df,
				"Unable to resume HW monitor (%d)\n", ret);
			goto out;
		}
		mutex_lock(&node->mon_lock);
		node->mon_started = true;
		mutex_unlock(&node->mon_lock);
		break;

	case DEVFREQ_GOV_SUSPEND: