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

Commit efff55e2 authored by Rama Aparna Mallavarapu's avatar Rama Aparna Mallavarapu
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>
parent 007833ae
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -1147,14 +1147,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;

	mutex_lock(&df->event_lock);
	if (!df->governor || df->dev_suspended) {
		dev_warn(dev, "device suspended, operation not allowed\n");
		mutex_unlock(&df->event_lock);
		return -EINVAL;
	}
	df->governor->event_handler(df, DEVFREQ_GOV_INTERVAL, &value);
	ret = count;
	mutex_unlock(&df->event_lock);
@@ -1176,6 +1178,11 @@ static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr,
		return -EINVAL;

	mutex_lock(&df->event_lock);
	if (df->dev_suspended) {
		dev_warn(dev, "device suspended, min freq not allowed\n");
		mutex_unlock(&df->event_lock);
		return -EINVAL;
	}
	mutex_lock(&df->lock);
	max = df->max_freq;
	if (value && max && value > max) {
@@ -1213,6 +1220,11 @@ static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
		return -EINVAL;

	mutex_lock(&df->event_lock);
	if (df->dev_suspended) {
		mutex_unlock(&df->event_lock);
		dev_warn(dev, "device suspended, max freq not allowed\n");
		return -EINVAL;
	}
	mutex_lock(&df->lock);
	min = df->min_freq;
	if (value && min && value < min) {