Commit 3668133e authored by Nicolas Frattaroli's avatar Nicolas Frattaroli Committed by Liviu Dudau
Browse files

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: default avatarChia-I Wu <olvaffe@gmail.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: default avatarSteven Price <steven.price@arm.com>
Reviewed-by: default avatarLiviu Dudau <liviu.dudau@arm.com>
Signed-off-by: default avatarNicolas Frattaroli <nicolas.frattaroli@collabora.com>
Link: https://patch.msgid.link/20251017-mt8196-gpufreq-v8-4-98fc1cc566a1@collabora.com


Signed-off-by: default avatarLiviu Dudau <liviu.dudau@arm.com>
parent 3dd4844b
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
	struct thermal_cooling_device *cooling;
	struct device *dev = ptdev->base.dev;
	struct panthor_devfreq *pdevfreq;
	struct opp_table *table;
	struct dev_pm_opp *opp;
	unsigned long cur_freq;
	unsigned long freq = ULONG_MAX;
@@ -153,6 +154,16 @@ int panthor_devfreq_init(struct panthor_device *ptdev)

	ptdev->devfreq = pdevfreq;

	/*
	 * The power domain associated with the GPU may have already added an
	 * OPP table, complete with OPPs, as part of the platform bus
	 * initialization. If this is the case, the power domain is in charge of
	 * also controlling the performance, with a set_performance callback.
	 * Only add a new OPP table from DT if there isn't such a table present
	 * already.
	 */
	table = dev_pm_opp_get_opp_table(dev);
	if (IS_ERR_OR_NULL(table)) {
		ret = devm_pm_opp_set_regulators(dev, reg_names);
		if (ret && ret != -ENODEV) {
			if (ret != -EPROBE_DEFER)
@@ -163,6 +174,9 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
		ret = devm_pm_opp_of_add_table(dev);
		if (ret)
			return ret;
	} else {
		dev_pm_opp_put_opp_table(table);
	}

	spin_lock_init(&pdevfreq->lock);