aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c182
1 files changed, 69 insertions, 113 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index cddb0c692334..82128b95785c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1157,12 +1157,10 @@ static const char *state_string(bool enabled)
1157void assert_pll(struct drm_i915_private *dev_priv, 1157void assert_pll(struct drm_i915_private *dev_priv,
1158 enum pipe pipe, bool state) 1158 enum pipe pipe, bool state)
1159{ 1159{
1160 int reg;
1161 u32 val; 1160 u32 val;
1162 bool cur_state; 1161 bool cur_state;
1163 1162
1164 reg = DPLL(pipe); 1163 val = I915_READ(DPLL(pipe));
1165 val = I915_READ(reg);
1166 cur_state = !!(val & DPLL_VCO_ENABLE); 1164 cur_state = !!(val & DPLL_VCO_ENABLE);
1167 I915_STATE_WARN(cur_state != state, 1165 I915_STATE_WARN(cur_state != state,
1168 "PLL state assertion failure (expected %s, current %s)\n", 1166 "PLL state assertion failure (expected %s, current %s)\n",
@@ -1219,20 +1217,16 @@ void assert_shared_dpll(struct drm_i915_private *dev_priv,
1219static void assert_fdi_tx(struct drm_i915_private *dev_priv, 1217static void assert_fdi_tx(struct drm_i915_private *dev_priv,
1220 enum pipe pipe, bool state) 1218 enum pipe pipe, bool state)
1221{ 1219{
1222 int reg;
1223 u32 val;
1224 bool cur_state; 1220 bool cur_state;
1225 enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, 1221 enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv,
1226 pipe); 1222 pipe);
1227 1223
1228 if (HAS_DDI(dev_priv->dev)) { 1224 if (HAS_DDI(dev_priv->dev)) {
1229 /* DDI does not have a specific FDI_TX register */ 1225 /* DDI does not have a specific FDI_TX register */
1230 reg = TRANS_DDI_FUNC_CTL(cpu_transcoder); 1226 u32 val = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder));
1231 val = I915_READ(reg);
1232 cur_state = !!(val & TRANS_DDI_FUNC_ENABLE); 1227 cur_state = !!(val & TRANS_DDI_FUNC_ENABLE);
1233 } else { 1228 } else {
1234 reg = FDI_TX_CTL(pipe); 1229 u32 val = I915_READ(FDI_TX_CTL(pipe));
1235 val = I915_READ(reg);
1236 cur_state = !!(val & FDI_TX_ENABLE); 1230 cur_state = !!(val & FDI_TX_ENABLE);
1237 } 1231 }
1238 I915_STATE_WARN(cur_state != state, 1232 I915_STATE_WARN(cur_state != state,
@@ -1245,12 +1239,10 @@ static void assert_fdi_tx(struct drm_i915_private *dev_priv,
1245static void assert_fdi_rx(struct drm_i915_private *dev_priv, 1239static void assert_fdi_rx(struct drm_i915_private *dev_priv,
1246 enum pipe pipe, bool state) 1240 enum pipe pipe, bool state)
1247{ 1241{
1248 int reg;
1249 u32 val; 1242 u32 val;
1250 bool cur_state; 1243 bool cur_state;
1251 1244
1252 reg = FDI_RX_CTL(pipe); 1245 val = I915_READ(FDI_RX_CTL(pipe));
1253 val = I915_READ(reg);
1254 cur_state = !!(val & FDI_RX_ENABLE); 1246 cur_state = !!(val & FDI_RX_ENABLE);
1255 I915_STATE_WARN(cur_state != state, 1247 I915_STATE_WARN(cur_state != state,
1256 "FDI RX state assertion failure (expected %s, current %s)\n", 1248 "FDI RX state assertion failure (expected %s, current %s)\n",
@@ -1262,7 +1254,6 @@ static void assert_fdi_rx(struct drm_i915_private *dev_priv,
1262static void assert_fdi_tx_pll_enabled(struct drm_i915_private *dev_priv, 1254static void assert_fdi_tx_pll_enabled(struct drm_i915_private *dev_priv,
1263 enum pipe pipe) 1255 enum pipe pipe)
1264{ 1256{
1265 int reg;
1266 u32 val; 1257 u32 val;
1267 1258
1268 /* ILK FDI PLL is always enabled */ 1259 /* ILK FDI PLL is always enabled */
@@ -1273,20 +1264,17 @@ static void assert_fdi_tx_pll_enabled(struct drm_i915_private *dev_priv,
1273 if (HAS_DDI(dev_priv->dev)) 1264 if (HAS_DDI(dev_priv->dev))
1274 return; 1265 return;
1275 1266
1276 reg = FDI_TX_CTL(pipe); 1267 val = I915_READ(FDI_TX_CTL(pipe));
1277 val = I915_READ(reg);
1278 I915_STATE_WARN(!(val & FDI_TX_PLL_ENABLE), "FDI TX PLL assertion failure, should be active but is disabled\n"); 1268 I915_STATE_WARN(!(val & FDI_TX_PLL_ENABLE), "FDI TX PLL assertion failure, should be active but is disabled\n");
1279} 1269}
1280 1270
1281void assert_fdi_rx_pll(struct drm_i915_private *dev_priv, 1271void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
1282 enum pipe pipe, bool state) 1272 enum pipe pipe, bool state)
1283{ 1273{
1284 int reg;
1285 u32 val; 1274 u32 val;
1286 bool cur_state; 1275 bool cur_state;
1287 1276
1288 reg = FDI_RX_CTL(pipe); 1277 val = I915_READ(FDI_RX_CTL(pipe));
1289 val = I915_READ(reg);
1290 cur_state = !!(val & FDI_RX_PLL_ENABLE); 1278 cur_state = !!(val & FDI_RX_PLL_ENABLE);
1291 I915_STATE_WARN(cur_state != state, 1279 I915_STATE_WARN(cur_state != state,
1292 "FDI RX PLL assertion failure (expected %s, current %s)\n", 1280 "FDI RX PLL assertion failure (expected %s, current %s)\n",
@@ -1356,8 +1344,6 @@ static void assert_cursor(struct drm_i915_private *dev_priv,
1356void assert_pipe(struct drm_i915_private *dev_priv, 1344void assert_pipe(struct drm_i915_private *dev_priv,
1357 enum pipe pipe, bool state) 1345 enum pipe pipe, bool state)
1358{ 1346{
1359 int reg;
1360 u32 val;
1361 bool cur_state; 1347 bool cur_state;
1362 enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, 1348 enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv,
1363 pipe); 1349 pipe);
@@ -1371,8 +1357,7 @@ void assert_pipe(struct drm_i915_private *dev_priv,
1371 POWER_DOMAIN_TRANSCODER(cpu_transcoder))) { 1357 POWER_DOMAIN_TRANSCODER(cpu_transcoder))) {
1372 cur_state = false; 1358 cur_state = false;
1373 } else { 1359 } else {
1374 reg = PIPECONF(cpu_transcoder); 1360 u32 val = I915_READ(PIPECONF(cpu_transcoder));
1375 val = I915_READ(reg);
1376 cur_state = !!(val & PIPECONF_ENABLE); 1361 cur_state = !!(val & PIPECONF_ENABLE);
1377 } 1362 }
1378 1363
@@ -1384,12 +1369,10 @@ void assert_pipe(struct drm_i915_private *dev_priv,
1384static void assert_plane(struct drm_i915_private *dev_priv, 1369static void assert_plane(struct drm_i915_private *dev_priv,
1385 enum plane plane, bool state) 1370 enum plane plane, bool state)
1386{ 1371{
1387 int reg;
1388 u32 val; 1372 u32 val;
1389 bool cur_state; 1373 bool cur_state;
1390 1374
1391 reg = DSPCNTR(plane); 1375 val = I915_READ(DSPCNTR(plane));
1392 val = I915_READ(reg);
1393 cur_state = !!(val & DISPLAY_PLANE_ENABLE); 1376 cur_state = !!(val & DISPLAY_PLANE_ENABLE);
1394 I915_STATE_WARN(cur_state != state, 1377 I915_STATE_WARN(cur_state != state,
1395 "plane %c assertion failure (expected %s, current %s)\n", 1378 "plane %c assertion failure (expected %s, current %s)\n",
@@ -1403,14 +1386,11 @@ static void assert_planes_disabled(struct drm_i915_private *dev_priv,
1403 enum pipe pipe) 1386 enum pipe pipe)
1404{ 1387{
1405 struct drm_device *dev = dev_priv->dev; 1388 struct drm_device *dev = dev_priv->dev;
1406 int reg, i; 1389 int i;
1407 u32 val;
1408 int cur_pipe;
1409 1390
1410 /* Primary planes are fixed to pipes on gen4+ */ 1391 /* Primary planes are fixed to pipes on gen4+ */
1411 if (INTEL_INFO(dev)->gen >= 4) { 1392 if (INTEL_INFO(dev)->gen >= 4) {
1412 reg = DSPCNTR(pipe); 1393 u32 val = I915_READ(DSPCNTR(pipe));
1413 val = I915_READ(reg);
1414 I915_STATE_WARN(val & DISPLAY_PLANE_ENABLE, 1394 I915_STATE_WARN(val & DISPLAY_PLANE_ENABLE,
1415 "plane %c assertion failure, should be disabled but not\n", 1395 "plane %c assertion failure, should be disabled but not\n",
1416 plane_name(pipe)); 1396 plane_name(pipe));
@@ -1419,9 +1399,8 @@ static void assert_planes_disabled(struct drm_i915_private *dev_priv,
1419 1399
1420 /* Need to check both planes against the pipe */ 1400 /* Need to check both planes against the pipe */
1421 for_each_pipe(dev_priv, i) { 1401 for_each_pipe(dev_priv, i) {
1422 reg = DSPCNTR(i); 1402 u32 val = I915_READ(DSPCNTR(i));
1423 val = I915_READ(reg); 1403 enum pipe cur_pipe = (val & DISPPLANE_SEL_PIPE_MASK) >>
1424 cur_pipe = (val & DISPPLANE_SEL_PIPE_MASK) >>
1425 DISPPLANE_SEL_PIPE_SHIFT; 1404 DISPPLANE_SEL_PIPE_SHIFT;
1426 I915_STATE_WARN((val & DISPLAY_PLANE_ENABLE) && pipe == cur_pipe, 1405 I915_STATE_WARN((val & DISPLAY_PLANE_ENABLE) && pipe == cur_pipe,
1427 "plane %c assertion failure, should be off on pipe %c but is still active\n", 1406 "plane %c assertion failure, should be off on pipe %c but is still active\n",
@@ -1433,33 +1412,29 @@ static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
1433 enum pipe pipe) 1412 enum pipe pipe)
1434{ 1413{
1435 struct drm_device *dev = dev_priv->dev; 1414 struct drm_device *dev = dev_priv->dev;
1436 int reg, sprite; 1415 int sprite;
1437 u32 val;
1438 1416
1439 if (INTEL_INFO(dev)->gen >= 9) { 1417 if (INTEL_INFO(dev)->gen >= 9) {
1440 for_each_sprite(dev_priv, pipe, sprite) { 1418 for_each_sprite(dev_priv, pipe, sprite) {
1441 val = I915_READ(PLANE_CTL(pipe, sprite)); 1419 u32 val = I915_READ(PLANE_CTL(pipe, sprite));
1442 I915_STATE_WARN(val & PLANE_CTL_ENABLE, 1420 I915_STATE_WARN(val & PLANE_CTL_ENABLE,
1443 "plane %d assertion failure, should be off on pipe %c but is still active\n", 1421 "plane %d assertion failure, should be off on pipe %c but is still active\n",
1444 sprite, pipe_name(pipe)); 1422 sprite, pipe_name(pipe));
1445 } 1423 }
1446 } else if (IS_VALLEYVIEW(dev)) { 1424 } else if (IS_VALLEYVIEW(dev)) {
1447 for_each_sprite(dev_priv, pipe, sprite) { 1425 for_each_sprite(dev_priv, pipe, sprite) {
1448 reg = SPCNTR(pipe, sprite); 1426 u32 val = I915_READ(SPCNTR(pipe, sprite));
1449 val = I915_READ(reg);
1450 I915_STATE_WARN(val & SP_ENABLE, 1427 I915_STATE_WARN(val & SP_ENABLE,
1451 "sprite %c assertion failure, should be off on pipe %c but is still active\n", 1428 "sprite %c assertion failure, should be off on pipe %c but is still active\n",
1452 sprite_name(pipe, sprite), pipe_name(pipe)); 1429 sprite_name(pipe, sprite), pipe_name(pipe));
1453 } 1430 }
1454 } else if (INTEL_INFO(dev)->gen >= 7) { 1431 } else if (INTEL_INFO(dev)->gen >= 7) {
1455 reg = SPRCTL(pipe); 1432 u32 val = I915_READ(SPRCTL(pipe));
1456 val = I915_READ(reg);
1457 I915_STATE_WARN(val & SPRITE_ENABLE, 1433 I915_STATE_WARN(val & SPRITE_ENABLE,
1458 "sprite %c assertion failure, should be off on pipe %c but is still active\n", 1434 "sprite %c assertion failure, should be off on pipe %c but is still active\n",
1459 plane_name(pipe), pipe_name(pipe)); 1435 plane_name(pipe), pipe_name(pipe));
1460 } else if (INTEL_INFO(dev)->gen >= 5) { 1436 } else if (INTEL_INFO(dev)->gen >= 5) {
1461 reg = DVSCNTR(pipe); 1437 u32 val = I915_READ(DVSCNTR(pipe));
1462 val = I915_READ(reg);
1463 I915_STATE_WARN(val & DVS_ENABLE, 1438 I915_STATE_WARN(val & DVS_ENABLE,
1464 "sprite %c assertion failure, should be off on pipe %c but is still active\n", 1439 "sprite %c assertion failure, should be off on pipe %c but is still active\n",
1465 plane_name(pipe), pipe_name(pipe)); 1440 plane_name(pipe), pipe_name(pipe));
@@ -1488,12 +1463,10 @@ static void ibx_assert_pch_refclk_enabled(struct drm_i915_private *dev_priv)
1488static void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv, 1463static void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
1489 enum pipe pipe) 1464 enum pipe pipe)
1490{ 1465{
1491 int reg;
1492 u32 val; 1466 u32 val;
1493 bool enabled; 1467 bool enabled;
1494 1468
1495 reg = PCH_TRANSCONF(pipe); 1469 val = I915_READ(PCH_TRANSCONF(pipe));
1496 val = I915_READ(reg);
1497 enabled = !!(val & TRANS_ENABLE); 1470 enabled = !!(val & TRANS_ENABLE);
1498 I915_STATE_WARN(enabled, 1471 I915_STATE_WARN(enabled,
1499 "transcoder assertion failed, should be off on pipe %c but is still active\n", 1472 "transcoder assertion failed, should be off on pipe %c but is still active\n",
@@ -1600,21 +1573,18 @@ static void assert_pch_hdmi_disabled(struct drm_i915_private *dev_priv,
1600static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv, 1573static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv,
1601 enum pipe pipe) 1574 enum pipe pipe)
1602{ 1575{
1603 int reg;
1604 u32 val; 1576 u32 val;
1605 1577
1606 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_B, TRANS_DP_PORT_SEL_B); 1578 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_B, TRANS_DP_PORT_SEL_B);
1607 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_C, TRANS_DP_PORT_SEL_C); 1579 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_C, TRANS_DP_PORT_SEL_C);
1608 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_D, TRANS_DP_PORT_SEL_D); 1580 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_D, TRANS_DP_PORT_SEL_D);
1609 1581
1610 reg = PCH_ADPA; 1582 val = I915_READ(PCH_ADPA);
1611 val = I915_READ(reg);
1612 I915_STATE_WARN(adpa_pipe_enabled(dev_priv, pipe, val), 1583 I915_STATE_WARN(adpa_pipe_enabled(dev_priv, pipe, val),
1613 "PCH VGA enabled on transcoder %c, should be disabled\n", 1584 "PCH VGA enabled on transcoder %c, should be disabled\n",
1614 pipe_name(pipe)); 1585 pipe_name(pipe));
1615 1586
1616 reg = PCH_LVDS; 1587 val = I915_READ(PCH_LVDS);
1617 val = I915_READ(reg);
1618 I915_STATE_WARN(lvds_pipe_enabled(dev_priv, pipe, val), 1588 I915_STATE_WARN(lvds_pipe_enabled(dev_priv, pipe, val),
1619 "PCH LVDS enabled on transcoder %c, should be disabled\n", 1589 "PCH LVDS enabled on transcoder %c, should be disabled\n",
1620 pipe_name(pipe)); 1590 pipe_name(pipe));
@@ -4804,6 +4774,7 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
4804 struct intel_crtc_atomic_commit *atomic = &crtc->atomic; 4774 struct intel_crtc_atomic_commit *atomic = &crtc->atomic;
4805 struct drm_device *dev = crtc->base.dev; 4775 struct drm_device *dev = crtc->base.dev;
4806 struct drm_i915_private *dev_priv = dev->dev_private; 4776 struct drm_i915_private *dev_priv = dev->dev_private;
4777 struct drm_plane *plane;
4807 4778
4808 if (atomic->wait_vblank) 4779 if (atomic->wait_vblank)
4809 intel_wait_for_vblank(dev, crtc->pipe); 4780 intel_wait_for_vblank(dev, crtc->pipe);
@@ -4822,6 +4793,10 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
4822 if (atomic->post_enable_primary) 4793 if (atomic->post_enable_primary)
4823 intel_post_enable_primary(&crtc->base); 4794 intel_post_enable_primary(&crtc->base);
4824 4795
4796 drm_for_each_plane_mask(plane, dev, atomic->update_sprite_watermarks)
4797 intel_update_sprite_watermarks(plane, &crtc->base,
4798 0, 0, 0, false, false);
4799
4825 memset(atomic, 0, sizeof(*atomic)); 4800 memset(atomic, 0, sizeof(*atomic));
4826} 4801}
4827 4802
@@ -9952,7 +9927,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
9952 } 9927 }
9953 cntl |= pipe << 28; /* Connect to correct pipe */ 9928 cntl |= pipe << 28; /* Connect to correct pipe */
9954 9929
9955 if (IS_HASWELL(dev) || IS_BROADWELL(dev)) 9930 if (HAS_DDI(dev))
9956 cntl |= CURSOR_PIPE_CSC_ENABLE; 9931 cntl |= CURSOR_PIPE_CSC_ENABLE;
9957 } 9932 }
9958 9933
@@ -10822,7 +10797,7 @@ static bool page_flip_finished(struct intel_crtc *crtc)
10822 */ 10797 */
10823 return (I915_READ(DSPSURFLIVE(crtc->plane)) & ~0xfff) == 10798 return (I915_READ(DSPSURFLIVE(crtc->plane)) & ~0xfff) ==
10824 crtc->unpin_work->gtt_offset && 10799 crtc->unpin_work->gtt_offset &&
10825 g4x_flip_count_after_eq(I915_READ(PIPE_FLIPCOUNT_GM45(crtc->pipe)), 10800 g4x_flip_count_after_eq(I915_READ(PIPE_FLIPCOUNT_G4X(crtc->pipe)),
10826 crtc->unpin_work->flip_count); 10801 crtc->unpin_work->flip_count);
10827} 10802}
10828 10803
@@ -10848,11 +10823,11 @@ void intel_prepare_page_flip(struct drm_device *dev, int plane)
10848 spin_unlock_irqrestore(&dev->event_lock, flags); 10823 spin_unlock_irqrestore(&dev->event_lock, flags);
10849} 10824}
10850 10825
10851static inline void intel_mark_page_flip_active(struct intel_crtc *intel_crtc) 10826static inline void intel_mark_page_flip_active(struct intel_unpin_work *work)
10852{ 10827{
10853 /* Ensure that the work item is consistent when activating it ... */ 10828 /* Ensure that the work item is consistent when activating it ... */
10854 smp_wmb(); 10829 smp_wmb();
10855 atomic_set(&intel_crtc->unpin_work->pending, INTEL_FLIP_PENDING); 10830 atomic_set(&work->pending, INTEL_FLIP_PENDING);
10856 /* and that it is marked active as soon as the irq could fire. */ 10831 /* and that it is marked active as soon as the irq could fire. */
10857 smp_wmb(); 10832 smp_wmb();
10858} 10833}
@@ -10888,7 +10863,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
10888 intel_ring_emit(ring, intel_crtc->unpin_work->gtt_offset); 10863 intel_ring_emit(ring, intel_crtc->unpin_work->gtt_offset);
10889 intel_ring_emit(ring, 0); /* aux display base address, unused */ 10864 intel_ring_emit(ring, 0); /* aux display base address, unused */
10890 10865
10891 intel_mark_page_flip_active(intel_crtc); 10866 intel_mark_page_flip_active(intel_crtc->unpin_work);
10892 return 0; 10867 return 0;
10893} 10868}
10894 10869
@@ -10920,7 +10895,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
10920 intel_ring_emit(ring, intel_crtc->unpin_work->gtt_offset); 10895 intel_ring_emit(ring, intel_crtc->unpin_work->gtt_offset);
10921 intel_ring_emit(ring, MI_NOOP); 10896 intel_ring_emit(ring, MI_NOOP);
10922 10897
10923 intel_mark_page_flip_active(intel_crtc); 10898 intel_mark_page_flip_active(intel_crtc->unpin_work);
10924 return 0; 10899 return 0;
10925} 10900}
10926 10901
@@ -10959,7 +10934,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
10959 pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff; 10934 pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff;
10960 intel_ring_emit(ring, pf | pipesrc); 10935 intel_ring_emit(ring, pf | pipesrc);
10961 10936
10962 intel_mark_page_flip_active(intel_crtc); 10937 intel_mark_page_flip_active(intel_crtc->unpin_work);
10963 return 0; 10938 return 0;
10964} 10939}
10965 10940
@@ -10995,7 +10970,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
10995 pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff; 10970 pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff;
10996 intel_ring_emit(ring, pf | pipesrc); 10971 intel_ring_emit(ring, pf | pipesrc);
10997 10972
10998 intel_mark_page_flip_active(intel_crtc); 10973 intel_mark_page_flip_active(intel_crtc->unpin_work);
10999 return 0; 10974 return 0;
11000} 10975}
11001 10976
@@ -11090,7 +11065,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
11090 intel_ring_emit(ring, intel_crtc->unpin_work->gtt_offset); 11065 intel_ring_emit(ring, intel_crtc->unpin_work->gtt_offset);
11091 intel_ring_emit(ring, (MI_NOOP)); 11066 intel_ring_emit(ring, (MI_NOOP));
11092 11067
11093 intel_mark_page_flip_active(intel_crtc); 11068 intel_mark_page_flip_active(intel_crtc->unpin_work);
11094 return 0; 11069 return 0;
11095} 11070}
11096 11071
@@ -11121,7 +11096,8 @@ static bool use_mmio_flip(struct intel_engine_cs *ring,
11121 return ring != i915_gem_request_get_ring(obj->last_write_req); 11096 return ring != i915_gem_request_get_ring(obj->last_write_req);
11122} 11097}
11123 11098
11124static void skl_do_mmio_flip(struct intel_crtc *intel_crtc) 11099static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
11100 struct intel_unpin_work *work)
11125{ 11101{
11126 struct drm_device *dev = intel_crtc->base.dev; 11102 struct drm_device *dev = intel_crtc->base.dev;
11127 struct drm_i915_private *dev_priv = dev->dev_private; 11103 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -11162,11 +11138,12 @@ static void skl_do_mmio_flip(struct intel_crtc *intel_crtc)
11162 I915_WRITE(PLANE_CTL(pipe, 0), ctl); 11138 I915_WRITE(PLANE_CTL(pipe, 0), ctl);
11163 I915_WRITE(PLANE_STRIDE(pipe, 0), stride); 11139 I915_WRITE(PLANE_STRIDE(pipe, 0), stride);
11164 11140
11165 I915_WRITE(PLANE_SURF(pipe, 0), intel_crtc->unpin_work->gtt_offset); 11141 I915_WRITE(PLANE_SURF(pipe, 0), work->gtt_offset);
11166 POSTING_READ(PLANE_SURF(pipe, 0)); 11142 POSTING_READ(PLANE_SURF(pipe, 0));
11167} 11143}
11168 11144
11169static void ilk_do_mmio_flip(struct intel_crtc *intel_crtc) 11145static void ilk_do_mmio_flip(struct intel_crtc *intel_crtc,
11146 struct intel_unpin_work *work)
11170{ 11147{
11171 struct drm_device *dev = intel_crtc->base.dev; 11148 struct drm_device *dev = intel_crtc->base.dev;
11172 struct drm_i915_private *dev_priv = dev->dev_private; 11149 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -11186,31 +11163,36 @@ static void ilk_do_mmio_flip(struct intel_crtc *intel_crtc)
11186 11163
11187 I915_WRITE(reg, dspcntr); 11164 I915_WRITE(reg, dspcntr);
11188 11165
11189 I915_WRITE(DSPSURF(intel_crtc->plane), 11166 I915_WRITE(DSPSURF(intel_crtc->plane), work->gtt_offset);
11190 intel_crtc->unpin_work->gtt_offset);
11191 POSTING_READ(DSPSURF(intel_crtc->plane)); 11167 POSTING_READ(DSPSURF(intel_crtc->plane));
11192
11193} 11168}
11194 11169
11195/* 11170/*
11196 * XXX: This is the temporary way to update the plane registers until we get 11171 * XXX: This is the temporary way to update the plane registers until we get
11197 * around to using the usual plane update functions for MMIO flips 11172 * around to using the usual plane update functions for MMIO flips
11198 */ 11173 */
11199static void intel_do_mmio_flip(struct intel_crtc *intel_crtc) 11174static void intel_do_mmio_flip(struct intel_mmio_flip *mmio_flip)
11200{ 11175{
11201 struct drm_device *dev = intel_crtc->base.dev; 11176 struct intel_crtc *crtc = mmio_flip->crtc;
11177 struct intel_unpin_work *work;
11202 11178
11203 intel_mark_page_flip_active(intel_crtc); 11179 spin_lock_irq(&crtc->base.dev->event_lock);
11180 work = crtc->unpin_work;
11181 spin_unlock_irq(&crtc->base.dev->event_lock);
11182 if (work == NULL)
11183 return;
11204 11184
11205 intel_pipe_update_start(intel_crtc); 11185 intel_mark_page_flip_active(work);
11206 11186
11207 if (INTEL_INFO(dev)->gen >= 9) 11187 intel_pipe_update_start(crtc);
11208 skl_do_mmio_flip(intel_crtc); 11188
11189 if (INTEL_INFO(mmio_flip->i915)->gen >= 9)
11190 skl_do_mmio_flip(crtc, work);
11209 else 11191 else
11210 /* use_mmio_flip() retricts MMIO flips to ilk+ */ 11192 /* use_mmio_flip() retricts MMIO flips to ilk+ */
11211 ilk_do_mmio_flip(intel_crtc); 11193 ilk_do_mmio_flip(crtc, work);
11212 11194
11213 intel_pipe_update_end(intel_crtc); 11195 intel_pipe_update_end(crtc);
11214} 11196}
11215 11197
11216static void intel_mmio_flip_work_func(struct work_struct *work) 11198static void intel_mmio_flip_work_func(struct work_struct *work)
@@ -11218,15 +11200,15 @@ static void intel_mmio_flip_work_func(struct work_struct *work)
11218 struct intel_mmio_flip *mmio_flip = 11200 struct intel_mmio_flip *mmio_flip =
11219 container_of(work, struct intel_mmio_flip, work); 11201 container_of(work, struct intel_mmio_flip, work);
11220 11202
11221 if (mmio_flip->req) 11203 if (mmio_flip->req) {
11222 WARN_ON(__i915_wait_request(mmio_flip->req, 11204 WARN_ON(__i915_wait_request(mmio_flip->req,
11223 mmio_flip->crtc->reset_counter, 11205 mmio_flip->crtc->reset_counter,
11224 false, NULL, 11206 false, NULL,
11225 &mmio_flip->i915->rps.mmioflips)); 11207 &mmio_flip->i915->rps.mmioflips));
11208 i915_gem_request_unreference__unlocked(mmio_flip->req);
11209 }
11226 11210
11227 intel_do_mmio_flip(mmio_flip->crtc); 11211 intel_do_mmio_flip(mmio_flip);
11228
11229 i915_gem_request_unreference__unlocked(mmio_flip->req);
11230 kfree(mmio_flip); 11212 kfree(mmio_flip);
11231} 11213}
11232 11214
@@ -11427,7 +11409,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
11427 intel_crtc->reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter); 11409 intel_crtc->reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
11428 11410
11429 if (INTEL_INFO(dev)->gen >= 5 || IS_G4X(dev)) 11411 if (INTEL_INFO(dev)->gen >= 5 || IS_G4X(dev))
11430 work->flip_count = I915_READ(PIPE_FLIPCOUNT_GM45(pipe)) + 1; 11412 work->flip_count = I915_READ(PIPE_FLIPCOUNT_G4X(pipe)) + 1;
11431 11413
11432 if (IS_VALLEYVIEW(dev)) { 11414 if (IS_VALLEYVIEW(dev)) {
11433 ring = &dev_priv->ring[BCS]; 11415 ring = &dev_priv->ring[BCS];
@@ -11577,30 +11559,16 @@ retry:
11577static bool intel_wm_need_update(struct drm_plane *plane, 11559static bool intel_wm_need_update(struct drm_plane *plane,
11578 struct drm_plane_state *state) 11560 struct drm_plane_state *state)
11579{ 11561{
11580 struct intel_plane_state *new = to_intel_plane_state(state); 11562 /* Update watermarks on tiling changes. */
11581 struct intel_plane_state *cur = to_intel_plane_state(plane->state);
11582
11583 /* Update watermarks on tiling or size changes. */
11584 if (!plane->state->fb || !state->fb || 11563 if (!plane->state->fb || !state->fb ||
11585 plane->state->fb->modifier[0] != state->fb->modifier[0] || 11564 plane->state->fb->modifier[0] != state->fb->modifier[0] ||
11586 plane->state->rotation != state->rotation || 11565 plane->state->rotation != state->rotation)
11587 drm_rect_width(&new->src) != drm_rect_width(&cur->src) ||
11588 drm_rect_height(&new->src) != drm_rect_height(&cur->src) ||
11589 drm_rect_width(&new->dst) != drm_rect_width(&cur->dst) ||
11590 drm_rect_height(&new->dst) != drm_rect_height(&cur->dst))
11591 return true; 11566 return true;
11592 11567
11593 return false; 11568 if (plane->state->crtc_w != state->crtc_w)
11594} 11569 return true;
11595
11596static bool needs_scaling(struct intel_plane_state *state)
11597{
11598 int src_w = drm_rect_width(&state->src) >> 16;
11599 int src_h = drm_rect_height(&state->src) >> 16;
11600 int dst_w = drm_rect_width(&state->dst);
11601 int dst_h = drm_rect_height(&state->dst);
11602 11570
11603 return (src_w != dst_w || src_h != dst_h); 11571 return false;
11604} 11572}
11605 11573
11606int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state, 11574int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
@@ -11618,6 +11586,7 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
11618 bool mode_changed = needs_modeset(crtc_state); 11586 bool mode_changed = needs_modeset(crtc_state);
11619 bool was_crtc_enabled = crtc->state->active; 11587 bool was_crtc_enabled = crtc->state->active;
11620 bool is_crtc_enabled = crtc_state->active; 11588 bool is_crtc_enabled = crtc_state->active;
11589
11621 bool turn_off, turn_on, visible, was_visible; 11590 bool turn_off, turn_on, visible, was_visible;
11622 struct drm_framebuffer *fb = plane_state->fb; 11591 struct drm_framebuffer *fb = plane_state->fb;
11623 11592
@@ -11735,23 +11704,11 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
11735 case DRM_PLANE_TYPE_CURSOR: 11704 case DRM_PLANE_TYPE_CURSOR:
11736 break; 11705 break;
11737 case DRM_PLANE_TYPE_OVERLAY: 11706 case DRM_PLANE_TYPE_OVERLAY:
11738 /* 11707 if (turn_off && !mode_changed) {
11739 * WaCxSRDisabledForSpriteScaling:ivb
11740 *
11741 * cstate->update_wm was already set above, so this flag will
11742 * take effect when we commit and program watermarks.
11743 */
11744 if (IS_IVYBRIDGE(dev) &&
11745 needs_scaling(to_intel_plane_state(plane_state)) &&
11746 !needs_scaling(old_plane_state)) {
11747 to_intel_crtc_state(crtc_state)->disable_lp_wm = true;
11748 } else if (turn_off && !mode_changed) {
11749 intel_crtc->atomic.wait_vblank = true; 11708 intel_crtc->atomic.wait_vblank = true;
11750 intel_crtc->atomic.update_sprite_watermarks |= 11709 intel_crtc->atomic.update_sprite_watermarks |=
11751 1 << i; 11710 1 << i;
11752 } 11711 }
11753
11754 break;
11755 } 11712 }
11756 return 0; 11713 return 0;
11757} 11714}
@@ -14942,13 +14899,12 @@ intel_check_plane_mapping(struct intel_crtc *crtc)
14942{ 14899{
14943 struct drm_device *dev = crtc->base.dev; 14900 struct drm_device *dev = crtc->base.dev;
14944 struct drm_i915_private *dev_priv = dev->dev_private; 14901 struct drm_i915_private *dev_priv = dev->dev_private;
14945 u32 reg, val; 14902 u32 val;
14946 14903
14947 if (INTEL_INFO(dev)->num_pipes == 1) 14904 if (INTEL_INFO(dev)->num_pipes == 1)
14948 return true; 14905 return true;
14949 14906
14950 reg = DSPCNTR(!crtc->plane); 14907 val = I915_READ(DSPCNTR(!crtc->plane));
14951 val = I915_READ(reg);
14952 14908
14953 if ((val & DISPLAY_PLANE_ENABLE) && 14909 if ((val & DISPLAY_PLANE_ENABLE) &&
14954 (!!(val & DISPPLANE_SEL_PIPE_MASK) == crtc->pipe)) 14910 (!!(val & DISPPLANE_SEL_PIPE_MASK) == crtc->pipe))