From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: "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>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
kernel@collabora.com, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH v6 2/5] drm/panthor: record current and maximum device clock frequencies
Date: Fri, 13 Sep 2024 16:14:07 +0200 [thread overview]
Message-ID: <20240913161407.0a30b68f@collabora.com> (raw)
In-Reply-To: <20240913124857.389630-3-adrian.larumbe@collabora.com>
On Fri, 13 Sep 2024 13:42:10 +0100
Adrián Larumbe <adrian.larumbe@collabora.com> wrote:
> In order to support UM in calculating rates of GPU utilisation, the current
> operating and maximum GPU clock frequencies must be recorded during device
> initialisation, and also during OPP state transitions.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
> drivers/gpu/drm/panthor/panthor_devfreq.c | 18 +++++++++++++++++-
> drivers/gpu/drm/panthor/panthor_device.h | 6 ++++++
> 2 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_devfreq.c b/drivers/gpu/drm/panthor/panthor_devfreq.c
> index c6d3c327cc24..9d0f891b9b53 100644
> --- a/drivers/gpu/drm/panthor/panthor_devfreq.c
> +++ b/drivers/gpu/drm/panthor/panthor_devfreq.c
> @@ -62,14 +62,20 @@ 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;
>
> opp = devfreq_recommended_opp(dev, freq, flags);
> if (IS_ERR(opp))
> return PTR_ERR(opp);
> dev_pm_opp_put(opp);
>
> - return dev_pm_opp_set_rate(dev, *freq);
> + err = dev_pm_opp_set_rate(dev, *freq);
> + if (!err)
> + ptdev->current_frequency = *freq;
> +
> + return err;
> }
>
> static void panthor_devfreq_reset(struct panthor_devfreq *pdevfreq)
> @@ -130,6 +136,7 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
> struct panthor_devfreq *pdevfreq;
> struct dev_pm_opp *opp;
> unsigned long cur_freq;
> + unsigned long freq = ULONG_MAX;
> int ret;
>
> pdevfreq = drmm_kzalloc(&ptdev->base, sizeof(*ptdev->devfreq), GFP_KERNEL);
> @@ -161,6 +168,7 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
> return PTR_ERR(opp);
>
> panthor_devfreq_profile.initial_freq = cur_freq;
> + ptdev->current_frequency = cur_freq;
>
> /* Regulator coupling only takes care of synchronizing/balancing voltage
> * updates, but the coupled regulator needs to be enabled manually.
> @@ -204,6 +212,14 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
>
> dev_pm_opp_put(opp);
>
> + /* Find the fastest defined rate */
> + opp = dev_pm_opp_find_freq_floor(dev, &freq);
> + if (IS_ERR(opp))
> + return PTR_ERR(opp);
> + ptdev->fast_rate = freq;
> +
> + dev_pm_opp_put(opp);
> +
> /*
> * Setup default thresholds for the simple_ondemand governor.
> * The values are chosen based on experiments.
> diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h
> index a48e30d0af30..2109905813e8 100644
> --- a/drivers/gpu/drm/panthor/panthor_device.h
> +++ b/drivers/gpu/drm/panthor/panthor_device.h
> @@ -184,6 +184,12 @@ 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;
> };
>
> /**
next prev parent reply other threads:[~2024-09-13 14:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-13 12:42 [PATCH v6 0/5] Support fdinfo runtime and memory stats on Panthor Adrián Larumbe
2024-09-13 12:42 ` [PATCH v6 1/5] drm/panthor: introduce job cycle and timestamp accounting Adrián Larumbe
2024-09-13 21:53 ` kernel test robot
2024-09-15 15:22 ` kernel test robot
2024-09-15 16:43 ` kernel test robot
2024-09-16 11:15 ` Steven Price
2024-09-20 22:36 ` Adrián Larumbe
2024-09-23 8:55 ` Steven Price
2024-09-23 20:43 ` Adrián Larumbe
2024-09-25 9:56 ` Steven Price
2024-09-27 14:53 ` Adrián Larumbe
2024-09-30 11:28 ` Steven Price
2024-09-13 12:42 ` [PATCH v6 2/5] drm/panthor: record current and maximum device clock frequencies Adrián Larumbe
2024-09-13 14:14 ` Boris Brezillon [this message]
2024-09-16 11:19 ` Steven Price
2024-09-13 12:42 ` [PATCH v6 3/5] drm/panthor: add DRM fdinfo support Adrián Larumbe
2024-09-13 14:15 ` Boris Brezillon
2024-09-13 12:42 ` [PATCH v6 4/5] drm/panthor: enable fdinfo for memory stats Adrián Larumbe
2024-09-13 12:42 ` [PATCH v6 5/5] drm/panthor: add sysfs knob for enabling job profiling Adrián Larumbe
2024-09-13 14:15 ` Boris Brezillon
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=20240913161407.0a30b68f@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=adrian.larumbe@collabora.com \
--cc=airlied@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=sumit.semwal@linaro.org \
--cc=tzimmermann@suse.de \
/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