From: Alex Deucher <alexander.deucher@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Alex Sierra <alex.sierra@amd.com>,
Mukul Joshi <mukul.joshi@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>
Subject: [PATCH 3/4] drm/amdgpu: add get_gpu_clock_counter to smuio v14_0_3
Date: Wed, 29 Oct 2025 13:53:52 -0400 [thread overview]
Message-ID: <20251029175353.2861924-3-alexander.deucher@amd.com> (raw)
In-Reply-To: <20251029175353.2861924-1-alexander.deucher@amd.com>
From: Alex Sierra <alex.sierra@amd.com>
Function get_gpu_clock_counter missing for smuio v14_0_3
Signed-off-by: Alex Sierra <alex.sierra@amd.com>
Reviewed-by: Mukul Joshi <mukul.joshi@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/smuio_v14_0_3.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_3.c b/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_3.c
index 804b7458b0661..f48ef572d9b41 100644
--- a/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_3.c
@@ -44,6 +44,25 @@ static void smuio_v14_0_3_update_rom_clock_gating(struct amdgpu_device *adev, bo
return;
}
+static u64 smuio_v14_0_3_get_gpu_clock_counter(struct amdgpu_device *adev)
+{
+ u64 clock;
+ u64 clock_counter_lo, clock_counter_hi_pre, clock_counter_hi_after;
+
+ preempt_disable();
+ clock_counter_hi_pre = (u64)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_UPPER);
+ clock_counter_lo = (u64)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_LOWER);
+ /* the clock counter may be udpated during polling the counters */
+ clock_counter_hi_after = (u64)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_UPPER);
+ if (clock_counter_hi_pre != clock_counter_hi_after)
+ clock_counter_lo = (u64)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_LOWER);
+ preempt_enable();
+
+ clock = clock_counter_lo | (clock_counter_hi_after << 32ULL);
+
+ return clock;
+}
+
static void smuio_v14_0_3_get_clock_gating_state(struct amdgpu_device *adev, u64 *flags)
{
u32 data;
@@ -184,6 +203,7 @@ static bool smuio_v14_0_3_is_custom_hbm_supported(struct amdgpu_device *adev)
const struct amdgpu_smuio_funcs smuio_v14_0_3_funcs = {
.get_rom_index_offset = smuio_v14_0_3_get_rom_index_offset,
.get_rom_data_offset = smuio_v14_0_3_get_rom_data_offset,
+ .get_gpu_clock_counter = smuio_v14_0_3_get_gpu_clock_counter,
.get_die_id = smuio_v14_0_3_get_die_id,
.get_socket_id = smuio_v14_0_3_get_socket_id,
.is_host_gpu_xgmi_supported = smuio_v14_0_3_is_host_gpu_xgmi_supported,
--
2.51.0
next prev parent reply other threads:[~2025-10-29 17:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 17:53 [PATCH 1/4] drm/amdgpu: Add smuio v14_0_3 ip headers v3 Alex Deucher
2025-10-29 17:53 ` [PATCH 2/4] drm/amdgpu: Add smuio v14_0_3 support v4 Alex Deucher
2025-10-29 17:53 ` Alex Deucher [this message]
2025-10-29 17:53 ` [PATCH 4/4] drm/amdgpu: add support for smuio v14_0_3 Alex Deucher
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=20251029175353.2861924-3-alexander.deucher@amd.com \
--to=alexander.deucher@amd.com \
--cc=alex.sierra@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=mukul.joshi@amd.com \
/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