Thanks,
Lijo
+ *value = data_u32[PPCLK_GFXCLK];
break;
case METRICS_CURR_SOCCLK:
- *value = metrics->CurrClock[PPCLK_SOCCLK];
+ GET_METRICS_MEMBER(CurrClock, &data_u32);
+ *value = data_u32[PPCLK_SOCCLK];
break;
case METRICS_CURR_UCLK:
- *value = metrics->CurrClock[PPCLK_UCLK];
+ GET_METRICS_MEMBER(CurrClock, &data_u32);
+ *value = data_u32[PPCLK_UCLK];
break;
case METRICS_CURR_VCLK:
- *value = metrics->CurrClock[PPCLK_VCLK_0];
+ GET_METRICS_MEMBER(CurrClock, &data_u32);
+ *value = data_u32[PPCLK_VCLK_0];
break;
case METRICS_CURR_VCLK1:
- *value = metrics->CurrClock[PPCLK_VCLK_1];
+ GET_METRICS_MEMBER(CurrClock, &data_u32);
+ *value = data_u32[PPCLK_VCLK_1];
break;
case METRICS_CURR_DCLK:
- *value = metrics->CurrClock[PPCLK_DCLK_0];
+ GET_METRICS_MEMBER(CurrClock, &data_u32);
+ *value = data_u32[PPCLK_DCLK_0];
break;
case METRICS_CURR_DCLK1:
- *value = metrics->CurrClock[PPCLK_DCLK_1];
+ GET_METRICS_MEMBER(CurrClock, &data_u32);
+ *value = data_u32[PPCLK_DCLK_1];
break;
case METRICS_CURR_DCEFCLK:
- *value = metrics->CurrClock[PPCLK_DCEFCLK];
+ GET_METRICS_MEMBER(CurrClock, &data_u32);
+ *value = data_u32[PPCLK_DCEFCLK];
break;
case METRICS_CURR_FCLK:
- *value = metrics->CurrClock[PPCLK_FCLK];
+ GET_METRICS_MEMBER(CurrClock, &data_u32);
+ *value = data_u32[PPCLK_FCLK];
break;
case METRICS_AVERAGE_GFXCLK:
- if (metrics->AverageGfxActivity <=
SMU_11_0_7_GFX_BUSY_THRESHOLD)
- *value = metrics->AverageGfxclkFrequencyPostDs;
+ GET_METRICS_MEMBER(AverageGfxActivity, &data_u16);
+ if (*data_u16 <= SMU_11_0_7_GFX_BUSY_THRESHOLD)
+
GET_METRICS_MEMBER(AverageGfxclkFrequencyPostDs,
&data_u16);
else
- *value = metrics->AverageGfxclkFrequencyPreDs;
+
GET_METRICS_MEMBER(AverageGfxclkFrequencyPreDs,
&data_u16);
+ *value = *data_u16;
break;
case METRICS_AVERAGE_FCLK:
- *value = metrics->AverageFclkFrequencyPostDs;
+ GET_METRICS_MEMBER(AverageFclkFrequencyPostDs,
&data_u16);
+ *value = *data_u16;
break;
case METRICS_AVERAGE_UCLK:
- *value = metrics->AverageUclkFrequencyPostDs;
+ GET_METRICS_MEMBER(AverageUclkFrequencyPostDs,
&data_u16);
+ *value = *data_u16;
break;
case METRICS_AVERAGE_GFXACTIVITY:
- *value = metrics->AverageGfxActivity;
+ GET_METRICS_MEMBER(AverageGfxActivity, &data_u16);
+ *value = *data_u16;
break;
case METRICS_AVERAGE_MEMACTIVITY:
- *value = metrics->AverageUclkActivity;
+ GET_METRICS_MEMBER(AverageUclkActivity, &data_u16);
+ *value = *data_u16;
break;
case METRICS_AVERAGE_SOCKETPOWER:
- *value = metrics->AverageSocketPower << 8;
+ GET_METRICS_MEMBER(AverageSocketPower, &data_u16);
+ *value = *data_u16 << 8;
break;
case METRICS_TEMPERATURE_EDGE:
- *value = metrics->TemperatureEdge *
+ GET_METRICS_MEMBER(TemperatureEdge, &data_u16);
+ *value = *data_u16 *
SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
break;
case METRICS_TEMPERATURE_HOTSPOT:
- *value = metrics->TemperatureHotspot *
+ GET_METRICS_MEMBER(TemperatureHotspot, &data_u16);
+ *value = *data_u16 *
SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
break;
case METRICS_TEMPERATURE_MEM:
- *value = metrics->TemperatureMem *
+ GET_METRICS_MEMBER(TemperatureMem, &data_u16);
+ *value = *data_u16 *
SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
break;
case METRICS_TEMPERATURE_VRGFX:
- *value = metrics->TemperatureVrGfx *
+ GET_METRICS_MEMBER(TemperatureVrGfx, &data_u16);
+ *value = *data_u16 *
SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
break;
case METRICS_TEMPERATURE_VRSOC:
- *value = metrics->TemperatureVrSoc *
+ GET_METRICS_MEMBER(TemperatureVrSoc, &data_u16);
+ *value = *data_u16 *
SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
break;
case METRICS_THROTTLER_STATUS:
- *value = metrics->ThrottlerStatus;
+ *value = sienna_cichlid_get_throttler_status_locked(smu);
break;
case METRICS_CURR_FANSPEED:
- *value = metrics->CurrFanSpeed;
+ GET_METRICS_MEMBER(CurrFanSpeed, &data_u16);
+ *value = *data_u16;
break;
default:
*value = UINT_MAX;
@@ -3564,68 +3613,103 @@ static ssize_t
sienna_cichlid_get_gpu_metrics(struct smu_context *smu,
struct smu_table_context *smu_table = &smu->smu_table;
struct gpu_metrics_v1_3 *gpu_metrics =
(struct gpu_metrics_v1_3 *)smu_table->gpu_metrics_table;
- SmuMetricsExternal_t metrics_external;
- SmuMetrics_t *metrics =
- &(metrics_external.SmuMetrics);
- struct amdgpu_device *adev = smu->adev;
- uint32_t smu_version;
+ uint32_t *data_u32;
+ uint16_t *data_u16;
+ uint8_t *data_u8;
int ret = 0;
- ret = smu_cmn_get_metrics_table(smu,
- &metrics_external,
- true);
- if (ret)
+ mutex_lock(&smu->metrics_lock);
+
+ ret = smu_cmn_get_metrics_table_locked(smu,
+ NULL,
+ true);
+ if (ret) {
+ mutex_unlock(&smu->metrics_lock);
return ret;
+ }
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
- gpu_metrics->temperature_edge = metrics->TemperatureEdge;
- gpu_metrics->temperature_hotspot = metrics-
TemperatureHotspot;
- gpu_metrics->temperature_mem = metrics->TemperatureMem;
- gpu_metrics->temperature_vrgfx = metrics->TemperatureVrGfx;
- gpu_metrics->temperature_vrsoc = metrics->TemperatureVrSoc;
- gpu_metrics->temperature_vrmem = metrics-
TemperatureVrMem0;
+ GET_METRICS_MEMBER(TemperatureEdge, &data_u16);
+ gpu_metrics->temperature_edge = *data_u16;
+
+ GET_METRICS_MEMBER(TemperatureHotspot, &data_u16);
+ gpu_metrics->temperature_hotspot = *data_u16;
+
+ GET_METRICS_MEMBER(TemperatureMem, &data_u16);
+ gpu_metrics->temperature_mem = *data_u16;
+
+ GET_METRICS_MEMBER(TemperatureVrGfx, &data_u16);
+ gpu_metrics->temperature_vrgfx = *data_u16;
+
+ GET_METRICS_MEMBER(TemperatureVrSoc, &data_u16);
+ gpu_metrics->temperature_vrsoc = *data_u16;
+
+ GET_METRICS_MEMBER(TemperatureVrMem0, &data_u16);
+ gpu_metrics->temperature_vrmem = *data_u16;
- gpu_metrics->average_gfx_activity = metrics->AverageGfxActivity;
- gpu_metrics->average_umc_activity = metrics->AverageUclkActivity;
- gpu_metrics->average_mm_activity = metrics-
VcnActivityPercentage;
+ GET_METRICS_MEMBER(AverageGfxActivity, &data_u16);
+ gpu_metrics->average_gfx_activity = *data_u16;
- gpu_metrics->average_socket_power = metrics-
AverageSocketPower;
- gpu_metrics->energy_accumulator = metrics->EnergyAccumulator;
+ GET_METRICS_MEMBER(AverageUclkActivity, &data_u16);
+ gpu_metrics->average_umc_activity = *data_u16;
- if (metrics->AverageGfxActivity <=
SMU_11_0_7_GFX_BUSY_THRESHOLD)
- gpu_metrics->average_gfxclk_frequency = metrics-
AverageGfxclkFrequencyPostDs;
+ GET_METRICS_MEMBER(VcnActivityPercentage, &data_u16);
+ gpu_metrics->average_mm_activity = *data_u16;
+
+ GET_METRICS_MEMBER(AverageSocketPower, &data_u16);
+ gpu_metrics->average_socket_power = *data_u16;
+
+ GET_METRICS_MEMBER(EnergyAccumulator, &data_u32);
+ gpu_metrics->energy_accumulator = *data_u32;
+
+ GET_METRICS_MEMBER(AverageGfxActivity, &data_u16);
+ if (*data_u16 <= SMU_11_0_7_GFX_BUSY_THRESHOLD)
+ GET_METRICS_MEMBER(AverageGfxclkFrequencyPostDs,
&data_u16);
else
- gpu_metrics->average_gfxclk_frequency = metrics-
AverageGfxclkFrequencyPreDs;
- gpu_metrics->average_uclk_frequency = metrics-
AverageUclkFrequencyPostDs;
- gpu_metrics->average_vclk0_frequency = metrics-
AverageVclk0Frequency;
- gpu_metrics->average_dclk0_frequency = metrics-
AverageDclk0Frequency;
- gpu_metrics->average_vclk1_frequency = metrics-
AverageVclk1Frequency;
- gpu_metrics->average_dclk1_frequency = metrics-
AverageDclk1Frequency;
-
- gpu_metrics->current_gfxclk = metrics->CurrClock[PPCLK_GFXCLK];
- gpu_metrics->current_socclk = metrics->CurrClock[PPCLK_SOCCLK];
- gpu_metrics->current_uclk = metrics->CurrClock[PPCLK_UCLK];
- gpu_metrics->current_vclk0 = metrics->CurrClock[PPCLK_VCLK_0];
- gpu_metrics->current_dclk0 = metrics->CurrClock[PPCLK_DCLK_0];
- gpu_metrics->current_vclk1 = metrics->CurrClock[PPCLK_VCLK_1];
- gpu_metrics->current_dclk1 = metrics->CurrClock[PPCLK_DCLK_1];
-
- gpu_metrics->throttle_status = metrics->ThrottlerStatus;
+ GET_METRICS_MEMBER(AverageGfxclkFrequencyPreDs,
&data_u16);
+ gpu_metrics->average_gfxclk_frequency = *data_u16;
+
+ GET_METRICS_MEMBER(AverageUclkFrequencyPostDs, &data_u16);
+ gpu_metrics->average_uclk_frequency = *data_u16;
+
+ GET_METRICS_MEMBER(AverageVclk0Frequency, &data_u16);
+ gpu_metrics->average_vclk0_frequency = *data_u16;
+
+ GET_METRICS_MEMBER(AverageDclk0Frequency, &data_u16);
+ gpu_metrics->average_dclk0_frequency = *data_u16;
+
+ GET_METRICS_MEMBER(AverageVclk1Frequency, &data_u16);
+ gpu_metrics->average_vclk1_frequency = *data_u16;
+
+ GET_METRICS_MEMBER(AverageDclk1Frequency, &data_u16);
+ gpu_metrics->average_dclk1_frequency = *data_u16;
+
+ GET_METRICS_MEMBER(CurrClock, &data_u32);
+ gpu_metrics->current_gfxclk = data_u32[PPCLK_GFXCLK];
+ gpu_metrics->current_socclk = data_u32[PPCLK_SOCCLK];
+ gpu_metrics->current_uclk = data_u32[PPCLK_UCLK];
+ gpu_metrics->current_vclk0 = data_u32[PPCLK_VCLK_0];
+ gpu_metrics->current_dclk0 = data_u32[PPCLK_DCLK_0];
+ gpu_metrics->current_vclk1 = data_u32[PPCLK_VCLK_1];
+ gpu_metrics->current_dclk1 = data_u32[PPCLK_DCLK_1];
+
+ gpu_metrics->throttle_status =
+ sienna_cichlid_get_throttler_status_locked(smu);
gpu_metrics->indep_throttle_status =
- smu_cmn_get_indep_throttler_status(metrics-
ThrottlerStatus,
+ smu_cmn_get_indep_throttler_status(gpu_metrics-
throttle_status,
sienna_cichlid_throttler_map);
- gpu_metrics->current_fan_speed = metrics->CurrFanSpeed;
+ GET_METRICS_MEMBER(CurrFanSpeed, &data_u16);
+ gpu_metrics->current_fan_speed = *data_u16;
- ret = smu_cmn_get_smc_version(smu, NULL, &smu_version);
- if (ret)
- return ret;
+ if (((smu->adev->asic_type == CHIP_SIENNA_CICHLID) && smu-
smc_fw_version > 0x003A1E00) ||
+ ((smu->adev->asic_type == CHIP_NAVY_FLOUNDER) && smu-
smc_fw_version > 0x00410400)) {
+ GET_METRICS_MEMBER(PcieWidth, &data_u8);
+ gpu_metrics->pcie_link_width = *data_u8;
- if (((adev->asic_type == CHIP_SIENNA_CICHLID) && smu_version >
0x003A1E00) ||
- ((adev->asic_type == CHIP_NAVY_FLOUNDER) && smu_version >
0x00410400)) {
- gpu_metrics->pcie_link_width = metrics->PcieWidth;
- gpu_metrics->pcie_link_speed = link_speed[metrics-
PcieRate];
+ GET_METRICS_MEMBER(PcieRate, &data_u8);
+ gpu_metrics->pcie_link_speed = link_speed[*data_u8];
} else {
gpu_metrics->pcie_link_width =
smu_v11_0_get_current_pcie_link_width(smu);
@@ -3633,6 +3717,8 @@ static ssize_t
sienna_cichlid_get_gpu_metrics(struct smu_context *smu,
smu_v11_0_get_current_pcie_link_speed(smu);
}
+ mutex_unlock(&smu->metrics_lock);
+
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
*table = (void *)gpu_metrics;