drm/amd/pm: add get_dpm_ultimate_freq function for cyan skillfish
Subsystems (3)
PATCH 1/2 drm/amd/pm: add get_dpm_ultimate_freq function for cyan skillfish
Some clients(e.g., kfd) query sclk/mclk through this function.
Before this patch:
# /opt/rocm/opencl/bin/clinfo
Max clock frequency: 0Mhz
After this patch:
# /opt/rocm/opencl/bin/clinfo
Max clock frequency: 1500Mhz
--- drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +9 -0
@@ -552,6 +552,14 @@ static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu,return ret; } +static int cyan_skillfish_get_dpm_ultimate_freq (struct smu_context *smu, +enum smu_clk_type clk_type, +uint32_t *min, +uint32_t *max) +{ +return cyan_skillfish_get_current_clk_freq (smu, clk_type, min ? min : max); +} +static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status,
@@ -565,6 +573,7 @@ static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .is_dpm_running = cyan_skillfish_is_dpm_running, .get_gpu_metrics = cyan_skillfish_get_gpu_metrics, .od_edit_dpm_table = cyan_skillfish_od_edit_dpm_table, + .get_dpm_ultimate_freq = cyan_skillfish_get_dpm_ultimate_freq, .register_irq_handler = smu_v11_0_register_irq_handler, .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location, .send_smc_msg_with_param = smu_cmn_send_smc_msg_with_param,
Signature · 1 line
2.25.1
PATCH 2/2 drm/amd/pm: use existing fini_smc_tables function for cyan skillfish
Remove redundant code and use general smu_v11_0_fini_smc_tables function.
--- .../amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +1 -17
@@ -125,22 +125,6 @@ static int cyan_skillfish_init_smc_tables(struct smu_context *smu)return smu_v11_0_init_smc_tables (smu); } -static int cyan_skillfish_finit_smc_tables (struct smu_context *smu) -{ -struct smu_table_context *smu_table = &smu->smu_table; - -kfree (smu_table->metrics_table); - smu_table->metrics_table =NULL ; - -kfree (smu_table->gpu_metrics_table); - smu_table->gpu_metrics_table =NULL ; - smu_table->gpu_metrics_table_size =0 ; - - smu_table->metrics_time =0 ; - -return 0 ; -} - static int cyan_skillfish_get_smu_metrics_data(struct smu_context *smu, MetricsMember_t member,
@@ -567,7 +551,7 @@ static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .init_power = smu_v11_0_init_power, .fini_power = smu_v11_0_fini_power, .init_smc_tables = cyan_skillfish_init_smc_tables, - .fini_smc_tables = cyan_skillfish_finit_smc_tables, + .fini_smc_tables = smu_v11_0_fini_smc_tables, .read_sensor = cyan_skillfish_read_sensor, .print_clk_levels = cyan_skillfish_print_clk_levels, .is_dpm_running = cyan_skillfish_is_dpm_running,
Signature · 1 line
2.25.1
Re: [PATCH 2/2] drm/amd/pm: use existing fini_smc_tables function for cyan skillfish
Quoted 3 lines · Lang
Remove redundant code and use general
smu_v11_0_fini_smc_tablesfunction.Signed-off-by Lang Yu <[email protected]>
Quoted 43 lines
--- .../amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +1
-17@@ -125,22 +125,6 @@ static int cyan_skillfish_init_smc_tables(struct smu_context *smu)return smu_v11_0_init_smc_tables (smu); } -static int cyan_skillfish_finit_smc_tables (struct smu_context *smu) -{ -struct smu_table_context *smu_table = &smu->smu_table; - -kfree (smu_table->metrics_table); - smu_table->metrics_table =NULL ; - -kfree (smu_table->gpu_metrics_table); - smu_table->gpu_metrics_table =NULL ; - smu_table->gpu_metrics_table_size =0 ; - - smu_table->metrics_time =0 ; - -return 0 ; -} - static int cyan_skillfish_get_smu_metrics_data(struct smu_context *smu, MetricsMember_t member,@@ -567,7 +551,7 @@ static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .init_power = smu_v11_0_init_power, .fini_power = smu_v11_0_fini_power, .init_smc_tables = cyan_skillfish_init_smc_tables, - .fini_smc_tables = cyan_skillfish_finit_smc_tables, + .fini_smc_tables = smu_v11_0_fini_smc_tables, .read_sensor = cyan_skillfish_read_sensor, .print_clk_levels = cyan_skillfish_print_clk_levels, .is_dpm_running = cyan_skillfish_is_dpm_running,Signature · 1 line
2.25.1
Quoted 22 lines · Lang
Some
clients(e.g., kfd)query sclk/mclk through this function.Before this patch:
# /opt/rocm/opencl/bin/clinfoMax clock frequency: 0Mhz
After this patch:
# /opt/rocm/opencl/bin/clinfoMax clock frequency: 1500Mhz
Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +0
-0
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu, · line 559
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +5
-0@@ -552,6 +552,14 @@ static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu,return ret; } +static int cyan_skillfish_get_dpm_ultimate_freq (struct smu_context *smu, +enum smu_clk_type clk_type, +uint32_t *min, +uint32_t *max) +{
We need to add comment here to explain in Cyan Skillfish, the clock is constant and not changed. So here, min = max = current clock.
With that updated, patch is Reviewed-by: Huang Rui <[email protected]>
Quoted 17 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +4
-0+return cyan_skillfish_get_current_clk_freq (smu, clk_type, min ? min : max); +} +static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status,@@ -565,6 +573,7 @@ static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .is_dpm_running = cyan_skillfish_is_dpm_running, .get_gpu_metrics = cyan_skillfish_get_gpu_metrics, .od_edit_dpm_table = cyan_skillfish_od_edit_dpm_table, + .get_dpm_ultimate_freq = cyan_skillfish_get_dpm_ultimate_freq, .register_irq_handler = smu_v11_0_register_irq_handler, .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location, .send_smc_msg_with_param = smu_cmn_send_smc_msg_with_param,Signature · 1 line
2.25.1
Quoted 23 lines · Lang Yu
Some
clients(e.g., kfd)query sclk/mclk through this function.Before this patch:
# /opt/rocm/opencl/bin/clinfoMax clock frequency: 0Mhz
After this patch:
# /opt/rocm/opencl/bin/clinfoMax clock frequency: 1500Mhz
Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +0
-0@@ -552,6 +552,14 @@ static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu,return ret;
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu, · line 562
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +8
-0} +static int cyan_skillfish_get_dpm_ultimate_freq (struct smu_context *smu, +enum smu_clk_type clk_type, +uint32_t *min, +uint32_t *max) +{ +return cyan_skillfish_get_current_clk_freq (smu, clk_type, min ? min : max); +} +
I see the below logic already there and this patch doesn't match with that.
case SMU_GFXCLK:
ret = cyan_skillfish_get_current_clk_freq(smu,
clk_type, &cur_value);
if (ret)
return ret;
if (cur_value == CYAN_SKILLFISH_SCLK_MAX)
i = 2;
else if (cur_value == CYAN_SKILLFISH_SCLK_MIN)
i = 0;
else
i = 1;
size += sysfs_emit_at(buf, size, "0: %uMhz %s\n",
CYAN_SKILLFISH_SCLK_MIN,
i == 0 ? "*" : "");
size += sysfs_emit_at(buf, size, "1: %uMhz %s\n",
i == 1 ? cur_value :
cyan_skillfish_sclk_default,
i == 1 ? "*" : "");
size += sysfs_emit_at(buf, size, "2: %uMhz %s\n",
CYAN_SKILLFISH_SCLK_MAX,
i == 2 ? "*" : "");
break;Thanks,
Lijo
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +1
-0static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status,@@ -565,6 +573,7 @@ static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .is_dpm_running = cyan_skillfish_is_dpm_running, .get_gpu_metrics = cyan_skillfish_get_gpu_metrics, .od_edit_dpm_table = cyan_skillfish_od_edit_dpm_table, + .get_dpm_ultimate_freq = cyan_skillfish_get_dpm_ultimate_freq, .register_irq_handler = smu_v11_0_register_irq_handler, .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location, .send_smc_msg_with_param = smu_cmn_send_smc_msg_with_param,
Quoted 52 lines · Lijo
Quoted 22 lines · Lang Yu
Some
clients(e.g., kfd)query sclk/mclk through this function.Before this patch:
# /opt/rocm/opencl/bin/clinfoMax clock frequency: 0Mhz
After this patch:
# /opt/rocm/opencl/bin/clinfoMax clock frequency: 1500Mhz
Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +0
-0drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu, · line 561
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +8
-0@@ -552,6 +552,14 @@ static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu,return ret; } +static int cyan_skillfish_get_dpm_ultimate_freq (struct smu_context *smu, +enum smu_clk_type clk_type, +uint32_t *min, +uint32_t *max) +{ +return cyan_skillfish_get_current_clk_freq (smu, clk_type, min ? min : max); +} +I see the below logic already there and this patch doesn't match with that.
case
SMU_GFXCLK:
ret = cyan_skillfish_get_current_clk_freq(smu,clk_type,&cur_value); if (ret) return ret; if (cur_value == CYAN_SKILLFISH_SCLK_MAX) i = 2; else if (cur_value == CYAN_SKILLFISH_SCLK_MIN) i = 0; else i = 1; size += sysfs_emit_at(buf, size, "0: %uMhz %s\n", CYAN_SKILLFISH_SCLK_MIN, i == 0 ? "*" : "");
Quoted 8 lines
size += sysfs_emit_at(buf, size, "1: %uMhz %s\n",
i == 1 ? cur_value :
cyan_skillfish_sclk_default,
i == 1 ? "*" : "");
size += sysfs_emit_at(buf, size, "2: %uMhz %s\n",
CYAN_SKILLFISH_SCLK_MAX,
i == 2 ? "*" : "");
break;Thanks for your comments. To maintain the logic, for sclk, just set min/max to CYAN_SKILLFISH_SCLK_MIN/CYAN_SKILLFISH_SCLK_MAX. For others, set min=max=current. What do you think? Thanks!
Regards,
Lang
Quoted 15 lines
Thanks,
LijoQuoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +1
-0static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status,@@ -565,6 +573,7 @@ static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .is_dpm_running = cyan_skillfish_is_dpm_running, .get_gpu_metrics = cyan_skillfish_get_gpu_metrics, .od_edit_dpm_table = cyan_skillfish_od_edit_dpm_table, + .get_dpm_ultimate_freq = cyan_skillfish_get_dpm_ultimate_freq, .register_irq_handler = smu_v11_0_register_irq_handler, .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location, .send_smc_msg_with_param = smu_cmn_send_smc_msg_with_param,
Quoted 62 lines · Lang Yu
Quoted 52 lines · Lijo
Quoted 22 lines · Lang Yu
Some
clients(e.g., kfd)query sclk/mclk through this function.Before this patch:
# /opt/rocm/opencl/bin/clinfoMax clock frequency: 0Mhz
After this patch:
# /opt/rocm/opencl/bin/clinfoMax clock frequency: 1500Mhz
Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +0
-0drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu, · line 561
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +8
-0@@ -552,6 +552,14 @@ static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu,return ret; } +static int cyan_skillfish_get_dpm_ultimate_freq (struct smu_context *smu, +enum smu_clk_type clk_type, +uint32_t *min, +uint32_t *max) +{ +return cyan_skillfish_get_current_clk_freq (smu, clk_type, min ? min : max); +} +I see the below logic already there and this patch doesn't match with that.
case
SMU_GFXCLK:
ret = cyan_skillfish_get_current_clk_freq(smu,clk_type,&cur_value); if (ret) return ret; if (cur_value == CYAN_SKILLFISH_SCLK_MAX) i = 2; else if (cur_value == CYAN_SKILLFISH_SCLK_MIN) i = 0; else i = 1; size += sysfs_emit_at(buf, size, "0: %uMhz %s\n", CYAN_SKILLFISH_SCLK_MIN, i == 0 ? "*" : "");Quoted 8 lines
size += sysfs_emit_at(buf, size, "1: %uMhz %s\n", i == 1 ? cur_value : cyan_skillfish_sclk_default, i == 1 ? "*" : ""); size += sysfs_emit_at(buf, size, "2: %uMhz %s\n", CYAN_SKILLFISH_SCLK_MAX, i == 2 ? "*" : ""); break;
Quoted 4 lines
Thanks for your comments. To maintain the logic, for sclk, just set min/max to CYAN_SKILLFISH_SCLK_MIN/CYAN_SKILLFISH_SCLK_MAX. For others, set min=max=current. What do you think? Thanks!
Should be fine. Also, from API perspective - make sure to check both min/max args for non-null and assign values to both when they are not null (doesn't matter whether min=max).
Thanks,
Lijo
Quoted 18 lines
Regards,
LangQuoted 15 lines
Thanks,
LijoQuoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +1
-0static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status,@@ -565,6 +573,7 @@ static const struct pptable_funcs cyan_skillfish_ppt_funcs = { .is_dpm_running = cyan_skillfish_is_dpm_running, .get_gpu_metrics = cyan_skillfish_get_gpu_metrics, .od_edit_dpm_table = cyan_skillfish_od_edit_dpm_table, + .get_dpm_ultimate_freq = cyan_skillfish_get_dpm_ultimate_freq, .register_irq_handler = smu_v11_0_register_irq_handler, .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location, .send_smc_msg_with_param = smu_cmn_send_smc_msg_with_param,