66
66
67
67
#define MP0_MP1_DATA_REGION_SIZE_COMBOPPTABLE 0x4000
68
68
#define DEBUGSMC_MSG_Mode1Reset 2
69
+ #define LINK_SPEED_MAX 3
69
70
70
71
static struct cmn2asic_msg_mapping smu_v14_0_2_message_map [SMU_MSG_MAX_COUNT ] = {
71
72
MSG_MAP (TestMessage , PPSMC_MSG_TestMessage , 1 ),
@@ -221,7 +222,6 @@ static struct cmn2asic_mapping smu_v14_0_2_workload_map[PP_SMC_POWER_PROFILE_COU
221
222
WORKLOAD_MAP (PP_SMC_POWER_PROFILE_WINDOW3D , WORKLOAD_PPLIB_WINDOW_3D_BIT ),
222
223
};
223
224
224
- #if 0
225
225
static const uint8_t smu_v14_0_2_throttler_map [] = {
226
226
[THROTTLER_PPT0_BIT ] = (SMU_THROTTLER_PPT0_BIT ),
227
227
[THROTTLER_PPT1_BIT ] = (SMU_THROTTLER_PPT1_BIT ),
@@ -241,7 +241,6 @@ static const uint8_t smu_v14_0_2_throttler_map[] = {
241
241
[THROTTLER_GFX_APCC_PLUS_BIT ] = (SMU_THROTTLER_APCC_BIT ),
242
242
[THROTTLER_FIT_BIT ] = (SMU_THROTTLER_FIT_BIT ),
243
243
};
244
- #endif
245
244
246
245
static int
247
246
smu_v14_0_2_get_allowed_feature_mask (struct smu_context * smu ,
@@ -1869,6 +1868,88 @@ static ssize_t smu_v14_0_2_get_ecc_info(struct smu_context *smu,
1869
1868
return ret ;
1870
1869
}
1871
1870
1871
+ static ssize_t smu_v14_0_2_get_gpu_metrics (struct smu_context * smu ,
1872
+ void * * table )
1873
+ {
1874
+ struct smu_table_context * smu_table = & smu -> smu_table ;
1875
+ struct gpu_metrics_v1_3 * gpu_metrics =
1876
+ (struct gpu_metrics_v1_3 * )smu_table -> gpu_metrics_table ;
1877
+ SmuMetricsExternal_t metrics_ext ;
1878
+ SmuMetrics_t * metrics = & metrics_ext .SmuMetrics ;
1879
+ int ret = 0 ;
1880
+
1881
+ ret = smu_cmn_get_metrics_table (smu ,
1882
+ & metrics_ext ,
1883
+ true);
1884
+ if (ret )
1885
+ return ret ;
1886
+
1887
+ smu_cmn_init_soft_gpu_metrics (gpu_metrics , 1 , 3 );
1888
+
1889
+ gpu_metrics -> temperature_edge = metrics -> AvgTemperature [TEMP_EDGE ];
1890
+ gpu_metrics -> temperature_hotspot = metrics -> AvgTemperature [TEMP_HOTSPOT ];
1891
+ gpu_metrics -> temperature_mem = metrics -> AvgTemperature [TEMP_MEM ];
1892
+ gpu_metrics -> temperature_vrgfx = metrics -> AvgTemperature [TEMP_VR_GFX ];
1893
+ gpu_metrics -> temperature_vrsoc = metrics -> AvgTemperature [TEMP_VR_SOC ];
1894
+ gpu_metrics -> temperature_vrmem = max (metrics -> AvgTemperature [TEMP_VR_MEM0 ],
1895
+ metrics -> AvgTemperature [TEMP_VR_MEM1 ]);
1896
+
1897
+ gpu_metrics -> average_gfx_activity = metrics -> AverageGfxActivity ;
1898
+ gpu_metrics -> average_umc_activity = metrics -> AverageUclkActivity ;
1899
+ gpu_metrics -> average_mm_activity = max (metrics -> Vcn0ActivityPercentage ,
1900
+ metrics -> Vcn1ActivityPercentage );
1901
+
1902
+ gpu_metrics -> average_socket_power = metrics -> AverageSocketPower ;
1903
+ gpu_metrics -> energy_accumulator = metrics -> EnergyAccumulator ;
1904
+
1905
+ if (metrics -> AverageGfxActivity <= SMU_14_0_2_BUSY_THRESHOLD )
1906
+ gpu_metrics -> average_gfxclk_frequency = metrics -> AverageGfxclkFrequencyPostDs ;
1907
+ else
1908
+ gpu_metrics -> average_gfxclk_frequency = metrics -> AverageGfxclkFrequencyPreDs ;
1909
+
1910
+ if (metrics -> AverageUclkActivity <= SMU_14_0_2_BUSY_THRESHOLD )
1911
+ gpu_metrics -> average_uclk_frequency = metrics -> AverageMemclkFrequencyPostDs ;
1912
+ else
1913
+ gpu_metrics -> average_uclk_frequency = metrics -> AverageMemclkFrequencyPreDs ;
1914
+
1915
+ gpu_metrics -> average_vclk0_frequency = metrics -> AverageVclk0Frequency ;
1916
+ gpu_metrics -> average_dclk0_frequency = metrics -> AverageDclk0Frequency ;
1917
+ gpu_metrics -> average_vclk1_frequency = metrics -> AverageVclk1Frequency ;
1918
+ gpu_metrics -> average_dclk1_frequency = metrics -> AverageDclk1Frequency ;
1919
+
1920
+ gpu_metrics -> current_gfxclk = gpu_metrics -> average_gfxclk_frequency ;
1921
+ gpu_metrics -> current_socclk = metrics -> CurrClock [PPCLK_SOCCLK ];
1922
+ gpu_metrics -> current_uclk = metrics -> CurrClock [PPCLK_UCLK ];
1923
+ gpu_metrics -> current_vclk0 = metrics -> CurrClock [PPCLK_VCLK_0 ];
1924
+ gpu_metrics -> current_dclk0 = metrics -> CurrClock [PPCLK_DCLK_0 ];
1925
+ gpu_metrics -> current_vclk1 = metrics -> CurrClock [PPCLK_VCLK_0 ];
1926
+ gpu_metrics -> current_dclk1 = metrics -> CurrClock [PPCLK_DCLK_0 ];
1927
+
1928
+ gpu_metrics -> throttle_status =
1929
+ smu_v14_0_2_get_throttler_status (metrics );
1930
+ gpu_metrics -> indep_throttle_status =
1931
+ smu_cmn_get_indep_throttler_status (gpu_metrics -> throttle_status ,
1932
+ smu_v14_0_2_throttler_map );
1933
+
1934
+ gpu_metrics -> current_fan_speed = metrics -> AvgFanRpm ;
1935
+
1936
+ gpu_metrics -> pcie_link_width = metrics -> PcieWidth ;
1937
+ if ((metrics -> PcieRate - 1 ) > LINK_SPEED_MAX )
1938
+ gpu_metrics -> pcie_link_speed = pcie_gen_to_speed (1 );
1939
+ else
1940
+ gpu_metrics -> pcie_link_speed = pcie_gen_to_speed (metrics -> PcieRate );
1941
+
1942
+ gpu_metrics -> system_clock_counter = ktime_get_boottime_ns ();
1943
+
1944
+ gpu_metrics -> voltage_gfx = metrics -> AvgVoltage [SVI_PLANE_VDD_GFX ];
1945
+ gpu_metrics -> voltage_soc = metrics -> AvgVoltage [SVI_PLANE_VDD_SOC ];
1946
+ gpu_metrics -> voltage_mem = metrics -> AvgVoltage [SVI_PLANE_VDDIO_MEM ];
1947
+
1948
+ * table = (void * )gpu_metrics ;
1949
+
1950
+ return sizeof (struct gpu_metrics_v1_3 );
1951
+ }
1952
+
1872
1953
static const struct pptable_funcs smu_v14_0_2_ppt_funcs = {
1873
1954
.get_allowed_feature_mask = smu_v14_0_2_get_allowed_feature_mask ,
1874
1955
.set_default_dpm_table = smu_v14_0_2_set_default_dpm_table ,
@@ -1905,6 +1986,7 @@ static const struct pptable_funcs smu_v14_0_2_ppt_funcs = {
1905
1986
.enable_thermal_alert = smu_v14_0_enable_thermal_alert ,
1906
1987
.disable_thermal_alert = smu_v14_0_disable_thermal_alert ,
1907
1988
.notify_memory_pool_location = smu_v14_0_notify_memory_pool_location ,
1989
+ .get_gpu_metrics = smu_v14_0_2_get_gpu_metrics ,
1908
1990
.set_soft_freq_limited_range = smu_v14_0_set_soft_freq_limited_range ,
1909
1991
.init_pptable_microcode = smu_v14_0_init_pptable_microcode ,
1910
1992
.populate_umd_state_clk = smu_v14_0_2_populate_umd_state_clk ,
0 commit comments