drm/amd/pm/swsmu: unify the init soft gpu metrics function
the soft gpu metrics is not asic related data structure. unify them to reduce duplicate code. Signed-off-by: Kevin Wang <kevin1.wang@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Родитель
1001f2a1f3
Коммит
de4b7cd8cb
|
@ -272,10 +272,6 @@ int smu_v11_0_get_current_pcie_link_speed_level(struct smu_context *smu);
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -60,7 +60,5 @@ int smu_v12_0_set_soft_freq_limited_range(struct smu_context *smu, enum smu_clk_
|
|||
|
||||
int smu_v12_0_set_driver_table_location(struct smu_context *smu);
|
||||
|
||||
void smu_v12_0_init_gpu_metrics_v2_0(struct gpu_metrics_v2_0 *gpu_metrics);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -2239,7 +2239,7 @@ static ssize_t arcturus_get_gpu_metrics(struct smu_context *smu,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
smu_v11_0_init_gpu_metrics_v1_0(gpu_metrics);
|
||||
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 0);
|
||||
|
||||
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
|
||||
gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;
|
||||
|
@ -2276,6 +2276,8 @@ static ssize_t arcturus_get_gpu_metrics(struct smu_context *smu,
|
|||
gpu_metrics->pcie_link_speed =
|
||||
arcturus_get_current_pcie_link_speed(smu);
|
||||
|
||||
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
|
||||
|
||||
*table = (void *)gpu_metrics;
|
||||
|
||||
return sizeof(struct gpu_metrics_v1_0);
|
||||
|
|
|
@ -2314,7 +2314,7 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,
|
|||
|
||||
mutex_unlock(&smu->metrics_lock);
|
||||
|
||||
smu_v11_0_init_gpu_metrics_v1_0(gpu_metrics);
|
||||
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 0);
|
||||
|
||||
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
|
||||
gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;
|
||||
|
@ -2354,6 +2354,8 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,
|
|||
gpu_metrics->pcie_link_speed =
|
||||
smu_v11_0_get_current_pcie_link_speed(smu);
|
||||
|
||||
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
|
||||
|
||||
*table = (void *)gpu_metrics;
|
||||
|
||||
return sizeof(struct gpu_metrics_v1_0);
|
||||
|
|
|
@ -2958,7 +2958,7 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
smu_v11_0_init_gpu_metrics_v1_0(gpu_metrics);
|
||||
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 0);
|
||||
|
||||
gpu_metrics->temperature_edge = metrics->TemperatureEdge;
|
||||
gpu_metrics->temperature_hotspot = metrics->TemperatureHotspot;
|
||||
|
@ -3001,6 +3001,8 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,
|
|||
gpu_metrics->pcie_link_speed =
|
||||
smu_v11_0_get_current_pcie_link_speed(smu);
|
||||
|
||||
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
|
||||
|
||||
*table = (void *)gpu_metrics;
|
||||
|
||||
return sizeof(struct gpu_metrics_v1_0);
|
||||
|
|
|
@ -2021,30 +2021,6 @@ int smu_v11_0_get_current_pcie_link_speed(struct smu_context *smu)
|
|||
return link_speed[speed_level];
|
||||
}
|
||||
|
||||
void smu_v11_0_init_gpu_metrics_v1_0(struct gpu_metrics_v1_0 *gpu_metrics)
|
||||
{
|
||||
memset(gpu_metrics, 0xFF, sizeof(struct gpu_metrics_v1_0));
|
||||
|
||||
gpu_metrics->common_header.structure_size =
|
||||
sizeof(struct gpu_metrics_v1_0);
|
||||
gpu_metrics->common_header.format_revision = 1;
|
||||
gpu_metrics->common_header.content_revision = 0;
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -1406,7 +1406,7 @@ static ssize_t vangogh_get_gpu_metrics(struct smu_context *smu,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
smu_v11_0_init_gpu_metrics_v2_0(gpu_metrics);
|
||||
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 2, 0);
|
||||
|
||||
gpu_metrics->temperature_gfx = metrics.GfxTemperature;
|
||||
gpu_metrics->temperature_soc = metrics.SocTemperature;
|
||||
|
@ -1442,6 +1442,8 @@ static ssize_t vangogh_get_gpu_metrics(struct smu_context *smu,
|
|||
|
||||
gpu_metrics->throttle_status = metrics.ThrottlerStatus;
|
||||
|
||||
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
|
||||
|
||||
*table = (void *)gpu_metrics;
|
||||
|
||||
return sizeof(struct gpu_metrics_v2_0);
|
||||
|
|
|
@ -1257,7 +1257,7 @@ static ssize_t renoir_get_gpu_metrics(struct smu_context *smu,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
smu_v12_0_init_gpu_metrics_v2_0(gpu_metrics);
|
||||
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 2, 0);
|
||||
|
||||
gpu_metrics->temperature_gfx = metrics.GfxTemperature;
|
||||
gpu_metrics->temperature_soc = metrics.SocTemperature;
|
||||
|
@ -1298,6 +1298,8 @@ static ssize_t renoir_get_gpu_metrics(struct smu_context *smu,
|
|||
|
||||
gpu_metrics->fan_pwm = metrics.FanPwm;
|
||||
|
||||
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
|
||||
|
||||
*table = (void *)gpu_metrics;
|
||||
|
||||
return sizeof(struct gpu_metrics_v2_0);
|
||||
|
|
|
@ -278,15 +278,3 @@ int smu_v12_0_set_driver_table_location(struct smu_context *smu)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void smu_v12_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();
|
||||
}
|
||||
|
|
|
@ -746,3 +746,31 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev)
|
||||
{
|
||||
struct metrics_table_header *header = (struct metrics_table_header *)table;
|
||||
uint16_t structure_size;
|
||||
|
||||
#define METRICS_VERSION(a, b) ((a << 16) | b )
|
||||
|
||||
switch (METRICS_VERSION(frev, crev)) {
|
||||
case METRICS_VERSION(1, 0):
|
||||
structure_size = sizeof(struct gpu_metrics_v1_0);
|
||||
break;
|
||||
case METRICS_VERSION(2, 0):
|
||||
structure_size = sizeof(struct gpu_metrics_v2_0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#undef METRICS_VERSION
|
||||
|
||||
memset(header, 0xFF, structure_size);
|
||||
|
||||
header->format_revision = frev;
|
||||
header->content_revision = crev;
|
||||
header->structure_size = structure_size;
|
||||
|
||||
}
|
||||
|
|
|
@ -97,5 +97,7 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,
|
|||
void *metrics_table,
|
||||
bool bypass_cache);
|
||||
|
||||
void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче