From 2f2e145e4b562ae7662cbfbca52d5c29608c7750 Mon Sep 17 00:00:00 2001 From: Harshdeep Dhatt Date: Wed, 20 Jan 2021 14:06:30 -0700 Subject: [PATCH] msm: kgsl: Take devfreq event lock for ddr qos vote This lock protects against any concurrent governor re-assignments through sysfs. Furthermore, such re-assignment can lead to another issue i.e. say someone assigns performance governor to this device from sysfs. Then there can be a mismatch in what kgsl intends to vote, and what actually gets voted. Therefore, fix both the min and max frequencies for this devfreq device at the desired qos level so that the intended vote is propagated regardless of the governor. Change-Id: Ibc3b0ef1f585dae311aab028d8c2bc9f1a53b4b8 Signed-off-by: Harshdeep Dhatt --- drivers/gpu/msm/kgsl_bus.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/msm/kgsl_bus.c b/drivers/gpu/msm/kgsl_bus.c index 810a16bbca5e..8cae22d18b54 100644 --- a/drivers/gpu/msm/kgsl_bus.c +++ b/drivers/gpu/msm/kgsl_bus.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. */ #include @@ -54,10 +54,21 @@ static void set_ddr_qos(struct kgsl_device *device, int buslevel) if (new_min_freq == cur_min_freq) return; + /* + * We need the event lock to protect against concurrent governor + * re-assignments. + */ + event_mutex_lock(dev); mutex_lock(&dev->lock); + /* + * Update both min/max to make sure correct vote is set regardless + * of the governor, which can be changed from sysfs + */ dev->min_freq = new_min_freq; + dev->max_freq = new_min_freq; ret = update_devfreq(dev); mutex_unlock(&dev->lock); + event_mutex_unlock(dev); if (!ret) cur_min_freq = new_min_freq;