Collection of i915 fixes. * tag 'drm-intel-fixes-2016-08-15' of git://anongit.freedesktop.org/drm-intel: drm/i915: Fix modeset handling during gpu reset, v5. drm/i915: fix aliasing_ppgtt leak drm/i915: fix WaInsertDummyPushConstPs drm/i915: Fix iboost setting for SKL Y/U DP DDI buffer translation entry 2 drm/i915/gen9: Give one extra block per line for SKL plane WM calculations drm/i915: Acquire audio powerwell for HD-Audio registers drm/i915: Add missing rpm wakelock to GGTT pread drm/i915/fbc: FBC causes display flicker when VT-d is enabled on Skylake drm/i915: Clean up the extra RPM ref on CHV with i915.enable_rc6=0 drm/i915: Program iboost settings for HDMI/DVI on SKL drm/i915: Fix iboost setting for DDI with 4 lanes on SKL drm/i915: Handle ENOSPC after failing to insert a mappable node drm/i915: Flush GT idle status upon reset
Unified · Split
| @@ -1854,6 +1854,7 @@ struct drm_i915_private { · 1853 unmodified lines | ||
| 1854 | 1854 | enum modeset_restore modeset_restore; |
| 1855 | 1855 | struct mutex modeset_restore_lock; |
| 1856 | 1856 | struct drm_atomic_state *modeset_restore_state; |
| 1857 | + struct drm_modeset_acquire_ctx reset_ctx; | |
| 1857 | 1858 | |
| 1858 | 1859 | struct list_head vm_list; /* Global list of all address spaces */ |
| 1859 | 1860 | struct i915_ggtt ggtt; /* VM representing the global address space */ |
| @@ -879,9 +879,12 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, · 878 unmodified lines | ||
| 879 | 879 | ret = i915_gem_shmem_pread(dev, obj, args, file); |
| 880 | 880 | |
| 881 | 881 | /* pread for non shmem backed objects */ |
| 882 | − if (ret == -EFAULT || ret == -ENODEV) | |
| 882 | + if (ret == -EFAULT || ret == -ENODEV) { | |
| 883 | + intel_runtime_pm_get(to_i915(dev)); | |
| 883 | 884 | ret = i915_gem_gtt_pread(dev, obj, args->size, |
| 884 | 885 | args->offset, args->data_ptr); |
| 886 | + intel_runtime_pm_put(to_i915(dev)); | |
| 887 | + } | |
| 885 | 888 | |
| 886 | 889 | out: |
| 887 | 890 | drm_gem_object_unreference(&obj->base); |
| @@ -1306,7 +1309,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, · 418 unmodified lines | ||
| 1306 | 1309 | * textures). Fallback to the shmem path in that case. */ |
| 1307 | 1310 | } |
| 1308 | 1311 | |
| 1309 | − if (ret == -EFAULT) { | |
| 1312 | + if (ret == -EFAULT || ret == -ENOSPC) { | |
| 1310 | 1313 | if (obj->phys_handle) |
| 1311 | 1314 | ret = i915_gem_phys_pwrite(obj, args, file); |
| 1312 | 1315 | else if (i915_gem_object_has_struct_page(obj)) |
| @@ -3169,6 +3172,8 @@ static void i915_gem_reset_engine_cleanup(struct intel_engine_cs *engine) · 1856 unmodified lines | ||
| 3169 | 3172 | } |
| 3170 | 3173 | |
| 3171 | 3174 | intel_ring_init_seqno(engine, engine->last_submitted_seqno); |
| 3175 | + | |
| 3176 | + engine->i915->gt.active_engines &= ~intel_engine_flag(engine); | |
| 3172 | 3177 | } |
| 3173 | 3178 | |
| 3174 | 3179 | void i915_gem_reset(struct drm_device *dev) |
| @@ -3186,6 +3191,7 @@ void i915_gem_reset(struct drm_device *dev) · 11 unmodified lines | ||
| 3186 | 3191 | |
| 3187 | 3192 | for_each_engine(engine, dev_priv) |
| 3188 | 3193 | i915_gem_reset_engine_cleanup(engine); |
| 3194 | + mod_delayed_work(dev_priv->wq, &dev_priv->gt.idle_work, 0); | |
| 3189 | 3195 | |
| 3190 | 3196 | i915_gem_context_reset(dev); |
| 3191 | 3197 | |
| @@ -2873,6 +2873,7 @@ void i915_ggtt_cleanup_hw(struct drm_device *dev) · 2872 unmodified lines | ||
| 2873 | 2873 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2874 | 2874 | |
| 2875 | 2875 | ppgtt->base.cleanup(&ppgtt->base); |
| 2876 | + kfree(ppgtt); | |
| 2876 | 2877 | } |
| 2877 | 2878 | |
| 2878 | 2879 | i915_gem_cleanup_stolen(dev); |
| @@ -1536,6 +1536,7 @@ enum skl_disp_power_wells { · 1535 unmodified lines | ||
| 1536 | 1536 | #define BALANCE_LEG_MASK(port) (7<<(8+3*(port))) |
| 1537 | 1537 | /* Balance leg disable bits */ |
| 1538 | 1538 | #define BALANCE_LEG_DISABLE_SHIFT 23 |
| 1539 | +#define BALANCE_LEG_DISABLE(port) (1 << (23 + (port))) | |
| 1539 | 1540 | |
| 1540 | 1541 | /* |
| 1541 | 1542 | * Fence registers |
| @@ -600,6 +600,8 @@ static void i915_audio_component_codec_wake_override(struct device *dev, · 599 unmodified lines | ||
| 600 | 600 | if (!IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv)) |
| 601 | 601 | return; |
| 602 | 602 | |
| 603 | + i915_audio_component_get_power(dev); | |
| 604 | + | |
| 603 | 605 | /* |
| 604 | 606 | * Enable/disable generating the codec wake signal, overriding the |
| 605 | 607 | * internal logic to generate the codec wake to controller. |
| @@ -615,6 +617,8 @@ static void i915_audio_component_codec_wake_override(struct device *dev, · 9 unmodified lines | ||
| 615 | 617 | I915_WRITE(HSW_AUD_CHICKENBIT, tmp); |
| 616 | 618 | usleep_range(1000, 1500); |
| 617 | 619 | } |
| 620 | + | |
| 621 | + i915_audio_component_put_power(dev); | |
| 618 | 622 | } |
| 619 | 623 | |
| 620 | 624 | /* Get CDCLK in kHz */ |
| @@ -648,6 +652,7 @@ static int i915_audio_component_sync_audio_rate(struct device *dev, · 27 unmodified lines | ||
| 648 | 652 | !IS_HASWELL(dev_priv)) |
| 649 | 653 | return 0; |
| 650 | 654 | |
| 655 | + i915_audio_component_get_power(dev); | |
| 651 | 656 | mutex_lock(&dev_priv->av_mutex); |
| 652 | 657 | /* 1. get the pipe */ |
| 653 | 658 | intel_encoder = dev_priv->dig_port_map[port]; |
| @@ -698,6 +703,7 @@ static int i915_audio_component_sync_audio_rate(struct device *dev, · 44 unmodified lines | ||
| 698 | 703 | |
| 699 | 704 | unlock: |
| 700 | 705 | mutex_unlock(&dev_priv->av_mutex); |
| 706 | + i915_audio_component_put_power(dev); | |
| 701 | 707 | return err; |
| 702 | 708 | } |
| 703 | 709 | |
| @@ -145,7 +145,7 @@ static const struct ddi_buf_trans skl_ddi_translations_dp[] = { · 144 unmodified lines | ||
| 145 | 145 | static const struct ddi_buf_trans skl_u_ddi_translations_dp[] = { |
| 146 | 146 | { 0x0000201B, 0x000000A2, 0x0 }, |
| 147 | 147 | { 0x00005012, 0x00000088, 0x0 }, |
| 148 | − { 0x80007011, 0x000000CD, 0x0 }, | |
| 148 | + { 0x80007011, 0x000000CD, 0x1 }, | |
| 149 | 149 | { 0x80009010, 0x000000C0, 0x1 }, |
| 150 | 150 | { 0x0000201B, 0x0000009D, 0x0 }, |
| 151 | 151 | { 0x80005012, 0x000000C0, 0x1 }, |
| @@ -158,7 +158,7 @@ static const struct ddi_buf_trans skl_u_ddi_translations_dp[] = { · 6 unmodified lines | ||
| 158 | 158 | static const struct ddi_buf_trans skl_y_ddi_translations_dp[] = { |
| 159 | 159 | { 0x00000018, 0x000000A2, 0x0 }, |
| 160 | 160 | { 0x00005012, 0x00000088, 0x0 }, |
| 161 | − { 0x80007011, 0x000000CD, 0x0 }, | |
| 161 | + { 0x80007011, 0x000000CD, 0x3 }, | |
| 162 | 162 | { 0x80009010, 0x000000C0, 0x3 }, |
| 163 | 163 | { 0x00000018, 0x0000009D, 0x0 }, |
| 164 | 164 | { 0x80005012, 0x000000C0, 0x3 }, |
| @@ -388,6 +388,40 @@ skl_get_buf_trans_hdmi(struct drm_i915_private *dev_priv, int *n_entries) · 223 unmodified lines | ||
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | +static int intel_ddi_hdmi_level(struct drm_i915_private *dev_priv, enum port port) | |
| 392 | +{ | |
| 393 | + int n_hdmi_entries; | |
| 394 | + int hdmi_level; | |
| 395 | + int hdmi_default_entry; | |
| 396 | + | |
| 397 | + hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift; | |
| 398 | + | |
| 399 | + if (IS_BROXTON(dev_priv)) | |
| 400 | + return hdmi_level; | |
| 401 | + | |
| 402 | + if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) { | |
| 403 | + skl_get_buf_trans_hdmi(dev_priv, &n_hdmi_entries); | |
| 404 | + hdmi_default_entry = 8; | |
| 405 | + } else if (IS_BROADWELL(dev_priv)) { | |
| 406 | + n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); | |
| 407 | + hdmi_default_entry = 7; | |
| 408 | + } else if (IS_HASWELL(dev_priv)) { | |
| 409 | + n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi); | |
| 410 | + hdmi_default_entry = 6; | |
| 411 | + } else { | |
| 412 | + WARN(1, "ddi translation table missing\n"); | |
| 413 | + n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); | |
| 414 | + hdmi_default_entry = 7; | |
| 415 | + } | |
| 416 | + | |
| 417 | + /* Choose a good default if VBT is badly populated */ | |
| 418 | + if (hdmi_level == HDMI_LEVEL_SHIFT_UNKNOWN || | |
| 419 | + hdmi_level >= n_hdmi_entries) | |
| 420 | + hdmi_level = hdmi_default_entry; | |
| 421 | + | |
| 422 | + return hdmi_level; | |
| 423 | +} | |
| 424 | + | |
| 391 | 425 | /* |
| 392 | 426 | * Starting with Haswell, DDI port buffers must be programmed with correct |
| 393 | 427 | * values in advance. The buffer values are different for FDI and DP modes, |
| @@ -399,7 +433,7 @@ void intel_prepare_ddi_buffer(struct intel_encoder *encoder) · 5 unmodified lines | ||
| 399 | 433 | { |
| 400 | 434 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 401 | 435 | u32 iboost_bit = 0; |
| 402 | − int i, n_hdmi_entries, n_dp_entries, n_edp_entries, hdmi_default_entry, | |
| 436 | + int i, n_hdmi_entries, n_dp_entries, n_edp_entries, | |
| 403 | 437 | size; |
| 404 | 438 | int hdmi_level; |
| 405 | 439 | enum port port; |
| @@ -410,7 +444,7 @@ void intel_prepare_ddi_buffer(struct intel_encoder *encoder) · 4 unmodified lines | ||
| 410 | 444 | const struct ddi_buf_trans *ddi_translations; |
| 411 | 445 | |
| 412 | 446 | port = intel_ddi_get_encoder_port(encoder); |
| 413 | − hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift; | |
| 447 | + hdmi_level = intel_ddi_hdmi_level(dev_priv, port); | |
| 414 | 448 | |
| 415 | 449 | if (IS_BROXTON(dev_priv)) { |
| 416 | 450 | if (encoder->type != INTEL_OUTPUT_HDMI) |
| @@ -430,7 +464,6 @@ void intel_prepare_ddi_buffer(struct intel_encoder *encoder) · 13 unmodified lines | ||
| 430 | 464 | skl_get_buf_trans_edp(dev_priv, &n_edp_entries); |
| 431 | 465 | ddi_translations_hdmi = |
| 432 | 466 | skl_get_buf_trans_hdmi(dev_priv, &n_hdmi_entries); |
| 433 | − hdmi_default_entry = 8; | |
| 434 | 467 | /* If we're boosting the current, set bit 31 of trans1 */ |
| 435 | 468 | if (dev_priv->vbt.ddi_port_info[port].hdmi_boost_level || |
| 436 | 469 | dev_priv->vbt.ddi_port_info[port].dp_boost_level) |
| @@ -456,7 +489,6 @@ void intel_prepare_ddi_buffer(struct intel_encoder *encoder) · 19 unmodified lines | ||
| 456 | 489 | |
| 457 | 490 | n_dp_entries = ARRAY_SIZE(bdw_ddi_translations_dp); |
| 458 | 491 | n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); |
| 459 | − hdmi_default_entry = 7; | |
| 460 | 492 | } else if (IS_HASWELL(dev_priv)) { |
| 461 | 493 | ddi_translations_fdi = hsw_ddi_translations_fdi; |
| 462 | 494 | ddi_translations_dp = hsw_ddi_translations_dp; |
| @@ -464,7 +496,6 @@ void intel_prepare_ddi_buffer(struct intel_encoder *encoder) · 1 unmodified line | ||
| 464 | 496 | ddi_translations_hdmi = hsw_ddi_translations_hdmi; |
| 465 | 497 | n_dp_entries = n_edp_entries = ARRAY_SIZE(hsw_ddi_translations_dp); |
| 466 | 498 | n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi); |
| 467 | − hdmi_default_entry = 6; | |
| 468 | 499 | } else { |
| 469 | 500 | WARN(1, "ddi translation table missing\n"); |
| 470 | 501 | ddi_translations_edp = bdw_ddi_translations_dp; |
| @@ -474,7 +505,6 @@ void intel_prepare_ddi_buffer(struct intel_encoder *encoder) · 3 unmodified lines | ||
| 474 | 505 | n_edp_entries = ARRAY_SIZE(bdw_ddi_translations_edp); |
| 475 | 506 | n_dp_entries = ARRAY_SIZE(bdw_ddi_translations_dp); |
| 476 | 507 | n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); |
| 477 | − hdmi_default_entry = 7; | |
| 478 | 508 | } |
| 479 | 509 | |
| 480 | 510 | switch (encoder->type) { |
| @@ -505,11 +535,6 @@ void intel_prepare_ddi_buffer(struct intel_encoder *encoder) · 24 unmodified lines | ||
| 505 | 535 | if (encoder->type != INTEL_OUTPUT_HDMI) |
| 506 | 536 | return; |
| 507 | 537 | |
| 508 | − /* Choose a good default if VBT is badly populated */ | |
| 509 | − if (hdmi_level == HDMI_LEVEL_SHIFT_UNKNOWN || | |
| 510 | − hdmi_level >= n_hdmi_entries) | |
| 511 | − hdmi_level = hdmi_default_entry; | |
| 512 | − | |
| 513 | 538 | /* Entry 9 is for HDMI: */ |
| 514 | 539 | I915_WRITE(DDI_BUF_TRANS_LO(port, i), |
| 515 | 540 | ddi_translations_hdmi[hdmi_level].trans1 | iboost_bit); |
| @@ -1379,14 +1404,30 @@ void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc) · 863 unmodified lines | ||
| 1379 | 1404 | TRANS_CLK_SEL_DISABLED); |
| 1380 | 1405 | } |
| 1381 | 1406 | |
| 1382 | −static void skl_ddi_set_iboost(struct drm_i915_private *dev_priv, | |
| 1383 | − u32 level, enum port port, int type) | |
| 1407 | +static void _skl_ddi_set_iboost(struct drm_i915_private *dev_priv, | |
| 1408 | + enum port port, uint8_t iboost) | |
| 1384 | 1409 | { |
| 1410 | + u32 tmp; | |
| 1411 | + | |
| 1412 | + tmp = I915_READ(DISPIO_CR_TX_BMU_CR0); | |
| 1413 | + tmp &= ~(BALANCE_LEG_MASK(port) | BALANCE_LEG_DISABLE(port)); | |
| 1414 | + if (iboost) | |
| 1415 | + tmp |= iboost << BALANCE_LEG_SHIFT(port); | |
| 1416 | + else | |
| 1417 | + tmp |= BALANCE_LEG_DISABLE(port); | |
| 1418 | + I915_WRITE(DISPIO_CR_TX_BMU_CR0, tmp); | |
| 1419 | +} | |
| 1420 | + | |
| 1421 | +static void skl_ddi_set_iboost(struct intel_encoder *encoder, u32 level) | |
| 1422 | +{ | |
| 1423 | + struct intel_digital_port *intel_dig_port = enc_to_dig_port(&encoder->base); | |
| 1424 | + struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); | |
| 1425 | + enum port port = intel_dig_port->port; | |
| 1426 | + int type = encoder->type; | |
| 1385 | 1427 | const struct ddi_buf_trans *ddi_translations; |
| 1386 | 1428 | uint8_t iboost; |
| 1387 | 1429 | uint8_t dp_iboost, hdmi_iboost; |
| 1388 | 1430 | int n_entries; |
| 1389 | − u32 reg; | |
| 1390 | 1431 | |
| 1391 | 1432 | /* VBT may override standard boost values */ |
| 1392 | 1433 | dp_iboost = dev_priv->vbt.ddi_port_info[port].dp_boost_level; |
| @@ -1428,16 +1469,10 @@ static void skl_ddi_set_iboost(struct drm_i915_private *dev_priv, · 35 unmodified lines | ||
| 1428 | 1469 | return; |
| 1429 | 1470 | } |
| 1430 | 1471 | |
| 1431 | − reg = I915_READ(DISPIO_CR_TX_BMU_CR0); | |
| 1432 | − reg &= ~BALANCE_LEG_MASK(port); | |
| 1433 | − reg &= ~(1 << (BALANCE_LEG_DISABLE_SHIFT + port)); | |
| 1434 | − | |
| 1435 | − if (iboost) | |
| 1436 | − reg |= iboost << BALANCE_LEG_SHIFT(port); | |
| 1437 | − else | |
| 1438 | − reg |= 1 << (BALANCE_LEG_DISABLE_SHIFT + port); | |
| 1472 | + _skl_ddi_set_iboost(dev_priv, port, iboost); | |
| 1439 | 1473 | |
| 1440 | − I915_WRITE(DISPIO_CR_TX_BMU_CR0, reg); | |
| 1474 | + if (port == PORT_A && intel_dig_port->max_lanes == 4) | |
| 1475 | + _skl_ddi_set_iboost(dev_priv, PORT_E, iboost); | |
| 1441 | 1476 | } |
| 1442 | 1477 | |
| 1443 | 1478 | static void bxt_ddi_vswing_sequence(struct drm_i915_private *dev_priv, |
| @@ -1568,7 +1603,7 @@ uint32_t ddi_signal_levels(struct intel_dp *intel_dp) · 124 unmodified lines | ||
| 1568 | 1603 | level = translate_signal_level(signal_levels); |
| 1569 | 1604 | |
| 1570 | 1605 | if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) |
| 1571 | − skl_ddi_set_iboost(dev_priv, level, port, encoder->type); | |
| 1606 | + skl_ddi_set_iboost(encoder, level); | |
| 1572 | 1607 | else if (IS_BROXTON(dev_priv)) |
| 1573 | 1608 | bxt_ddi_vswing_sequence(dev_priv, level, port, encoder->type); |
| 1574 | 1609 | |
| @@ -1637,6 +1672,10 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) · 62 unmodified lines | ||
| 1637 | 1672 | intel_dp_stop_link_train(intel_dp); |
| 1638 | 1673 | } else if (type == INTEL_OUTPUT_HDMI) { |
| 1639 | 1674 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
| 1675 | + int level = intel_ddi_hdmi_level(dev_priv, port); | |
| 1676 | + | |
| 1677 | + if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) | |
| 1678 | + skl_ddi_set_iboost(intel_encoder, level); | |
| 1640 | 1679 | |
| 1641 | 1680 | intel_hdmi->set_infoframes(encoder, |
| 1642 | 1681 | crtc->config->has_hdmi_sink, |
| @@ -3093,40 +3093,110 @@ static void intel_update_primary_planes(struct drm_device *dev) · 3092 unmodified lines | ||
| 3093 | 3093 | |
| 3094 | 3094 | for_each_crtc(dev, crtc) { |
| 3095 | 3095 | struct intel_plane *plane = to_intel_plane(crtc->primary); |
| 3096 | − struct intel_plane_state *plane_state; | |
| 3097 | − | |
| 3098 | − drm_modeset_lock_crtc(crtc, &plane->base); | |
| 3099 | − plane_state = to_intel_plane_state(plane->base.state); | |
| 3096 | + struct intel_plane_state *plane_state = | |
| 3097 | + to_intel_plane_state(plane->base.state); | |
| 3100 | 3098 | |
| 3101 | 3099 | if (plane_state->visible) |
| 3102 | 3100 | plane->update_plane(&plane->base, |
| 3103 | 3101 | to_intel_crtc_state(crtc->state), |
| 3104 | 3102 | plane_state); |
| 3103 | + } | |
| 3104 | +} | |
| 3105 | + | |
| 3106 | +static int | |
| 3107 | +__intel_display_resume(struct drm_device *dev, | |
| 3108 | + struct drm_atomic_state *state) | |
| 3109 | +{ | |
| 3110 | + struct drm_crtc_state *crtc_state; | |
| 3111 | + struct drm_crtc *crtc; | |
| 3112 | + int i, ret; | |
| 3113 | + | |
| 3114 | + intel_modeset_setup_hw_state(dev); | |
| 3115 | + i915_redisable_vga(dev); | |
| 3105 | 3116 | |
| 3106 | − drm_modeset_unlock_crtc(crtc); | |
| 3117 | + if (!state) | |
| 3118 | + return 0; | |
| 3119 | + | |
| 3120 | + for_each_crtc_in_state(state, crtc, crtc_state, i) { | |
| 3121 | + /* | |
| 3122 | + * Force recalculation even if we restore | |
| 3123 | + * current state. With fast modeset this may not result | |
| 3124 | + * in a modeset when the state is compatible. | |
| 3125 | + */ | |
| 3126 | + crtc_state->mode_changed = true; | |
| 3107 | 3127 | } |
| 3128 | + | |
| 3129 | + /* ignore any reset values/BIOS leftovers in the WM registers */ | |
| 3130 | + to_intel_atomic_state(state)->skip_intermediate_wm = true; | |
| 3131 | + | |
| 3132 | + ret = drm_atomic_commit(state); | |
| 3133 | + | |
| 3134 | + WARN_ON(ret == -EDEADLK); | |
| 3135 | + return ret; | |
| 3108 | 3136 | } |
| 3109 | 3137 | |
| 3110 | 3138 | void intel_prepare_reset(struct drm_i915_private *dev_priv) |
| 3111 | 3139 | { |
| 3140 | + struct drm_device *dev = &dev_priv->drm; | |
| 3141 | + struct drm_modeset_acquire_ctx *ctx = &dev_priv->reset_ctx; | |
| 3142 | + struct drm_atomic_state *state; | |
| 3143 | + int ret; | |
| 3144 | + | |
| 3112 | 3145 | /* no reset support for gen2 */ |
| 3113 | 3146 | if (IS_GEN2(dev_priv)) |
| 3114 | 3147 | return; |
| 3115 | 3148 | |
| 3116 | − /* reset doesn't touch the display */ | |
| 3149 | + /* | |
| 3150 | + * Need mode_config.mutex so that we don't | |
| 3151 | + * trample ongoing ->detect() and whatnot. | |
| 3152 | + */ | |
| 3153 | + mutex_lock(&dev->mode_config.mutex); | |
| 3154 | + drm_modeset_acquire_init(ctx, 0); | |
| 3155 | + while (1) { | |
| 3156 | + ret = drm_modeset_lock_all_ctx(dev, ctx); | |
| 3157 | + if (ret != -EDEADLK) | |
| 3158 | + break; | |
| 3159 | + | |
| 3160 | + drm_modeset_backoff(ctx); | |
| 3161 | + } | |
| 3162 | + | |
| 3163 | + /* reset doesn't touch the display, but flips might get nuked anyway, */ | |
| 3117 | 3164 | if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) |
| 3118 | 3165 | return; |
| 3119 | 3166 | |
| 3120 | − drm_modeset_lock_all(&dev_priv->drm); | |
| 3121 | 3167 | /* |
| 3122 | 3168 | * Disabling the crtcs gracefully seems nicer. Also the |
| 3123 | 3169 | * g33 docs say we should at least disable all the planes. |
| 3124 | 3170 | */ |
| 3125 | − intel_display_suspend(&dev_priv->drm); | |
| 3171 | + state = drm_atomic_helper_duplicate_state(dev, ctx); | |
| 3172 | + if (IS_ERR(state)) { | |
| 3173 | + ret = PTR_ERR(state); | |
| 3174 | + state = NULL; | |
| 3175 | + DRM_ERROR("Duplicating state failed with %i\n", ret); | |
| 3176 | + goto err; | |
| 3177 | + } | |
| 3178 | + | |
| 3179 | + ret = drm_atomic_helper_disable_all(dev, ctx); | |
| 3180 | + if (ret) { | |
| 3181 | + DRM_ERROR("Suspending crtc's failed with %i\n", ret); | |
| 3182 | + goto err; | |
| 3183 | + } | |
| 3184 | + | |
| 3185 | + dev_priv->modeset_restore_state = state; | |
| 3186 | + state->acquire_ctx = ctx; | |
| 3187 | + return; | |
| 3188 | + | |
| 3189 | +err: | |
| 3190 | + drm_atomic_state_free(state); | |
| 3126 | 3191 | } |
| 3127 | 3192 | |
| 3128 | 3193 | void intel_finish_reset(struct drm_i915_private *dev_priv) |
| 3129 | 3194 | { |
| 3195 | + struct drm_device *dev = &dev_priv->drm; | |
| 3196 | + struct drm_modeset_acquire_ctx *ctx = &dev_priv->reset_ctx; | |
| 3197 | + struct drm_atomic_state *state = dev_priv->modeset_restore_state; | |
| 3198 | + int ret; | |
| 3199 | + | |
| 3130 | 3200 | /* |
| 3131 | 3201 | * Flips in the rings will be nuked by the reset, |
| 3132 | 3202 | * so complete all pending flips so that user space |
| @@ -3138,6 +3208,8 @@ void intel_finish_reset(struct drm_i915_private *dev_priv) · 5 unmodified lines | ||
| 3138 | 3208 | if (IS_GEN2(dev_priv)) |
| 3139 | 3209 | return; |
| 3140 | 3210 | |
| 3211 | + dev_priv->modeset_restore_state = NULL; | |
| 3212 | + | |
| 3141 | 3213 | /* reset doesn't touch the display */ |
| 3142 | 3214 | if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) { |
| 3143 | 3215 | /* |
| @@ -3149,29 +3221,32 @@ void intel_finish_reset(struct drm_i915_private *dev_priv) · 5 unmodified lines | ||
| 3149 | 3221 | * FIXME: Atomic will make this obsolete since we won't schedule |
| 3150 | 3222 | * CS-based flips (which might get lost in gpu resets) any more. |
| 3151 | 3223 | */ |
| 3152 | − intel_update_primary_planes(&dev_priv->drm); | |
| 3153 | − return; | |
| 3154 | − } | |
| 3155 | − | |
| 3156 | − /* | |
| 3157 | − * The display has been reset as well, | |
| 3158 | − * so need a full re-initialization. | |
| 3159 | − */ | |
| 3160 | − intel_runtime_pm_disable_interrupts(dev_priv); | |
| 3161 | − intel_runtime_pm_enable_interrupts(dev_priv); | |
| 3224 | + intel_update_primary_planes(dev); | |
| 3225 | + } else { | |
| 3226 | + /* | |
| 3227 | + * The display has been reset as well, | |
| 3228 | + * so need a full re-initialization. | |
| 3229 | + */ | |
| 3230 | + intel_runtime_pm_disable_interrupts(dev_priv); | |
| 3231 | + intel_runtime_pm_enable_interrupts(dev_priv); | |
| 3162 | 3232 | |
| 3163 | − intel_modeset_init_hw(&dev_priv->drm); | |
| 3233 | + intel_modeset_init_hw(dev); | |
| 3164 | 3234 | |
| 3165 | − spin_lock_irq(&dev_priv->irq_lock); | |
| 3166 | − if (dev_priv->display.hpd_irq_setup) | |
| 3167 | − dev_priv->display.hpd_irq_setup(dev_priv); | |
| 3168 | − spin_unlock_irq(&dev_priv->irq_lock); | |
| 3235 | + spin_lock_irq(&dev_priv->irq_lock); | |
| 3236 | + if (dev_priv->display.hpd_irq_setup) | |
| 3237 | + dev_priv->display.hpd_irq_setup(dev_priv); | |
| 3238 | + spin_unlock_irq(&dev_priv->irq_lock); | |
| 3169 | 3239 | |
| 3170 | − intel_display_resume(&dev_priv->drm); | |
| 3240 | + ret = __intel_display_resume(dev, state); | |
| 3241 | + if (ret) | |
| 3242 | + DRM_ERROR("Restoring old state failed with %i\n", ret); | |
| 3171 | 3243 | |
| 3172 | − intel_hpd_init(dev_priv); | |
| 3244 | + intel_hpd_init(dev_priv); | |
| 3245 | + } | |
| 3173 | 3246 | |
| 3174 | − drm_modeset_unlock_all(&dev_priv->drm); | |
| 3247 | + drm_modeset_drop_locks(ctx); | |
| 3248 | + drm_modeset_acquire_fini(ctx); | |
| 3249 | + mutex_unlock(&dev->mode_config.mutex); | |
| 3175 | 3250 | } |
| 3176 | 3251 | |
| 3177 | 3252 | static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc) |
| @@ -16156,9 +16231,10 @@ void intel_display_resume(struct drm_device *dev) · 12978 unmodified lines | ||
| 16156 | 16231 | struct drm_atomic_state *state = dev_priv->modeset_restore_state; |
| 16157 | 16232 | struct drm_modeset_acquire_ctx ctx; |
| 16158 | 16233 | int ret; |
| 16159 | − bool setup = false; | |
| 16160 | 16234 | |
| 16161 | 16235 | dev_priv->modeset_restore_state = NULL; |
| 16236 | + if (state) | |
| 16237 | + state->acquire_ctx = &ctx; | |
| 16162 | 16238 | |
| 16163 | 16239 | /* |
| 16164 | 16240 | * This is a cludge because with real atomic modeset mode_config.mutex |
| @@ -16169,43 +16245,17 @@ void intel_display_resume(struct drm_device *dev) · 4 unmodified lines | ||
| 16169 | 16245 | mutex_lock(&dev->mode_config.mutex); |
| 16170 | 16246 | drm_modeset_acquire_init(&ctx, 0); |
| 16171 | 16247 | |
| 16172 | −retry: | |
| 16173 | − ret = drm_modeset_lock_all_ctx(dev, &ctx); | |
| 16174 | − | |
| 16175 | − if (ret == 0 && !setup) { | |
| 16176 | − setup = true; | |
| 16177 | − | |
| 16178 | − intel_modeset_setup_hw_state(dev); | |
| 16179 | − i915_redisable_vga(dev); | |
| 16180 | − } | |
| 16181 | − | |
| 16182 | − if (ret == 0 && state) { | |
| 16183 | − struct drm_crtc_state *crtc_state; | |
| 16184 | − struct drm_crtc *crtc; | |
| 16185 | − int i; | |
| 16186 | − | |
| 16187 | − state->acquire_ctx = &ctx; | |
| 16188 | − | |
| 16189 | − /* ignore any reset values/BIOS leftovers in the WM registers */ | |
| 16190 | − to_intel_atomic_state(state)->skip_intermediate_wm = true; | |
| 16191 | − | |
| 16192 | − for_each_crtc_in_state(state, crtc, crtc_state, i) { | |
| 16193 | − /* | |
| 16194 | − * Force recalculation even if we restore | |
| 16195 | − * current state. With fast modeset this may not result | |
| 16196 | − * in a modeset when the state is compatible. | |
| 16197 | − */ | |
| 16198 | − crtc_state->mode_changed = true; | |
| 16199 | − } | |
| 16200 | − | |
| 16201 | − ret = drm_atomic_commit(state); | |
| 16202 | − } | |
| 16248 | + while (1) { | |
| 16249 | + ret = drm_modeset_lock_all_ctx(dev, &ctx); | |
| 16250 | + if (ret != -EDEADLK) | |
| 16251 | + break; | |
| 16203 | 16252 | |
| 16204 | − if (ret == -EDEADLK) { | |
| 16205 | 16253 | drm_modeset_backoff(&ctx); |
| 16206 | − goto retry; | |
| 16207 | 16254 | } |
| 16208 | 16255 | |
| 16256 | + if (!ret) | |
| 16257 | + ret = __intel_display_resume(dev, state); | |
| 16258 | + | |
| 16209 | 16259 | drm_modeset_drop_locks(&ctx); |
| 16210 | 16260 | drm_modeset_acquire_fini(&ctx); |
| 16211 | 16261 | mutex_unlock(&dev->mode_config.mutex); |
| @@ -1230,12 +1230,29 @@ static int intel_sanitize_fbc_option(struct drm_i915_private *dev_priv) · 1229 unmodified lines | ||
| 1230 | 1230 | if (i915.enable_fbc >= 0) |
| 1231 | 1231 | return !!i915.enable_fbc; |
| 1232 | 1232 | |
| 1233 | + if (!HAS_FBC(dev_priv)) | |
| 1234 | + return 0; | |
| 1235 | + | |
| 1233 | 1236 | if (IS_BROADWELL(dev_priv)) |
| 1234 | 1237 | return 1; |
| 1235 | 1238 | |
| 1236 | 1239 | return 0; |
| 1237 | 1240 | } |
| 1238 | 1241 | |
| 1242 | +static bool need_fbc_vtd_wa(struct drm_i915_private *dev_priv) | |
| 1243 | +{ | |
| 1244 | +#ifdef CONFIG_INTEL_IOMMU | |
| 1245 | + /* WaFbcTurnOffFbcWhenHyperVisorIsUsed:skl,bxt */ | |
| 1246 | + if (intel_iommu_gfx_mapped && | |
| 1247 | + (IS_SKYLAKE(dev_priv) || IS_BROXTON(dev_priv))) { | |
| 1248 | + DRM_INFO("Disabling framebuffer compression (FBC) to prevent screen flicker with VT-d enabled\n"); | |
| 1249 | + return true; | |
| 1250 | + } | |
| 1251 | +#endif | |
| 1252 | + | |
| 1253 | + return false; | |
| 1254 | +} | |
| 1255 | + | |
| 1239 | 1256 | /** |
| 1240 | 1257 | * intel_fbc_init - Initialize FBC |
| 1241 | 1258 | * @dev_priv: the i915 device |
| @@ -1253,6 +1270,9 @@ void intel_fbc_init(struct drm_i915_private *dev_priv) · 11 unmodified lines | ||
| 1253 | 1270 | fbc->active = false; |
| 1254 | 1271 | fbc->work.scheduled = false; |
| 1255 | 1272 | |
| 1273 | + if (need_fbc_vtd_wa(dev_priv)) | |
| 1274 | + mkwrite_device_info(dev_priv)->has_fbc = false; | |
| 1275 | + | |
| 1256 | 1276 | i915.enable_fbc = intel_sanitize_fbc_option(dev_priv); |
| 1257 | 1277 | DRM_DEBUG_KMS("Sanitized enable_fbc value: %d\n", i915.enable_fbc); |
| 1258 | 1278 | |
| @@ -3344,6 +3344,8 @@ static uint32_t skl_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal, · 3343 unmodified lines | ||
| 3344 | 3344 | plane_bytes_per_line *= 4; |
| 3345 | 3345 | plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512); |
| 3346 | 3346 | plane_blocks_per_line /= 4; |
| 3347 | + } else if (tiling == DRM_FORMAT_MOD_NONE) { | |
| 3348 | + plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512) + 1; | |
| 3347 | 3349 | } else { |
| 3348 | 3350 | plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512); |
| 3349 | 3351 | } |
| @@ -6574,9 +6576,7 @@ void intel_init_gt_powersave(struct drm_i915_private *dev_priv) · 3224 unmodified lines | ||
| 6574 | 6576 | |
| 6575 | 6577 | void intel_cleanup_gt_powersave(struct drm_i915_private *dev_priv) |
| 6576 | 6578 | { |
| 6577 | − if (IS_CHERRYVIEW(dev_priv)) | |
| 6578 | − return; | |
| 6579 | − else if (IS_VALLEYVIEW(dev_priv)) | |
| 6579 | + if (IS_VALLEYVIEW(dev_priv)) | |
| 6580 | 6580 | valleyview_cleanup_gt_powersave(dev_priv); |
| 6581 | 6581 | |
| 6582 | 6582 | if (!i915.enable_rc6) |
| @@ -1178,8 +1178,8 @@ static int bxt_init_workarounds(struct intel_engine_cs *engine) · 1177 unmodified lines | ||
| 1178 | 1178 | I915_WRITE(GEN8_L3SQCREG1, L3_GENERAL_PRIO_CREDITS(62) | |
| 1179 | 1179 | L3_HIGH_PRIO_CREDITS(2)); |
| 1180 | 1180 | |
| 1181 | − /* WaInsertDummyPushConstPs:bxt */ | |
| 1182 | − if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_B0)) | |
| 1181 | + /* WaToEnableHwFixForPushConstHWBug:bxt */ | |
| 1182 | + if (IS_BXT_REVID(dev_priv, BXT_REVID_C0, REVID_FOREVER)) | |
| 1183 | 1183 | WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, |
| 1184 | 1184 | GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); |
| 1185 | 1185 | |
| @@ -1222,8 +1222,8 @@ static int kbl_init_workarounds(struct intel_engine_cs *engine) · 36 unmodified lines | ||
| 1222 | 1222 | I915_WRITE(GEN8_L3SQCREG4, I915_READ(GEN8_L3SQCREG4) | |
| 1223 | 1223 | GEN8_LQSC_RO_PERF_DIS); |
| 1224 | 1224 | |
| 1225 | − /* WaInsertDummyPushConstPs:kbl */ | |
| 1226 | − if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_B0)) | |
| 1225 | + /* WaToEnableHwFixForPushConstHWBug:kbl */ | |
| 1226 | + if (IS_KBL_REVID(dev_priv, KBL_REVID_C0, REVID_FOREVER)) | |
| 1227 | 1227 | WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, |
| 1228 | 1228 | GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); |
| 1229 | 1229 | |