aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Vivi <rodrigo.vivi@intel.com>2014-10-17 11:05:08 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-10-24 10:34:12 -0400
commit5e56ba45053ab5d7a77b60924e7a15cbbb11dcad (patch)
tree4bff497aff1f50acb0e2a77bf1b190bd9538c405
parentf7f3d48ac858e4d2f0c71f8479d4ea022a35dd9c (diff)
drm/i915/chv: Use 16 and 32 for low and high drain latency precision.
Current chv spec teels we can only use either 16 or 32 bits as precision. Although in the past VLV went from 16/32 to 32/64 and spec might not be updated, these precision values brings stability and fixes some issues Wayne was facing. Cc: Wayne Boyer <wayne.boyer@intel.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Tested-by: Wayne Boyer <wayne.boyer@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> [danvet: Sprinkle const as requested by Ville.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h13
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c40
2 files changed, 32 insertions, 21 deletions
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 46cfbc7466ef..1e6f7fb15672 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -4054,17 +4054,18 @@ enum punit_power_well {
4054#define DSPFW_PLANEA_WM1_HI_MASK (1<<0) 4054#define DSPFW_PLANEA_WM1_HI_MASK (1<<0)
4055 4055
4056/* drain latency register values*/ 4056/* drain latency register values*/
4057#define DRAIN_LATENCY_PRECISION_16 16
4057#define DRAIN_LATENCY_PRECISION_32 32 4058#define DRAIN_LATENCY_PRECISION_32 32
4058#define DRAIN_LATENCY_PRECISION_64 64 4059#define DRAIN_LATENCY_PRECISION_64 64
4059#define VLV_DDL(pipe) (VLV_DISPLAY_BASE + 0x70050 + 4 * (pipe)) 4060#define VLV_DDL(pipe) (VLV_DISPLAY_BASE + 0x70050 + 4 * (pipe))
4060#define DDL_CURSOR_PRECISION_64 (1<<31) 4061#define DDL_CURSOR_PRECISION_HIGH (1<<31)
4061#define DDL_CURSOR_PRECISION_32 (0<<31) 4062#define DDL_CURSOR_PRECISION_LOW (0<<31)
4062#define DDL_CURSOR_SHIFT 24 4063#define DDL_CURSOR_SHIFT 24
4063#define DDL_SPRITE_PRECISION_64(sprite) (1<<(15+8*(sprite))) 4064#define DDL_SPRITE_PRECISION_HIGH(sprite) (1<<(15+8*(sprite)))
4064#define DDL_SPRITE_PRECISION_32(sprite) (0<<(15+8*(sprite))) 4065#define DDL_SPRITE_PRECISION_LOW(sprite) (0<<(15+8*(sprite)))
4065#define DDL_SPRITE_SHIFT(sprite) (8+8*(sprite)) 4066#define DDL_SPRITE_SHIFT(sprite) (8+8*(sprite))
4066#define DDL_PLANE_PRECISION_64 (1<<7) 4067#define DDL_PLANE_PRECISION_HIGH (1<<7)
4067#define DDL_PLANE_PRECISION_32 (0<<7) 4068#define DDL_PLANE_PRECISION_LOW (0<<7)
4068#define DDL_PLANE_SHIFT 0 4069#define DDL_PLANE_SHIFT 0
4069#define DRAIN_LATENCY_MASK 0x7f 4070#define DRAIN_LATENCY_MASK 0x7f
4070 4071
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 23d331884944..7a69eba533c7 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -1345,6 +1345,7 @@ static bool vlv_compute_drain_latency(struct drm_crtc *crtc,
1345 int *prec_mult, 1345 int *prec_mult,
1346 int *drain_latency) 1346 int *drain_latency)
1347{ 1347{
1348 struct drm_device *dev = crtc->dev;
1348 int entries; 1349 int entries;
1349 int clock = to_intel_crtc(crtc)->config.adjusted_mode.crtc_clock; 1350 int clock = to_intel_crtc(crtc)->config.adjusted_mode.crtc_clock;
1350 1351
@@ -1355,8 +1356,12 @@ static bool vlv_compute_drain_latency(struct drm_crtc *crtc,
1355 return false; 1356 return false;
1356 1357
1357 entries = DIV_ROUND_UP(clock, 1000) * pixel_size; 1358 entries = DIV_ROUND_UP(clock, 1000) * pixel_size;
1358 *prec_mult = (entries > 128) ? DRAIN_LATENCY_PRECISION_64 : 1359 if (IS_CHERRYVIEW(dev))
1359 DRAIN_LATENCY_PRECISION_32; 1360 *prec_mult = (entries > 128) ? DRAIN_LATENCY_PRECISION_32 :
1361 DRAIN_LATENCY_PRECISION_16;
1362 else
1363 *prec_mult = (entries > 128) ? DRAIN_LATENCY_PRECISION_64 :
1364 DRAIN_LATENCY_PRECISION_32;
1360 *drain_latency = (64 * (*prec_mult) * 4) / entries; 1365 *drain_latency = (64 * (*prec_mult) * 4) / entries;
1361 1366
1362 if (*drain_latency > DRAIN_LATENCY_MASK) 1367 if (*drain_latency > DRAIN_LATENCY_MASK)
@@ -1375,15 +1380,18 @@ static bool vlv_compute_drain_latency(struct drm_crtc *crtc,
1375 1380
1376static void vlv_update_drain_latency(struct drm_crtc *crtc) 1381static void vlv_update_drain_latency(struct drm_crtc *crtc)
1377{ 1382{
1378 struct drm_i915_private *dev_priv = crtc->dev->dev_private; 1383 struct drm_device *dev = crtc->dev;
1384 struct drm_i915_private *dev_priv = dev->dev_private;
1379 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 1385 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1380 int pixel_size; 1386 int pixel_size;
1381 int drain_latency; 1387 int drain_latency;
1382 enum pipe pipe = intel_crtc->pipe; 1388 enum pipe pipe = intel_crtc->pipe;
1383 int plane_prec, prec_mult, plane_dl; 1389 int plane_prec, prec_mult, plane_dl;
1390 const int high_precision = IS_CHERRYVIEW(dev) ?
1391 DRAIN_LATENCY_PRECISION_32 : DRAIN_LATENCY_PRECISION_64;
1384 1392
1385 plane_dl = I915_READ(VLV_DDL(pipe)) & ~(DDL_PLANE_PRECISION_64 | 1393 plane_dl = I915_READ(VLV_DDL(pipe)) & ~(DDL_PLANE_PRECISION_HIGH |
1386 DRAIN_LATENCY_MASK | DDL_CURSOR_PRECISION_64 | 1394 DRAIN_LATENCY_MASK | DDL_CURSOR_PRECISION_HIGH |
1387 (DRAIN_LATENCY_MASK << DDL_CURSOR_SHIFT)); 1395 (DRAIN_LATENCY_MASK << DDL_CURSOR_SHIFT));
1388 1396
1389 if (!intel_crtc_active(crtc)) { 1397 if (!intel_crtc_active(crtc)) {
@@ -1394,9 +1402,9 @@ static void vlv_update_drain_latency(struct drm_crtc *crtc)
1394 /* Primary plane Drain Latency */ 1402 /* Primary plane Drain Latency */
1395 pixel_size = crtc->primary->fb->bits_per_pixel / 8; /* BPP */ 1403 pixel_size = crtc->primary->fb->bits_per_pixel / 8; /* BPP */
1396 if (vlv_compute_drain_latency(crtc, pixel_size, &prec_mult, &drain_latency)) { 1404 if (vlv_compute_drain_latency(crtc, pixel_size, &prec_mult, &drain_latency)) {
1397 plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ? 1405 plane_prec = (prec_mult == high_precision) ?
1398 DDL_PLANE_PRECISION_64 : 1406 DDL_PLANE_PRECISION_HIGH :
1399 DDL_PLANE_PRECISION_32; 1407 DDL_PLANE_PRECISION_LOW;
1400 plane_dl |= plane_prec | drain_latency; 1408 plane_dl |= plane_prec | drain_latency;
1401 } 1409 }
1402 1410
@@ -1408,9 +1416,9 @@ static void vlv_update_drain_latency(struct drm_crtc *crtc)
1408 /* Program cursor DL only if it is enabled */ 1416 /* Program cursor DL only if it is enabled */
1409 if (intel_crtc->cursor_base && 1417 if (intel_crtc->cursor_base &&
1410 vlv_compute_drain_latency(crtc, pixel_size, &prec_mult, &drain_latency)) { 1418 vlv_compute_drain_latency(crtc, pixel_size, &prec_mult, &drain_latency)) {
1411 plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ? 1419 plane_prec = (prec_mult == high_precision) ?
1412 DDL_CURSOR_PRECISION_64 : 1420 DDL_CURSOR_PRECISION_HIGH :
1413 DDL_CURSOR_PRECISION_32; 1421 DDL_CURSOR_PRECISION_LOW;
1414 plane_dl |= plane_prec | (drain_latency << DDL_CURSOR_SHIFT); 1422 plane_dl |= plane_prec | (drain_latency << DDL_CURSOR_SHIFT);
1415 } 1423 }
1416 1424
@@ -1578,15 +1586,17 @@ static void valleyview_update_sprite_wm(struct drm_plane *plane,
1578 int plane_prec; 1586 int plane_prec;
1579 int sprite_dl; 1587 int sprite_dl;
1580 int prec_mult; 1588 int prec_mult;
1589 const int high_precision = IS_CHERRYVIEW(dev) ?
1590 DRAIN_LATENCY_PRECISION_32 : DRAIN_LATENCY_PRECISION_64;
1581 1591
1582 sprite_dl = I915_READ(VLV_DDL(pipe)) & ~(DDL_SPRITE_PRECISION_64(sprite) | 1592 sprite_dl = I915_READ(VLV_DDL(pipe)) & ~(DDL_SPRITE_PRECISION_HIGH(sprite) |
1583 (DRAIN_LATENCY_MASK << DDL_SPRITE_SHIFT(sprite))); 1593 (DRAIN_LATENCY_MASK << DDL_SPRITE_SHIFT(sprite)));
1584 1594
1585 if (enabled && vlv_compute_drain_latency(crtc, pixel_size, &prec_mult, 1595 if (enabled && vlv_compute_drain_latency(crtc, pixel_size, &prec_mult,
1586 &drain_latency)) { 1596 &drain_latency)) {
1587 plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ? 1597 plane_prec = (prec_mult == high_precision) ?
1588 DDL_SPRITE_PRECISION_64(sprite) : 1598 DDL_SPRITE_PRECISION_HIGH(sprite) :
1589 DDL_SPRITE_PRECISION_32(sprite); 1599 DDL_SPRITE_PRECISION_LOW(sprite);
1590 sprite_dl |= plane_prec | 1600 sprite_dl |= plane_prec |
1591 (drain_latency << DDL_SPRITE_SHIFT(sprite)); 1601 (drain_latency << DDL_SPRITE_SHIFT(sprite));
1592 } 1602 }