Commit fd253334 authored by Xiaojian Du's avatar Xiaojian Du Committed by Alex Deucher

drm/amd/pm: add the interface to dump smu metrics table for vangogh

This patch is to add the interface to dump smu metrics table for vangogh.
Signed-off-by: default avatarXiaojian Du <Xiaojian.Du@amd.com>
Reviewed-by: default avatarHuang Rui <ray.huang@amd.com>
Reviewed-by: default avatarEvan Quan <evan.quan@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 55a79cc2
...@@ -276,6 +276,8 @@ int smu_v11_0_get_current_pcie_link_speed(struct smu_context *smu); ...@@ -276,6 +276,8 @@ int smu_v11_0_get_current_pcie_link_speed(struct smu_context *smu);
void smu_v11_0_init_gpu_metrics_v1_0(struct gpu_metrics_v1_0 *gpu_metrics); void smu_v11_0_init_gpu_metrics_v1_0(struct gpu_metrics_v1_0 *gpu_metrics);
void smu_v11_0_init_gpu_metrics_v2_0(struct gpu_metrics_v2_0 *gpu_metrics);
int smu_v11_0_gfx_ulv_control(struct smu_context *smu, int smu_v11_0_gfx_ulv_control(struct smu_context *smu,
bool enablement); bool enablement);
......
...@@ -1999,6 +1999,18 @@ void smu_v11_0_init_gpu_metrics_v1_0(struct gpu_metrics_v1_0 *gpu_metrics) ...@@ -1999,6 +1999,18 @@ void smu_v11_0_init_gpu_metrics_v1_0(struct gpu_metrics_v1_0 *gpu_metrics)
gpu_metrics->system_clock_counter = ktime_get_boottime_ns(); gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
} }
void smu_v11_0_init_gpu_metrics_v2_0(struct gpu_metrics_v2_0 *gpu_metrics)
{
memset(gpu_metrics, 0xFF, sizeof(struct gpu_metrics_v2_0));
gpu_metrics->common_header.structure_size =
sizeof(struct gpu_metrics_v2_0);
gpu_metrics->common_header.format_revision = 2;
gpu_metrics->common_header.content_revision = 0;
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
}
int smu_v11_0_gfx_ulv_control(struct smu_context *smu, int smu_v11_0_gfx_ulv_control(struct smu_context *smu,
bool enablement) bool enablement)
{ {
......
...@@ -584,6 +584,57 @@ static int vangogh_set_watermarks_table(struct smu_context *smu, ...@@ -584,6 +584,57 @@ static int vangogh_set_watermarks_table(struct smu_context *smu,
return 0; return 0;
} }
static ssize_t vangogh_get_gpu_metrics(struct smu_context *smu,
void **table)
{
struct smu_table_context *smu_table = &smu->smu_table;
struct gpu_metrics_v2_0 *gpu_metrics =
(struct gpu_metrics_v2_0 *)smu_table->gpu_metrics_table;
SmuMetrics_t metrics;
int ret = 0;
ret = smu_cmn_get_metrics_table(smu, &metrics, true);
if (ret)
return ret;
smu_v11_0_init_gpu_metrics_v2_0(gpu_metrics);
gpu_metrics->temperature_gfx = metrics.GfxTemperature;
gpu_metrics->temperature_soc = metrics.SocTemperature;
memcpy(&gpu_metrics->temperature_core[0],
&metrics.CoreTemperature[0],
sizeof(uint16_t) * 8);
gpu_metrics->temperature_l3[0] = metrics.L3Temperature[0];
gpu_metrics->temperature_l3[1] = metrics.L3Temperature[1];
gpu_metrics->average_gfx_activity = metrics.GfxActivity;
gpu_metrics->average_mm_activity = metrics.UvdActivity;
gpu_metrics->average_socket_power = metrics.CurrentSocketPower;
gpu_metrics->average_cpu_power = metrics.Power[0];
gpu_metrics->average_soc_power = metrics.Power[1];
memcpy(&gpu_metrics->average_core_power[0],
&metrics.CorePower[0],
sizeof(uint16_t) * 8);
gpu_metrics->average_gfxclk_frequency = metrics.GfxclkFrequency;
gpu_metrics->average_socclk_frequency = metrics.SocclkFrequency;
gpu_metrics->average_fclk_frequency = metrics.MemclkFrequency;
gpu_metrics->average_vclk_frequency = metrics.VclkFrequency;
memcpy(&gpu_metrics->current_coreclk[0],
&metrics.CoreFrequency[0],
sizeof(uint16_t) * 8);
gpu_metrics->current_l3clk[0] = metrics.L3Frequency[0];
gpu_metrics->current_l3clk[1] = metrics.L3Frequency[1];
gpu_metrics->throttle_status = metrics.ThrottlerStatus;
*table = (void *)gpu_metrics;
return sizeof(struct gpu_metrics_v2_0);
}
static const struct pptable_funcs vangogh_ppt_funcs = { static const struct pptable_funcs vangogh_ppt_funcs = {
.check_fw_status = smu_v11_0_check_fw_status, .check_fw_status = smu_v11_0_check_fw_status,
...@@ -607,6 +658,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = { ...@@ -607,6 +658,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = {
.set_driver_table_location = smu_v11_0_set_driver_table_location, .set_driver_table_location = smu_v11_0_set_driver_table_location,
.disable_all_features_with_exception = smu_cmn_disable_all_features_with_exception, .disable_all_features_with_exception = smu_cmn_disable_all_features_with_exception,
.interrupt_work = smu_v11_0_interrupt_work, .interrupt_work = smu_v11_0_interrupt_work,
.get_gpu_metrics = vangogh_get_gpu_metrics,
}; };
void vangogh_set_ppt_funcs(struct smu_context *smu) void vangogh_set_ppt_funcs(struct smu_context *smu)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment