From: Karunika Choo <karunika.choo@arm.com>
To: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Boris Brezillon <boris.brezillon@collabora.com>,
Jassi Brar <jassisinghbrar@gmail.com>,
Chia-I Wu <olvaffe@gmail.com>, Chen-Yu Tsai <wenst@chromium.org>,
Steven Price <steven.price@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>
Cc: kernel@collabora.com, dri-devel@lists.freedesktop.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
linux-hardening@vger.kernel.org, linux-pm@vger.kernel.org,
nd@arm.com
Subject: Re: [PATCH v8 3/5] drm/panthor: call into devfreq for current frequency
Date: Mon, 20 Oct 2025 09:16:55 +0100 [thread overview]
Message-ID: <6ee4b717-6c7e-4114-9130-0b2daccb3d3a@arm.com> (raw)
In-Reply-To: <20251017-mt8196-gpufreq-v8-3-98fc1cc566a1@collabora.com>
On 17/10/2025 16:31, Nicolas Frattaroli wrote:
> As it stands, panthor keeps a cached current frequency value for when it
> wants to retrieve it. This doesn't work well for when things might
> switch frequency without panthor's knowledge.
>
> Instead, implement the get_cur_freq operation, and expose it through a
> helper function to the rest of panthor.
>
> Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
> Reviewed-by: Steven Price <steven.price@arm.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> ---
> drivers/gpu/drm/panthor/panthor_devfreq.c | 30 ++++++++++++++++++++++++++----
> drivers/gpu/drm/panthor/panthor_devfreq.h | 2 ++
> drivers/gpu/drm/panthor/panthor_device.h | 3 ---
> drivers/gpu/drm/panthor/panthor_drv.c | 4 +++-
> 4 files changed, 31 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_devfreq.c b/drivers/gpu/drm/panthor/panthor_devfreq.c
> index 2df1d76d84a0..a6dca599f0a5 100644
> --- a/drivers/gpu/drm/panthor/panthor_devfreq.c
> +++ b/drivers/gpu/drm/panthor/panthor_devfreq.c
> @@ -62,7 +62,6 @@ static void panthor_devfreq_update_utilization(struct panthor_devfreq *pdevfreq)
> static int panthor_devfreq_target(struct device *dev, unsigned long *freq,
> u32 flags)
> {
> - struct panthor_device *ptdev = dev_get_drvdata(dev);
> struct dev_pm_opp *opp;
> int err;
>
> @@ -72,8 +71,6 @@ static int panthor_devfreq_target(struct device *dev, unsigned long *freq,
> dev_pm_opp_put(opp);
>
> err = dev_pm_opp_set_rate(dev, *freq);
> - if (!err)
> - ptdev->current_frequency = *freq;
>
> return err;
> }
> @@ -115,11 +112,21 @@ static int panthor_devfreq_get_dev_status(struct device *dev,
> return 0;
> }
>
> +static int panthor_devfreq_get_cur_freq(struct device *dev, unsigned long *freq)
> +{
> + struct panthor_device *ptdev = dev_get_drvdata(dev);
> +
> + *freq = clk_get_rate(ptdev->clks.core);
> +
> + return 0;
> +}
> +
> static struct devfreq_dev_profile panthor_devfreq_profile = {
> .timer = DEVFREQ_TIMER_DELAYED,
> .polling_ms = 50, /* ~3 frames */
> .target = panthor_devfreq_target,
> .get_dev_status = panthor_devfreq_get_dev_status,
> + .get_cur_freq = panthor_devfreq_get_cur_freq,
> };
>
> int panthor_devfreq_init(struct panthor_device *ptdev)
> @@ -197,7 +204,6 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
> return PTR_ERR(opp);
>
> panthor_devfreq_profile.initial_freq = cur_freq;
> - ptdev->current_frequency = cur_freq;
>
> /*
> * Set the recommend OPP this will enable and configure the regulator
> @@ -295,3 +301,19 @@ void panthor_devfreq_record_idle(struct panthor_device *ptdev)
>
> spin_unlock_irqrestore(&pdevfreq->lock, irqflags);
> }
> +
> +unsigned long panthor_devfreq_get_freq(struct panthor_device *ptdev)
> +{
> + struct panthor_devfreq *pdevfreq = ptdev->devfreq;
> + unsigned long freq = 0;
> + int ret;
> +
> + if (!pdevfreq->devfreq)
> + return 0;
> +
> + ret = pdevfreq->devfreq->profile->get_cur_freq(ptdev->base.dev, &freq);
> + if (ret)
> + return 0;
> +
> + return freq;
> +}
> diff --git a/drivers/gpu/drm/panthor/panthor_devfreq.h b/drivers/gpu/drm/panthor/panthor_devfreq.h
> index b7631de695f7..f8e29e02f66c 100644
> --- a/drivers/gpu/drm/panthor/panthor_devfreq.h
> +++ b/drivers/gpu/drm/panthor/panthor_devfreq.h
> @@ -18,4 +18,6 @@ void panthor_devfreq_suspend(struct panthor_device *ptdev);
> void panthor_devfreq_record_busy(struct panthor_device *ptdev);
> void panthor_devfreq_record_idle(struct panthor_device *ptdev);
>
> +unsigned long panthor_devfreq_get_freq(struct panthor_device *ptdev);
> +
> #endif /* __PANTHOR_DEVFREQ_H__ */
> diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h
> index 9f0649ecfc4f..f32c1868bf6d 100644
> --- a/drivers/gpu/drm/panthor/panthor_device.h
> +++ b/drivers/gpu/drm/panthor/panthor_device.h
> @@ -214,9 +214,6 @@ struct panthor_device {
> /** @profile_mask: User-set profiling flags for job accounting. */
> u32 profile_mask;
>
> - /** @current_frequency: Device clock frequency at present. Set by DVFS*/
> - unsigned long current_frequency;
> -
> /** @fast_rate: Maximum device clock frequency. Set by DVFS */
> unsigned long fast_rate;
>
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index fb4b293f17f0..75898d83a207 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> @@ -25,6 +25,7 @@
> #include <drm/gpu_scheduler.h>
> #include <drm/panthor_drm.h>
>
> +#include "panthor_devfreq.h"
> #include "panthor_device.h"
> #include "panthor_fw.h"
> #include "panthor_gem.h"
> @@ -1519,7 +1520,8 @@ static void panthor_gpu_show_fdinfo(struct panthor_device *ptdev,
> drm_printf(p, "drm-cycles-panthor:\t%llu\n", pfile->stats.cycles);
>
> drm_printf(p, "drm-maxfreq-panthor:\t%lu Hz\n", ptdev->fast_rate);
> - drm_printf(p, "drm-curfreq-panthor:\t%lu Hz\n", ptdev->current_frequency);
> + drm_printf(p, "drm-curfreq-panthor:\t%lu Hz\n",
> + panthor_devfreq_get_freq(ptdev));
> }
>
> static void panthor_show_internal_memory_stats(struct drm_printer *p, struct drm_file *file)
>
Reviewed-by: Karunika Choo <karunika.choo@arm.com>
next prev parent reply other threads:[~2025-10-20 8:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 15:31 [PATCH v8 0/5] MT8196 GPU Frequency/Power Control Support Nicolas Frattaroli
2025-10-17 15:31 ` [PATCH v8 1/5] dt-bindings: gpu: mali-valhall-csf: add mediatek,mt8196-mali variant Nicolas Frattaroli
2025-10-28 17:12 ` Liviu Dudau
2025-10-28 20:51 ` Nicolas Frattaroli
2025-10-29 1:04 ` Liviu Dudau
2025-10-29 13:42 ` Nicolas Frattaroli
2025-10-29 13:55 ` Liviu Dudau
2025-11-03 15:24 ` Liviu Dudau
2025-10-17 15:31 ` [PATCH v8 2/5] dt-bindings: power: Add MT8196 GPU frequency control binding Nicolas Frattaroli
2025-10-17 15:31 ` [PATCH v8 3/5] drm/panthor: call into devfreq for current frequency Nicolas Frattaroli
2025-10-20 8:16 ` Karunika Choo [this message]
2025-10-17 15:31 ` [PATCH v8 4/5] drm/panthor: Use existing OPP table if present Nicolas Frattaroli
2025-10-20 8:35 ` Karunika Choo
2025-10-20 11:50 ` Nicolas Frattaroli
2025-10-20 13:47 ` Steven Price
2025-10-17 15:31 ` [PATCH v8 5/5] pmdomain: mediatek: Add support for MFlexGraphics Nicolas Frattaroli
2025-10-22 13:52 ` [PATCH v8 0/5] MT8196 GPU Frequency/Power Control Support Ulf Hansson
2025-10-24 13:08 ` Steven Price
2025-10-24 14:50 ` Ulf Hansson
2025-11-03 16:07 ` Liviu Dudau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6ee4b717-6c7e-4114-9130-0b2daccb3d3a@arm.com \
--to=karunika.choo@arm.com \
--cc=airlied@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=boris.brezillon@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavoars@kernel.org \
--cc=jassisinghbrar@gmail.com \
--cc=kees@kernel.org \
--cc=kernel@collabora.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthias.bgg@gmail.com \
--cc=mripard@kernel.org \
--cc=nd@arm.com \
--cc=nicolas.frattaroli@collabora.com \
--cc=olvaffe@gmail.com \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=tzimmermann@suse.de \
--cc=ulf.hansson@linaro.org \
--cc=wenst@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox