]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amd/pm: add the interface to dump smu metrics table for vangogh
authorXiaojian Du <Xiaojian.Du@amd.com>
Tue, 3 Nov 2020 07:53:31 +0000 (15:53 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 13 Nov 2020 05:12:32 +0000 (00:12 -0500)
This patch is to add the interface to dump smu metrics table for vangogh.

Signed-off-by: Xiaojian Du <Xiaojian.Du@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c

index dc06459af91cc04e92fb56900515e0c6c891fc52..5ad693312187d97c9cb6a16b18b4009a8d90506f 100644 (file)
@@ -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_v2_0(struct gpu_metrics_v2_0 *gpu_metrics);
+
 int smu_v11_0_gfx_ulv_control(struct smu_context *smu,
                              bool enablement);
 
index 6b7d1335b46d8fbd10e86ed42c3d9159aa299412..b880c72c322c110f7ddfddbc56c8055ac549a2e7 100644 (file)
@@ -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();
 }
 
+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,
                              bool enablement)
 {
index 83a1b0a04eb160e259c8597c881fcf170b9ecd07..cbcbcd8514f0c0939c8d8f5920ae1d4197752f7a 100644 (file)
@@ -584,6 +584,57 @@ static int vangogh_set_watermarks_table(struct smu_context *smu,
        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 = {
 
        .check_fw_status = smu_v11_0_check_fw_status,
@@ -607,6 +658,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = {
        .set_driver_table_location = smu_v11_0_set_driver_table_location,
        .disable_all_features_with_exception = smu_cmn_disable_all_features_with_exception,
        .interrupt_work = smu_v11_0_interrupt_work,
+       .get_gpu_metrics = vangogh_get_gpu_metrics,
 };
 
 void vangogh_set_ppt_funcs(struct smu_context *smu)