Commit 61e2d322 authored by David M Nieto's avatar David M Nieto Committed by Alex Deucher

drm/amdgpu/pm: add new fields for Navi1x (v3)

Fill voltage fields in metrics table

v2: Removed dpm and freq ranges info
v3: Added check to ensure volrage offset is not zero
Signed-off-by: default avatarDavid M Nieto <david.nieto@amd.com>
Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 0b7db431
......@@ -505,7 +505,7 @@ static int navi10_tables_init(struct smu_context *smu)
goto err0_out;
smu_table->metrics_time = 0;
smu_table->gpu_metrics_table_size = sizeof(struct gpu_metrics_v1_1);
smu_table->gpu_metrics_table_size = sizeof(struct gpu_metrics_v1_3);
smu_table->gpu_metrics_table = kzalloc(smu_table->gpu_metrics_table_size, GFP_KERNEL);
if (!smu_table->gpu_metrics_table)
goto err1_out;
......@@ -2627,8 +2627,8 @@ static ssize_t navi10_get_legacy_gpu_metrics(struct smu_context *smu,
void **table)
{
struct smu_table_context *smu_table = &smu->smu_table;
struct gpu_metrics_v1_1 *gpu_metrics =
(struct gpu_metrics_v1_1 *)smu_table->gpu_metrics_table;
struct gpu_metrics_v1_3 *gpu_metrics =
(struct gpu_metrics_v1_3 *)smu_table->gpu_metrics_table;
SmuMetrics_legacy_t metrics;
int ret = 0;
......@@ -2646,7 +2646,7 @@ static ssize_t navi10_get_legacy_gpu_metrics(struct smu_context *smu,
mutex_unlock(&smu->metrics_lock);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 1);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;
......@@ -2681,17 +2681,29 @@ static ssize_t navi10_get_legacy_gpu_metrics(struct smu_context *smu,
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
if (metrics.CurrGfxVoltageOffset)
gpu_metrics->voltage_gfx =
(155000 - 625 * metrics.CurrGfxVoltageOffset) / 100;
if (metrics.CurrMemVidOffset)
gpu_metrics->voltage_mem =
(155000 - 625 * metrics.CurrMemVidOffset) / 100;
if (metrics.CurrSocVoltageOffset)
gpu_metrics->voltage_soc =
(155000 - 625 * metrics.CurrSocVoltageOffset) / 100;
*table = (void *)gpu_metrics;
return sizeof(struct gpu_metrics_v1_1);
return sizeof(struct gpu_metrics_v1_3);
out:
return ret;
}
static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,
void **table)
{
struct smu_table_context *smu_table = &smu->smu_table;
struct gpu_metrics_v1_1 *gpu_metrics =
(struct gpu_metrics_v1_1 *)smu_table->gpu_metrics_table;
struct gpu_metrics_v1_3 *gpu_metrics =
(struct gpu_metrics_v1_3 *)smu_table->gpu_metrics_table;
SmuMetrics_t metrics;
int ret = 0;
......@@ -2709,7 +2721,7 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,
mutex_unlock(&smu->metrics_lock);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 1);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;
......@@ -2746,17 +2758,29 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
if (metrics.CurrGfxVoltageOffset)
gpu_metrics->voltage_gfx =
(155000 - 625 * metrics.CurrGfxVoltageOffset) / 100;
if (metrics.CurrMemVidOffset)
gpu_metrics->voltage_mem =
(155000 - 625 * metrics.CurrMemVidOffset) / 100;
if (metrics.CurrSocVoltageOffset)
gpu_metrics->voltage_soc =
(155000 - 625 * metrics.CurrSocVoltageOffset) / 100;
*table = (void *)gpu_metrics;
return sizeof(struct gpu_metrics_v1_1);
return sizeof(struct gpu_metrics_v1_3);
out:
return ret;
}
static ssize_t navi12_get_legacy_gpu_metrics(struct smu_context *smu,
void **table)
{
struct smu_table_context *smu_table = &smu->smu_table;
struct gpu_metrics_v1_1 *gpu_metrics =
(struct gpu_metrics_v1_1 *)smu_table->gpu_metrics_table;
struct gpu_metrics_v1_3 *gpu_metrics =
(struct gpu_metrics_v1_3 *)smu_table->gpu_metrics_table;
SmuMetrics_NV12_legacy_t metrics;
int ret = 0;
......@@ -2774,7 +2798,7 @@ static ssize_t navi12_get_legacy_gpu_metrics(struct smu_context *smu,
mutex_unlock(&smu->metrics_lock);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 1);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;
......@@ -2814,17 +2838,29 @@ static ssize_t navi12_get_legacy_gpu_metrics(struct smu_context *smu,
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
if (metrics.CurrGfxVoltageOffset)
gpu_metrics->voltage_gfx =
(155000 - 625 * metrics.CurrGfxVoltageOffset) / 100;
if (metrics.CurrMemVidOffset)
gpu_metrics->voltage_mem =
(155000 - 625 * metrics.CurrMemVidOffset) / 100;
if (metrics.CurrSocVoltageOffset)
gpu_metrics->voltage_soc =
(155000 - 625 * metrics.CurrSocVoltageOffset) / 100;
*table = (void *)gpu_metrics;
return sizeof(struct gpu_metrics_v1_1);
return sizeof(struct gpu_metrics_v1_3);
out:
return ret;
}
static ssize_t navi12_get_gpu_metrics(struct smu_context *smu,
void **table)
{
struct smu_table_context *smu_table = &smu->smu_table;
struct gpu_metrics_v1_1 *gpu_metrics =
(struct gpu_metrics_v1_1 *)smu_table->gpu_metrics_table;
struct gpu_metrics_v1_3 *gpu_metrics =
(struct gpu_metrics_v1_3 *)smu_table->gpu_metrics_table;
SmuMetrics_NV12_t metrics;
int ret = 0;
......@@ -2842,7 +2878,7 @@ static ssize_t navi12_get_gpu_metrics(struct smu_context *smu,
mutex_unlock(&smu->metrics_lock);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 1);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;
......@@ -2884,9 +2920,21 @@ static ssize_t navi12_get_gpu_metrics(struct smu_context *smu,
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
if (metrics.CurrGfxVoltageOffset)
gpu_metrics->voltage_gfx =
(155000 - 625 * metrics.CurrGfxVoltageOffset) / 100;
if (metrics.CurrMemVidOffset)
gpu_metrics->voltage_mem =
(155000 - 625 * metrics.CurrMemVidOffset) / 100;
if (metrics.CurrSocVoltageOffset)
gpu_metrics->voltage_soc =
(155000 - 625 * metrics.CurrSocVoltageOffset) / 100;
*table = (void *)gpu_metrics;
return sizeof(struct gpu_metrics_v1_1);
return sizeof(struct gpu_metrics_v1_3);
out:
return ret;
}
static ssize_t navi1x_get_gpu_metrics(struct smu_context *smu,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment