Skip to content

Commit d280560

Browse files
Mark Tsengchanwoochoi
authored andcommitted
PM / devfreq: mediatek: protect oop in critical session
mtk_ccifreq_opp_notifier is reenter function when policy0 / policy6 change freq, so mutex_lock should protect all OPP event. Link: https://lore.kernel.org/lkml/20230818021741.6173-1-chun-jen.tseng@mediatek.com/T/ Signed-off-by: Mark Tseng <chun-jen.tseng@mediatek.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
1 parent 8a749fd commit d280560

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/devfreq/mtk-cci-devfreq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ static int mtk_ccifreq_target(struct device *dev, unsigned long *freq,
137137
if (drv->pre_freq == *freq)
138138
return 0;
139139

140+
mutex_lock(&drv->reg_lock);
141+
140142
inter_voltage = drv->inter_voltage;
141143
cci_pll = clk_get_parent(drv->cci_clk);
142144

@@ -147,8 +149,6 @@ static int mtk_ccifreq_target(struct device *dev, unsigned long *freq,
147149
return PTR_ERR(opp);
148150
}
149151

150-
mutex_lock(&drv->reg_lock);
151-
152152
voltage = dev_pm_opp_get_voltage(opp);
153153
dev_pm_opp_put(opp);
154154

@@ -227,9 +227,9 @@ static int mtk_ccifreq_opp_notifier(struct notifier_block *nb,
227227
drv = container_of(nb, struct mtk_ccifreq_drv, opp_nb);
228228

229229
if (event == OPP_EVENT_ADJUST_VOLTAGE) {
230+
mutex_lock(&drv->reg_lock);
230231
freq = dev_pm_opp_get_freq(opp);
231232

232-
mutex_lock(&drv->reg_lock);
233233
/* current opp item is changed */
234234
if (freq == drv->pre_freq) {
235235
volt = dev_pm_opp_get_voltage(opp);

0 commit comments

Comments
 (0)