Skip to contentSkip to conversation

drm/i915: Use DIV_ROUND_CLOSEST() to calculate dot/vco

PATCH In review [email protected] 3 participants 5 messages Oct 14, 2013

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

PATCH 1/2 drm/i915: Use DIV_ROUND_CLOSEST() to calculate dot/vco

From: Ville Syrjälä <[email protected]>

Rounding down when calculating the dot/vco frequencies doesn't make much sense. Round to closest should give slightly nicer answers.

---
 drivers/gpu/drm/i915/intel_display.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +6 -6
index fbd028e..baa6ef6 100644
@@ -329,8 +329,8 @@ static void vlv_clock(int refclk, intel_clock_t *clock)
 {
 	clock->m = clock->m1 * clock->m2;
 	clock->p = clock->p1 * clock->p2;
-	clock->vco = refclk * clock->m / clock->n;
-	clock->dot = clock->vco / clock->p;
+	clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n);
+	clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
 }
 
 /**
@@ -430,8 +430,8 @@ static void pineview_clock(int refclk, intel_clock_t *clock)
 {
 	clock->m = clock->m2 + 2;
 	clock->p = clock->p1 * clock->p2;
-	clock->vco = refclk * clock->m / clock->n;
-	clock->dot = clock->vco / clock->p;
+	clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n);
+	clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
 }
 
 static uint32_t i9xx_dpll_compute_m(struct dpll *dpll)
@@ -443,8 +443,8 @@ static void i9xx_clock(int refclk, intel_clock_t *clock)
 {
 	clock->m = i9xx_dpll_compute_m(clock);
 	clock->p = clock->p1 * clock->p2;
-	clock->vco = refclk * clock->m / (clock->n + 2);
-	clock->dot = clock->vco / clock->p;
+	clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n + 2);
+	clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
 }
 
 #define INTELPllInvalid(s)   do { /* DRM_DEBUG(s); */ return false; } while (0)
Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 drm/i915: Use vlv_clock() in vlv_crtc_clock_get()

From: Ville Syrjälä <[email protected]>

Avoid some code duplication.

---
 drivers/gpu/drm/i915/intel_display.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -3
index baa6ef6..b334c50 100644
@@ -5211,10 +5211,10 @@ static void vlv_crtc_clock_get(struct intel_crtc *crtc,
 	clock.p1 = (mdiv >> DPIO_P1_SHIFT) & 7;
 	clock.p2 = (mdiv >> DPIO_P2_SHIFT) & 0x1f;
 
-	clock.vco = refclk * clock.m1 * clock.m2 / clock.n;
-	clock.dot = 2 * clock.vco / (clock.p1 * clock.p2);
+	vlv_clock(refclk, &clock);
 
-	pipe_config->port_clock = clock.dot / 10;
+	/* clock.dot is the fast clock */
+	pipe_config->port_clock = clock.dot / 5;
 }
 
 static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/i915: Use vlv_clock() in vlv_crtc_clock_get()

Quoted 17 lines · On Mon, 14 Oct 2013 14:50:31 +0300 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Avoid some code duplication.

---
 drivers/gpu/drm/i915/intel_display.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index baa6ef6..b334c50 100644
@@ -5211,10 +5211,10 @@ static void vlv_crtc_clock_get(struct intel_crtc *crtc,
 	clock.p1 = (mdiv >> DPIO_P1_SHIFT) & 7;
 	clock.p2 = (mdiv >> DPIO_P2_SHIFT) & 0x1f;
 

drivers/gpu/drm/i915/intel_display.c static void vlv_crtc_clock_get(struct intel_crtc *crtc, · line 5220

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +3 -3
-	clock.vco = refclk * clock.m1 * clock.m2 / clock.n;
-	clock.dot = 2 * clock.vco / (clock.p1 * clock.p2);
+	vlv_clock(refclk, &clock);
 
-	pipe_config->port_clock = clock.dot / 10;
+	/* clock.dot is the fast clock */
+	pipe_config->port_clock = clock.dot / 5;
 }
 
 static bool i9xx_get_pipe_config(struct intel_crtc *crtc,

Looks like this will result in the same bits.

Signature · 5 lines
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH 2/2] drm/i915: Use vlv_clock() in vlv_crtc_clock_get()

Quoted 29 lines · Jesse Barnes
Quoted 26 lines · On Mon, 14 Oct 2013 14:50:31 +0300 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Avoid some code duplication.

---
 drivers/gpu/drm/i915/intel_display.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -3
index baa6ef6..b334c50 100644
@@ -5211,10 +5211,10 @@ static void vlv_crtc_clock_get(struct intel_crtc *crtc,
 	clock.p1 = (mdiv >> DPIO_P1_SHIFT) & 7;
 	clock.p2 = (mdiv >> DPIO_P2_SHIFT) & 0x1f;
 
-	clock.vco = refclk * clock.m1 * clock.m2 / clock.n;
-	clock.dot = 2 * clock.vco / (clock.p1 * clock.p2);
+	vlv_clock(refclk, &clock);
 
-	pipe_config->port_clock = clock.dot / 10;
+	/* clock.dot is the fast clock */
+	pipe_config->port_clock = clock.dot / 5;
 }
 
Quoted 5 lines

drivers/gpu/drm/i915/intel_display.c static void vlv_crtc_clock_get(struct intel_crtc *crtc, · line 5220

Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +0 -0
 static bool i9xx_get_pipe_config(struct intel_crtc *crtc,

Looks like this will result in the same bits.

Both merged, thanks for patches&review.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Reviewed-by on v1 1/2
#4 lore raw
In reply to [email protected]
Quoted 37 lines · On Mon, 14 Oct 2013 14:50:30 +0300 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Rounding down when calculating the dot/vco frequencies doesn't make much sense. Round to closest should give slightly nicer answers.

---
 drivers/gpu/drm/i915/intel_display.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +4 -4
index fbd028e..baa6ef6 100644
@@ -329,8 +329,8 @@ static void vlv_clock(int refclk, intel_clock_t *clock)
 {
 	clock->m = clock->m1 * clock->m2;
 	clock->p = clock->p1 * clock->p2;
-	clock->vco = refclk * clock->m / clock->n;
-	clock->dot = clock->vco / clock->p;
+	clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n);
+	clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
 }
 
 /**
@@ -430,8 +430,8 @@ static void pineview_clock(int refclk, intel_clock_t *clock)
 {
 	clock->m = clock->m2 + 2;
 	clock->p = clock->p1 * clock->p2;
-	clock->vco = refclk * clock->m / clock->n;
-	clock->dot = clock->vco / clock->p;
+	clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n);
+	clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
 }
 
 static uint32_t i9xx_dpll_compute_m(struct dpll *dpll)

drivers/gpu/drm/i915/intel_display.c static void i9xx_clock(int refclk, intel_clock_t *clock) · line 450

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +2 -2
@@ -443,8 +443,8 @@ static void i9xx_clock(int refclk, intel_clock_t *clock)
 {
 	clock->m = i9xx_dpll_compute_m(clock);
 	clock->p = clock->p1 * clock->p2;
-	clock->vco = refclk * clock->m / (clock->n + 2);
-	clock->dot = clock->vco / clock->p;
+	clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n + 2);
+	clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
 }
 
 #define INTELPllInvalid(s)   do { /* DRM_DEBUG(s); */ return false; } while (0)
Signature · 5 lines
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx