[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20230818021741.6173-1-chun-jen.tseng@mediatek.com>
Date: Fri, 18 Aug 2023 10:17:41 +0800
From: Mark Tseng <chun-jen.tseng@...iatek.com>
To: MyungJoo Ham <myungjoo.ham@...sung.com>,
Kyungmin Park <kyungmin.park@...sung.com>,
Chanwoo Choi <cw00.choi@...sung.com>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
CC: <linux-pm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-mediatek@...ts.infradead.org>, <devicetree@...r.kernel.org>,
<Project_Global_Chrome_Upstream_Group@...iatek.com>,
<chun-jen.tseng@...iatek.com>
Subject: [PATCH] PM / devfreq: mediatek: protect oop in critical session
mtk_ccifreq_opp_notifier is reenter function when policy0 / policy6
change freq, so metex_lock should protect all OPP event.
Signed-off-by: Mark Tseng <chun-jen.tseng@...iatek.com>
---
drivers/devfreq/mtk-cci-devfreq.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/devfreq/mtk-cci-devfreq.c b/drivers/devfreq/mtk-cci-devfreq.c
index 83a73f0ccd80..b0ed25e33f2b 100644
--- a/drivers/devfreq/mtk-cci-devfreq.c
+++ b/drivers/devfreq/mtk-cci-devfreq.c
@@ -137,6 +137,8 @@ static int mtk_ccifreq_target(struct device *dev, unsigned long *freq,
if (drv->pre_freq == *freq)
return 0;
+ mutex_lock(&drv->reg_lock);
+
inter_voltage = drv->inter_voltage;
cci_pll = clk_get_parent(drv->cci_clk);
@@ -147,8 +149,6 @@ static int mtk_ccifreq_target(struct device *dev, unsigned long *freq,
return PTR_ERR(opp);
}
- mutex_lock(&drv->reg_lock);
-
voltage = dev_pm_opp_get_voltage(opp);
dev_pm_opp_put(opp);
@@ -227,9 +227,9 @@ static int mtk_ccifreq_opp_notifier(struct notifier_block *nb,
drv = container_of(nb, struct mtk_ccifreq_drv, opp_nb);
if (event == OPP_EVENT_ADJUST_VOLTAGE) {
+ mutex_lock(&drv->reg_lock);
freq = dev_pm_opp_get_freq(opp);
- mutex_lock(&drv->reg_lock);
/* current opp item is changed */
if (freq == drv->pre_freq) {
volt = dev_pm_opp_get_voltage(opp);
--
2.18.0
Powered by blists - more mailing lists