aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorhersen wu <hersenxs.wu@amd.com>2019-05-21 15:02:23 -0400
committerAlex Deucher <alexander.deucher@amd.com>2019-06-21 19:59:32 -0400
commitf4b3295fa228eef5fe1a0a736f945d757eaaaed1 (patch)
tree0bc85c3725c0e12d3f9f879d2a1625177c9f66fb /drivers/gpu/drm
parent26e2b581482d69053eff27d355c04e182fb6b662 (diff)
drm/amd/powerplay: add interface to get uclk dpm table
dc needs get uclk dpm table for bandwidth calculation Signed-off-by: hersen wu <hersenxs.wu@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h3
-rw-r--r--drivers/gpu/drm/amd/powerplay/navi10_ppt.c30
2 files changed, 33 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
index 8acc17973577..ccb41fc4f74f 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
@@ -611,6 +611,7 @@ struct pptable_funcs {
611 enum smu_clk_type clk_type, 611 enum smu_clk_type clk_type,
612 uint32_t *value); 612 uint32_t *value);
613 int (*get_thermal_temperature_range)(struct smu_context *smu, struct smu_temperature_range *range); 613 int (*get_thermal_temperature_range)(struct smu_context *smu, struct smu_temperature_range *range);
614 int (*get_uclk_dpm_states)(struct smu_context *smu, uint32_t *clocks_in_khz, uint32_t *num_states);
614}; 615};
615 616
616struct smu_funcs 617struct smu_funcs
@@ -897,6 +898,8 @@ struct smu_funcs
897 ((smu)->funcs->register_irq_handler ? (smu)->funcs->register_irq_handler(smu) : 0) 898 ((smu)->funcs->register_irq_handler ? (smu)->funcs->register_irq_handler(smu) : 0)
898#define smu_set_azalia_d3_pme(smu) \ 899#define smu_set_azalia_d3_pme(smu) \
899 ((smu)->funcs->set_azalia_d3_pme ? (smu)->funcs->set_azalia_d3_pme((smu)) : 0) 900 ((smu)->funcs->set_azalia_d3_pme ? (smu)->funcs->set_azalia_d3_pme((smu)) : 0)
901#define smu_get_uclk_dpm_states(smu, clocks_in_khz, num_states) \
902 ((smu)->ppt_funcs->get_uclk_dpm_states ? (smu)->ppt_funcs->get_uclk_dpm_states((smu), (clocks_in_khz), (num_states)) : 0)
900 903
901extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, 904extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
902 uint16_t *size, uint8_t *frev, uint8_t *crev, 905 uint16_t *size, uint8_t *frev, uint8_t *crev,
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index b16ee40da7c8..5b4332392cf5 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -1248,6 +1248,35 @@ static int navi10_read_sensor(struct smu_context *smu,
1248 return ret; 1248 return ret;
1249} 1249}
1250 1250
1251static int navi10_get_uclk_dpm_states(struct smu_context *smu, uint32_t *clocks_in_khz, uint32_t *num_states)
1252{
1253 uint32_t num_discrete_levels = 0;
1254 uint16_t *dpm_levels = NULL;
1255 uint16_t i = 0;
1256 struct smu_table_context *table_context = &smu->smu_table;
1257 PPTable_t *driver_ppt = NULL;
1258
1259 if (!clocks_in_khz || !num_states || !table_context->driver_pptable)
1260 return -EINVAL;
1261
1262 driver_ppt = table_context->driver_pptable;
1263 num_discrete_levels = driver_ppt->DpmDescriptor[PPCLK_UCLK].NumDiscreteLevels;
1264 dpm_levels = driver_ppt->FreqTableUclk;
1265
1266 if (num_discrete_levels == 0 || dpm_levels == NULL)
1267 return -EINVAL;
1268
1269 *num_states = num_discrete_levels;
1270 for (i = 0; i < num_discrete_levels; i++) {
1271 /* convert to khz */
1272 *clocks_in_khz = (*dpm_levels) * 1000;
1273 clocks_in_khz++;
1274 dpm_levels++;
1275 }
1276
1277 return 0;
1278}
1279
1251static const struct pptable_funcs navi10_ppt_funcs = { 1280static const struct pptable_funcs navi10_ppt_funcs = {
1252 .tables_init = navi10_tables_init, 1281 .tables_init = navi10_tables_init,
1253 .alloc_dpm_context = navi10_allocate_dpm_context, 1282 .alloc_dpm_context = navi10_allocate_dpm_context,
@@ -1281,6 +1310,7 @@ static const struct pptable_funcs navi10_ppt_funcs = {
1281 .get_profiling_clk_mask = navi10_get_profiling_clk_mask, 1310 .get_profiling_clk_mask = navi10_get_profiling_clk_mask,
1282 .set_watermarks_table = navi10_set_watermarks_table, 1311 .set_watermarks_table = navi10_set_watermarks_table,
1283 .read_sensor = navi10_read_sensor, 1312 .read_sensor = navi10_read_sensor,
1313 .get_uclk_dpm_states = navi10_get_uclk_dpm_states,
1284}; 1314};
1285 1315
1286void navi10_set_ppt_funcs(struct smu_context *smu) 1316void navi10_set_ppt_funcs(struct smu_context *smu)