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

Commit 4f9183cc authored by Rama Aparna Mallavarapu's avatar Rama Aparna Mallavarapu Committed by Saravana Kannan
Browse files

ANDROID: GKI: PM/devfreq: Do not switch governors from sysfs when device is suspended



There is a possibility to switch the governors from sysfs even when the
device is in suspended state. This can cause a NOC error at times when
trying to access the device's monitor registers in a suspended state. This
change fixes this issue. Introduce a variable dev_suspended to know if
the device is in suspended state or not. Check if the device is suspended
before switching the governor from sysfs.

Change-Id: I15055aa51daa35272be4667e5bafb8ccd7933098
Signed-off-by: default avatarRama Aparna Mallavarapu <aparnam@codeaurora.org>
Bug: 152343889
(cherry picked from commit 9c41437c)
Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
parent 902ad8fa
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -637,6 +637,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
	devfreq->last_status.current_frequency = profile->initial_freq;
	devfreq->data = data;
	devfreq->nb.notifier_call = devfreq_notifier_call;
	devfreq->dev_suspended = false;

	if (!devfreq->profile->max_state && !devfreq->profile->freq_table) {
		mutex_unlock(&devfreq->lock);
@@ -867,12 +868,16 @@ int devfreq_suspend_device(struct devfreq *devfreq)
	if (!devfreq)
		return -EINVAL;

	if (!devfreq->governor)
	mutex_lock(&devfreq->event_lock);
	if (!devfreq->governor || devfreq->dev_suspended) {
		mutex_unlock(&devfreq->event_lock);
		return 0;
	}

	mutex_lock(&devfreq->event_lock);
	ret = devfreq->governor->event_handler(devfreq,
				DEVFREQ_GOV_SUSPEND, NULL);
	if (!ret)
		devfreq->dev_suspended = true;
	mutex_unlock(&devfreq->event_lock);
	return ret;
}
@@ -892,12 +897,16 @@ int devfreq_resume_device(struct devfreq *devfreq)
	if (!devfreq)
		return -EINVAL;

	if (!devfreq->governor)
	mutex_lock(&devfreq->event_lock);
	if (!devfreq->governor) {
		mutex_unlock(&devfreq->event_lock);
		return 0;
	}

	mutex_lock(&devfreq->event_lock);
	ret = devfreq->governor->event_handler(devfreq,
				DEVFREQ_GOV_RESUME, NULL);
	if (!ret)
		devfreq->dev_suspended = false;
	mutex_unlock(&devfreq->event_lock);
	return ret;
}
@@ -1068,6 +1077,10 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
	}

	mutex_lock(&df->event_lock);
	if (df->dev_suspended) {
		ret = -EINVAL;
		goto gov_stop_out;
	}
	if (df->governor) {
		ret = df->governor->event_handler(df, DEVFREQ_GOV_STOP, NULL);
		if (ret) {
+1 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ struct devfreq {
	unsigned long last_stat_updated;

	struct srcu_notifier_head transition_notifier_list;
	bool dev_suspended;
};

struct devfreq_freqs {