diff options
author | Likun Gao <Likun.Gao@amd.com> | 2018-12-24 06:49:38 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-03-19 16:03:57 -0400 |
commit | 133438fa4e60d017b2c45b9fca64bcc4fc64007f (patch) | |
tree | 54b9992768d1ed41a518b695215164c96ef6494e /drivers | |
parent | d6a4aa825a65ee7ec0293666fd1572e4621ad13d (diff) |
drm/amd/powerplay: add function to populate umd state clk.
Add vega20_populate_umd_state_clk function to set pstate_sclk and pstate_mclk.
Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 27 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/vega20_ppt.h | 3 |
4 files changed, 40 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c index e03132c17f4e..f5ffc9bd31a6 100644 --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | |||
@@ -393,6 +393,10 @@ static int smu_smc_table_hw_init(struct smu_context *smu) | |||
393 | if (ret) | 393 | if (ret) |
394 | return ret; | 394 | return ret; |
395 | 395 | ||
396 | ret = smu_populate_umd_state_clk(smu); | ||
397 | if (ret) | ||
398 | return ret; | ||
399 | |||
396 | /* | 400 | /* |
397 | * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools. | 401 | * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools. |
398 | */ | 402 | */ |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h index 24babb836a0c..94013c5ca2e3 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | |||
@@ -198,6 +198,9 @@ struct smu_context | |||
198 | struct smu_dpm_context smu_dpm; | 198 | struct smu_dpm_context smu_dpm; |
199 | struct smu_power_context smu_power; | 199 | struct smu_power_context smu_power; |
200 | struct smu_feature smu_feature; | 200 | struct smu_feature smu_feature; |
201 | |||
202 | uint32_t pstate_sclk; | ||
203 | uint32_t pstate_mclk; | ||
201 | }; | 204 | }; |
202 | 205 | ||
203 | struct pptable_funcs { | 206 | struct pptable_funcs { |
@@ -209,6 +212,7 @@ struct pptable_funcs { | |||
209 | int (*run_afll_btc)(struct smu_context *smu); | 212 | int (*run_afll_btc)(struct smu_context *smu); |
210 | int (*get_unallowed_feature_mask)(struct smu_context *smu, uint32_t *feature_mask, uint32_t num); | 213 | int (*get_unallowed_feature_mask)(struct smu_context *smu, uint32_t *feature_mask, uint32_t num); |
211 | int (*set_default_dpm_table)(struct smu_context *smu); | 214 | int (*set_default_dpm_table)(struct smu_context *smu); |
215 | int (*populate_umd_state_clk)(struct smu_context *smu); | ||
212 | }; | 216 | }; |
213 | 217 | ||
214 | struct smu_funcs | 218 | struct smu_funcs |
@@ -316,6 +320,8 @@ struct smu_funcs | |||
316 | ((smu)->ppt_funcs->append_powerplay_table ? (smu)->ppt_funcs->append_powerplay_table((smu)) : 0) | 320 | ((smu)->ppt_funcs->append_powerplay_table ? (smu)->ppt_funcs->append_powerplay_table((smu)) : 0) |
317 | #define smu_set_default_dpm_table(smu) \ | 321 | #define smu_set_default_dpm_table(smu) \ |
318 | ((smu)->ppt_funcs->set_default_dpm_table ? (smu)->ppt_funcs->set_default_dpm_table((smu)) : 0) | 322 | ((smu)->ppt_funcs->set_default_dpm_table ? (smu)->ppt_funcs->set_default_dpm_table((smu)) : 0) |
323 | #define smu_populate_umd_state_clk(smu) \ | ||
324 | ((smu)->ppt_funcs->populate_umd_state_clk ? (smu)->ppt_funcs->populate_umd_state_clk((smu)) : 0) | ||
319 | 325 | ||
320 | #define smu_msg_get_index(smu, msg) \ | 326 | #define smu_msg_get_index(smu, msg) \ |
321 | ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL) | 327 | ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL) |
diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c index bca4085696d2..d794290b2839 100644 --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c | |||
@@ -526,6 +526,32 @@ static int vega20_set_default_dpm_table(struct smu_context *smu) | |||
526 | return 0; | 526 | return 0; |
527 | } | 527 | } |
528 | 528 | ||
529 | static int vega20_populate_umd_state_clk(struct smu_context *smu) | ||
530 | { | ||
531 | struct smu_dpm_context *smu_dpm = &smu->smu_dpm; | ||
532 | struct vega20_dpm_table *dpm_table = NULL; | ||
533 | struct vega20_single_dpm_table *gfx_table = NULL; | ||
534 | struct vega20_single_dpm_table *mem_table = NULL; | ||
535 | |||
536 | dpm_table = smu_dpm->dpm_context; | ||
537 | gfx_table = &(dpm_table->gfx_table); | ||
538 | mem_table = &(dpm_table->mem_table); | ||
539 | |||
540 | smu->pstate_sclk = gfx_table->dpm_levels[0].value; | ||
541 | smu->pstate_mclk = mem_table->dpm_levels[0].value; | ||
542 | |||
543 | if (gfx_table->count > VEGA20_UMD_PSTATE_GFXCLK_LEVEL && | ||
544 | mem_table->count > VEGA20_UMD_PSTATE_MCLK_LEVEL) { | ||
545 | smu->pstate_sclk = gfx_table->dpm_levels[VEGA20_UMD_PSTATE_GFXCLK_LEVEL].value; | ||
546 | smu->pstate_mclk = mem_table->dpm_levels[VEGA20_UMD_PSTATE_MCLK_LEVEL].value; | ||
547 | } | ||
548 | |||
549 | smu->pstate_sclk = smu->pstate_sclk * 100; | ||
550 | smu->pstate_mclk = smu->pstate_mclk * 100; | ||
551 | |||
552 | return 0; | ||
553 | } | ||
554 | |||
529 | static const struct pptable_funcs vega20_ppt_funcs = { | 555 | static const struct pptable_funcs vega20_ppt_funcs = { |
530 | .alloc_dpm_context = vega20_allocate_dpm_context, | 556 | .alloc_dpm_context = vega20_allocate_dpm_context, |
531 | .store_powerplay_table = vega20_store_powerplay_table, | 557 | .store_powerplay_table = vega20_store_powerplay_table, |
@@ -535,6 +561,7 @@ static const struct pptable_funcs vega20_ppt_funcs = { | |||
535 | .run_afll_btc = vega20_run_btc_afll, | 561 | .run_afll_btc = vega20_run_btc_afll, |
536 | .get_unallowed_feature_mask = vega20_get_unallowed_feature_mask, | 562 | .get_unallowed_feature_mask = vega20_get_unallowed_feature_mask, |
537 | .set_default_dpm_table = vega20_set_default_dpm_table, | 563 | .set_default_dpm_table = vega20_set_default_dpm_table, |
564 | .populate_umd_state_clk = vega20_populate_umd_state_clk, | ||
538 | }; | 565 | }; |
539 | 566 | ||
540 | void vega20_set_ppt_funcs(struct smu_context *smu) | 567 | void vega20_set_ppt_funcs(struct smu_context *smu) |
diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.h b/drivers/gpu/drm/amd/powerplay/vega20_ppt.h index 27b2f1ea44ef..ceba4f7dbab4 100644 --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.h +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.h | |||
@@ -23,6 +23,9 @@ | |||
23 | #ifndef __VEGA20_PPT_H__ | 23 | #ifndef __VEGA20_PPT_H__ |
24 | #define __VEGA20_PPT_H__ | 24 | #define __VEGA20_PPT_H__ |
25 | 25 | ||
26 | #define VEGA20_UMD_PSTATE_GFXCLK_LEVEL 0x3 | ||
27 | #define VEGA20_UMD_PSTATE_MCLK_LEVEL 0x2 | ||
28 | |||
26 | #define MAX_REGULAR_DPM_NUMBER 16 | 29 | #define MAX_REGULAR_DPM_NUMBER 16 |
27 | #define MAX_PCIE_CONF 2 | 30 | #define MAX_PCIE_CONF 2 |
28 | 31 | ||