[PATCH v2] drm/amd/pm: Use cached data for min/max clocks

Kamal, Asad Asad.Kamal at amd.com
Mon Jul 14 11:05:51 UTC 2025


[AMD Official Use Only - AMD Internal Distribution Only]

Reviewed-by: Asad Kamal <asad.kamal at amd.com>

Thanks & Regards
Asad

-----Original Message-----
From: Lazar, Lijo <Lijo.Lazar at amd.com>
Sent: Monday, July 14, 2025 8:56 AM
To: amd-gfx at lists.freedesktop.org
Cc: Zhang, Hawking <Hawking.Zhang at amd.com>; Deucher, Alexander <Alexander.Deucher at amd.com>; Kamal, Asad <Asad.Kamal at amd.com>
Subject: [PATCH v2] drm/amd/pm: Use cached data for min/max clocks

If dpm tables are already populated on SMU v13.0.6 SOCs, use the cached data. Otherwise, fetch values from firmware.

Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
---
v2: Coding style - reorder declarations and remove unwanted initializations

 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 38 +++++++++----------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
index 68624afe7d83..f2cf333b2e40 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
@@ -881,51 +881,51 @@ static int smu_v13_0_6_get_dpm_ultimate_freq(struct smu_context *smu,
                                             enum smu_clk_type clk_type,
                                             uint32_t *min, uint32_t *max)  {
+       struct smu_13_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context;
        struct smu_table_context *smu_table = &smu->smu_table;
        struct PPTable_t *pptable =
                (struct PPTable_t *)smu_table->driver_pptable;
-       uint32_t clock_limit = 0, param;
+       struct smu_13_0_dpm_table *dpm_table;
+       uint32_t min_clk, max_clk, param;
        int ret = 0, clk_id = 0;

-       if (!smu_cmn_clk_dpm_is_enabled(smu, clk_type)) {
+       /* Use dpm tables, if data is already fetched */
+       if (pptable->Init) {
                switch (clk_type) {
                case SMU_MCLK:
                case SMU_UCLK:
-                       if (pptable->Init)
-                               clock_limit = pptable->UclkFrequencyTable[0];
+                       dpm_table = &dpm_context->dpm_tables.uclk_table;
                        break;
                case SMU_GFXCLK:
                case SMU_SCLK:
-                       if (pptable->Init)
-                               clock_limit = pptable->MinGfxclkFrequency;
+                       dpm_table = &dpm_context->dpm_tables.gfx_table;
                        break;
                case SMU_SOCCLK:
-                       if (pptable->Init)
-                               clock_limit = pptable->SocclkFrequencyTable[0];
+                       dpm_table = &dpm_context->dpm_tables.soc_table;
                        break;
                case SMU_FCLK:
-                       if (pptable->Init)
-                               clock_limit = pptable->FclkFrequencyTable[0];
+                       dpm_table = &dpm_context->dpm_tables.fclk_table;
                        break;
                case SMU_VCLK:
-                       if (pptable->Init)
-                               clock_limit = pptable->VclkFrequencyTable[0];
+                       dpm_table = &dpm_context->dpm_tables.vclk_table;
                        break;
                case SMU_DCLK:
-                       if (pptable->Init)
-                               clock_limit = pptable->DclkFrequencyTable[0];
+                       dpm_table = &dpm_context->dpm_tables.dclk_table;
                        break;
                default:
-                       break;
+                       return -EINVAL;
                }

-               if (min)
-                       *min = clock_limit;
+               min_clk = dpm_table->min;
+               max_clk = dpm_table->max;

+               if (min)
+                       *min = min_clk;
                if (max)
-                       *max = clock_limit;
+                       *max = max_clk;

-               return 0;
+               if (min_clk && max_clk)
+                       return 0;
        }

        if (!(clk_type == SMU_GFXCLK || clk_type == SMU_SCLK)) {
--
2.49.0



More information about the amd-gfx mailing list