Some platforms provide GPU clocks through firmware without an OPP table that the driver can use. Failing probe when the DT has no OPP table prevents these platforms from using the clock settings already provided by firmware.
Continue without devfreq when devm_pm_opp_of_add_table() returns -ENODEV, as Panfrost does. Keep the current core clock rate for profiling and report the clock provider's rate when devfreq is not registered. Only allow the fallback when neither mali-supply nor sram-supply is present. GPU supply properties require an OPP table to configure and enable the supplies. Without these properties, the platform must provide a usable clock and power configuration. Signed-off-by: Cunyuan Liu <[email protected]> --- drivers/gpu/drm/panthor/panthor_devfreq.c | 13 ++++++++++++- drivers/gpu/drm/panthor/panthor_device.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_devfreq.c b/drivers/gpu/drm/panthor/panthor_devfreq.c index 2249b41ca4af..778c20f0921a 100644 --- a/drivers/gpu/drm/panthor/panthor_devfreq.c +++ b/drivers/gpu/drm/panthor/panthor_devfreq.c @@ -6,6 +6,7 @@ #include <linux/devfreq_cooling.h> #include <linux/platform_device.h> #include <linux/pm_opp.h> +#include <linux/property.h> #include <drm/drm_managed.h> #include <drm/drm_print.h> @@ -172,6 +173,16 @@ int panthor_devfreq_init(struct panthor_device *ptdev) } ret = devm_pm_opp_of_add_table(dev); + if (ret == -ENODEV) { + if (device_property_present(dev, "mali-supply") || + device_property_present(dev, "sram-supply")) + return dev_err_probe(dev, -ENODEV, + "GPU supplies require an OPP table\n"); + + /* Keep the clock provider's rate when no OPP table is present. */ + ptdev->fast_rate = clk_get_rate(ptdev->clks.core); + return 0; + } if (ret) return ret; } else { @@ -324,7 +335,7 @@ unsigned long panthor_devfreq_get_freq(struct panthor_device *ptdev) int ret; if (!pdevfreq->devfreq) - return 0; + return clk_get_rate(ptdev->clks.core); ret = pdevfreq->devfreq->profile->get_cur_freq(ptdev->base.dev, &freq); if (ret) diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h index adbc2e2f03be..f5353372c1ae 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -328,7 +328,7 @@ struct panthor_device { /** @profile_mask: User-set profiling flags for job accounting. */ u32 profile_mask; - /** @fast_rate: Maximum device clock frequency. Set by DVFS */ + /** @fast_rate: Maximum OPP frequency, or the clock rate without OPPs. */ unsigned long fast_rate; #ifdef CONFIG_DEBUG_FS -- 2.53.0
