aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorRex Zhu <Rex.Zhu@amd.com>2017-08-25 03:51:03 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-08-29 15:28:00 -0400
commite154162ef75d9cc444f6107e1f6cca5efe8e9640 (patch)
treed03a70f94c119b6e68eb8bf0afb407f867756f85 /drivers/gpu/drm/amd
parentffe6d881e99413f3ebdfebf99570c2e840879e68 (diff)
drm/amd/powerplay: refine pp code for raven
delete useless code. Signed-off-by: Rex Zhu <Rex.Zhu@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c135
1 files changed, 16 insertions, 119 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c
index edc5fb6412d9..3e443c11f47b 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c
@@ -38,20 +38,17 @@
38#include "pp_soc15.h" 38#include "pp_soc15.h"
39 39
40#define RAVEN_MAX_DEEPSLEEP_DIVIDER_ID 5 40#define RAVEN_MAX_DEEPSLEEP_DIVIDER_ID 5
41#define RAVEN_MINIMUM_ENGINE_CLOCK 800 //8Mhz, the low boundary of engine clock allowed on this chip 41#define RAVEN_MINIMUM_ENGINE_CLOCK 800 /* 8Mhz, the low boundary of engine clock allowed on this chip */
42#define SCLK_MIN_DIV_INTV_SHIFT 12 42#define SCLK_MIN_DIV_INTV_SHIFT 12
43#define RAVEN_DISPCLK_BYPASS_THRESHOLD 10000 //100mhz 43#define RAVEN_DISPCLK_BYPASS_THRESHOLD 10000 /* 100Mhz */
44#define SMC_RAM_END 0x40000 44#define SMC_RAM_END 0x40000
45 45
46static const unsigned long PhwRaven_Magic = (unsigned long) PHM_Rv_Magic; 46static const unsigned long PhwRaven_Magic = (unsigned long) PHM_Rv_Magic;
47
48
47int rv_display_clock_voltage_request(struct pp_hwmgr *hwmgr, 49int rv_display_clock_voltage_request(struct pp_hwmgr *hwmgr,
48 struct pp_display_clock_request *clock_req); 50 struct pp_display_clock_request *clock_req);
49 51
50struct phm_vq_budgeting_record rv_vqtable[] = {
51 /* _TBD
52 * CUs, SSP low, SSP High, Min Sclk Low, Min Sclk, High, AWD/non-AWD, DCLK, ECLK, Sustainable Sclk, Sustainable CUs */
53 { 8, 0, 45, 0, 0, VQ_DisplayConfig_NoneAWD, 80000, 120000, 4, 0 },
54};
55 52
56static struct rv_power_state *cast_rv_ps(struct pp_hw_power_state *hw_ps) 53static struct rv_power_state *cast_rv_ps(struct pp_hw_power_state *hw_ps)
57{ 54{
@@ -70,101 +67,24 @@ static const struct rv_power_state *cast_const_rv_ps(
70 return (struct rv_power_state *)hw_ps; 67 return (struct rv_power_state *)hw_ps;
71} 68}
72 69
73static int rv_init_vq_budget_table(struct pp_hwmgr *hwmgr)
74{
75 uint32_t table_size, i;
76 struct phm_vq_budgeting_table *ptable;
77 uint32_t num_entries = ARRAY_SIZE(rv_vqtable);
78
79 if (hwmgr->dyn_state.vq_budgeting_table != NULL)
80 return 0;
81
82 table_size = sizeof(struct phm_vq_budgeting_table) +
83 sizeof(struct phm_vq_budgeting_record) * (num_entries - 1);
84
85 ptable = kzalloc(table_size, GFP_KERNEL);
86 if (NULL == ptable)
87 return -ENOMEM;
88
89 ptable->numEntries = (uint8_t) num_entries;
90
91 for (i = 0; i < ptable->numEntries; i++) {
92 ptable->entries[i].ulCUs = rv_vqtable[i].ulCUs;
93 ptable->entries[i].ulSustainableSOCPowerLimitLow = rv_vqtable[i].ulSustainableSOCPowerLimitLow;
94 ptable->entries[i].ulSustainableSOCPowerLimitHigh = rv_vqtable[i].ulSustainableSOCPowerLimitHigh;
95 ptable->entries[i].ulMinSclkLow = rv_vqtable[i].ulMinSclkLow;
96 ptable->entries[i].ulMinSclkHigh = rv_vqtable[i].ulMinSclkHigh;
97 ptable->entries[i].ucDispConfig = rv_vqtable[i].ucDispConfig;
98 ptable->entries[i].ulDClk = rv_vqtable[i].ulDClk;
99 ptable->entries[i].ulEClk = rv_vqtable[i].ulEClk;
100 ptable->entries[i].ulSustainableSclk = rv_vqtable[i].ulSustainableSclk;
101 ptable->entries[i].ulSustainableCUs = rv_vqtable[i].ulSustainableCUs;
102 }
103
104 hwmgr->dyn_state.vq_budgeting_table = ptable;
105
106 return 0;
107}
108
109static int rv_initialize_dpm_defaults(struct pp_hwmgr *hwmgr) 70static int rv_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
110{ 71{
111 struct rv_hwmgr *rv_hwmgr = (struct rv_hwmgr *)(hwmgr->backend); 72 struct rv_hwmgr *rv_hwmgr = (struct rv_hwmgr *)(hwmgr->backend);
112 struct cgs_system_info sys_info = {0};
113 int result;
114 73
115 rv_hwmgr->ddi_power_gating_disabled = 0;
116 rv_hwmgr->bapm_enabled = 1;
117 rv_hwmgr->dce_slow_sclk_threshold = 30000; 74 rv_hwmgr->dce_slow_sclk_threshold = 30000;
118 rv_hwmgr->disable_driver_thermal_policy = 1;
119 rv_hwmgr->thermal_auto_throttling_treshold = 0; 75 rv_hwmgr->thermal_auto_throttling_treshold = 0;
120 rv_hwmgr->is_nb_dpm_enabled = 1; 76 rv_hwmgr->is_nb_dpm_enabled = 1;
121 rv_hwmgr->dpm_flags = 1; 77 rv_hwmgr->dpm_flags = 1;
122 rv_hwmgr->disable_smu_acp_s3_handshake = 1;
123 rv_hwmgr->disable_notify_smu_vpu_recovery = 0;
124 rv_hwmgr->gfx_off_controled_by_driver = false; 78 rv_hwmgr->gfx_off_controled_by_driver = false;
125 79
126 phm_cap_unset(hwmgr->platform_descriptor.platformCaps, 80 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
127 PHM_PlatformCaps_DynamicM3Arbiter);
128
129 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
130 PHM_PlatformCaps_UVDPowerGating);
131
132 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
133 PHM_PlatformCaps_UVDDynamicPowerGating);
134
135 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
136 PHM_PlatformCaps_VCEPowerGating);
137
138 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
139 PHM_PlatformCaps_SamuPowerGating);
140
141 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
142 PHM_PlatformCaps_ACP);
143
144 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
145 PHM_PlatformCaps_SclkDeepSleep); 81 PHM_PlatformCaps_SclkDeepSleep);
146 82
147 phm_cap_unset(hwmgr->platform_descriptor.platformCaps, 83 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
148 PHM_PlatformCaps_GFXDynamicMGPowerGating);
149
150 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
151 PHM_PlatformCaps_SclkThrottleLowNotification); 84 PHM_PlatformCaps_SclkThrottleLowNotification);
152 85
153 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
154 PHM_PlatformCaps_DisableVoltageIsland);
155
156 phm_cap_set(hwmgr->platform_descriptor.platformCaps, 86 phm_cap_set(hwmgr->platform_descriptor.platformCaps,
157 PHM_PlatformCaps_DynamicUVDState); 87 PHM_PlatformCaps_PowerPlaySupport);
158
159 sys_info.size = sizeof(struct cgs_system_info);
160 sys_info.info_id = CGS_SYSTEM_INFO_PG_FLAGS;
161 result = cgs_query_system_info(hwmgr->device, &sys_info);
162 if (!result) {
163 if (sys_info.value & AMD_PG_SUPPORT_GFX_DMG)
164 phm_cap_set(hwmgr->platform_descriptor.platformCaps,
165 PHM_PlatformCaps_GFXDynamicMGPowerGating);
166 }
167
168 return 0; 88 return 0;
169} 89}
170 90
@@ -256,14 +176,6 @@ static int rv_tf_set_clock_limit(struct pp_hwmgr *hwmgr, void *input,
256 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, 176 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
257 PPSMC_MSG_SetMinDeepSleepDcefclk, 177 PPSMC_MSG_SetMinDeepSleepDcefclk,
258 clocks.dcefClockInSR / 100); 178 clocks.dcefClockInSR / 100);
259 /*
260 if(!rv_data->isp_tileA_power_gated || !rv_data->isp_tileB_power_gated) {
261 if ((hwmgr->ispArbiter.iclk != 0) && (rv_data->ISPActualHardMinFreq != (hwmgr->ispArbiter.iclk / 100) )) {
262 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
263 PPSMC_MSG_SetHardMinIspclkByFreq, hwmgr->ispArbiter.iclk / 100);
264 rv_read_arg_from_smc(hwmgr->smumgr, &rv_data->ISPActualHardMinFreq),
265 }
266 } */
267 179
268 if (((hwmgr->uvd_arbiter.vclk_soft_min / 100) != rv_data->vclk_soft_min) || 180 if (((hwmgr->uvd_arbiter.vclk_soft_min / 100) != rv_data->vclk_soft_min) ||
269 ((hwmgr->uvd_arbiter.dclk_soft_min / 100) != rv_data->dclk_soft_min)) { 181 ((hwmgr->uvd_arbiter.dclk_soft_min / 100) != rv_data->dclk_soft_min)) {
@@ -279,7 +191,7 @@ static int rv_tf_set_clock_limit(struct pp_hwmgr *hwmgr, void *input,
279 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, 191 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
280 PPSMC_MSG_SetHardMinSocclkByFreq, 192 PPSMC_MSG_SetHardMinSocclkByFreq,
281 hwmgr->gfx_arbiter.sclk_hard_min / 100); 193 hwmgr->gfx_arbiter.sclk_hard_min / 100);
282 rv_read_arg_from_smc(hwmgr->smumgr, &rv_data->soc_actual_hard_min_freq); 194 rv_read_arg_from_smc(hwmgr->smumgr, &rv_data->soc_actual_hard_min_freq);
283 } 195 }
284 196
285 if ((hwmgr->gfx_arbiter.gfxclk != 0) && 197 if ((hwmgr->gfx_arbiter.gfxclk != 0) &&
@@ -301,6 +213,7 @@ static int rv_tf_set_clock_limit(struct pp_hwmgr *hwmgr, void *input,
301 return 0; 213 return 0;
302} 214}
303 215
216
304static int rv_tf_set_num_active_display(struct pp_hwmgr *hwmgr, void *input, 217static int rv_tf_set_num_active_display(struct pp_hwmgr *hwmgr, void *input,
305 void *output, void *storage, int result) 218 void *output, void *storage, int result)
306{ 219{
@@ -313,6 +226,7 @@ static int rv_tf_set_num_active_display(struct pp_hwmgr *hwmgr, void *input,
313 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, 226 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
314 PPSMC_MSG_SetDisplayCount, 227 PPSMC_MSG_SetDisplayCount,
315 num_of_active_displays); 228 num_of_active_displays);
229
316 return 0; 230 return 0;
317} 231}
318 232
@@ -563,9 +477,6 @@ static int rv_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
563 return result; 477 return result;
564 } 478 }
565 479
566 phm_cap_set(hwmgr->platform_descriptor.platformCaps,
567 PHM_PlatformCaps_PowerPlaySupport);
568
569 rv_populate_clock_table(hwmgr); 480 rv_populate_clock_table(hwmgr);
570 481
571 result = rv_get_system_info_data(hwmgr); 482 result = rv_get_system_info_data(hwmgr);
@@ -624,8 +535,6 @@ static int rv_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
624 535
625 hwmgr->platform_descriptor.minimumClocksReductionPercentage = 50; 536 hwmgr->platform_descriptor.minimumClocksReductionPercentage = 50;
626 537
627 rv_init_vq_budget_table(hwmgr);
628
629 return result; 538 return result;
630} 539}
631 540
@@ -670,11 +579,6 @@ static int rv_hwmgr_backend_fini(struct pp_hwmgr *hwmgr)
670 hwmgr->dyn_state.vddc_dep_on_dal_pwrl = NULL; 579 hwmgr->dyn_state.vddc_dep_on_dal_pwrl = NULL;
671 } 580 }
672 581
673 if (NULL != hwmgr->dyn_state.vq_budgeting_table) {
674 kfree(hwmgr->dyn_state.vq_budgeting_table);
675 hwmgr->dyn_state.vq_budgeting_table = NULL;
676 }
677
678 kfree(hwmgr->backend); 582 kfree(hwmgr->backend);
679 hwmgr->backend = NULL; 583 hwmgr->backend = NULL;
680 584
@@ -711,18 +615,9 @@ static int rv_dpm_get_pp_table_entry_callback(
711{ 615{
712 struct rv_power_state *rv_ps = cast_rv_ps(hw_ps); 616 struct rv_power_state *rv_ps = cast_rv_ps(hw_ps);
713 617
714 const ATOM_PPLIB_CZ_CLOCK_INFO *rv_clock_info = clock_info; 618 rv_ps->levels[index].engine_clock = 0;
715
716 struct phm_clock_voltage_dependency_table *table =
717 hwmgr->dyn_state.vddc_dependency_on_sclk;
718 uint8_t clock_info_index = rv_clock_info->index;
719
720 if (clock_info_index > (uint8_t)(hwmgr->platform_descriptor.hardwareActivityPerformanceLevels - 1))
721 clock_info_index = (uint8_t)(hwmgr->platform_descriptor.hardwareActivityPerformanceLevels - 1);
722
723 rv_ps->levels[index].engine_clock = table->entries[clock_info_index].clk;
724 rv_ps->levels[index].vddc_index = (uint8_t)table->entries[clock_info_index].v;
725 619
620 rv_ps->levels[index].vddc_index = 0;
726 rv_ps->level = index + 1; 621 rv_ps->level = index + 1;
727 622
728 if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_SclkDeepSleep)) { 623 if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_SclkDeepSleep)) {
@@ -814,12 +709,12 @@ static int rv_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw_p
814 ps = cast_const_rv_ps(state); 709 ps = cast_const_rv_ps(state);
815 710
816 level_index = index > ps->level - 1 ? ps->level - 1 : index; 711 level_index = index > ps->level - 1 ? ps->level - 1 : index;
817 level->coreClock = ps->levels[level_index].engine_clock; 712 level->coreClock = 30000;
818 713
819 if (designation == PHM_PerformanceLevelDesignation_PowerContainment) { 714 if (designation == PHM_PerformanceLevelDesignation_PowerContainment) {
820 for (i = 1; i < ps->level; i++) { 715 for (i = 1; i < ps->level; i++) {
821 if (ps->levels[i].engine_clock > data->dce_slow_sclk_threshold) { 716 if (ps->levels[i].engine_clock > data->dce_slow_sclk_threshold) {
822 level->coreClock = ps->levels[i].engine_clock; 717 level->coreClock = 30000;
823 break; 718 break;
824 } 719 }
825 } 720 }
@@ -829,8 +724,9 @@ static int rv_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw_p
829 vol_dep_record_index = data->clock_vol_info.vdd_dep_on_fclk->count - 1; 724 vol_dep_record_index = data->clock_vol_info.vdd_dep_on_fclk->count - 1;
830 level->memory_clock = 725 level->memory_clock =
831 data->clock_vol_info.vdd_dep_on_fclk->entries[vol_dep_record_index].clk; 726 data->clock_vol_info.vdd_dep_on_fclk->entries[vol_dep_record_index].clk;
832 } else 727 } else {
833 level->memory_clock = data->clock_vol_info.vdd_dep_on_fclk->entries[0].clk; 728 level->memory_clock = data->clock_vol_info.vdd_dep_on_fclk->entries[0].clk;
729 }
834 730
835 level->nonLocalMemoryFreq = 0; 731 level->nonLocalMemoryFreq = 0;
836 level->nonLocalMemoryWidth = 0; 732 level->nonLocalMemoryWidth = 0;
@@ -1001,7 +897,8 @@ int rv_display_clock_voltage_request(struct pp_hwmgr *hwmgr,
1001 897
1002static int rv_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks) 898static int rv_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks)
1003{ 899{
1004 return -EINVAL; 900 clocks->engine_max_clock = 80000; /* driver can't get engine clock, temp hard code to 800MHz */
901 return 0;
1005} 902}
1006 903
1007static int rv_thermal_get_temperature(struct pp_hwmgr *hwmgr) 904static int rv_thermal_get_temperature(struct pp_hwmgr *hwmgr)