[PATCH] drm/amdgpu: not hardcode high performance level to 1 on Ci.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change-Id: I39009697639f1aeaefbe444bae2bf081f156de61
Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
index 1027f92..8683782 100644
--- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
@@ -913,6 +913,15 @@ static void ci_apply_state_adjust_rules(struct amdgpu_device *adev,
 	bool disable_mclk_switching;
 	u32 sclk, mclk;
 	int i;
+	int high_level;
+
+
+	if (ps == NULL || ps->performance_level_count < 1) {
+		DRM_ERROR("failed to apply state adjust\n");
+		return;
+	}
+
+	high_level = ps->performance_level_count - 1;
 
 	if (rps->vce_active) {
 		rps->evclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].evclk;
@@ -950,7 +959,7 @@ static void ci_apply_state_adjust_rules(struct amdgpu_device *adev,
 	/* XXX validate the min clocks required for display */
 
 	if (disable_mclk_switching) {
-		mclk  = ps->performance_levels[ps->performance_level_count - 1].mclk;
+		mclk  = ps->performance_levels[high_level].mclk;
 		sclk = ps->performance_levels[0].sclk;
 	} else {
 		mclk = ps->performance_levels[0].mclk;
@@ -973,15 +982,15 @@ static void ci_apply_state_adjust_rules(struct amdgpu_device *adev,
 	ps->performance_levels[0].sclk = sclk;
 	ps->performance_levels[0].mclk = mclk;
 
-	if (ps->performance_levels[1].sclk < ps->performance_levels[0].sclk)
-		ps->performance_levels[1].sclk = ps->performance_levels[0].sclk;
+	if (ps->performance_levels[high_level].sclk < ps->performance_levels[0].sclk)
+		ps->performance_levels[high_level].sclk = ps->performance_levels[0].sclk;
 
 	if (disable_mclk_switching) {
-		if (ps->performance_levels[0].mclk < ps->performance_levels[1].mclk)
-			ps->performance_levels[0].mclk = ps->performance_levels[1].mclk;
+		if (ps->performance_levels[0].mclk < ps->performance_levels[high_level].mclk)
+			ps->performance_levels[0].mclk = ps->performance_levels[high_level].mclk;
 	} else {
-		if (ps->performance_levels[1].mclk < ps->performance_levels[0].mclk)
-			ps->performance_levels[1].mclk = ps->performance_levels[0].mclk;
+		if (ps->performance_levels[high_level].mclk < ps->performance_levels[0].mclk)
+			ps->performance_levels[high_level].mclk = ps->performance_levels[0].mclk;
 	}
 }
 
-- 
1.9.1



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux