mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-04 20:53:07 -04:00
drm/amd/pm: Add pm metrics support to SMU v13.0.6
Add support to fetch PM metrics sample from SMU v13.0.6 Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Reviewed-by: Yang Wang <kevinyang.wang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
@@ -120,6 +120,7 @@ struct mca_ras_info {
|
||||
#define P2S_TABLE_ID_A 0x50325341
|
||||
#define P2S_TABLE_ID_X 0x50325358
|
||||
|
||||
// clang-format off
|
||||
static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COUNT] = {
|
||||
MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 0),
|
||||
MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion, 1),
|
||||
@@ -128,6 +129,7 @@ static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COU
|
||||
MSG_MAP(DisableAllSmuFeatures, PPSMC_MSG_DisableAllSmuFeatures, 0),
|
||||
MSG_MAP(RequestI2cTransaction, PPSMC_MSG_RequestI2cTransaction, 0),
|
||||
MSG_MAP(GetMetricsTable, PPSMC_MSG_GetMetricsTable, 1),
|
||||
MSG_MAP(GetMetricsVersion, PPSMC_MSG_GetMetricsVersion, 1),
|
||||
MSG_MAP(GetEnabledSmuFeaturesHigh, PPSMC_MSG_GetEnabledSmuFeaturesHigh, 1),
|
||||
MSG_MAP(GetEnabledSmuFeaturesLow, PPSMC_MSG_GetEnabledSmuFeaturesLow, 1),
|
||||
MSG_MAP(SetDriverDramAddrHigh, PPSMC_MSG_SetDriverDramAddrHigh, 1),
|
||||
@@ -171,6 +173,7 @@ static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COU
|
||||
MSG_MAP(SelectPLPDMode, PPSMC_MSG_SelectPLPDMode, 0),
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
static const struct cmn2asic_mapping smu_v13_0_6_clk_map[SMU_CLK_COUNT] = {
|
||||
CLK_MAP(SOCCLK, PPCLK_SOCCLK),
|
||||
CLK_MAP(FCLK, PPCLK_FCLK),
|
||||
@@ -428,6 +431,41 @@ static int smu_v13_0_6_get_metrics_table(struct smu_context *smu,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t smu_v13_0_6_get_pm_metrics(struct smu_context *smu,
|
||||
void *metrics, size_t max_size)
|
||||
{
|
||||
struct smu_table_context *smu_tbl_ctxt = &smu->smu_table;
|
||||
uint32_t table_version = smu_tbl_ctxt->tables[SMU_TABLE_SMU_METRICS].version;
|
||||
uint32_t table_size = smu_tbl_ctxt->tables[SMU_TABLE_SMU_METRICS].size;
|
||||
struct amdgpu_pm_metrics *pm_metrics = metrics;
|
||||
uint32_t pmfw_version;
|
||||
int ret;
|
||||
|
||||
if (!pm_metrics || !max_size)
|
||||
return -EINVAL;
|
||||
|
||||
if (max_size < (table_size + sizeof(pm_metrics->common_header)))
|
||||
return -EOVERFLOW;
|
||||
|
||||
/* Don't use cached metrics data */
|
||||
ret = smu_v13_0_6_get_metrics_table(smu, pm_metrics->data, true);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
smu_cmn_get_smc_version(smu, NULL, &pmfw_version);
|
||||
|
||||
memset(&pm_metrics->common_header, 0,
|
||||
sizeof(pm_metrics->common_header));
|
||||
pm_metrics->common_header.mp1_ip_discovery_version =
|
||||
IP_VERSION(13, 0, 6);
|
||||
pm_metrics->common_header.pmfw_version = pmfw_version;
|
||||
pm_metrics->common_header.pmmetrics_version = table_version;
|
||||
pm_metrics->common_header.structure_size =
|
||||
sizeof(pm_metrics->common_header) + table_size;
|
||||
|
||||
return pm_metrics->common_header.structure_size;
|
||||
}
|
||||
|
||||
static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
|
||||
{
|
||||
struct smu_table_context *smu_table = &smu->smu_table;
|
||||
@@ -435,6 +473,7 @@ static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
|
||||
struct PPTable_t *pptable =
|
||||
(struct PPTable_t *)smu_table->driver_pptable;
|
||||
int ret, i, retry = 100;
|
||||
uint32_t table_version;
|
||||
|
||||
/* Store one-time values in driver PPTable */
|
||||
if (!pptable->Init) {
|
||||
@@ -453,6 +492,13 @@ static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
|
||||
if (!retry)
|
||||
return -ETIME;
|
||||
|
||||
ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetMetricsVersion,
|
||||
&table_version);
|
||||
if (ret)
|
||||
return ret;
|
||||
smu_table->tables[SMU_TABLE_SMU_METRICS].version =
|
||||
table_version;
|
||||
|
||||
pptable->MaxSocketPowerLimit =
|
||||
SMUQ10_ROUND(metrics->MaxSocketPowerLimit);
|
||||
pptable->MaxGfxclkFrequency =
|
||||
@@ -2864,6 +2910,7 @@ static const struct pptable_funcs smu_v13_0_6_ppt_funcs = {
|
||||
.log_thermal_throttling_event = smu_v13_0_6_log_thermal_throttling_event,
|
||||
.get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
|
||||
.get_gpu_metrics = smu_v13_0_6_get_gpu_metrics,
|
||||
.get_pm_metrics = smu_v13_0_6_get_pm_metrics,
|
||||
.get_thermal_temperature_range = smu_v13_0_6_get_thermal_temperature_range,
|
||||
.mode1_reset_is_support = smu_v13_0_6_is_mode1_reset_supported,
|
||||
.mode2_reset_is_support = smu_v13_0_6_is_mode2_reset_supported,
|
||||
|
||||
Reference in New Issue
Block a user