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

Commit 5e33579a authored by Rama Aparna Mallavarapu's avatar Rama Aparna Mallavarapu Committed by Amir Vajid
Browse files

devfreq: Do not allow tunable updates when device is suspended



Tunables update accesses the monitor's registers for some devices.
When the device is suspended, the clocks for those devices are turned
off and updating the tunables of a suspended device causes the device
to crash. Fix this by checking the flag dev_suspended before allowing
the tunable updates.

Change-Id: I3a0938edf761a9ea6d39ffeec19f35c228d5c306
Signed-off-by: default avatarRama Aparna Mallavarapu <aparnam@codeaurora.org>
[avajid@codeaurora.org: updated to utilize suspend_count from upstream and resolved minor merge conflicts]
Signed-off-by: default avatarAmir Vajid <avajid@codeaurora.org>
parent db4f4a09
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -1274,14 +1274,16 @@ static ssize_t polling_interval_store(struct device *dev,
	unsigned int value;
	int ret;

	if (!df->governor)
		return -EINVAL;

	ret = sscanf(buf, "%u", &value);
	if (ret != 1)
		return -EINVAL;

	event_mutex_lock(df);
	if (!df->governor || atomic_read(&df->suspend_count) > 0) {
		dev_warn(dev, "device suspended, operation not allowed\n");
		event_mutex_unlock(df);
		return -EINVAL;
	}
	df->governor->event_handler(df, DEVFREQ_GOV_INTERVAL, &value);
	ret = count;
	event_mutex_unlock(df);
@@ -1302,6 +1304,11 @@ static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr,
		return -EINVAL;

	event_mutex_lock(df);
	if (atomic_read(&df->suspend_count) > 0) {
		dev_warn(dev, "device suspended, min freq not allowed\n");
		event_mutex_unlock(df);
		return -EINVAL;
	}
	mutex_lock(&df->lock);

	if (value) {
@@ -1348,6 +1355,11 @@ static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
		return -EINVAL;

	event_mutex_lock(df);
	if (atomic_read(&df->suspend_count) > 0) {
		event_mutex_unlock(df);
		dev_warn(dev, "device suspended, max freq not allowed\n");
		return -EINVAL;
	}
	mutex_lock(&df->lock);

	if (value) {