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

Commit 48e5c602 authored by Deepak Kumar's avatar Deepak Kumar
Browse files

msm: kgsl: Put OPP reference count



dev_pm_opp_find_freq_* and devfreq_recommended_opp APIs
takes a reference count of the returned OPP. Put this
reference count after using OPP. Also, drop RCU read
locks as it is guaranteed that OPP wouldn't get freed
because of the reference count.

Change-Id: I2da8d5a63a7071e8670fa3152003e570ceeba76d
Signed-off-by: default avatarDeepak Kumar <dkumar@codeaurora.org>
parent 0ba27bd6
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1399,8 +1399,10 @@ static uint32_t _write_voltage_table(struct adreno_device *adreno_dev,
		opp = dev_pm_opp_find_freq_exact(&device->pdev->dev,
				pwr->pwrlevels[i].gpu_freq, true);
		/* _opp_get returns uV, convert to mV */
		if (!IS_ERR(opp))
		if (!IS_ERR(opp)) {
			mvolt = dev_pm_opp_get_voltage(opp) / 1000;
			dev_pm_opp_put(opp);
		}
		kgsl_regwrite(device, addr++, mvolt);
		kgsl_regwrite(device, addr++,
				pwr->pwrlevels[i].gpu_freq / 1000000);
+1 −0
Original line number Diff line number Diff line
@@ -661,6 +661,7 @@ static int rpmh_arc_votes_init(struct gmu_device *gmu,

		/* Values from OPP framework are offset by 1 */
		vlvl_tbl[i] = dev_pm_opp_get_voltage(opp) - 1;
		dev_pm_opp_put(opp);
	}

	ret = setup_volt_dependency_tbl(votes,
+1 −3
Original line number Diff line number Diff line
@@ -2209,16 +2209,14 @@ static void kgsl_pwrctrl_disable_unused_opp(struct kgsl_device *device)
		return;

	while (1) {
		rcu_read_lock();
		opp = dev_pm_opp_find_freq_ceil(dev, &freq);
		rcu_read_unlock();

		if (IS_ERR(opp))
			break;

		if (!_gpu_freq_supported(&device->pwrctrl, freq))
			dev_pm_opp_disable(dev, freq);

		dev_pm_opp_put(opp);
		freq++;
	}
}
+4 −4
Original line number Diff line number Diff line
@@ -886,19 +886,19 @@ static int opp_notify(struct notifier_block *nb,
	if (type != OPP_EVENT_ENABLE && type != OPP_EVENT_DISABLE)
		return result;

	rcu_read_lock();
	opp = dev_pm_opp_find_freq_floor(dev, &max_freq);
	dev_pm_opp_put(opp);

	if (IS_ERR(opp)) {
		rcu_read_unlock();
		return PTR_ERR(opp);
	}

	opp = dev_pm_opp_find_freq_ceil(dev, &min_freq);
	dev_pm_opp_put(opp);

	if (IS_ERR(opp))
		min_freq = pwr->pwrlevels[pwr->min_pwrlevel].gpu_freq;

	rcu_read_unlock();

	mutex_lock(&device->mutex);

	max_level = pwr->thermal_pwrlevel;