aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorRex Zhu <Rex.Zhu@amd.com>2017-01-06 00:32:49 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-01-27 11:13:14 -0500
commit570272d2296ce42b7d0b4c5afa5b668100930507 (patch)
tree127897c329a360f9d5392b3ec1b54e976237c8e6 /drivers/gpu/drm/amd
parent7f61bed0c45df0b58af589b0569ce3349cbc53cb (diff)
drm/amdgpu: extend profiling mode.
in profiling mode, powerplay will fix power state as stable as possible.and disable gfx cg and LBPW feature. profile_standard: as a prerequisite, ensure power and thermal sustainable, set clocks ratio as close to the highest clock ratio as possible. profile_min_sclk: fix mclk as profile_normal, set lowest sclk profile_min_mclk: fix sclk as profile_normal, set lowest mclk profile_peak: set highest sclk and mclk, power and thermal not sustainable profile_exit: exit profile mode. enable gfx cg/lbpw feature. 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/amdgpu/amdgpu_pm.c38
-rw-r--r--drivers/gpu/drm/amd/amdgpu/ci_dpm.c5
-rw-r--r--drivers/gpu/drm/amd/include/amd_shared.h6
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c3
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c127
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/hwmgr.h1
6 files changed, 154 insertions, 26 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 9abd8f6705c0..f35893c19531 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -142,12 +142,15 @@ static ssize_t amdgpu_get_dpm_forced_performance_level(struct device *dev,
142 142
143 level = amdgpu_dpm_get_performance_level(adev); 143 level = amdgpu_dpm_get_performance_level(adev);
144 return snprintf(buf, PAGE_SIZE, "%s\n", 144 return snprintf(buf, PAGE_SIZE, "%s\n",
145 (level & (AMD_DPM_FORCED_LEVEL_AUTO) ? "auto" : 145 (level == AMD_DPM_FORCED_LEVEL_AUTO) ? "auto" :
146 (level & AMD_DPM_FORCED_LEVEL_LOW) ? "low" : 146 (level == AMD_DPM_FORCED_LEVEL_LOW) ? "low" :
147 (level & AMD_DPM_FORCED_LEVEL_HIGH) ? "high" : 147 (level == AMD_DPM_FORCED_LEVEL_HIGH) ? "high" :
148 (level & AMD_DPM_FORCED_LEVEL_MANUAL) ? "manual" : 148 (level == AMD_DPM_FORCED_LEVEL_MANUAL) ? "manual" :
149 (level & AMD_DPM_FORCED_LEVEL_PROFILING) ? "profiling" : 149 (level == AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD) ? "profile_standard" :
150 "unknown")); 150 (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) ? "profile_min_sclk" :
151 (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK) ? "profile_min_mclk" :
152 (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) ? "profile_peak" :
153 "unknown");
151} 154}
152 155
153static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev, 156static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
@@ -176,9 +179,17 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
176 level = AMD_DPM_FORCED_LEVEL_AUTO; 179 level = AMD_DPM_FORCED_LEVEL_AUTO;
177 } else if (strncmp("manual", buf, strlen("manual")) == 0) { 180 } else if (strncmp("manual", buf, strlen("manual")) == 0) {
178 level = AMD_DPM_FORCED_LEVEL_MANUAL; 181 level = AMD_DPM_FORCED_LEVEL_MANUAL;
179 } else if (strncmp("profile", buf, strlen("profile")) == 0) { 182 } else if (strncmp("profile_exit", buf, strlen("profile_exit")) == 0) {
180 level = AMD_DPM_FORCED_LEVEL_PROFILING; 183 level = AMD_DPM_FORCED_LEVEL_PROFILE_EXIT;
181 } else { 184 } else if (strncmp("profile_standard", buf, strlen("profile_standard")) == 0) {
185 level = AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD;
186 } else if (strncmp("profile_min_sclk", buf, strlen("profile_min_sclk")) == 0) {
187 level = AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK;
188 } else if (strncmp("profile_min_mclk", buf, strlen("profile_min_mclk")) == 0) {
189 level = AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK;
190 } else if (strncmp("profile_peak", buf, strlen("profile_peak")) == 0) {
191 level = AMD_DPM_FORCED_LEVEL_PROFILE_PEAK;
192 } else {
182 count = -EINVAL; 193 count = -EINVAL;
183 goto fail; 194 goto fail;
184 } 195 }
@@ -186,14 +197,6 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
186 if (current_level == level) 197 if (current_level == level)
187 return count; 198 return count;
188 199
189 if (level == AMD_DPM_FORCED_LEVEL_PROFILING)
190 amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
191 AMD_CG_STATE_UNGATE);
192 else if (level != AMD_DPM_FORCED_LEVEL_PROFILING &&
193 current_level == AMD_DPM_FORCED_LEVEL_PROFILING)
194 amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
195 AMD_CG_STATE_GATE);
196
197 if (adev->pp_enabled) 200 if (adev->pp_enabled)
198 amdgpu_dpm_force_performance_level(adev, level); 201 amdgpu_dpm_force_performance_level(adev, level);
199 else { 202 else {
@@ -210,6 +213,7 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
210 adev->pm.dpm.forced_level = level; 213 adev->pm.dpm.forced_level = level;
211 mutex_unlock(&adev->pm.mutex); 214 mutex_unlock(&adev->pm.mutex);
212 } 215 }
216
213fail: 217fail:
214 return count; 218 return count;
215} 219}
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
index 9a544ad41f4c..ece94eeb638e 100644
--- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
@@ -6571,8 +6571,9 @@ static int ci_dpm_force_clock_level(struct amdgpu_device *adev,
6571{ 6571{
6572 struct ci_power_info *pi = ci_get_pi(adev); 6572 struct ci_power_info *pi = ci_get_pi(adev);
6573 6573
6574 if (!(adev->pm.dpm.forced_level & 6574 if (adev->pm.dpm.forced_level & (AMD_DPM_FORCED_LEVEL_AUTO |
6575 (AMD_DPM_FORCED_LEVEL_MANUAL | AMD_DPM_FORCED_LEVEL_PROFILING))) 6575 AMD_DPM_FORCED_LEVEL_LOW |
6576 AMD_DPM_FORCED_LEVEL_HIGH))
6576 return -EINVAL; 6577 return -EINVAL;
6577 6578
6578 switch (type) { 6579 switch (type) {
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index 5fffe6f72640..43f45adeccd1 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -85,7 +85,11 @@ enum amd_dpm_forced_level {
85 AMD_DPM_FORCED_LEVEL_MANUAL = 0x2, 85 AMD_DPM_FORCED_LEVEL_MANUAL = 0x2,
86 AMD_DPM_FORCED_LEVEL_LOW = 0x4, 86 AMD_DPM_FORCED_LEVEL_LOW = 0x4,
87 AMD_DPM_FORCED_LEVEL_HIGH = 0x8, 87 AMD_DPM_FORCED_LEVEL_HIGH = 0x8,
88 AMD_DPM_FORCED_LEVEL_PROFILING = 0x10, 88 AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD = 0x10,
89 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK = 0x20,
90 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK = 0x40,
91 AMD_DPM_FORCED_LEVEL_PROFILE_PEAK = 0x80,
92 AMD_DPM_FORCED_LEVEL_PROFILE_EXIT = 0x100,
89}; 93};
90 94
91enum amd_powergating_state { 95enum amd_powergating_state {
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
index c15af0b6797c..a4cde3d778b8 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
@@ -1650,8 +1650,7 @@ static int cz_get_dal_power_level(struct pp_hwmgr *hwmgr,
1650static int cz_force_clock_level(struct pp_hwmgr *hwmgr, 1650static int cz_force_clock_level(struct pp_hwmgr *hwmgr,
1651 enum pp_clock_type type, uint32_t mask) 1651 enum pp_clock_type type, uint32_t mask)
1652{ 1652{
1653 if (!(hwmgr->dpm_level & 1653 if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL)
1654 (AMD_DPM_FORCED_LEVEL_MANUAL | AMD_DPM_FORCED_LEVEL_PROFILING)))
1655 return -EINVAL; 1654 return -EINVAL;
1656 1655
1657 switch (type) { 1656 switch (type) {
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 3777996b36dc..6c661bb7e2f3 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -90,6 +90,8 @@ enum DPM_EVENT_SRC {
90}; 90};
91 91
92static const unsigned long PhwVIslands_Magic = (unsigned long)(PHM_VIslands_Magic); 92static const unsigned long PhwVIslands_Magic = (unsigned long)(PHM_VIslands_Magic);
93static int smu7_force_clock_level(struct pp_hwmgr *hwmgr,
94 enum pp_clock_type type, uint32_t mask);
93 95
94static struct smu7_power_state *cast_phw_smu7_power_state( 96static struct smu7_power_state *cast_phw_smu7_power_state(
95 struct pp_hw_power_state *hw_ps) 97 struct pp_hw_power_state *hw_ps)
@@ -2488,36 +2490,152 @@ static int smu7_force_dpm_lowest(struct pp_hwmgr *hwmgr)
2488 } 2490 }
2489 2491
2490 return 0; 2492 return 0;
2493}
2494
2495static int smu7_get_profiling_clk(struct pp_hwmgr *hwmgr, enum amd_dpm_forced_level level,
2496 uint32_t *sclk_mask, uint32_t *mclk_mask, uint32_t *pcie_mask)
2497{
2498 uint32_t percentage;
2499 struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
2500 struct smu7_dpm_table *golden_dpm_table = &data->golden_dpm_table;
2501 int32_t tmp_mclk;
2502 int32_t tmp_sclk;
2503 int32_t count;
2504
2505 if (golden_dpm_table->mclk_table.count < 1)
2506 return -EINVAL;
2507
2508 percentage = 100 * golden_dpm_table->sclk_table.dpm_levels[golden_dpm_table->sclk_table.count - 1].value /
2509 golden_dpm_table->mclk_table.dpm_levels[golden_dpm_table->mclk_table.count - 1].value;
2510
2511 if (golden_dpm_table->mclk_table.count == 1) {
2512 percentage = 70;
2513 tmp_mclk = golden_dpm_table->mclk_table.dpm_levels[golden_dpm_table->mclk_table.count - 1].value;
2514 *mclk_mask = golden_dpm_table->mclk_table.count - 1;
2515 } else {
2516 tmp_mclk = golden_dpm_table->mclk_table.dpm_levels[golden_dpm_table->mclk_table.count - 2].value;
2517 *mclk_mask = golden_dpm_table->mclk_table.count - 2;
2518 }
2519
2520 tmp_sclk = tmp_mclk * percentage / 100;
2521
2522 if (hwmgr->pp_table_version == PP_TABLE_V0) {
2523 for (count = hwmgr->dyn_state.vddc_dependency_on_sclk->count-1;
2524 count >= 0; count--) {
2525 if (tmp_sclk >= hwmgr->dyn_state.vddc_dependency_on_sclk->entries[count].clk) {
2526 tmp_sclk = hwmgr->dyn_state.vddc_dependency_on_sclk->entries[count].clk;
2527 *sclk_mask = count;
2528 break;
2529 }
2530 }
2531 if (count < 0 || level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK)
2532 *sclk_mask = 0;
2533
2534 if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK)
2535 *sclk_mask = hwmgr->dyn_state.vddc_dependency_on_sclk->count-1;
2536 } else if (hwmgr->pp_table_version == PP_TABLE_V1) {
2537 struct phm_ppt_v1_information *table_info =
2538 (struct phm_ppt_v1_information *)(hwmgr->pptable);
2491 2539
2540 for (count = table_info->vdd_dep_on_sclk->count-1; count >= 0; count--) {
2541 if (tmp_sclk >= table_info->vdd_dep_on_sclk->entries[count].clk) {
2542 tmp_sclk = table_info->vdd_dep_on_sclk->entries[count].clk;
2543 *sclk_mask = count;
2544 break;
2545 }
2546 }
2547 if (count < 0 || level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK)
2548 *sclk_mask = 0;
2549
2550 if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK)
2551 *sclk_mask = table_info->vdd_dep_on_sclk->count - 1;
2552 }
2553
2554 if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK)
2555 *mclk_mask = 0;
2556 else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK)
2557 *mclk_mask = golden_dpm_table->mclk_table.count - 1;
2558
2559 *pcie_mask = data->dpm_table.pcie_speed_table.count - 1;
2560 return 0;
2492} 2561}
2562
2493static int smu7_force_dpm_level(struct pp_hwmgr *hwmgr, 2563static int smu7_force_dpm_level(struct pp_hwmgr *hwmgr,
2494 enum amd_dpm_forced_level level) 2564 enum amd_dpm_forced_level level)
2495{ 2565{
2496 int ret = 0; 2566 int ret = 0;
2567 uint32_t sclk_mask = 0;
2568 uint32_t mclk_mask = 0;
2569 uint32_t pcie_mask = 0;
2570 uint32_t profile_mode_mask = AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD |
2571 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK |
2572 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK |
2573 AMD_DPM_FORCED_LEVEL_PROFILE_PEAK;
2574
2575 if (level == hwmgr->dpm_level)
2576 return ret;
2577
2578 if (!(hwmgr->dpm_level & profile_mode_mask)) {
2579 /* enter profile mode, save current level, disable gfx cg*/
2580 if (level & profile_mode_mask) {
2581 hwmgr->saved_dpm_level = hwmgr->dpm_level;
2582 cgs_set_clockgating_state(hwmgr->device,
2583 AMD_IP_BLOCK_TYPE_GFX,
2584 AMD_CG_STATE_UNGATE);
2585 }
2586 } else {
2587 /* exit profile mode, restore level, enable gfx cg*/
2588 if (!(level & profile_mode_mask)) {
2589 if (level == AMD_DPM_FORCED_LEVEL_PROFILE_EXIT)
2590 level = hwmgr->saved_dpm_level;
2591 cgs_set_clockgating_state(hwmgr->device,
2592 AMD_IP_BLOCK_TYPE_GFX,
2593 AMD_CG_STATE_GATE);
2594 }
2595 }
2497 2596
2498 switch (level) { 2597 switch (level) {
2499 case AMD_DPM_FORCED_LEVEL_HIGH: 2598 case AMD_DPM_FORCED_LEVEL_HIGH:
2500 ret = smu7_force_dpm_highest(hwmgr); 2599 ret = smu7_force_dpm_highest(hwmgr);
2501 if (ret) 2600 if (ret)
2502 return ret; 2601 return ret;
2602 hwmgr->dpm_level = level;
2503 break; 2603 break;
2504 case AMD_DPM_FORCED_LEVEL_LOW: 2604 case AMD_DPM_FORCED_LEVEL_LOW:
2505 ret = smu7_force_dpm_lowest(hwmgr); 2605 ret = smu7_force_dpm_lowest(hwmgr);
2506 if (ret) 2606 if (ret)
2507 return ret; 2607 return ret;
2608 hwmgr->dpm_level = level;
2508 break; 2609 break;
2509 case AMD_DPM_FORCED_LEVEL_AUTO: 2610 case AMD_DPM_FORCED_LEVEL_AUTO:
2510 ret = smu7_unforce_dpm_levels(hwmgr); 2611 ret = smu7_unforce_dpm_levels(hwmgr);
2511 if (ret) 2612 if (ret)
2512 return ret; 2613 return ret;
2614 hwmgr->dpm_level = level;
2615 break;
2616 case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD:
2617 case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK:
2618 case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK:
2619 case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK:
2620 ret = smu7_get_profiling_clk(hwmgr, level, &sclk_mask, &mclk_mask, &pcie_mask);
2621 if (ret)
2622 return ret;
2623 hwmgr->dpm_level = level;
2624 smu7_force_clock_level(hwmgr, PP_SCLK, 1<<sclk_mask);
2625 smu7_force_clock_level(hwmgr, PP_MCLK, 1<<mclk_mask);
2626 smu7_force_clock_level(hwmgr, PP_PCIE, 1<<pcie_mask);
2513 break; 2627 break;
2628 case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT:
2514 default: 2629 default:
2515 break; 2630 break;
2516 } 2631 }
2517 2632
2518 hwmgr->dpm_level = level; 2633 if (level & (AMD_DPM_FORCED_LEVEL_PROFILE_PEAK | AMD_DPM_FORCED_LEVEL_HIGH))
2634 smu7_fan_ctrl_set_fan_speed_percent(hwmgr, 100);
2635 else
2636 smu7_fan_ctrl_reset_fan_speed_to_default(hwmgr);
2519 2637
2520 return ret; 2638 return 0;
2521} 2639}
2522 2640
2523static int smu7_get_power_state_size(struct pp_hwmgr *hwmgr) 2641static int smu7_get_power_state_size(struct pp_hwmgr *hwmgr)
@@ -4051,8 +4169,9 @@ static int smu7_force_clock_level(struct pp_hwmgr *hwmgr,
4051{ 4169{
4052 struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); 4170 struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
4053 4171
4054 if (!(hwmgr->dpm_level & 4172 if (hwmgr->dpm_level & (AMD_DPM_FORCED_LEVEL_AUTO |
4055 (AMD_DPM_FORCED_LEVEL_MANUAL | AMD_DPM_FORCED_LEVEL_PROFILING))) 4173 AMD_DPM_FORCED_LEVEL_LOW |
4174 AMD_DPM_FORCED_LEVEL_HIGH))
4056 return -EINVAL; 4175 return -EINVAL;
4057 4176
4058 switch (type) { 4177 switch (type) {
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 27217a7ae039..7275a29293eb 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -612,6 +612,7 @@ struct pp_hwmgr {
612 uint32_t num_vce_state_tables; 612 uint32_t num_vce_state_tables;
613 613
614 enum amd_dpm_forced_level dpm_level; 614 enum amd_dpm_forced_level dpm_level;
615 enum amd_dpm_forced_level saved_dpm_level;
615 bool block_hw_access; 616 bool block_hw_access;
616 struct phm_gfx_arbiter gfx_arbiter; 617 struct phm_gfx_arbiter gfx_arbiter;
617 struct phm_acp_arbiter acp_arbiter; 618 struct phm_acp_arbiter acp_arbiter;