Skip to content

Commit 21c23e4

Browse files
larunbeSteven Price
authored andcommitted
drm/panthor: Fix OPP refcnt leaks in devfreq initialisation
Rearrange lookup of recommended OPP for the Mali GPU device and its refcnt decremental to make sure no OPP object leaks happen in the error path. Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com> Fixes: fac9b22 ("drm/panthor: Add the devfreq logical block") Reviewed-by: Steven Price <steven.price@arm.com> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Signed-off-by: Steven Price <steven.price@arm.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241105205458.1318989-2-adrian.larumbe@collabora.com
1 parent 043e8af commit 21c23e4

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/gpu/drm/panthor/panthor_devfreq.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,6 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
163163

164164
cur_freq = clk_get_rate(ptdev->clks.core);
165165

166-
opp = devfreq_recommended_opp(dev, &cur_freq, 0);
167-
if (IS_ERR(opp))
168-
return PTR_ERR(opp);
169-
170-
panthor_devfreq_profile.initial_freq = cur_freq;
171-
ptdev->current_frequency = cur_freq;
172-
173166
/* Regulator coupling only takes care of synchronizing/balancing voltage
174167
* updates, but the coupled regulator needs to be enabled manually.
175168
*
@@ -200,18 +193,24 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
200193
return ret;
201194
}
202195

196+
opp = devfreq_recommended_opp(dev, &cur_freq, 0);
197+
if (IS_ERR(opp))
198+
return PTR_ERR(opp);
199+
200+
panthor_devfreq_profile.initial_freq = cur_freq;
201+
ptdev->current_frequency = cur_freq;
202+
203203
/*
204204
* Set the recommend OPP this will enable and configure the regulator
205205
* if any and will avoid a switch off by regulator_late_cleanup()
206206
*/
207207
ret = dev_pm_opp_set_opp(dev, opp);
208+
dev_pm_opp_put(opp);
208209
if (ret) {
209210
DRM_DEV_ERROR(dev, "Couldn't set recommended OPP\n");
210211
return ret;
211212
}
212213

213-
dev_pm_opp_put(opp);
214-
215214
/* Find the fastest defined rate */
216215
opp = dev_pm_opp_find_freq_floor(dev, &freq);
217216
if (IS_ERR(opp))

0 commit comments

Comments
 (0)