the SmuMetrics_t table is asic related data structure.
so move vega20_ppt file to implement.
Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
void *power_play_table;
uint32_t power_play_table_size;
void *hardcode_pptable;
+ unsigned long metrics_time;
+ void *metrics_table;
void *max_sustainable_clocks;
struct smu_bios_boot_up_values boot_values;
uint32_t smc_if_version;
- unsigned long metrics_time;
- void *metrics_table;
};
struct pptable_funcs {
int (*set_ppfeature_status)(struct smu_context *smu, uint64_t ppfeatures);
int (*get_ppfeature_status)(struct smu_context *smu, char *buf);
bool (*is_dpm_running)(struct smu_context *smu);
- void (*tables_init)(struct smu_context *smu, struct smu_table *tables);
+ int (*tables_init)(struct smu_context *smu, struct smu_table *tables);
int (*set_thermal_fan_table)(struct smu_context *smu);
int (*get_fan_speed_percent)(struct smu_context *smu, uint32_t *speed);
int (*set_watermarks_table)(struct smu_context *smu, void *watermarks,
return 0;
}
-static void navi10_tables_init(struct smu_context *smu, struct smu_table *tables)
+static int navi10_tables_init(struct smu_context *smu, struct smu_table *tables)
{
SMU_TABLE_INIT(tables, SMU_TABLE_PPTABLE, sizeof(PPTable_t),
PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
smu_table->tables = tables;
- smu_tables_init(smu, tables);
+ ret = smu_tables_init(smu, tables);
+ if (ret)
+ return ret;
ret = smu_v11_0_init_dpm_context(smu);
if (ret)
return -EINVAL;
kfree(smu_table->tables);
+ kfree(smu_table->metrics_table);
smu_table->tables = NULL;
smu_table->table_count = 0;
+ smu_table->metrics_table = NULL;
+ smu_table->metrics_time = 0;
ret = smu_v11_0_fini_dpm_context(smu);
if (ret)
return -ENOMEM;
smu_power->power_context_size = sizeof(struct smu_11_0_dpm_context);
- smu->metrics_time = 0;
- smu->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);
- if (!smu->metrics_table) {
- kfree(smu_power->power_context);
- return -ENOMEM;
- }
-
return 0;
}
if (!smu_power->power_context || smu_power->power_context_size == 0)
return -EINVAL;
- kfree(smu->metrics_table);
kfree(smu_power->power_context);
- smu->metrics_table = NULL;
smu_power->power_context = NULL;
smu_power->power_context_size = 0;
return ret;
}
-static int smu_v11_0_get_metrics_table(struct smu_context *smu,
- SmuMetrics_t *metrics_table)
-{
- int ret = 0;
-
- if (!smu->metrics_time || time_after(jiffies, smu->metrics_time + HZ / 1000)) {
- ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS,
- (void *)metrics_table, false);
- if (ret) {
- pr_info("Failed to export SMU metrics table!\n");
- return ret;
- }
- memcpy(smu->metrics_table, metrics_table, sizeof(SmuMetrics_t));
- smu->metrics_time = jiffies;
- } else
- memcpy(metrics_table, smu->metrics_table, sizeof(SmuMetrics_t));
-
- return ret;
-}
-
static int smu_v11_0_thermal_get_temperature(struct smu_context *smu,
enum amd_pp_sensors sensor,
uint32_t *value)
return val;
}
-static void vega20_tables_init(struct smu_context *smu, struct smu_table *tables)
+static int vega20_tables_init(struct smu_context *smu, struct smu_table *tables)
{
+ struct smu_table_context *smu_table = &smu->smu_table;
+
SMU_TABLE_INIT(tables, SMU_TABLE_PPTABLE, sizeof(PPTable_t),
PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
SMU_TABLE_INIT(tables, SMU_TABLE_WATERMARKS, sizeof(Watermarks_t),
SMU_TABLE_INIT(tables, SMU_TABLE_ACTIVITY_MONITOR_COEFF,
sizeof(DpmActivityMonitorCoeffInt_t), PAGE_SIZE,
AMDGPU_GEM_DOMAIN_VRAM);
+
+ smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);
+ if (smu_table->metrics_table)
+ return -ENOMEM;
+ smu_table->metrics_time = 0;
+
+ return 0;
}
static int vega20_allocate_dpm_context(struct smu_context *smu)
return 0;
}
+static int vega20_get_metrics_table(struct smu_context *smu,
+ SmuMetrics_t *metrics_table)
+{
+ struct smu_table_context *smu_table= &smu->smu_table;
+ int ret = 0;
+
+ if (!smu_table->metrics_time || time_after(jiffies, smu_table->metrics_time + HZ / 1000)) {
+ ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS,
+ (void *)smu_table->metrics_table, false);
+ if (ret) {
+ pr_info("Failed to export SMU metrics table!\n");
+ return ret;
+ }
+ smu_table->metrics_time = jiffies;
+ }
+
+ memcpy(metrics_table, smu_table->metrics_table, sizeof(SmuMetrics_t));
+
+ return ret;
+}
static int vega20_get_od_percentage(struct smu_context *smu,
enum pp_clock_type type)
{
if (!value)
return -EINVAL;
- ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, (void *)&metrics,
- false);
+ ret = vega20_get_metrics_table(smu, &metrics);
if (ret)
return ret;
if (!value)
return -EINVAL;
- ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS,
- (void *)&metrics, false);
+ ret = vega20_get_metrics_table(smu, &metrics);
if (ret)
return ret;