summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>2017-02-27 14:51:03 +0530
committerManaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>2017-02-27 14:52:58 +0530
commit82cc4f26dc497657b8506950b78158df7ab795ba (patch)
tree0338499fdfbc3ea2e7217628e91aac41427896f2
parent541fe938d28fd1d61c22f25c031ebf600af2c61d (diff)
power: bcl: Serialize frequency mitigation request from BCL events
For cpu frequency mitigation, there is one common device request handle for all BCL events. There is a possible race condition for frequency mitigation request if two BCL events are cleared simultaneously and cpu frequency mitigation handler for these two events are handled in different cpus. This gives rise to a scenario where cpu frequency in mitigated state even though all BCL events are cleared. To avoid this race condition, serialize frequency mitigation request using a mutex. CRs-Fixed: 2005131 Change-Id: I29b189b2ecd18603441d0b69faa4c38123244a4a Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
-rw-r--r--drivers/power/supply/qcom/battery_current_limit.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/power/supply/qcom/battery_current_limit.c b/drivers/power/supply/qcom/battery_current_limit.c
index d2c25bfbf66c..022c665ad60b 100644
--- a/drivers/power/supply/qcom/battery_current_limit.c
+++ b/drivers/power/supply/qcom/battery_current_limit.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2017, 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
@@ -204,6 +204,7 @@ static uint32_t bcl_hotplug_request, bcl_hotplug_mask, bcl_soc_hotplug_mask;
static uint32_t bcl_frequency_mask;
static struct work_struct bcl_hotplug_work;
static DEFINE_MUTEX(bcl_hotplug_mutex);
+static DEFINE_MUTEX(bcl_cpufreq_mutex);
static bool bcl_hotplug_enabled;
static uint32_t battery_soc_val = 100;
static uint32_t soc_low_threshold;
@@ -251,6 +252,7 @@ static void update_cpu_freq(void)
union device_request cpufreq_req;
trace_bcl_sw_mitigation_event("Start Frequency Mitigate");
+ mutex_lock(&bcl_cpufreq_mutex);
cpufreq_req.freq.max_freq = UINT_MAX;
cpufreq_req.freq.min_freq = CPUFREQ_MIN_NO_MITIGATION;
@@ -275,6 +277,7 @@ static void update_cpu_freq(void)
pr_err("Error updating freq for CPU%d. ret:%d\n",
cpu, ret);
}
+ mutex_unlock(&bcl_cpufreq_mutex);
trace_bcl_sw_mitigation_event("End Frequency Mitigation");
}