diff options
| author | Apurv Mishra <Apurv.Mishra@amd.com> | 2026-10-26 14:15:48 -0400 |
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2026-11-09 17:34:26 -0500 |
| commit | 8a2a988911847974c7bc4dafd4ff6eee93470b06 (patch) | |
| tree | de937613ed53b49bdc63e4255518d7b9b632a5f4 /include/uapi/linux | |
| parent | 8a4dfdc0d2adfc362ec310ff70526e79ff8377b6 (diff) | |
| download | linux-next-8a2a988911847974c7bc4dafd4ff6eee93470b06.tar.gz linux-next-8a2a988911847974c7bc4dafd4ff6eee93470b06.zip | |
drm/amdkfd: Force perfmon clock on for profiler PMC requests
Counters and SQ/PC sampling read 0 at DPM AUTO on gfx11/gfx12 because
RLC_CGTT_MGCG_OVERRIDE.PERFMON_CLOCK_STATE is gated, and the existing
workaround (STABLE_STD) needs root and pins clocks.
Add a refcounted amdgpu_gfx_perfmon_clk_override() that forces the
perfmon clock on per XCC, keeps GFXOFF disallowed while held, and
restores the previous state on last release, resume and reset.
perfmon_clk_mutex serializes it with the GFX clock gating sequences
and the soc21/soc24 stable pstate hook.
Use it from KFD_IOC_PROFILER_PMC, after binding the process to the GPU
and under reset_domain->sem:
- lock=1 (device mode, CAP_PERFMON): held until unlock or exit.
- lock=0, perfcount_enable=1 (dispatch mode): no CAP_PERFMON needed,
held until lock=0, perfcount_enable=0 or process exit.
No DPM change, no new ioctl, no struct change. Bump
KFD_IOC_PROFILER_VERSION_NUM to 2.
v2:
- Take GFXOFF outside perfmon_clk_mutex to break a pm.mutex lock cycle
- Replace the racy defer() with amdgpu_gfx_perfmon_clk_update(), and hold
perfmon_clk_mutex across the GFX clock gating sequences
- Bind the process to the GPU before forcing the perfmon clock on
- Take reset_domain->sem before profiler_lock
- Release a dispatch-mode hold with lock=0, perfcount_enable=0
v3: Add lockdep_assert_held() in amdgpu_gfx_perfmon_clk_program().
Proposed userspace:
https://github.com/ROCm/rocm-systems/pull/14521
Signed-off-by: Apurv Mishra <Apurv.Mishra@amd.com>
Tested-by: Jason Tang <Jason.Tang@amd.com>
Reviewed-by: James Zhu <James.Zhu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/kfd_ioctl.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h index 564faefe6978..3d608d6b0ab8 100644 --- a/include/uapi/linux/kfd_ioctl.h +++ b/include/uapi/linux/kfd_ioctl.h @@ -1558,7 +1558,16 @@ struct kfd_ioctl_dbg_trap_args { }; }; -#define KFD_IOC_PROFILER_VERSION_NUM 1 +/* + * KFD_IOC_PROFILER_VERSION_NUM history: + * - 1 - initial version + * - 2 - KFD_IOC_PROFILER_PMC lock also forces the perfmon clock on until the + * lock is released or the process exits. lock == 0 with + * perfcount_enable == 1 forces it on without CAP_PERFMON and without + * locking, until lock == 0 with perfcount_enable == 0 or the process + * exits + */ +#define KFD_IOC_PROFILER_VERSION_NUM 2 enum kfd_profiler_ops { KFD_IOC_PROFILER_PMC = 0, KFD_IOC_PROFILER_VERSION = 2, |
