memory: samsung: exynos5422-dmc: Additional locking for 'curr_rate'
authorLukasz Luba <lukasz.luba@arm.com>
Tue, 11 Aug 2020 10:17:27 +0000 (11:17 +0100)
committerKrzysztof Kozlowski <krzk@kernel.org>
Mon, 17 Aug 2020 11:54:14 +0000 (13:54 +0200)
The 'curr_rate' is protected by local 'dmc->lock' in various places, but
not in a function exynos5_dmc_get_status(). The lock protects frequency
(and voltage) change process and the corresponding value stored in
'curr_rate'. Add the locking mechanism to protect the 'curr_rate' reading
also in the exynos5_dmc_get_status().

Suggested-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://lore.kernel.org/r/20200811101727.3976-1-lukasz.luba@arm.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
drivers/memory/samsung/exynos5422-dmc.c

index b9c7956..952bc61 100644 (file)
@@ -908,7 +908,10 @@ static int exynos5_dmc_get_status(struct device *dev,
        int ret;
 
        if (dmc->in_irq_mode) {
+               mutex_lock(&dmc->lock);
                stat->current_frequency = dmc->curr_rate;
+               mutex_unlock(&dmc->lock);
+
                stat->busy_time = dmc->load;
                stat->total_time = dmc->total;
        } else {