Skip to contentSkip to conversation

drm/radeon/dpm/rs780: use drm_mode_vrefresh()

PATCH In review Alex Deucher 2 participants 5 messages Sep 13, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 drm/radeon/dpm/rs780: use drm_mode_vrefresh()

Rather than open coding it.

---
 drivers/gpu/drm/radeon/rs780_dpm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/radeon/rs780_dpm.c +1 -3
index 828a776..afb7584 100644
@@ -62,9 +62,7 @@ static void rs780_get_pm_mode_parameters(struct radeon_device *rdev)
 			radeon_crtc = to_radeon_crtc(crtc);
 			pi->crtc_id = radeon_crtc->crtc_id;
 			if (crtc->mode.htotal && crtc->mode.vtotal)
-				pi->refresh_rate =
-					(crtc->mode.clock * 1000) /
-					(crtc->mode.htotal * crtc->mode.vtotal);
+				pi->refresh_rate = drm_mode_vrefresh(&crtc->mode);
 			break;
 		}
 	}
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 2/4 drm/radeon/dpm/rs780: add some sanity checking to sclk scaling

Since the clock scaling is based on fb divider adjustments, make sure the other pll parameters are the same.

---
 drivers/gpu/drm/radeon/rs780_dpm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/radeon/rs780_dpm.c +6 -0
index afb7584..31487ce 100644
@@ -449,6 +449,12 @@ static int rs780_set_engine_clock_scaling(struct radeon_device *rdev,
 	if (ret)
 		return ret;
 
+	if ((min_dividers.ref_div != max_dividers.ref_div) ||
+	    (min_dividers.post_div != max_dividers.post_div) ||
+	    (max_dividers.ref_div != current_max_dividers.ref_div) ||
+	    (max_dividers.post_div != current_max_dividers.post_div))
+		return -EINVAL;
+
 	rs780_force_fbdiv(rdev, max_dividers.fb_div);
 
 	if (max_dividers.fb_div > min_dividers.fb_div) {
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 3/4 drm/radeon/dpm/rs780: don't enable sclk scaling if not required

In reply to Alex Deucher

If the low and high sclks are the same, there is no need to enable sclk scaling. This causes display stability issues on certain boards.

Fixes:
https://bugzilla.kernel.org/show_bug.cgi?id=60857

---
 drivers/gpu/drm/radeon/rs780_dpm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/radeon/rs780_dpm.c +3 -0
index 31487ce..eb336bf 100644
@@ -499,6 +499,9 @@ static void rs780_activate_engine_clk_scaling(struct radeon_device *rdev,
 	    (new_state->sclk_low == old_state->sclk_low))
 		return;
 
+	if (new_state->sclk_high == new_state->sclk_low)
+		return;
+
 	rs780_clk_scaling_enable(rdev, true);
 }
 
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 4/4 drm/radeon/dpm/rs780: fix force_performance state for same sclks

In reply to Alex Deucher

If the low and high sclks within a power state are the same, there no need to enable sclk scaling. Enabling sclk scaling can cause display stability issues on some boards.

---
 drivers/gpu/drm/radeon/rs780_dpm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/rs780_dpm.c +4 -2
index eb336bf..6af8505 100644
@@ -1043,8 +1043,10 @@ int rs780_dpm_force_performance_level(struct radeon_device *rdev,
 		if (pi->voltage_control)
 			rs780_force_voltage(rdev, pi->max_voltage);
 
-		WREG32_P(FVTHROT_FBDIV_REG1, 0, ~FORCE_FEEDBACK_DIV);
-		rs780_clk_scaling_enable(rdev, true);
+		if (ps->sclk_high != ps->sclk_low) {
+			WREG32_P(FVTHROT_FBDIV_REG1, 0, ~FORCE_FEEDBACK_DIV);
+			rs780_clk_scaling_enable(rdev, true);
+		}
 
 		if (pi->voltage_control) {
 			rs780_voltage_scaling_enable(rdev, true);
Signature · 1 line
1.8.3.1
#4 lore raw
In reply to Alex Deucher

Am 13.09.2013 17:08, schrieb Alex Deucher:

Quoted 3 lines

Rather than open coding it.

For this series: Reviewed-by: Christian König <[email protected]>

Quoted 19 lines
---
  drivers/gpu/drm/radeon/rs780_dpm.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/radeon/rs780_dpm.c +1 -3
index 828a776..afb7584 100644
@@ -62,9 +62,7 @@ static void rs780_get_pm_mode_parameters(struct radeon_device *rdev)
  			radeon_crtc = to_radeon_crtc(crtc);
  			pi->crtc_id = radeon_crtc->crtc_id;
  			if (crtc->mode.htotal && crtc->mode.vtotal)
-				pi->refresh_rate =
-					(crtc->mode.clock * 1000) /
-					(crtc->mode.htotal * crtc->mode.vtotal);
+				pi->refresh_rate = drm_mode_vrefresh(&crtc->mode);
  			break;
  		}
  	}