aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Huang <JinHuiEric.Huang@amd.com>2016-04-15 16:33:20 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-05-04 20:29:55 -0400
commit65ba4f227c2f9318551b0faad5c08e31b55ba598 (patch)
tree8b65ce705c71521ef53174d722499fbee3f922b4
parent1551019523a01f477888835b9ed363d3a2e73d7b (diff)
drm/amd/powerplay: revise reading/writing pptable on Fiji
Change the way we store pptables in the driver to better facilitate eventual runtime updates for debugging. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Eric Huang <JinHuiEric.Huang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c40
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.h4
2 files changed, 37 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
index f8d49f1b44f5..55e877c4b862 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
@@ -579,6 +579,18 @@ static int fiji_patch_boot_state(struct pp_hwmgr *hwmgr,
579 return 0; 579 return 0;
580} 580}
581 581
582static int fiji_hwmgr_backend_fini(struct pp_hwmgr *hwmgr)
583{
584 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
585
586 if (data->soft_pp_table) {
587 kfree(data->soft_pp_table);
588 data->soft_pp_table = NULL;
589 }
590
591 return phm_hwmgr_backend_fini(hwmgr);
592}
593
582static int fiji_hwmgr_backend_init(struct pp_hwmgr *hwmgr) 594static int fiji_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
583{ 595{
584 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); 596 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
@@ -734,7 +746,7 @@ static int fiji_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
734 data->pcie_lane_cap = (uint32_t)sys_info.value; 746 data->pcie_lane_cap = (uint32_t)sys_info.value;
735 } else { 747 } else {
736 /* Ignore return value in here, we are cleaning up a mess. */ 748 /* Ignore return value in here, we are cleaning up a mess. */
737 tonga_hwmgr_backend_fini(hwmgr); 749 fiji_hwmgr_backend_fini(hwmgr);
738 } 750 }
739 751
740 return 0; 752 return 0;
@@ -5096,18 +5108,34 @@ static int fiji_get_pp_table(struct pp_hwmgr *hwmgr, char **table)
5096{ 5108{
5097 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); 5109 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
5098 5110
5099 *table = (char *)&data->smc_state_table; 5111 if (!data->soft_pp_table) {
5112 data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL);
5113 if (!data->soft_pp_table)
5114 return -ENOMEM;
5115 memcpy(data->soft_pp_table, hwmgr->soft_pp_table,
5116 hwmgr->soft_pp_table_size);
5117 }
5118
5119 *table = (char *)&data->soft_pp_table;
5100 5120
5101 return sizeof(struct SMU73_Discrete_DpmTable); 5121 return hwmgr->soft_pp_table_size;
5102} 5122}
5103 5123
5104static int fiji_set_pp_table(struct pp_hwmgr *hwmgr, const char *buf, size_t size) 5124static int fiji_set_pp_table(struct pp_hwmgr *hwmgr, const char *buf, size_t size)
5105{ 5125{
5106 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); 5126 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
5107 5127
5108 void *table = (void *)&data->smc_state_table; 5128 if (!data->soft_pp_table) {
5129 data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL);
5130 if (!data->soft_pp_table)
5131 return -ENOMEM;
5132 }
5133
5134 memcpy(data->soft_pp_table, buf, size);
5135
5136 hwmgr->soft_pp_table = data->soft_pp_table;
5109 5137
5110 memcpy(table, buf, size); 5138 /* TODO: re-init powerplay to implement modified pptable */
5111 5139
5112 return 0; 5140 return 0;
5113} 5141}
@@ -5284,7 +5312,7 @@ bool fiji_check_smc_update_required_for_display_configuration(struct pp_hwmgr *h
5284 5312
5285static const struct pp_hwmgr_func fiji_hwmgr_funcs = { 5313static const struct pp_hwmgr_func fiji_hwmgr_funcs = {
5286 .backend_init = &fiji_hwmgr_backend_init, 5314 .backend_init = &fiji_hwmgr_backend_init,
5287 .backend_fini = &tonga_hwmgr_backend_fini, 5315 .backend_fini = &fiji_hwmgr_backend_fini,
5288 .asic_setup = &fiji_setup_asic_task, 5316 .asic_setup = &fiji_setup_asic_task,
5289 .dynamic_state_management_enable = &fiji_enable_dpm_tasks, 5317 .dynamic_state_management_enable = &fiji_enable_dpm_tasks,
5290 .force_dpm_level = &fiji_dpm_force_dpm_level, 5318 .force_dpm_level = &fiji_dpm_force_dpm_level,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.h b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.h
index 4b29d9ef07ce..170edf5a772d 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.h
@@ -302,6 +302,9 @@ struct fiji_hwmgr {
302 bool pg_acp_init; 302 bool pg_acp_init;
303 bool frtc_enabled; 303 bool frtc_enabled;
304 bool frtc_status_changed; 304 bool frtc_status_changed;
305
306 /* soft pptable for re-uploading into smu */
307 void *soft_pp_table;
305}; 308};
306 309
307/* To convert to Q8.8 format for firmware */ 310/* To convert to Q8.8 format for firmware */
@@ -338,7 +341,6 @@ enum Fiji_I2CLineID {
338#define FIJI_UNUSED_GPIO_PIN 0x7F 341#define FIJI_UNUSED_GPIO_PIN 0x7F
339 342
340extern int tonga_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr); 343extern int tonga_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr);
341extern int tonga_hwmgr_backend_fini(struct pp_hwmgr *hwmgr);
342extern int tonga_get_mc_microcode_version (struct pp_hwmgr *hwmgr); 344extern int tonga_get_mc_microcode_version (struct pp_hwmgr *hwmgr);
343extern int tonga_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr); 345extern int tonga_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr);
344extern int tonga_notify_smc_display_change(struct pp_hwmgr *hwmgr, bool has_display); 346extern int tonga_notify_smc_display_change(struct pp_hwmgr *hwmgr, bool has_display);