From: Akhil P Oommen <akhilpo@oss.qualcomm.com>
To: Konrad Dybcio <konradybcio@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
Rob Clark <robin.clark@oss.qualcomm.com>,
Sean Paul <sean@poorly.run>, Dmitry Baryshkov <lumag@kernel.org>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Jessica Zhang <jesszhan0024@gmail.com>,
Marijn Suijten <marijn.suijten@somainline.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Subject: Re: [PATCH 3/8] drm/msm/a6xx: Expose GMU IFPC entry count in debugfs
Date: Fri, 27 Nov 2026 00:43:37 +0530 [thread overview]
Message-ID: <ea19dcb2-9d9e-4d6c-86f5-72a677fca5b8@oss.qualcomm.com> (raw)
In-Reply-To: <20261030-topic-a6xx_ifpc-v1-3-6992841a9a32@oss.qualcomm.com>
On 10/30/2026 3:33 PM, Konrad Dybcio wrote:
> From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>
> Add a read-only debugfs file, ifpc_count, that reports how many times
> the GMU has entered IFPC.
>
> The count is accumulated from the GMU XOCLK_4 power counter. The
> counter is selected in hw_init, and the delta is folded into the total
> from the busy callback, so the value advances whenever devfreq samples
> the GPU.
>
> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> drivers/gpu/drm/msm/Makefile | 1 +
> drivers/gpu/drm/msm/adreno/a6xx_debugfs.c | 23 +++++++++++++++++++++++
> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 30 ++++++++++++++++++++++++++++++
> drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 10 ++++++++++
> drivers/gpu/drm/msm/adreno/a8xx_gpu.c | 9 +++++++++
> 5 files changed, 73 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
> index 1e246616f83f..afd42e5bda00 100644
> --- a/drivers/gpu/drm/msm/Makefile
> +++ b/drivers/gpu/drm/msm/Makefile
> @@ -30,6 +30,7 @@ adreno-y := \
> adreno/a8xx_preempt.o \
>
> adreno-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
> + adreno/a6xx_debugfs.o \
>
> adreno-$(CONFIG_DRM_MSM_GPU_STATE) += adreno/a6xx_gpu_state.o
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_debugfs.c b/drivers/gpu/drm/msm/adreno/a6xx_debugfs.c
> new file mode 100644
> index 000000000000..a3f622cb189f
> --- /dev/null
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_debugfs.c
> @@ -0,0 +1,23 @@
> +// SPDX-License-Identifier: GPL-2.0-only
Qualcomm Copyright?
> +
> +#include <linux/types.h>
> +#include <linux/debugfs.h>
> +
> +#include <drm/drm_file.h>
> +
> +#include "a6xx_gpu.h"
> +
> +void a6xx_debugfs_init(struct msm_gpu *gpu, struct drm_minor *minor)
> +{
> + struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
> + struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
> +
> + if (!minor)
> + return;
> +
> + if (!(adreno_gpu->info->quirks & ADRENO_QUIRK_IFPC))
> + return;
> +
> + debugfs_create_u32("ifpc_count", 0444, minor->debugfs_root,
> + &a6xx_gpu->ifpc_count);
> +}
Can we keep this in a6xx_gpu.c untill there are more a6xx debugfs nodes?
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index 48d3ee4d55d9..e7c3da5d3ac6 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -1338,6 +1338,11 @@ static int hw_init(struct msm_gpu *gpu)
> GENMASK(7, 0), 0x4);
> }
>
> + if (adreno_gpu->info->quirks & ADRENO_QUIRK_IFPC) {
> + a6xx_gpu->ifpc_counter_last =
> + gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L);
> + }
> +
> /* Select CP0 to always count cycles */
> gpu_write(gpu, REG_A6XX_CP_PERFCTR_CP_SEL(0), PERF_CP_ALWAYS_COUNT);
>
> @@ -2334,6 +2339,17 @@ static void a6xx_destroy(struct msm_gpu *gpu)
> kfree(a6xx_gpu);
> }
>
> +void a6xx_ifpc_count_update(struct a6xx_gpu *a6xx_gpu, u32 cur)
> +{
> + /* A counter below the last sample means the GMU restarted it */
> + if (cur >= a6xx_gpu->ifpc_counter_last)
> + a6xx_gpu->ifpc_count += cur - a6xx_gpu->ifpc_counter_last;
> + else
> + a6xx_gpu->ifpc_count += cur;
> +
> + a6xx_gpu->ifpc_counter_last = cur;
> +}
> +
> static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
> {
> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
> @@ -2347,6 +2363,11 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
> REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L,
> REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
>
> + if (adreno_gpu->info->quirks & ADRENO_QUIRK_IFPC)
> + a6xx_ifpc_count_update(a6xx_gpu,
> + gmu_read(&a6xx_gpu->gmu,
> + REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L));
> +
> return busy_cycles;
> }
>
> @@ -2818,6 +2839,9 @@ const struct adreno_gpu_funcs a6xx_gpu_funcs = {
> #if defined(CONFIG_DRM_MSM_GPU_STATE)
> .gpu_state_get = a6xx_gpu_state_get,
> .gpu_state_put = a6xx_gpu_state_put,
> +#endif
> +#if defined(CONFIG_DEBUG_FS)
> + .debugfs_init = a6xx_debugfs_init,
> #endif
> .create_vm = a6xx_create_vm,
> .create_private_vm = a6xx_create_private_vm,
> @@ -2889,6 +2913,9 @@ const struct adreno_gpu_funcs a7xx_gpu_funcs = {
> #if defined(CONFIG_DRM_MSM_GPU_STATE)
> .gpu_state_get = a6xx_gpu_state_get,
> .gpu_state_put = a6xx_gpu_state_put,
> +#endif
> +#if defined(CONFIG_DEBUG_FS)
> + .debugfs_init = a6xx_debugfs_init,
> #endif
> .create_vm = a6xx_create_vm,
> .create_private_vm = a6xx_create_private_vm,
> @@ -2921,6 +2948,9 @@ const struct adreno_gpu_funcs a8xx_gpu_funcs = {
> .gpu_busy = a8xx_gpu_busy,
> .gpu_get_freq = a6xx_gmu_get_freq,
> .gpu_set_freq = a6xx_gpu_set_freq,
> +#if defined(CONFIG_DEBUG_FS)
> + .debugfs_init = a6xx_debugfs_init,
> +#endif
> .create_vm = a6xx_create_vm,
> .create_private_vm = a6xx_create_private_vm,
> .get_rptr = a6xx_get_rptr,
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h
> index 79912a33e17c..8f0cb168a535 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h
> @@ -139,6 +139,10 @@ struct a6xx_gpu {
> spinlock_t aperture_lock;
>
> u32 slice_mask;
> +
> + /* Total GMU IFPC entries, accumulated from the XOCLK_4 counter */
> + u32 ifpc_count;
> + u32 ifpc_counter_last;
> };
>
> #define to_a6xx_gpu(x) container_of(x, struct a6xx_gpu, base)
> @@ -254,6 +258,12 @@ struct a7xx_cp_smmu_info {
> #define A6XX_PROTECT_RDONLY(_reg, _len) \
> ((((_len) & 0x3FFF) << 18) | ((_reg) & 0x3FFFF))
>
> +#ifdef CONFIG_DEBUG_FS
> +void a6xx_debugfs_init(struct msm_gpu *gpu, struct drm_minor *minor);
> +#endif
> +
> +void a6xx_ifpc_count_update(struct a6xx_gpu *a6xx_gpu, u32 cur);
> +
> extern const struct adreno_gpu_funcs a6xx_gpu_funcs;
> extern const struct adreno_gpu_funcs a6xx_gmuwrapper_funcs;
> extern const struct adreno_gpu_funcs a7xx_gpu_funcs;
> diff --git a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c b/drivers/gpu/drm/msm/adreno/a8xx_gpu.c
> index f892731cd3d3..ba81a1c9c551 100644
> --- a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a8xx_gpu.c
> @@ -680,6 +680,10 @@ static int hw_init(struct msm_gpu *gpu)
> gmu_write(&a6xx_gpu->gmu, REG_A8XX_GMU_CX_GMU_POWER_COUNTER_SELECT_XOCLK_1,
> FIELD_PREP(GENMASK(7, 0), 0x4));
>
> + if (adreno_gpu->info->quirks & ADRENO_QUIRK_IFPC)
> + a6xx_gpu->ifpc_counter_last =
> + gmu_read(gmu, REG_A8XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L);
> +
> /* Select CP0 to always count cycles */
> gpu_write(gpu, REG_A8XX_CP_PERFCTR_CP_SEL(0), 1);
>
> @@ -1354,6 +1358,11 @@ u64 a8xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
> REG_A8XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L,
> REG_A8XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
>
> + if (adreno_gpu->info->quirks & ADRENO_QUIRK_IFPC)
> + a6xx_ifpc_count_update(a6xx_gpu,
> + gmu_read(&a6xx_gpu->gmu,
> + REG_A8XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L));
> +
This is all unnecessary plumbing. This counter is not useful outside of a litmus test to see
if IFPC works. Also, this won't work if devfreq is disabled for some reason
or with performance/powersave governors.
We can just read the register from the debugfs callback instead.
-Akhil
> return busy_cycles;
> }
>
>
next prev parent reply other threads:[~2026-11-26 19:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 10:03 [PATCH 0/8] IFPC support for A6xx Konrad Dybcio
2026-10-30 10:03 ` [PATCH 1/8] drm/msm/a6xx: Polish up the IFPC counter enable Konrad Dybcio
2026-11-23 21:39 ` Akhil P Oommen
2026-10-30 10:03 ` [PATCH 2/8] drm/msm/adreno: Register GPU debugfs only on the primary minor Konrad Dybcio
2026-10-30 10:03 ` [PATCH 3/8] drm/msm/a6xx: Expose GMU IFPC entry count in debugfs Konrad Dybcio
2026-11-26 19:13 ` Akhil P Oommen [this message]
2026-10-30 10:04 ` [PATCH 4/8] drm/msm/a6xx: Add A6xx IFPC support Konrad Dybcio
2026-11-26 19:21 ` Akhil P Oommen
2026-10-30 10:04 ` [PATCH 5/8] drm/msm/a6xx: Add IFPC tables for Adreno 630 Konrad Dybcio
2026-11-26 19:24 ` Akhil P Oommen
2026-10-30 10:04 ` [PATCH 6/8] drm/msm/a6xx: Add IFPC tables for Adreno 640/680 Konrad Dybcio
2026-11-26 19:26 ` Akhil P Oommen
2026-10-30 10:04 ` [PATCH RFT 7/8] drm/msm/a6xx: Add IFPC tables for Adreno 650 family Konrad Dybcio
2026-11-19 6:20 ` Demeter Barna
2026-11-26 19:33 ` Akhil P Oommen
2026-10-30 10:04 ` [PATCH RFT 8/8] drm/msm/a6xx: Wire up IFPC on A615-family GPUs Konrad Dybcio
2026-11-26 19:42 ` Akhil P Oommen
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=ea19dcb2-9d9e-4d6c-86f5-72a677fca5b8@oss.qualcomm.com \
--to=akhilpo@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jesszhan0024@gmail.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=robin.clark@oss.qualcomm.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
/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
all inboxes | Powered by JetHome®