Skip to content

Commit 3668133

Browse files
Nicolas Frattarolidliviu
authored andcommitted
drm/panthor: Use existing OPP table if present
On SoCs where the GPU's power-domain is in charge of setting performance levels, the OPP table of the GPU node will have already been populated during said power-domain's attach_dev operation. To avoid initialising an OPP table twice, only set the OPP regulator and the OPPs from DT if there's no OPP table present. Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Steven Price <steven.price@arm.com> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> Link: https://patch.msgid.link/20251017-mt8196-gpufreq-v8-4-98fc1cc566a1@collabora.com Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
1 parent 3dd4844 commit 3668133

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

drivers/gpu/drm/panthor/panthor_devfreq.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
142142
struct thermal_cooling_device *cooling;
143143
struct device *dev = ptdev->base.dev;
144144
struct panthor_devfreq *pdevfreq;
145+
struct opp_table *table;
145146
struct dev_pm_opp *opp;
146147
unsigned long cur_freq;
147148
unsigned long freq = ULONG_MAX;
@@ -153,17 +154,30 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
153154

154155
ptdev->devfreq = pdevfreq;
155156

156-
ret = devm_pm_opp_set_regulators(dev, reg_names);
157-
if (ret && ret != -ENODEV) {
158-
if (ret != -EPROBE_DEFER)
159-
DRM_DEV_ERROR(dev, "Couldn't set OPP regulators\n");
160-
return ret;
157+
/*
158+
* The power domain associated with the GPU may have already added an
159+
* OPP table, complete with OPPs, as part of the platform bus
160+
* initialization. If this is the case, the power domain is in charge of
161+
* also controlling the performance, with a set_performance callback.
162+
* Only add a new OPP table from DT if there isn't such a table present
163+
* already.
164+
*/
165+
table = dev_pm_opp_get_opp_table(dev);
166+
if (IS_ERR_OR_NULL(table)) {
167+
ret = devm_pm_opp_set_regulators(dev, reg_names);
168+
if (ret && ret != -ENODEV) {
169+
if (ret != -EPROBE_DEFER)
170+
DRM_DEV_ERROR(dev, "Couldn't set OPP regulators\n");
171+
return ret;
172+
}
173+
174+
ret = devm_pm_opp_of_add_table(dev);
175+
if (ret)
176+
return ret;
177+
} else {
178+
dev_pm_opp_put_opp_table(table);
161179
}
162180

163-
ret = devm_pm_opp_of_add_table(dev);
164-
if (ret)
165-
return ret;
166-
167181
spin_lock_init(&pdevfreq->lock);
168182

169183
panthor_devfreq_reset(pdevfreq);

0 commit comments

Comments
 (0)