From 1996970773a323533e1cc1b6b97f00a95d675f32 Mon Sep 17 00:00:00 2001 From: Martin Blumenstingl Date: Thu, 19 Mar 2020 21:34:27 +0100 Subject: drm/lima: Add optional devfreq and cooling device support Most platforms with a Mali-400 or Mali-450 GPU also have support for changing the GPU clock frequency. Add devfreq support so the GPU clock rate is updated based on the actual GPU usage when the "operating-points-v2" property is present in the board.dts. The actual devfreq code is taken from panfrost_devfreq.c and modified so it matches what the lima hardware needs: - a call to dev_pm_opp_set_clkname() during initialization because there are two clocks on Mali-4x0 IPs. "core" is the one that actually clocks the GPU so we need to control it using devfreq. - locking when reading or writing the devfreq statistics because (unlike than panfrost) we have multiple PP and GP IRQs which may finish jobs concurrently. Signed-off-by: Martin Blumenstingl Signed-off-by: Qiang Yu Link: https://patchwork.freedesktop.org/patch/msgid/20200319203427.2259891-3-martin.blumenstingl@googlemail.com --- drivers/gpu/drm/lima/lima_drv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/drm/lima/lima_drv.c') diff --git a/drivers/gpu/drm/lima/lima_drv.c b/drivers/gpu/drm/lima/lima_drv.c index 97ed70c36340..bbbdc8455e2f 100644 --- a/drivers/gpu/drm/lima/lima_drv.c +++ b/drivers/gpu/drm/lima/lima_drv.c @@ -10,6 +10,7 @@ #include #include +#include "lima_device.h" #include "lima_drv.h" #include "lima_gem.h" #include "lima_vm.h" @@ -397,13 +398,19 @@ static int lima_pdev_probe(struct platform_device *pdev) if (err) goto err_out1; + err = lima_devfreq_init(ldev); + if (err) { + dev_err(&pdev->dev, "Fatal error during devfreq init\n"); + goto err_out2; + } + /* * Register the DRM device with the core and the connectors with * sysfs. */ err = drm_dev_register(ddev, 0); if (err < 0) - goto err_out2; + goto err_out3; platform_set_drvdata(pdev, ldev); @@ -412,8 +419,10 @@ static int lima_pdev_probe(struct platform_device *pdev) return 0; -err_out2: +err_out3: lima_device_fini(ldev); +err_out2: + lima_devfreq_fini(ldev); err_out1: drm_dev_put(ddev); err_out0: @@ -429,6 +438,7 @@ static int lima_pdev_remove(struct platform_device *pdev) sysfs_remove_bin_file(&ldev->dev->kobj, &lima_error_state_attr); platform_set_drvdata(pdev, NULL); drm_dev_unregister(ddev); + lima_devfreq_fini(ldev); lima_device_fini(ldev); drm_dev_put(ddev); lima_sched_slab_fini(); -- cgit v1.2.3