Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'drm-intel-fixes-2019-10-03-1' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes

- Fix DP-MST crtc_mask
- Fix dsc dpp calculations
- Fix g4x sprite scaling stride check with GTT remapping

Signed-off-by: Dave Airlie <airlied@redhat.com>

From: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191003193051.GA26421@intel.com

+111 -102
+8 -4
drivers/gpu/drm/i915/display/intel_display.c
··· 7261 7261 pipe_config->fdi_lanes = lane; 7262 7262 7263 7263 intel_link_compute_m_n(pipe_config->pipe_bpp, lane, fdi_dotclock, 7264 - link_bw, &pipe_config->fdi_m_n, false); 7264 + link_bw, &pipe_config->fdi_m_n, false, false); 7265 7265 7266 7266 ret = ironlake_check_fdi_lanes(dev, intel_crtc->pipe, pipe_config); 7267 7267 if (ret == -EDEADLK) ··· 7508 7508 intel_link_compute_m_n(u16 bits_per_pixel, int nlanes, 7509 7509 int pixel_clock, int link_clock, 7510 7510 struct intel_link_m_n *m_n, 7511 - bool constant_n) 7511 + bool constant_n, bool fec_enable) 7512 7512 { 7513 - m_n->tu = 64; 7513 + u32 data_clock = bits_per_pixel * pixel_clock; 7514 7514 7515 - compute_m_n(bits_per_pixel * pixel_clock, 7515 + if (fec_enable) 7516 + data_clock = intel_dp_mode_to_fec_clock(data_clock); 7517 + 7518 + m_n->tu = 64; 7519 + compute_m_n(data_clock, 7516 7520 link_clock * nlanes * 8, 7517 7521 &m_n->gmch_m, &m_n->gmch_n, 7518 7522 constant_n);
+1 -1
drivers/gpu/drm/i915/display/intel_display.h
··· 414 414 void intel_link_compute_m_n(u16 bpp, int nlanes, 415 415 int pixel_clock, int link_clock, 416 416 struct intel_link_m_n *m_n, 417 - bool constant_n); 417 + bool constant_n, bool fec_enable); 418 418 bool is_ccs_modifier(u64 modifier); 419 419 void lpt_disable_clkout_dp(struct drm_i915_private *dev_priv); 420 420 u32 intel_plane_fb_max_stride(struct drm_i915_private *dev_priv,
+95 -89
drivers/gpu/drm/i915/display/intel_dp.c
··· 78 78 #define DP_DSC_MAX_ENC_THROUGHPUT_0 340000 79 79 #define DP_DSC_MAX_ENC_THROUGHPUT_1 400000 80 80 81 - /* DP DSC FEC Overhead factor = (100 - 2.4)/100 */ 82 - #define DP_DSC_FEC_OVERHEAD_FACTOR 976 81 + /* DP DSC FEC Overhead factor = 1/(0.972261) */ 82 + #define DP_DSC_FEC_OVERHEAD_FACTOR 972261 83 83 84 84 /* Compliance test status bits */ 85 85 #define INTEL_DP_RESOLUTION_SHIFT_MASK 0 ··· 491 491 return -1; 492 492 } 493 493 494 + return 0; 495 + } 496 + 497 + u32 intel_dp_mode_to_fec_clock(u32 mode_clock) 498 + { 499 + return div_u64(mul_u32_u32(mode_clock, 1000000U), 500 + DP_DSC_FEC_OVERHEAD_FACTOR); 501 + } 502 + 503 + static u16 intel_dp_dsc_get_output_bpp(u32 link_clock, u32 lane_count, 504 + u32 mode_clock, u32 mode_hdisplay) 505 + { 506 + u32 bits_per_pixel, max_bpp_small_joiner_ram; 507 + int i; 508 + 509 + /* 510 + * Available Link Bandwidth(Kbits/sec) = (NumberOfLanes)* 511 + * (LinkSymbolClock)* 8 * (TimeSlotsPerMTP) 512 + * for SST -> TimeSlotsPerMTP is 1, 513 + * for MST -> TimeSlotsPerMTP has to be calculated 514 + */ 515 + bits_per_pixel = (link_clock * lane_count * 8) / 516 + intel_dp_mode_to_fec_clock(mode_clock); 517 + DRM_DEBUG_KMS("Max link bpp: %u\n", bits_per_pixel); 518 + 519 + /* Small Joiner Check: output bpp <= joiner RAM (bits) / Horiz. width */ 520 + max_bpp_small_joiner_ram = DP_DSC_MAX_SMALL_JOINER_RAM_BUFFER / mode_hdisplay; 521 + DRM_DEBUG_KMS("Max small joiner bpp: %u\n", max_bpp_small_joiner_ram); 522 + 523 + /* 524 + * Greatest allowed DSC BPP = MIN (output BPP from available Link BW 525 + * check, output bpp from small joiner RAM check) 526 + */ 527 + bits_per_pixel = min(bits_per_pixel, max_bpp_small_joiner_ram); 528 + 529 + /* Error out if the max bpp is less than smallest allowed valid bpp */ 530 + if (bits_per_pixel < valid_dsc_bpp[0]) { 531 + DRM_DEBUG_KMS("Unsupported BPP %u, min %u\n", 532 + bits_per_pixel, valid_dsc_bpp[0]); 533 + return 0; 534 + } 535 + 536 + /* Find the nearest match in the array of known BPPs from VESA */ 537 + for (i = 0; i < ARRAY_SIZE(valid_dsc_bpp) - 1; i++) { 538 + if (bits_per_pixel < valid_dsc_bpp[i + 1]) 539 + break; 540 + } 541 + bits_per_pixel = valid_dsc_bpp[i]; 542 + 543 + /* 544 + * Compressed BPP in U6.4 format so multiply by 16, for Gen 11, 545 + * fractional part is 0 546 + */ 547 + return bits_per_pixel << 4; 548 + } 549 + 550 + static u8 intel_dp_dsc_get_slice_count(struct intel_dp *intel_dp, 551 + int mode_clock, int mode_hdisplay) 552 + { 553 + u8 min_slice_count, i; 554 + int max_slice_width; 555 + 556 + if (mode_clock <= DP_DSC_PEAK_PIXEL_RATE) 557 + min_slice_count = DIV_ROUND_UP(mode_clock, 558 + DP_DSC_MAX_ENC_THROUGHPUT_0); 559 + else 560 + min_slice_count = DIV_ROUND_UP(mode_clock, 561 + DP_DSC_MAX_ENC_THROUGHPUT_1); 562 + 563 + max_slice_width = drm_dp_dsc_sink_max_slice_width(intel_dp->dsc_dpcd); 564 + if (max_slice_width < DP_DSC_MIN_SLICE_WIDTH_VALUE) { 565 + DRM_DEBUG_KMS("Unsupported slice width %d by DP DSC Sink device\n", 566 + max_slice_width); 567 + return 0; 568 + } 569 + /* Also take into account max slice width */ 570 + min_slice_count = min_t(u8, min_slice_count, 571 + DIV_ROUND_UP(mode_hdisplay, 572 + max_slice_width)); 573 + 574 + /* Find the closest match to the valid slice count values */ 575 + for (i = 0; i < ARRAY_SIZE(valid_dsc_slicecount); i++) { 576 + if (valid_dsc_slicecount[i] > 577 + drm_dp_dsc_sink_max_slice_count(intel_dp->dsc_dpcd, 578 + false)) 579 + break; 580 + if (min_slice_count <= valid_dsc_slicecount[i]) 581 + return valid_dsc_slicecount[i]; 582 + } 583 + 584 + DRM_DEBUG_KMS("Unsupported Slice Count %d\n", min_slice_count); 494 585 return 0; 495 586 } 496 587 ··· 2317 2226 adjusted_mode->crtc_clock, 2318 2227 pipe_config->port_clock, 2319 2228 &pipe_config->dp_m_n, 2320 - constant_n); 2229 + constant_n, pipe_config->fec_enable); 2321 2230 2322 2231 if (intel_connector->panel.downclock_mode != NULL && 2323 2232 dev_priv->drrs.type == SEAMLESS_DRRS_SUPPORT) { ··· 2327 2236 intel_connector->panel.downclock_mode->clock, 2328 2237 pipe_config->port_clock, 2329 2238 &pipe_config->dp_m2_n2, 2330 - constant_n); 2239 + constant_n, pipe_config->fec_enable); 2331 2240 } 2332 2241 2333 2242 if (!HAS_DDI(dev_priv)) ··· 4412 4321 return drm_dp_dpcd_read(&intel_dp->aux, DP_SINK_COUNT_ESI, 4413 4322 sink_irq_vector, DP_DPRX_ESI_LEN) == 4414 4323 DP_DPRX_ESI_LEN; 4415 - } 4416 - 4417 - u16 intel_dp_dsc_get_output_bpp(int link_clock, u8 lane_count, 4418 - int mode_clock, int mode_hdisplay) 4419 - { 4420 - u16 bits_per_pixel, max_bpp_small_joiner_ram; 4421 - int i; 4422 - 4423 - /* 4424 - * Available Link Bandwidth(Kbits/sec) = (NumberOfLanes)* 4425 - * (LinkSymbolClock)* 8 * ((100-FECOverhead)/100)*(TimeSlotsPerMTP) 4426 - * FECOverhead = 2.4%, for SST -> TimeSlotsPerMTP is 1, 4427 - * for MST -> TimeSlotsPerMTP has to be calculated 4428 - */ 4429 - bits_per_pixel = (link_clock * lane_count * 8 * 4430 - DP_DSC_FEC_OVERHEAD_FACTOR) / 4431 - mode_clock; 4432 - 4433 - /* Small Joiner Check: output bpp <= joiner RAM (bits) / Horiz. width */ 4434 - max_bpp_small_joiner_ram = DP_DSC_MAX_SMALL_JOINER_RAM_BUFFER / 4435 - mode_hdisplay; 4436 - 4437 - /* 4438 - * Greatest allowed DSC BPP = MIN (output BPP from avaialble Link BW 4439 - * check, output bpp from small joiner RAM check) 4440 - */ 4441 - bits_per_pixel = min(bits_per_pixel, max_bpp_small_joiner_ram); 4442 - 4443 - /* Error out if the max bpp is less than smallest allowed valid bpp */ 4444 - if (bits_per_pixel < valid_dsc_bpp[0]) { 4445 - DRM_DEBUG_KMS("Unsupported BPP %d\n", bits_per_pixel); 4446 - return 0; 4447 - } 4448 - 4449 - /* Find the nearest match in the array of known BPPs from VESA */ 4450 - for (i = 0; i < ARRAY_SIZE(valid_dsc_bpp) - 1; i++) { 4451 - if (bits_per_pixel < valid_dsc_bpp[i + 1]) 4452 - break; 4453 - } 4454 - bits_per_pixel = valid_dsc_bpp[i]; 4455 - 4456 - /* 4457 - * Compressed BPP in U6.4 format so multiply by 16, for Gen 11, 4458 - * fractional part is 0 4459 - */ 4460 - return bits_per_pixel << 4; 4461 - } 4462 - 4463 - u8 intel_dp_dsc_get_slice_count(struct intel_dp *intel_dp, 4464 - int mode_clock, 4465 - int mode_hdisplay) 4466 - { 4467 - u8 min_slice_count, i; 4468 - int max_slice_width; 4469 - 4470 - if (mode_clock <= DP_DSC_PEAK_PIXEL_RATE) 4471 - min_slice_count = DIV_ROUND_UP(mode_clock, 4472 - DP_DSC_MAX_ENC_THROUGHPUT_0); 4473 - else 4474 - min_slice_count = DIV_ROUND_UP(mode_clock, 4475 - DP_DSC_MAX_ENC_THROUGHPUT_1); 4476 - 4477 - max_slice_width = drm_dp_dsc_sink_max_slice_width(intel_dp->dsc_dpcd); 4478 - if (max_slice_width < DP_DSC_MIN_SLICE_WIDTH_VALUE) { 4479 - DRM_DEBUG_KMS("Unsupported slice width %d by DP DSC Sink device\n", 4480 - max_slice_width); 4481 - return 0; 4482 - } 4483 - /* Also take into account max slice width */ 4484 - min_slice_count = min_t(u8, min_slice_count, 4485 - DIV_ROUND_UP(mode_hdisplay, 4486 - max_slice_width)); 4487 - 4488 - /* Find the closest match to the valid slice count values */ 4489 - for (i = 0; i < ARRAY_SIZE(valid_dsc_slicecount); i++) { 4490 - if (valid_dsc_slicecount[i] > 4491 - drm_dp_dsc_sink_max_slice_count(intel_dp->dsc_dpcd, 4492 - false)) 4493 - break; 4494 - if (min_slice_count <= valid_dsc_slicecount[i]) 4495 - return valid_dsc_slicecount[i]; 4496 - } 4497 - 4498 - DRM_DEBUG_KMS("Unsupported Slice Count %d\n", min_slice_count); 4499 - return 0; 4500 4324 } 4501 4325 4502 4326 static void
+2 -4
drivers/gpu/drm/i915/display/intel_dp.h
··· 102 102 bool intel_dp_source_supports_hbr3(struct intel_dp *intel_dp); 103 103 bool 104 104 intel_dp_get_link_status(struct intel_dp *intel_dp, u8 *link_status); 105 - u16 intel_dp_dsc_get_output_bpp(int link_clock, u8 lane_count, 106 - int mode_clock, int mode_hdisplay); 107 - u8 intel_dp_dsc_get_slice_count(struct intel_dp *intel_dp, int mode_clock, 108 - int mode_hdisplay); 109 105 110 106 bool intel_dp_read_dpcd(struct intel_dp *intel_dp); 111 107 bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp); ··· 113 117 { 114 118 return ~((1 << lane_count) - 1) & 0xf; 115 119 } 120 + 121 + u32 intel_dp_mode_to_fec_clock(u32 mode_clock); 116 122 117 123 #endif /* __INTEL_DP_H__ */
+2 -2
drivers/gpu/drm/i915/display/intel_dp_mst.c
··· 81 81 adjusted_mode->crtc_clock, 82 82 crtc_state->port_clock, 83 83 &crtc_state->dp_m_n, 84 - constant_n); 84 + constant_n, crtc_state->fec_enable); 85 85 crtc_state->dp_m_n.tu = slots; 86 86 87 87 return 0; ··· 615 615 intel_encoder->type = INTEL_OUTPUT_DP_MST; 616 616 intel_encoder->power_domain = intel_dig_port->base.power_domain; 617 617 intel_encoder->port = intel_dig_port->base.port; 618 - intel_encoder->crtc_mask = BIT(pipe); 618 + intel_encoder->crtc_mask = 0x7; 619 619 intel_encoder->cloneable = 0; 620 620 621 621 intel_encoder->compute_config = intel_dp_mst_compute_config;
+3 -2
drivers/gpu/drm/i915/display/intel_sprite.c
··· 1528 1528 int src_x, src_w, src_h, crtc_w, crtc_h; 1529 1529 const struct drm_display_mode *adjusted_mode = 1530 1530 &crtc_state->base.adjusted_mode; 1531 + unsigned int stride = plane_state->color_plane[0].stride; 1531 1532 unsigned int cpp = fb->format->cpp[0]; 1532 1533 unsigned int width_bytes; 1533 1534 int min_width, min_height; ··· 1570 1569 return -EINVAL; 1571 1570 } 1572 1571 1573 - if (width_bytes > 4096 || fb->pitches[0] > 4096) { 1572 + if (stride > 4096) { 1574 1573 DRM_DEBUG_KMS("Stride (%u) exceeds hardware max with scaling (%u)\n", 1575 - fb->pitches[0], 4096); 1574 + stride, 4096); 1576 1575 return -EINVAL; 1577 1576 } 1578 1577