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

Merge tag 'drm-intel-next-2022-09-16-1' of git://anongit.freedesktop.org/drm/drm-intel into drm-next

drm/i915 feature pull #2 for v6.1:

Features and functionality:
- More Meteorlake platform enabling (Radhakrishna, Imre, Madhumitha)
- Allow seamless M/N changes on eDP panels that support it (Ville)
- Switch DSC debugfs from output bpp to input bpc (Swati)

Refactoring and cleanups:
- Clocking and DPLL refactoring and cleanups to support seamless M/N (Ville)
- Plenty of VBT definition and parsing updates and cleanups (Ville)
- Extract SKL watermark code to a separate file, and clean up (Ville)
- Clean up IPC interfaces and debugfs (Jani)
- Continue moving display data under drm_i915_private display sub-struct (Jani)
- Display quirk handling refactoring and abstractions (Jani)
- Stop using implicit dev_priv in gmbus registers (Jani)
- BUG_ON() removals and conversions to drm_WARN_ON() and BUILD_BUG_ON() (Jani)
- Use drm_dp_phy_name() for logging (Jani)
- Use REG_BIT() macros for CDCLK registers (Stan)
- Move display and media IP versions to runtime info (Radhakrishna)

Fixes:
- Fix DP MST suspend to avoid use-after-free (Andrzej)
- Fix HPD suspend to avoid use-after-free for fbdev (Andrzej)
- Fix various PSR issues regarding selective update and damage clips (Jouni)
- Fix runtime pm wakerefs for driver remove and release (Mitul Golani)
- Fix conditions for filtering fixed modes for panels (Ville)
- Fix TV encoder clock computation (Ville)
- Fix dvo mode_valid hook return type (Nathan Huckleberry)

Merges:
- Backmerge drm-next to sync the DP MST atomic changes (Jani)

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

From: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/87o7vfr064.fsf@intel.com

+6260 -5531
+2 -1
drivers/gpu/drm/i915/Makefile
··· 258 258 display/intel_vga.o \ 259 259 display/i9xx_plane.o \ 260 260 display/skl_scaler.o \ 261 - display/skl_universal_plane.o 261 + display/skl_universal_plane.o \ 262 + display/skl_watermark.o 262 263 i915-$(CONFIG_ACPI) += \ 263 264 display/intel_acpi.o \ 264 265 display/intel_opregion.o
+1 -1
drivers/gpu/drm/i915/display/hsw_ips.c
··· 202 202 * Should measure whether using a lower cdclk w/o IPS 203 203 */ 204 204 if (IS_BROADWELL(i915) && 205 - crtc_state->pixel_rate > i915->max_cdclk_freq * 95 / 100) 205 + crtc_state->pixel_rate > i915->display.cdclk.max_cdclk_freq * 95 / 100) 206 206 return false; 207 207 208 208 return true;
+1 -1
drivers/gpu/drm/i915/display/i9xx_plane.c
··· 125 125 enum i9xx_plane_id i9xx_plane) 126 126 { 127 127 if (i9xx_plane_has_fbc(dev_priv, i9xx_plane)) 128 - return dev_priv->fbc[INTEL_FBC_A]; 128 + return dev_priv->display.fbc[INTEL_FBC_A]; 129 129 else 130 130 return NULL; 131 131 }
+2
drivers/gpu/drm/i915/display/icl_dsi.c
··· 1630 1630 /* FIXME: initialize from VBT */ 1631 1631 vdsc_cfg->rc_model_size = DSC_RC_MODEL_SIZE_CONST; 1632 1632 1633 + vdsc_cfg->pic_height = crtc_state->hw.adjusted_mode.crtc_vdisplay; 1634 + 1633 1635 ret = intel_dsc_compute_params(crtc_state); 1634 1636 if (ret) 1635 1637 return ret;
+4 -4
drivers/gpu/drm/i915/display/intel_atomic.c
··· 62 62 struct intel_digital_connector_state *intel_conn_state = 63 63 to_intel_digital_connector_state(state); 64 64 65 - if (property == dev_priv->force_audio_property) 65 + if (property == dev_priv->display.properties.force_audio) 66 66 *val = intel_conn_state->force_audio; 67 - else if (property == dev_priv->broadcast_rgb_property) 67 + else if (property == dev_priv->display.properties.broadcast_rgb) 68 68 *val = intel_conn_state->broadcast_rgb; 69 69 else { 70 70 drm_dbg_atomic(&dev_priv->drm, ··· 95 95 struct intel_digital_connector_state *intel_conn_state = 96 96 to_intel_digital_connector_state(state); 97 97 98 - if (property == dev_priv->force_audio_property) { 98 + if (property == dev_priv->display.properties.force_audio) { 99 99 intel_conn_state->force_audio = val; 100 100 return 0; 101 101 } 102 102 103 - if (property == dev_priv->broadcast_rgb_property) { 103 + if (property == dev_priv->display.properties.broadcast_rgb) { 104 104 intel_conn_state->broadcast_rgb = val; 105 105 return 0; 106 106 }
+1 -1
drivers/gpu/drm/i915/display/intel_atomic_plane.c
··· 42 42 #include "intel_display_types.h" 43 43 #include "intel_fb.h" 44 44 #include "intel_fb_pin.h" 45 - #include "intel_pm.h" 46 45 #include "intel_sprite.h" 47 46 #include "skl_scaler.h" 47 + #include "skl_watermark.h" 48 48 49 49 static void intel_plane_state_reset(struct intel_plane_state *plane_state, 50 50 struct intel_plane *plane)
+3 -3
drivers/gpu/drm/i915/display/intel_audio.c
··· 532 532 h_total = crtc_state->hw.adjusted_mode.crtc_htotal; 533 533 pixel_clk = crtc_state->hw.adjusted_mode.crtc_clock; 534 534 vdsc_bpp = crtc_state->dsc.compressed_bpp; 535 - cdclk = i915->cdclk.hw.cdclk; 535 + cdclk = i915->display.cdclk.hw.cdclk; 536 536 /* fec= 0.972261, using rounding multiplier of 1000000 */ 537 537 fec_coeff = 972261; 538 538 link_clk = crtc_state->port_clock; ··· 971 971 struct aud_ts_cdclk_m_n aud_ts; 972 972 973 973 if (DISPLAY_VER(i915) >= 13) { 974 - get_aud_ts_cdclk_m_n(i915->cdclk.hw.ref, i915->cdclk.hw.cdclk, &aud_ts); 974 + get_aud_ts_cdclk_m_n(i915->display.cdclk.hw.ref, i915->display.cdclk.hw.cdclk, &aud_ts); 975 975 976 976 intel_de_write(i915, AUD_TS_CDCLK_N, aud_ts.n); 977 977 intel_de_write(i915, AUD_TS_CDCLK_M, aud_ts.m | AUD_TS_CDCLK_M_EN); ··· 1119 1119 if (drm_WARN_ON_ONCE(&dev_priv->drm, !HAS_DDI(dev_priv))) 1120 1120 return -ENODEV; 1121 1121 1122 - return dev_priv->cdclk.hw.cdclk; 1122 + return dev_priv->display.cdclk.hw.cdclk; 1123 1123 } 1124 1124 1125 1125 /*
+21 -20
drivers/gpu/drm/i915/display/intel_backlight.c
··· 18 18 #include "intel_panel.h" 19 19 #include "intel_pci_config.h" 20 20 #include "intel_pps.h" 21 + #include "intel_quirks.h" 21 22 22 23 /** 23 24 * scale - scale values from one range to another ··· 89 88 return val; 90 89 91 90 if (dev_priv->params.invert_brightness > 0 || 92 - dev_priv->quirks & QUIRK_INVERT_BRIGHTNESS) { 91 + intel_has_quirk(dev_priv, QUIRK_INVERT_BRIGHTNESS)) { 93 92 return panel->backlight.pwm_level_max - val + panel->backlight.pwm_level_min; 94 93 } 95 94 ··· 129 128 panel->backlight.max == 0 || panel->backlight.pwm_level_max == 0); 130 129 131 130 if (dev_priv->params.invert_brightness > 0 || 132 - (dev_priv->params.invert_brightness == 0 && dev_priv->quirks & QUIRK_INVERT_BRIGHTNESS)) 131 + (dev_priv->params.invert_brightness == 0 && intel_has_quirk(dev_priv, QUIRK_INVERT_BRIGHTNESS))) 133 132 val = panel->backlight.pwm_level_max - (val - panel->backlight.pwm_level_min); 134 133 135 134 return scale(val, panel->backlight.pwm_level_min, panel->backlight.pwm_level_max, ··· 306 305 if (!panel->backlight.present || !conn_state->crtc) 307 306 return; 308 307 309 - mutex_lock(&dev_priv->backlight_lock); 308 + mutex_lock(&dev_priv->display.backlight.lock); 310 309 311 310 drm_WARN_ON(&dev_priv->drm, panel->backlight.max == 0); 312 311 ··· 322 321 if (panel->backlight.enabled) 323 322 intel_panel_actually_set_backlight(conn_state, hw_level); 324 323 325 - mutex_unlock(&dev_priv->backlight_lock); 324 + mutex_unlock(&dev_priv->display.backlight.lock); 326 325 } 327 326 328 327 static void lpt_disable_backlight(const struct drm_connector_state *old_conn_state, u32 level) ··· 466 465 return; 467 466 } 468 467 469 - mutex_lock(&dev_priv->backlight_lock); 468 + mutex_lock(&dev_priv->display.backlight.lock); 470 469 471 470 if (panel->backlight.device) 472 471 panel->backlight.device->props.power = FB_BLANK_POWERDOWN; 473 472 panel->backlight.enabled = false; 474 473 panel->backlight.funcs->disable(old_conn_state, 0); 475 474 476 - mutex_unlock(&dev_priv->backlight_lock); 475 + mutex_unlock(&dev_priv->display.backlight.lock); 477 476 } 478 477 479 478 static void lpt_enable_backlight(const struct intel_crtc_state *crtc_state, ··· 816 815 817 816 drm_dbg_kms(&dev_priv->drm, "pipe %c\n", pipe_name(pipe)); 818 817 819 - mutex_lock(&dev_priv->backlight_lock); 818 + mutex_lock(&dev_priv->display.backlight.lock); 820 819 821 820 __intel_backlight_enable(crtc_state, conn_state); 822 821 823 - mutex_unlock(&dev_priv->backlight_lock); 822 + mutex_unlock(&dev_priv->display.backlight.lock); 824 823 } 825 824 826 825 #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) ··· 830 829 struct intel_panel *panel = &connector->panel; 831 830 u32 val = 0; 832 831 833 - mutex_lock(&dev_priv->backlight_lock); 832 + mutex_lock(&dev_priv->display.backlight.lock); 834 833 835 834 if (panel->backlight.enabled) 836 835 val = panel->backlight.funcs->get(connector, intel_connector_get_pipe(connector)); 837 836 838 - mutex_unlock(&dev_priv->backlight_lock); 837 + mutex_unlock(&dev_priv->display.backlight.lock); 839 838 840 839 drm_dbg_kms(&dev_priv->drm, "get backlight PWM = %d\n", val); 841 840 return val; ··· 863 862 if (!panel->backlight.present) 864 863 return; 865 864 866 - mutex_lock(&dev_priv->backlight_lock); 865 + mutex_lock(&dev_priv->display.backlight.lock); 867 866 868 867 drm_WARN_ON(&dev_priv->drm, panel->backlight.max == 0); 869 868 ··· 873 872 if (panel->backlight.enabled) 874 873 intel_panel_actually_set_backlight(conn_state, hw_level); 875 874 876 - mutex_unlock(&dev_priv->backlight_lock); 875 + mutex_unlock(&dev_priv->display.backlight.lock); 877 876 } 878 877 879 878 static int intel_backlight_device_update_status(struct backlight_device *bd) ··· 1114 1113 if (IS_PINEVIEW(dev_priv)) 1115 1114 clock = KHz(RUNTIME_INFO(dev_priv)->rawclk_freq); 1116 1115 else 1117 - clock = KHz(dev_priv->cdclk.hw.cdclk); 1116 + clock = KHz(dev_priv->display.cdclk.hw.cdclk); 1118 1117 1119 1118 return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 32); 1120 1119 } ··· 1132 1131 if (IS_G4X(dev_priv)) 1133 1132 clock = KHz(RUNTIME_INFO(dev_priv)->rawclk_freq); 1134 1133 else 1135 - clock = KHz(dev_priv->cdclk.hw.cdclk); 1134 + clock = KHz(dev_priv->display.cdclk.hw.cdclk); 1136 1135 1137 1136 return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 128); 1138 1137 } ··· 1592 1591 if (!panel->backlight.present) 1593 1592 return; 1594 1593 1595 - mutex_lock(&dev_priv->backlight_lock); 1594 + mutex_lock(&dev_priv->display.backlight.lock); 1596 1595 if (!panel->backlight.enabled) 1597 1596 __intel_backlight_enable(crtc_state, conn_state); 1598 1597 1599 - mutex_unlock(&dev_priv->backlight_lock); 1598 + mutex_unlock(&dev_priv->display.backlight.lock); 1600 1599 } 1601 1600 1602 1601 int intel_backlight_setup(struct intel_connector *connector, enum pipe pipe) ··· 1606 1605 int ret; 1607 1606 1608 1607 if (!connector->panel.vbt.backlight.present) { 1609 - if (dev_priv->quirks & QUIRK_BACKLIGHT_PRESENT) { 1608 + if (intel_has_quirk(dev_priv, QUIRK_BACKLIGHT_PRESENT)) { 1610 1609 drm_dbg_kms(&dev_priv->drm, 1611 1610 "no backlight present per VBT, but present per quirk\n"); 1612 1611 } else { ··· 1621 1620 return -ENODEV; 1622 1621 1623 1622 /* set level and max in panel struct */ 1624 - mutex_lock(&dev_priv->backlight_lock); 1623 + mutex_lock(&dev_priv->display.backlight.lock); 1625 1624 ret = panel->backlight.funcs->setup(connector, pipe); 1626 - mutex_unlock(&dev_priv->backlight_lock); 1625 + mutex_unlock(&dev_priv->display.backlight.lock); 1627 1626 1628 1627 if (ret) { 1629 1628 drm_dbg_kms(&dev_priv->drm, ··· 1778 1777 if (intel_dp_aux_init_backlight_funcs(connector) == 0) 1779 1778 return; 1780 1779 1781 - if (!(dev_priv->quirks & QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK)) 1780 + if (!intel_has_quirk(dev_priv, QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK)) 1782 1781 connector->panel.backlight.power = intel_pps_backlight_power; 1783 1782 } 1784 1783
+204 -164
drivers/gpu/drm/i915/display/intel_bios.c
··· 135 135 return block - bdb; 136 136 } 137 137 138 - /* size of the block excluding the header */ 139 - static u32 raw_block_size(const void *bdb, enum bdb_block_id section_id) 140 - { 141 - const void *block; 142 - 143 - block = find_raw_section(bdb, section_id); 144 - if (!block) 145 - return 0; 146 - 147 - return get_blocksize(block); 148 - } 149 - 150 138 struct bdb_block_entry { 151 139 struct list_head node; 152 140 enum bdb_block_id section_id; ··· 147 159 { 148 160 struct bdb_block_entry *entry; 149 161 150 - list_for_each_entry(entry, &i915->vbt.bdb_blocks, node) { 162 + list_for_each_entry(entry, &i915->display.vbt.bdb_blocks, node) { 151 163 if (entry->section_id == section_id) 152 164 return entry->data + 3; 153 165 } ··· 219 231 { 220 232 int fp_timing_size, dvo_timing_size, panel_pnp_id_size, panel_name_size; 221 233 int data_block_size, lfp_data_size; 234 + const void *data_block; 222 235 int i; 223 236 224 - data_block_size = raw_block_size(bdb, BDB_LVDS_LFP_DATA); 237 + data_block = find_raw_section(bdb, BDB_LVDS_LFP_DATA); 238 + if (!data_block) 239 + return false; 240 + 241 + data_block_size = get_blocksize(data_block); 225 242 if (data_block_size == 0) 226 243 return false; 227 244 ··· 254 261 if (16 * lfp_data_size > data_block_size) 255 262 return false; 256 263 257 - /* 258 - * Except for vlv/chv machines all real VBTs seem to have 6 259 - * unaccounted bytes in the fp_timing table. And it doesn't 260 - * appear to be a really intentional hole as the fp_timing 261 - * 0xffff terminator is always within those 6 missing bytes. 262 - */ 263 - if (fp_timing_size + dvo_timing_size + panel_pnp_id_size != lfp_data_size && 264 - fp_timing_size + 6 + dvo_timing_size + panel_pnp_id_size != lfp_data_size) 265 - return false; 266 - 267 - if (ptrs->ptr[0].fp_timing.offset + fp_timing_size > ptrs->ptr[0].dvo_timing.offset || 268 - ptrs->ptr[0].dvo_timing.offset + dvo_timing_size != ptrs->ptr[0].panel_pnp_id.offset || 269 - ptrs->ptr[0].panel_pnp_id.offset + panel_pnp_id_size != lfp_data_size) 270 - return false; 271 - 272 264 /* make sure the table entries have uniform size */ 273 265 for (i = 1; i < 16; i++) { 274 266 if (ptrs->ptr[i].fp_timing.table_size != fp_timing_size || ··· 267 289 return false; 268 290 } 269 291 292 + /* 293 + * Except for vlv/chv machines all real VBTs seem to have 6 294 + * unaccounted bytes in the fp_timing table. And it doesn't 295 + * appear to be a really intentional hole as the fp_timing 296 + * 0xffff terminator is always within those 6 missing bytes. 297 + */ 298 + if (fp_timing_size + 6 + dvo_timing_size + panel_pnp_id_size == lfp_data_size) 299 + fp_timing_size += 6; 300 + 301 + if (fp_timing_size + dvo_timing_size + panel_pnp_id_size != lfp_data_size) 302 + return false; 303 + 304 + if (ptrs->ptr[0].fp_timing.offset + fp_timing_size != ptrs->ptr[0].dvo_timing.offset || 305 + ptrs->ptr[0].dvo_timing.offset + dvo_timing_size != ptrs->ptr[0].panel_pnp_id.offset || 306 + ptrs->ptr[0].panel_pnp_id.offset + panel_pnp_id_size != lfp_data_size) 307 + return false; 308 + 270 309 /* make sure the tables fit inside the data block */ 271 310 for (i = 0; i < 16; i++) { 272 311 if (ptrs->ptr[i].fp_timing.offset + fp_timing_size > data_block_size || ··· 294 299 295 300 if (ptrs->panel_name.offset + 16 * panel_name_size > data_block_size) 296 301 return false; 302 + 303 + /* make sure fp_timing terminators are present at expected locations */ 304 + for (i = 0; i < 16; i++) { 305 + const u16 *t = data_block + ptrs->ptr[i].fp_timing.offset + 306 + fp_timing_size - 2; 307 + 308 + if (*t != 0xffff) 309 + return false; 310 + } 297 311 298 312 return true; 299 313 } ··· 337 333 return validate_lfp_data_ptrs(bdb, ptrs); 338 334 } 339 335 340 - static const void *find_fp_timing_terminator(const u8 *data, int size) 341 - { 342 - int i; 343 - 344 - for (i = 0; i < size - 1; i++) { 345 - if (data[i] == 0xff && data[i+1] == 0xff) 346 - return &data[i]; 347 - } 348 - 349 - return NULL; 350 - } 351 - 352 336 static int make_lfp_data_ptr(struct lvds_lfp_data_ptr_table *table, 353 337 int table_size, int total_size) 354 338 { ··· 360 368 static void *generate_lfp_data_ptrs(struct drm_i915_private *i915, 361 369 const void *bdb) 362 370 { 363 - int i, size, table_size, block_size, offset; 364 - const void *t0, *t1, *block; 371 + int i, size, table_size, block_size, offset, fp_timing_size; 365 372 struct bdb_lvds_lfp_data_ptrs *ptrs; 373 + const void *block; 366 374 void *ptrs_block; 375 + 376 + /* 377 + * The hardcoded fp_timing_size is only valid for 378 + * modernish VBTs. All older VBTs definitely should 379 + * include block 41 and thus we don't need to 380 + * generate one. 381 + */ 382 + if (i915->display.vbt.version < 155) 383 + return NULL; 384 + 385 + fp_timing_size = 38; 367 386 368 387 block = find_raw_section(bdb, BDB_LVDS_LFP_DATA); 369 388 if (!block) ··· 384 381 385 382 block_size = get_blocksize(block); 386 383 387 - size = block_size; 388 - t0 = find_fp_timing_terminator(block, size); 389 - if (!t0) 390 - return NULL; 391 - 392 - size -= t0 - block - 2; 393 - t1 = find_fp_timing_terminator(t0 + 2, size); 394 - if (!t1) 395 - return NULL; 396 - 397 - size = t1 - t0; 384 + size = fp_timing_size + sizeof(struct lvds_dvo_timing) + 385 + sizeof(struct lvds_pnp_id); 398 386 if (size * 16 > block_size) 399 387 return NULL; 400 388 ··· 403 409 table_size = sizeof(struct lvds_dvo_timing); 404 410 size = make_lfp_data_ptr(&ptrs->ptr[0].dvo_timing, table_size, size); 405 411 406 - table_size = t0 - block + 2; 412 + table_size = fp_timing_size; 407 413 size = make_lfp_data_ptr(&ptrs->ptr[0].fp_timing, table_size, size); 408 414 409 415 if (ptrs->ptr[0].fp_timing.table_size) ··· 418 424 return NULL; 419 425 } 420 426 421 - size = t1 - t0; 427 + size = fp_timing_size + sizeof(struct lvds_dvo_timing) + 428 + sizeof(struct lvds_pnp_id); 422 429 for (i = 1; i < 16; i++) { 423 430 next_lfp_data_ptr(&ptrs->ptr[i].fp_timing, &ptrs->ptr[i-1].fp_timing, size); 424 431 next_lfp_data_ptr(&ptrs->ptr[i].dvo_timing, &ptrs->ptr[i-1].dvo_timing, size); 425 432 next_lfp_data_ptr(&ptrs->ptr[i].panel_pnp_id, &ptrs->ptr[i-1].panel_pnp_id, size); 426 433 } 427 434 428 - size = t1 - t0; 429 435 table_size = sizeof(struct lvds_lfp_panel_name); 430 436 431 437 if (16 * (size + table_size) <= block_size) { ··· 473 479 474 480 block_size = get_blocksize(block); 475 481 482 + /* 483 + * Version number and new block size are considered 484 + * part of the header for MIPI sequenece block v3+. 485 + */ 486 + if (section_id == BDB_MIPI_SEQUENCE && *(const u8 *)block >= 3) 487 + block_size += 5; 488 + 476 489 entry = kzalloc(struct_size(entry, data, max(min_size, block_size) + 3), 477 490 GFP_KERNEL); 478 491 if (!entry) { ··· 502 501 return; 503 502 } 504 503 505 - list_add_tail(&entry->node, &i915->vbt.bdb_blocks); 504 + list_add_tail(&entry->node, &i915->display.vbt.bdb_blocks); 506 505 } 507 506 508 507 static void init_bdb_blocks(struct drm_i915_private *i915, ··· 605 604 return NULL; 606 605 } 607 606 607 + static void dump_pnp_id(struct drm_i915_private *i915, 608 + const struct lvds_pnp_id *pnp_id, 609 + const char *name) 610 + { 611 + u16 mfg_name = be16_to_cpu((__force __be16)pnp_id->mfg_name); 612 + char vend[4]; 613 + 614 + drm_dbg_kms(&i915->drm, "%s PNPID mfg: %s (0x%x), prod: %u, serial: %u, week: %d, year: %d\n", 615 + name, drm_edid_decode_mfg_id(mfg_name, vend), 616 + pnp_id->mfg_name, pnp_id->product_code, pnp_id->serial, 617 + pnp_id->mfg_week, pnp_id->mfg_year + 1990); 618 + } 619 + 608 620 static int opregion_get_panel_type(struct drm_i915_private *i915, 609 621 const struct intel_bios_encoder_data *devdata, 610 622 const struct edid *edid) ··· 668 654 edid_id_nodate = *edid_id; 669 655 edid_id_nodate.mfg_week = 0; 670 656 edid_id_nodate.mfg_year = 0; 657 + 658 + dump_pnp_id(i915, edid_id, "EDID"); 671 659 672 660 ptrs = find_section(i915, BDB_LVDS_LFP_DATA_PTRS); 673 661 if (!ptrs) ··· 877 861 const struct bdb_lvds_lfp_data *data; 878 862 const struct bdb_lvds_lfp_data_tail *tail; 879 863 const struct bdb_lvds_lfp_data_ptrs *ptrs; 864 + const struct lvds_pnp_id *pnp_id; 880 865 int panel_type = panel->vbt.panel_type; 881 866 882 867 ptrs = find_section(i915, BDB_LVDS_LFP_DATA_PTRS); ··· 891 874 if (!panel->vbt.lfp_lvds_vbt_mode) 892 875 parse_lfp_panel_dtd(i915, panel, data, ptrs); 893 876 877 + pnp_id = get_lvds_pnp_id(data, ptrs, panel_type); 878 + dump_pnp_id(i915, pnp_id, "Panel"); 879 + 894 880 tail = get_lfp_data_tail(data, ptrs); 895 881 if (!tail) 896 882 return; 897 883 898 - if (i915->vbt.version >= 188) { 884 + drm_dbg_kms(&i915->drm, "Panel name: %.*s\n", 885 + (int)sizeof(tail->panel_name[0].name), 886 + tail->panel_name[panel_type].name); 887 + 888 + if (i915->display.vbt.version >= 188) { 899 889 panel->vbt.seamless_drrs_min_refresh_rate = 900 890 tail->seamless_drrs_min_refresh_rate[panel_type]; 901 891 drm_dbg_kms(&i915->drm, ··· 928 904 * first on VBT >= 229, but still fall back to trying the old LFP 929 905 * block if that fails. 930 906 */ 931 - if (i915->vbt.version < 229) 907 + if (i915->display.vbt.version < 229) 932 908 return; 933 909 934 910 generic_dtd = find_section(i915, BDB_GENERIC_DTD); ··· 1032 1008 } 1033 1009 1034 1010 panel->vbt.backlight.type = INTEL_BACKLIGHT_DISPLAY_DDI; 1035 - if (i915->vbt.version >= 191) { 1011 + if (i915->display.vbt.version >= 191) { 1036 1012 size_t exp_size; 1037 1013 1038 - if (i915->vbt.version >= 236) 1014 + if (i915->display.vbt.version >= 236) 1039 1015 exp_size = sizeof(struct bdb_lfp_backlight_data); 1040 - else if (i915->vbt.version >= 234) 1016 + else if (i915->display.vbt.version >= 234) 1041 1017 exp_size = EXP_BDB_LFP_BL_DATA_SIZE_REV_234; 1042 1018 else 1043 1019 exp_size = EXP_BDB_LFP_BL_DATA_SIZE_REV_191; ··· 1054 1030 panel->vbt.backlight.pwm_freq_hz = entry->pwm_freq_hz; 1055 1031 panel->vbt.backlight.active_low_pwm = entry->active_low_pwm; 1056 1032 1057 - if (i915->vbt.version >= 234) { 1033 + if (i915->display.vbt.version >= 234) { 1058 1034 u16 min_level; 1059 1035 bool scale; 1060 1036 1061 1037 level = backlight_data->brightness_level[panel_type].level; 1062 1038 min_level = backlight_data->brightness_min_level[panel_type].level; 1063 1039 1064 - if (i915->vbt.version >= 236) 1040 + if (i915->display.vbt.version >= 236) 1065 1041 scale = backlight_data->brightness_precision_bits[panel_type] == 16; 1066 1042 else 1067 1043 scale = level > 255; ··· 1158 1134 if (!general) 1159 1135 return; 1160 1136 1161 - i915->vbt.int_tv_support = general->int_tv_support; 1137 + i915->display.vbt.int_tv_support = general->int_tv_support; 1162 1138 /* int_crt_support can't be trusted on earlier platforms */ 1163 - if (i915->vbt.version >= 155 && 1139 + if (i915->display.vbt.version >= 155 && 1164 1140 (HAS_DDI(i915) || IS_VALLEYVIEW(i915))) 1165 - i915->vbt.int_crt_support = general->int_crt_support; 1166 - i915->vbt.lvds_use_ssc = general->enable_ssc; 1167 - i915->vbt.lvds_ssc_freq = 1141 + i915->display.vbt.int_crt_support = general->int_crt_support; 1142 + i915->display.vbt.lvds_use_ssc = general->enable_ssc; 1143 + i915->display.vbt.lvds_ssc_freq = 1168 1144 intel_bios_ssc_frequency(i915, general->ssc_freq); 1169 - i915->vbt.display_clock_mode = general->display_clock_mode; 1170 - i915->vbt.fdi_rx_polarity_inverted = general->fdi_rx_polarity_inverted; 1171 - if (i915->vbt.version >= 181) { 1172 - i915->vbt.orientation = general->rotate_180 ? 1145 + i915->display.vbt.display_clock_mode = general->display_clock_mode; 1146 + i915->display.vbt.fdi_rx_polarity_inverted = general->fdi_rx_polarity_inverted; 1147 + if (i915->display.vbt.version >= 181) { 1148 + i915->display.vbt.orientation = general->rotate_180 ? 1173 1149 DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP : 1174 1150 DRM_MODE_PANEL_ORIENTATION_NORMAL; 1175 1151 } else { 1176 - i915->vbt.orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; 1152 + i915->display.vbt.orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; 1177 1153 } 1178 1154 1179 - if (i915->vbt.version >= 249 && general->afc_startup_config) { 1180 - i915->vbt.override_afc_startup = true; 1181 - i915->vbt.override_afc_startup_val = general->afc_startup_config == 0x1 ? 0x0 : 0x7; 1155 + if (i915->display.vbt.version >= 249 && general->afc_startup_config) { 1156 + i915->display.vbt.override_afc_startup = true; 1157 + i915->display.vbt.override_afc_startup_val = general->afc_startup_config == 0x1 ? 0x0 : 0x7; 1182 1158 } 1183 1159 1184 1160 drm_dbg_kms(&i915->drm, 1185 1161 "BDB_GENERAL_FEATURES int_tv_support %d int_crt_support %d lvds_use_ssc %d lvds_ssc_freq %d display_clock_mode %d fdi_rx_polarity_inverted %d\n", 1186 - i915->vbt.int_tv_support, 1187 - i915->vbt.int_crt_support, 1188 - i915->vbt.lvds_use_ssc, 1189 - i915->vbt.lvds_ssc_freq, 1190 - i915->vbt.display_clock_mode, 1191 - i915->vbt.fdi_rx_polarity_inverted); 1162 + i915->display.vbt.int_tv_support, 1163 + i915->display.vbt.int_crt_support, 1164 + i915->display.vbt.lvds_use_ssc, 1165 + i915->display.vbt.lvds_ssc_freq, 1166 + i915->display.vbt.display_clock_mode, 1167 + i915->display.vbt.fdi_rx_polarity_inverted); 1192 1168 } 1193 1169 1194 1170 static const struct child_device_config * ··· 1214 1190 return; 1215 1191 } 1216 1192 1217 - list_for_each_entry(devdata, &i915->vbt.display_devices, node) { 1193 + list_for_each_entry(devdata, &i915->display.vbt.display_devices, node) { 1218 1194 child = &devdata->child; 1219 1195 1220 1196 if (child->slave_addr != SLAVE_ADDR1 && ··· 1238 1214 child->slave_addr, 1239 1215 (child->dvo_port == DEVICE_PORT_DVOB) ? 1240 1216 "SDVOB" : "SDVOC"); 1241 - mapping = &i915->vbt.sdvo_mappings[child->dvo_port - 1]; 1217 + mapping = &i915->display.vbt.sdvo_mappings[child->dvo_port - 1]; 1242 1218 if (!mapping->initialized) { 1243 1219 mapping->dvo_port = child->dvo_port; 1244 1220 mapping->slave_addr = child->slave_addr; ··· 1289 1265 * interpretation, but real world VBTs seem to. 1290 1266 */ 1291 1267 if (driver->lvds_config != BDB_DRIVER_FEATURE_INT_LVDS) 1292 - i915->vbt.int_lvds_support = 0; 1268 + i915->display.vbt.int_lvds_support = 0; 1293 1269 } else { 1294 1270 /* 1295 1271 * FIXME it's not clear which BDB version has the LVDS config ··· 1302 1278 * in the wild with the bits correctly populated. Version 1303 1279 * 108 (on i85x) does not have the bits correctly populated. 1304 1280 */ 1305 - if (i915->vbt.version >= 134 && 1281 + if (i915->display.vbt.version >= 134 && 1306 1282 driver->lvds_config != BDB_DRIVER_FEATURE_INT_LVDS && 1307 1283 driver->lvds_config != BDB_DRIVER_FEATURE_INT_SDVO_LVDS) 1308 - i915->vbt.int_lvds_support = 0; 1284 + i915->display.vbt.int_lvds_support = 0; 1309 1285 } 1310 1286 } 1311 1287 ··· 1319 1295 if (!driver) 1320 1296 return; 1321 1297 1322 - if (i915->vbt.version < 228) { 1298 + if (i915->display.vbt.version < 228) { 1323 1299 drm_dbg_kms(&i915->drm, "DRRS State Enabled:%d\n", 1324 1300 driver->drrs_enabled); 1325 1301 /* ··· 1352 1328 1353 1329 panel->vbt.vrr = true; /* matches Windows behaviour */ 1354 1330 1355 - if (i915->vbt.version < 228) 1331 + if (i915->display.vbt.version < 228) 1356 1332 return; 1357 1333 1358 1334 power = find_section(i915, BDB_LFP_POWER); ··· 1378 1354 panel->vbt.drrs_type = DRRS_TYPE_NONE; 1379 1355 } 1380 1356 1381 - if (i915->vbt.version >= 232) 1357 + if (i915->display.vbt.version >= 232) 1382 1358 panel->vbt.edp.hobl = panel_bool(power->hobl, panel_type); 1383 1359 1384 - if (i915->vbt.version >= 233) 1360 + if (i915->display.vbt.version >= 233) 1385 1361 panel->vbt.vrr = panel_bool(power->vrr_feature_enabled, 1386 1362 panel_type); 1387 1363 } ··· 1417 1393 1418 1394 panel->vbt.edp.pps = *edp_pps; 1419 1395 1420 - if (i915->vbt.version >= 224) { 1396 + if (i915->display.vbt.version >= 224) { 1421 1397 panel->vbt.edp.rate = 1422 1398 edp->edp_fast_link_training_rate[panel_type] * 20; 1423 1399 } else { ··· 1496 1472 break; 1497 1473 } 1498 1474 1499 - if (i915->vbt.version >= 173) { 1475 + if (i915->display.vbt.version >= 173) { 1500 1476 u8 vswing; 1501 1477 1502 1478 /* Don't read from VBT if module parameter has valid value*/ ··· 1512 1488 panel->vbt.edp.drrs_msa_timing_delay = 1513 1489 panel_bits(edp->sdrrs_msa_timing_delay, panel_type, 2); 1514 1490 1515 - if (i915->vbt.version >= 244) 1491 + if (i915->display.vbt.version >= 244) 1516 1492 panel->vbt.edp.max_link_rate = 1517 1493 edp->edp_max_port_link_rate[panel_type] * 20; 1518 1494 } ··· 1544 1520 * New psr options 0=500us, 1=100us, 2=2500us, 3=0us 1545 1521 * Old decimal value is wake up time in multiples of 100 us. 1546 1522 */ 1547 - if (i915->vbt.version >= 205 && 1523 + if (i915->display.vbt.version >= 205 && 1548 1524 (DISPLAY_VER(i915) >= 9 && !IS_BROXTON(i915))) { 1549 1525 switch (psr_table->tp1_wakeup_time) { 1550 1526 case 0: ··· 1590 1566 panel->vbt.psr.tp2_tp3_wakeup_time_us = psr_table->tp2_tp3_wakeup_time * 100; 1591 1567 } 1592 1568 1593 - if (i915->vbt.version >= 226) { 1569 + if (i915->display.vbt.version >= 226) { 1594 1570 u32 wakeup_time = psr->psr2_tp2_tp3_wakeup_time; 1595 1571 1596 1572 wakeup_time = panel_bits(wakeup_time, panel_type, 2); ··· 1622 1598 { 1623 1599 enum port port_bc = DISPLAY_VER(i915) >= 11 ? PORT_B : PORT_C; 1624 1600 1625 - if (!panel->vbt.dsi.config->dual_link || i915->vbt.version < 197) { 1601 + if (!panel->vbt.dsi.config->dual_link || i915->display.vbt.version < 197) { 1626 1602 panel->vbt.dsi.bl_ports = BIT(port); 1627 1603 if (panel->vbt.dsi.config->cabc_supported) 1628 1604 panel->vbt.dsi.cabc_ports = BIT(port); ··· 2077 2053 u16 block_size; 2078 2054 int index; 2079 2055 2080 - if (i915->vbt.version < 198) 2056 + if (i915->display.vbt.version < 198) 2081 2057 return; 2082 2058 2083 2059 params = find_section(i915, BDB_COMPRESSION_PARAMETERS); ··· 2097 2073 } 2098 2074 } 2099 2075 2100 - list_for_each_entry(devdata, &i915->vbt.display_devices, node) { 2076 + list_for_each_entry(devdata, &i915->display.vbt.display_devices, node) { 2101 2077 child = &devdata->child; 2102 2078 2103 2079 if (!child->compression_enable) ··· 2231 2207 return PORT_NONE; 2232 2208 2233 2209 for_each_port(port) { 2234 - devdata = i915->vbt.ports[port]; 2210 + devdata = i915->display.vbt.ports[port]; 2235 2211 2236 2212 if (devdata && ddc_pin == devdata->child.ddc_pin) 2237 2213 return port; ··· 2280 2256 * there are real machines (eg. Asrock B250M-HDV) where VBT has both 2281 2257 * port A and port E with the same AUX ch and we must pick port E :( 2282 2258 */ 2283 - child = &i915->vbt.ports[p]->child; 2259 + child = &i915->display.vbt.ports[p]->child; 2284 2260 2285 2261 child->device_type &= ~DEVICE_TYPE_TMDS_DVI_SIGNALING; 2286 2262 child->device_type |= DEVICE_TYPE_NOT_HDMI_OUTPUT; ··· 2297 2273 return PORT_NONE; 2298 2274 2299 2275 for_each_port(port) { 2300 - devdata = i915->vbt.ports[port]; 2276 + devdata = i915->display.vbt.ports[port]; 2301 2277 2302 2278 if (devdata && aux_ch == devdata->child.aux_channel) 2303 2279 return port; ··· 2332 2308 * there are real machines (eg. Asrock B250M-HDV) where VBT has both 2333 2309 * port A and port E with the same AUX ch and we must pick port E :( 2334 2310 */ 2335 - child = &i915->vbt.ports[p]->child; 2311 + child = &i915->display.vbt.ports[p]->child; 2336 2312 2337 2313 child->device_type &= ~DEVICE_TYPE_DISPLAYPORT_OUTPUT; 2338 2314 child->aux_channel = 0; ··· 2506 2482 2507 2483 static int _intel_bios_dp_max_link_rate(const struct intel_bios_encoder_data *devdata) 2508 2484 { 2509 - if (!devdata || devdata->i915->vbt.version < 216) 2485 + if (!devdata || devdata->i915->display.vbt.version < 216) 2510 2486 return 0; 2511 2487 2512 - if (devdata->i915->vbt.version >= 230) 2488 + if (devdata->i915->display.vbt.version >= 230) 2513 2489 return parse_bdb_230_dp_max_link_rate(devdata->child.dp_max_link_rate); 2514 2490 else 2515 2491 return parse_bdb_216_dp_max_link_rate(devdata->child.dp_max_link_rate); 2492 + } 2493 + 2494 + static int _intel_bios_dp_max_lane_count(const struct intel_bios_encoder_data *devdata) 2495 + { 2496 + if (!devdata || devdata->i915->display.vbt.version < 244) 2497 + return 0; 2498 + 2499 + return devdata->child.dp_max_lane_count + 1; 2516 2500 } 2517 2501 2518 2502 static void sanitize_device_type(struct intel_bios_encoder_data *devdata, ··· 2578 2546 2579 2547 static int _intel_bios_hdmi_level_shift(const struct intel_bios_encoder_data *devdata) 2580 2548 { 2581 - if (!devdata || devdata->i915->vbt.version < 158) 2549 + if (!devdata || devdata->i915->display.vbt.version < 158) 2582 2550 return -1; 2583 2551 2584 2552 return devdata->child.hdmi_level_shifter_value; ··· 2586 2554 2587 2555 static int _intel_bios_max_tmds_clock(const struct intel_bios_encoder_data *devdata) 2588 2556 { 2589 - if (!devdata || devdata->i915->vbt.version < 204) 2557 + if (!devdata || devdata->i915->display.vbt.version < 204) 2590 2558 return 0; 2591 2559 2592 2560 switch (devdata->child.hdmi_max_data_rate) { ··· 2695 2663 return; 2696 2664 } 2697 2665 2698 - if (i915->vbt.ports[port]) { 2666 + if (i915->display.vbt.ports[port]) { 2699 2667 drm_dbg_kms(&i915->drm, 2700 2668 "More than one child device for port %c in VBT, using the first.\n", 2701 2669 port_name(port)); ··· 2710 2678 if (intel_bios_encoder_supports_dp(devdata)) 2711 2679 sanitize_aux_ch(devdata, port); 2712 2680 2713 - i915->vbt.ports[port] = devdata; 2681 + i915->display.vbt.ports[port] = devdata; 2714 2682 } 2715 2683 2716 2684 static bool has_ddi_port_info(struct drm_i915_private *i915) ··· 2726 2694 if (!has_ddi_port_info(i915)) 2727 2695 return; 2728 2696 2729 - list_for_each_entry(devdata, &i915->vbt.display_devices, node) 2697 + list_for_each_entry(devdata, &i915->display.vbt.display_devices, node) 2730 2698 parse_ddi_port(devdata); 2731 2699 2732 2700 for_each_port(port) { 2733 - if (i915->vbt.ports[port]) 2734 - print_ddi_port(i915->vbt.ports[port], port); 2701 + if (i915->display.vbt.ports[port]) 2702 + print_ddi_port(i915->display.vbt.ports[port], port); 2735 2703 } 2736 2704 } 2737 2705 ··· 2764 2732 bus_pin = defs->crt_ddc_gmbus_pin; 2765 2733 drm_dbg_kms(&i915->drm, "crt_ddc_bus_pin: %d\n", bus_pin); 2766 2734 if (intel_gmbus_is_valid_pin(i915, bus_pin)) 2767 - i915->vbt.crt_ddc_pin = bus_pin; 2735 + i915->display.vbt.crt_ddc_pin = bus_pin; 2768 2736 2769 - if (i915->vbt.version < 106) { 2737 + if (i915->display.vbt.version < 106) { 2770 2738 expected_size = 22; 2771 - } else if (i915->vbt.version < 111) { 2739 + } else if (i915->display.vbt.version < 111) { 2772 2740 expected_size = 27; 2773 - } else if (i915->vbt.version < 195) { 2741 + } else if (i915->display.vbt.version < 195) { 2774 2742 expected_size = LEGACY_CHILD_DEVICE_CONFIG_SIZE; 2775 - } else if (i915->vbt.version == 195) { 2743 + } else if (i915->display.vbt.version == 195) { 2776 2744 expected_size = 37; 2777 - } else if (i915->vbt.version <= 215) { 2745 + } else if (i915->display.vbt.version <= 215) { 2778 2746 expected_size = 38; 2779 - } else if (i915->vbt.version <= 237) { 2747 + } else if (i915->display.vbt.version <= 237) { 2780 2748 expected_size = 39; 2781 2749 } else { 2782 2750 expected_size = sizeof(*child); 2783 2751 BUILD_BUG_ON(sizeof(*child) < 39); 2784 2752 drm_dbg(&i915->drm, 2785 2753 "Expected child device config size for VBT version %u not known; assuming %u\n", 2786 - i915->vbt.version, expected_size); 2754 + i915->display.vbt.version, expected_size); 2787 2755 } 2788 2756 2789 2757 /* Flag an error for unexpected size, but continue anyway. */ 2790 2758 if (defs->child_dev_size != expected_size) 2791 2759 drm_err(&i915->drm, 2792 2760 "Unexpected child device config size %u (expected %u for VBT version %u)\n", 2793 - defs->child_dev_size, expected_size, i915->vbt.version); 2761 + defs->child_dev_size, expected_size, i915->display.vbt.version); 2794 2762 2795 2763 /* The legacy sized child device config is the minimum we need. */ 2796 2764 if (defs->child_dev_size < LEGACY_CHILD_DEVICE_CONFIG_SIZE) { ··· 2826 2794 memcpy(&devdata->child, child, 2827 2795 min_t(size_t, defs->child_dev_size, sizeof(*child))); 2828 2796 2829 - list_add_tail(&devdata->node, &i915->vbt.display_devices); 2797 + list_add_tail(&devdata->node, &i915->display.vbt.display_devices); 2830 2798 } 2831 2799 2832 - if (list_empty(&i915->vbt.display_devices)) 2800 + if (list_empty(&i915->display.vbt.display_devices)) 2833 2801 drm_dbg_kms(&i915->drm, 2834 2802 "no child dev is parsed from VBT\n"); 2835 2803 } ··· 2838 2806 static void 2839 2807 init_vbt_defaults(struct drm_i915_private *i915) 2840 2808 { 2841 - i915->vbt.crt_ddc_pin = GMBUS_PIN_VGADDC; 2809 + i915->display.vbt.crt_ddc_pin = GMBUS_PIN_VGADDC; 2842 2810 2843 2811 /* general features */ 2844 - i915->vbt.int_tv_support = 1; 2845 - i915->vbt.int_crt_support = 1; 2812 + i915->display.vbt.int_tv_support = 1; 2813 + i915->display.vbt.int_crt_support = 1; 2846 2814 2847 2815 /* driver features */ 2848 - i915->vbt.int_lvds_support = 1; 2816 + i915->display.vbt.int_lvds_support = 1; 2849 2817 2850 2818 /* Default to using SSC */ 2851 - i915->vbt.lvds_use_ssc = 1; 2819 + i915->display.vbt.lvds_use_ssc = 1; 2852 2820 /* 2853 2821 * Core/SandyBridge/IvyBridge use alternative (120MHz) reference 2854 2822 * clock for LVDS. 2855 2823 */ 2856 - i915->vbt.lvds_ssc_freq = intel_bios_ssc_frequency(i915, 2857 - !HAS_PCH_SPLIT(i915)); 2824 + i915->display.vbt.lvds_ssc_freq = intel_bios_ssc_frequency(i915, 2825 + !HAS_PCH_SPLIT(i915)); 2858 2826 drm_dbg_kms(&i915->drm, "Set default to SSC at %d kHz\n", 2859 - i915->vbt.lvds_ssc_freq); 2827 + i915->display.vbt.lvds_ssc_freq); 2860 2828 } 2861 2829 2862 2830 /* Common defaults which may be overridden by VBT. */ ··· 2917 2885 if (port == PORT_A) 2918 2886 child->device_type |= DEVICE_TYPE_INTERNAL_CONNECTOR; 2919 2887 2920 - list_add_tail(&devdata->node, &i915->vbt.display_devices); 2888 + list_add_tail(&devdata->node, &i915->display.vbt.display_devices); 2921 2889 2922 2890 drm_dbg_kms(&i915->drm, 2923 2891 "Generating default VBT child device with type 0x04%x on port %c\n", ··· 2925 2893 } 2926 2894 2927 2895 /* Bypass some minimum baseline VBT version checks */ 2928 - i915->vbt.version = 155; 2896 + i915->display.vbt.version = 155; 2929 2897 } 2930 2898 2931 2899 static const struct bdb_header *get_bdb_header(const struct vbt_header *vbt) ··· 3112 3080 */ 3113 3081 void intel_bios_init(struct drm_i915_private *i915) 3114 3082 { 3115 - const struct vbt_header *vbt = i915->opregion.vbt; 3083 + const struct vbt_header *vbt = i915->display.opregion.vbt; 3116 3084 struct vbt_header *oprom_vbt = NULL; 3117 3085 const struct bdb_header *bdb; 3118 3086 3119 - INIT_LIST_HEAD(&i915->vbt.display_devices); 3120 - INIT_LIST_HEAD(&i915->vbt.bdb_blocks); 3087 + INIT_LIST_HEAD(&i915->display.vbt.display_devices); 3088 + INIT_LIST_HEAD(&i915->display.vbt.bdb_blocks); 3121 3089 3122 3090 if (!HAS_DISPLAY(i915)) { 3123 3091 drm_dbg_kms(&i915->drm, ··· 3145 3113 goto out; 3146 3114 3147 3115 bdb = get_bdb_header(vbt); 3148 - i915->vbt.version = bdb->version; 3116 + i915->display.vbt.version = bdb->version; 3149 3117 3150 3118 drm_dbg_kms(&i915->drm, 3151 3119 "VBT signature \"%.*s\", BDB version %d\n", 3152 - (int)sizeof(vbt->signature), vbt->signature, i915->vbt.version); 3120 + (int)sizeof(vbt->signature), vbt->signature, i915->display.vbt.version); 3153 3121 3154 3122 init_bdb_blocks(i915, bdb); 3155 3123 ··· 3206 3174 struct intel_bios_encoder_data *devdata, *nd; 3207 3175 struct bdb_block_entry *entry, *ne; 3208 3176 3209 - list_for_each_entry_safe(devdata, nd, &i915->vbt.display_devices, node) { 3177 + list_for_each_entry_safe(devdata, nd, &i915->display.vbt.display_devices, node) { 3210 3178 list_del(&devdata->node); 3211 3179 kfree(devdata->dsc); 3212 3180 kfree(devdata); 3213 3181 } 3214 3182 3215 - list_for_each_entry_safe(entry, ne, &i915->vbt.bdb_blocks, node) { 3183 + list_for_each_entry_safe(entry, ne, &i915->display.vbt.bdb_blocks, node) { 3216 3184 list_del(&entry->node); 3217 3185 kfree(entry); 3218 3186 } ··· 3246 3214 const struct intel_bios_encoder_data *devdata; 3247 3215 const struct child_device_config *child; 3248 3216 3249 - if (!i915->vbt.int_tv_support) 3217 + if (!i915->display.vbt.int_tv_support) 3250 3218 return false; 3251 3219 3252 - if (list_empty(&i915->vbt.display_devices)) 3220 + if (list_empty(&i915->display.vbt.display_devices)) 3253 3221 return true; 3254 3222 3255 - list_for_each_entry(devdata, &i915->vbt.display_devices, node) { 3223 + list_for_each_entry(devdata, &i915->display.vbt.display_devices, node) { 3256 3224 child = &devdata->child; 3257 3225 3258 3226 /* ··· 3289 3257 const struct intel_bios_encoder_data *devdata; 3290 3258 const struct child_device_config *child; 3291 3259 3292 - if (list_empty(&i915->vbt.display_devices)) 3260 + if (list_empty(&i915->display.vbt.display_devices)) 3293 3261 return true; 3294 3262 3295 - list_for_each_entry(devdata, &i915->vbt.display_devices, node) { 3263 + list_for_each_entry(devdata, &i915->display.vbt.display_devices, node) { 3296 3264 child = &devdata->child; 3297 3265 3298 3266 /* If the device type is not LFP, continue. ··· 3319 3287 * additional data. Trust that if the VBT was written into 3320 3288 * the OpRegion then they have validated the LVDS's existence. 3321 3289 */ 3322 - if (i915->opregion.vbt) 3290 + if (i915->display.opregion.vbt) 3323 3291 return true; 3324 3292 } 3325 3293 ··· 3338 3306 if (WARN_ON(!has_ddi_port_info(i915))) 3339 3307 return true; 3340 3308 3341 - return i915->vbt.ports[port]; 3309 + return i915->display.vbt.ports[port]; 3342 3310 } 3343 3311 3344 3312 /** ··· 3398 3366 const struct child_device_config *child; 3399 3367 u8 dvo_port; 3400 3368 3401 - list_for_each_entry(devdata, &i915->vbt.display_devices, node) { 3369 + list_for_each_entry(devdata, &i915->display.vbt.display_devices, node) { 3402 3370 child = &devdata->child; 3403 3371 3404 3372 if (!(child->device_type & DEVICE_TYPE_MIPI_OUTPUT)) ··· 3497 3465 const struct intel_bios_encoder_data *devdata; 3498 3466 const struct child_device_config *child; 3499 3467 3500 - list_for_each_entry(devdata, &i915->vbt.display_devices, node) { 3468 + list_for_each_entry(devdata, &i915->display.vbt.display_devices, node) { 3501 3469 child = &devdata->child; 3502 3470 3503 3471 if (!(child->device_type & DEVICE_TYPE_MIPI_OUTPUT)) ··· 3528 3496 intel_bios_is_port_hpd_inverted(const struct drm_i915_private *i915, 3529 3497 enum port port) 3530 3498 { 3531 - const struct intel_bios_encoder_data *devdata = i915->vbt.ports[port]; 3499 + const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[port]; 3532 3500 3533 3501 if (drm_WARN_ON_ONCE(&i915->drm, 3534 3502 !IS_GEMINILAKE(i915) && !IS_BROXTON(i915))) ··· 3548 3516 intel_bios_is_lspcon_present(const struct drm_i915_private *i915, 3549 3517 enum port port) 3550 3518 { 3551 - const struct intel_bios_encoder_data *devdata = i915->vbt.ports[port]; 3519 + const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[port]; 3552 3520 3553 3521 return HAS_LSPCON(i915) && devdata && devdata->child.lspcon; 3554 3522 } ··· 3564 3532 intel_bios_is_lane_reversal_needed(const struct drm_i915_private *i915, 3565 3533 enum port port) 3566 3534 { 3567 - const struct intel_bios_encoder_data *devdata = i915->vbt.ports[port]; 3535 + const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[port]; 3568 3536 3569 3537 return devdata && devdata->child.lane_reversal; 3570 3538 } ··· 3572 3540 enum aux_ch intel_bios_port_aux_ch(struct drm_i915_private *i915, 3573 3541 enum port port) 3574 3542 { 3575 - const struct intel_bios_encoder_data *devdata = i915->vbt.ports[port]; 3543 + const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[port]; 3576 3544 enum aux_ch aux_ch; 3577 3545 3578 3546 if (!devdata || !devdata->child.aux_channel) { ··· 3666 3634 int intel_bios_max_tmds_clock(struct intel_encoder *encoder) 3667 3635 { 3668 3636 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 3669 - const struct intel_bios_encoder_data *devdata = i915->vbt.ports[encoder->port]; 3637 + const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[encoder->port]; 3670 3638 3671 3639 return _intel_bios_max_tmds_clock(devdata); 3672 3640 } ··· 3675 3643 int intel_bios_hdmi_level_shift(struct intel_encoder *encoder) 3676 3644 { 3677 3645 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 3678 - const struct intel_bios_encoder_data *devdata = i915->vbt.ports[encoder->port]; 3646 + const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[encoder->port]; 3679 3647 3680 3648 return _intel_bios_hdmi_level_shift(devdata); 3681 3649 } 3682 3650 3683 3651 int intel_bios_encoder_dp_boost_level(const struct intel_bios_encoder_data *devdata) 3684 3652 { 3685 - if (!devdata || devdata->i915->vbt.version < 196 || !devdata->child.iboost) 3653 + if (!devdata || devdata->i915->display.vbt.version < 196 || !devdata->child.iboost) 3686 3654 return 0; 3687 3655 3688 3656 return translate_iboost(devdata->child.dp_iboost_level); ··· 3690 3658 3691 3659 int intel_bios_encoder_hdmi_boost_level(const struct intel_bios_encoder_data *devdata) 3692 3660 { 3693 - if (!devdata || devdata->i915->vbt.version < 196 || !devdata->child.iboost) 3661 + if (!devdata || devdata->i915->display.vbt.version < 196 || !devdata->child.iboost) 3694 3662 return 0; 3695 3663 3696 3664 return translate_iboost(devdata->child.hdmi_iboost_level); ··· 3699 3667 int intel_bios_dp_max_link_rate(struct intel_encoder *encoder) 3700 3668 { 3701 3669 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 3702 - const struct intel_bios_encoder_data *devdata = i915->vbt.ports[encoder->port]; 3670 + const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[encoder->port]; 3703 3671 3704 3672 return _intel_bios_dp_max_link_rate(devdata); 3673 + } 3674 + 3675 + int intel_bios_dp_max_lane_count(struct intel_encoder *encoder) 3676 + { 3677 + struct drm_i915_private *i915 = to_i915(encoder->base.dev); 3678 + const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[encoder->port]; 3679 + 3680 + return _intel_bios_dp_max_lane_count(devdata); 3705 3681 } 3706 3682 3707 3683 int intel_bios_alternate_ddc_pin(struct intel_encoder *encoder) 3708 3684 { 3709 3685 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 3710 - const struct intel_bios_encoder_data *devdata = i915->vbt.ports[encoder->port]; 3686 + const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[encoder->port]; 3711 3687 3712 3688 if (!devdata || !devdata->child.ddc_pin) 3713 3689 return 0; ··· 3725 3685 3726 3686 bool intel_bios_encoder_supports_typec_usb(const struct intel_bios_encoder_data *devdata) 3727 3687 { 3728 - return devdata->i915->vbt.version >= 195 && devdata->child.dp_usb_type_c; 3688 + return devdata->i915->display.vbt.version >= 195 && devdata->child.dp_usb_type_c; 3729 3689 } 3730 3690 3731 3691 bool intel_bios_encoder_supports_tbt(const struct intel_bios_encoder_data *devdata) 3732 3692 { 3733 - return devdata->i915->vbt.version >= 209 && devdata->child.tbt; 3693 + return devdata->i915->display.vbt.version >= 209 && devdata->child.tbt; 3734 3694 } 3735 3695 3736 3696 const struct intel_bios_encoder_data * 3737 3697 intel_bios_encoder_data_lookup(struct drm_i915_private *i915, enum port port) 3738 3698 { 3739 - return i915->vbt.ports[port]; 3699 + return i915->display.vbt.ports[port]; 3740 3700 }
+1
drivers/gpu/drm/i915/display/intel_bios.h
··· 258 258 int intel_bios_max_tmds_clock(struct intel_encoder *encoder); 259 259 int intel_bios_hdmi_level_shift(struct intel_encoder *encoder); 260 260 int intel_bios_dp_max_link_rate(struct intel_encoder *encoder); 261 + int intel_bios_dp_max_lane_count(struct intel_encoder *encoder); 261 262 int intel_bios_alternate_ddc_pin(struct intel_encoder *encoder); 262 263 bool intel_bios_port_supports_typec_usb(struct drm_i915_private *i915, enum port port); 263 264 bool intel_bios_port_supports_tbt(struct drm_i915_private *i915, enum port port);
+61 -27
drivers/gpu/drm/i915/display/intel_bw.c
··· 5 5 6 6 #include <drm/drm_atomic_state_helper.h> 7 7 8 + #include "i915_drv.h" 8 9 #include "i915_reg.h" 9 10 #include "i915_utils.h" 10 11 #include "intel_atomic.h" 11 12 #include "intel_bw.h" 12 13 #include "intel_cdclk.h" 14 + #include "intel_display_core.h" 13 15 #include "intel_display_types.h" 16 + #include "skl_watermark.h" 14 17 #include "intel_mchbar_regs.h" 15 18 #include "intel_pcode.h" 16 - #include "intel_pm.h" 17 19 18 20 /* Parameters for Qclk Geyserville (QGV) */ 19 21 struct intel_qgv_point { ··· 139 137 return 0; 140 138 } 141 139 140 + static int mtl_read_qgv_point_info(struct drm_i915_private *dev_priv, 141 + struct intel_qgv_point *sp, int point) 142 + { 143 + u32 val, val2; 144 + u16 dclk; 145 + 146 + val = intel_uncore_read(&dev_priv->uncore, 147 + MTL_MEM_SS_INFO_QGV_POINT_LOW(point)); 148 + val2 = intel_uncore_read(&dev_priv->uncore, 149 + MTL_MEM_SS_INFO_QGV_POINT_HIGH(point)); 150 + dclk = REG_FIELD_GET(MTL_DCLK_MASK, val); 151 + sp->dclk = DIV_ROUND_UP((16667 * dclk), 1000); 152 + sp->t_rp = REG_FIELD_GET(MTL_TRP_MASK, val); 153 + sp->t_rcd = REG_FIELD_GET(MTL_TRCD_MASK, val); 154 + 155 + sp->t_rdpre = REG_FIELD_GET(MTL_TRDPRE_MASK, val2); 156 + sp->t_ras = REG_FIELD_GET(MTL_TRAS_MASK, val2); 157 + 158 + sp->t_rc = sp->t_rp + sp->t_ras; 159 + 160 + return 0; 161 + } 162 + 163 + static int 164 + intel_read_qgv_point_info(struct drm_i915_private *dev_priv, 165 + struct intel_qgv_point *sp, 166 + int point) 167 + { 168 + if (DISPLAY_VER(dev_priv) >= 14) 169 + return mtl_read_qgv_point_info(dev_priv, sp, point); 170 + else if (IS_DG1(dev_priv)) 171 + return dg1_mchbar_read_qgv_point_info(dev_priv, sp, point); 172 + else 173 + return icl_pcode_read_qgv_point_info(dev_priv, sp, point); 174 + } 175 + 142 176 static int icl_get_qgv_points(struct drm_i915_private *dev_priv, 143 177 struct intel_qgv_info *qi, 144 178 bool is_y_tile) ··· 256 218 for (i = 0; i < qi->num_points; i++) { 257 219 struct intel_qgv_point *sp = &qi->points[i]; 258 220 259 - if (IS_DG1(dev_priv)) 260 - ret = dg1_mchbar_read_qgv_point_info(dev_priv, sp, i); 261 - else 262 - ret = icl_pcode_read_qgv_point_info(dev_priv, sp, i); 263 - 221 + ret = intel_read_qgv_point_info(dev_priv, sp, i); 264 222 if (ret) 265 223 return ret; 266 224 ··· 358 324 int ipqdepth, ipqdepthpch = 16; 359 325 int dclk_max; 360 326 int maxdebw; 361 - int num_groups = ARRAY_SIZE(dev_priv->max_bw); 327 + int num_groups = ARRAY_SIZE(dev_priv->display.bw.max); 362 328 int i, ret; 363 329 364 330 ret = icl_get_qgv_points(dev_priv, &qi, is_y_tile); ··· 374 340 qi.deinterleave = DIV_ROUND_UP(num_channels, is_y_tile ? 4 : 2); 375 341 376 342 for (i = 0; i < num_groups; i++) { 377 - struct intel_bw_info *bi = &dev_priv->max_bw[i]; 343 + struct intel_bw_info *bi = &dev_priv->display.bw.max[i]; 378 344 int clpchgroup; 379 345 int j; 380 346 ··· 429 395 int dclk_max; 430 396 int maxdebw, peakbw; 431 397 int clperchgroup; 432 - int num_groups = ARRAY_SIZE(dev_priv->max_bw); 398 + int num_groups = ARRAY_SIZE(dev_priv->display.bw.max); 433 399 int i, ret; 434 400 435 401 ret = icl_get_qgv_points(dev_priv, &qi, is_y_tile); ··· 465 431 clperchgroup = 4 * DIV_ROUND_UP(8, num_channels) * qi.deinterleave; 466 432 467 433 for (i = 0; i < num_groups; i++) { 468 - struct intel_bw_info *bi = &dev_priv->max_bw[i]; 434 + struct intel_bw_info *bi = &dev_priv->display.bw.max[i]; 469 435 struct intel_bw_info *bi_next; 470 436 int clpchgroup; 471 437 int j; ··· 473 439 clpchgroup = (sa->deburst * qi.deinterleave / num_channels) << i; 474 440 475 441 if (i < num_groups - 1) { 476 - bi_next = &dev_priv->max_bw[i + 1]; 442 + bi_next = &dev_priv->display.bw.max[i + 1]; 477 443 478 444 if (clpchgroup < clperchgroup) 479 445 bi_next->num_planes = (ipqdepth - clpchgroup) / ··· 534 500 static void dg2_get_bw_info(struct drm_i915_private *i915) 535 501 { 536 502 unsigned int deratedbw = IS_DG2_G11(i915) ? 38000 : 50000; 537 - int num_groups = ARRAY_SIZE(i915->max_bw); 503 + int num_groups = ARRAY_SIZE(i915->display.bw.max); 538 504 int i; 539 505 540 506 /* ··· 545 511 * whereas DG2-G11 platforms have 38 GB/s. 546 512 */ 547 513 for (i = 0; i < num_groups; i++) { 548 - struct intel_bw_info *bi = &i915->max_bw[i]; 514 + struct intel_bw_info *bi = &i915->display.bw.max[i]; 549 515 550 516 bi->num_planes = 1; 551 517 /* Need only one dummy QGV point per group */ ··· 566 532 */ 567 533 num_planes = max(1, num_planes); 568 534 569 - for (i = 0; i < ARRAY_SIZE(dev_priv->max_bw); i++) { 535 + for (i = 0; i < ARRAY_SIZE(dev_priv->display.bw.max); i++) { 570 536 const struct intel_bw_info *bi = 571 - &dev_priv->max_bw[i]; 537 + &dev_priv->display.bw.max[i]; 572 538 573 539 /* 574 540 * Pcode will not expose all QGV points when ··· 594 560 */ 595 561 num_planes = max(1, num_planes); 596 562 597 - for (i = ARRAY_SIZE(dev_priv->max_bw) - 1; i >= 0; i--) { 563 + for (i = ARRAY_SIZE(dev_priv->display.bw.max) - 1; i >= 0; i--) { 598 564 const struct intel_bw_info *bi = 599 - &dev_priv->max_bw[i]; 565 + &dev_priv->display.bw.max[i]; 600 566 601 567 /* 602 568 * Pcode will not expose all QGV points when ··· 609 575 return bi->deratedbw[qgv_point]; 610 576 } 611 577 612 - return dev_priv->max_bw[0].deratedbw[qgv_point]; 578 + return dev_priv->display.bw.max[0].deratedbw[qgv_point]; 613 579 } 614 580 615 581 static unsigned int adl_psf_bw(struct drm_i915_private *dev_priv, 616 582 int psf_gv_point) 617 583 { 618 584 const struct intel_bw_info *bi = 619 - &dev_priv->max_bw[0]; 585 + &dev_priv->display.bw.max[0]; 620 586 621 587 return bi->psf_bw[psf_gv_point]; 622 588 } ··· 737 703 struct drm_i915_private *dev_priv = to_i915(state->base.dev); 738 704 struct intel_global_state *bw_state; 739 705 740 - bw_state = intel_atomic_get_old_global_obj_state(state, &dev_priv->bw_obj); 706 + bw_state = intel_atomic_get_old_global_obj_state(state, &dev_priv->display.bw.obj); 741 707 742 708 return to_intel_bw_state(bw_state); 743 709 } ··· 748 714 struct drm_i915_private *dev_priv = to_i915(state->base.dev); 749 715 struct intel_global_state *bw_state; 750 716 751 - bw_state = intel_atomic_get_new_global_obj_state(state, &dev_priv->bw_obj); 717 + bw_state = intel_atomic_get_new_global_obj_state(state, &dev_priv->display.bw.obj); 752 718 753 719 return to_intel_bw_state(bw_state); 754 720 } ··· 759 725 struct drm_i915_private *dev_priv = to_i915(state->base.dev); 760 726 struct intel_global_state *bw_state; 761 727 762 - bw_state = intel_atomic_get_global_obj_state(state, &dev_priv->bw_obj); 728 + bw_state = intel_atomic_get_global_obj_state(state, &dev_priv->display.bw.obj); 763 729 if (IS_ERR(bw_state)) 764 730 return ERR_CAST(bw_state); 765 731 ··· 966 932 967 933 static u16 icl_qgv_points_mask(struct drm_i915_private *i915) 968 934 { 969 - unsigned int num_psf_gv_points = i915->max_bw[0].num_psf_gv_points; 970 - unsigned int num_qgv_points = i915->max_bw[0].num_qgv_points; 935 + unsigned int num_psf_gv_points = i915->display.bw.max[0].num_psf_gv_points; 936 + unsigned int num_qgv_points = i915->display.bw.max[0].num_qgv_points; 971 937 u16 qgv_points = 0, psf_points = 0; 972 938 973 939 /* ··· 1040 1006 int i, ret; 1041 1007 u16 qgv_points = 0, psf_points = 0; 1042 1008 unsigned int max_bw_point = 0, max_bw = 0; 1043 - unsigned int num_qgv_points = dev_priv->max_bw[0].num_qgv_points; 1044 - unsigned int num_psf_gv_points = dev_priv->max_bw[0].num_psf_gv_points; 1009 + unsigned int num_qgv_points = dev_priv->display.bw.max[0].num_qgv_points; 1010 + unsigned int num_psf_gv_points = dev_priv->display.bw.max[0].num_psf_gv_points; 1045 1011 bool changed = false; 1046 1012 1047 1013 /* FIXME earlier gens need some checks too */ ··· 1196 1162 if (!state) 1197 1163 return -ENOMEM; 1198 1164 1199 - intel_atomic_global_obj_init(dev_priv, &dev_priv->bw_obj, 1165 + intel_atomic_global_obj_init(dev_priv, &dev_priv->display.bw.obj, 1200 1166 &state->base, &intel_bw_funcs); 1201 1167 1202 1168 return 0;
+103 -103
drivers/gpu/drm/i915/display/intel_cdclk.c
··· 548 548 else 549 549 default_credits = PFI_CREDIT(8); 550 550 551 - if (dev_priv->cdclk.hw.cdclk >= dev_priv->czclk_freq) { 551 + if (dev_priv->display.cdclk.hw.cdclk >= dev_priv->czclk_freq) { 552 552 /* CHV suggested value is 31 or 63 */ 553 553 if (IS_CHERRYVIEW(dev_priv)) 554 554 credits = PFI_CREDIT_63; ··· 1026 1026 if (intel_de_wait_for_set(dev_priv, LCPLL1_CTL, LCPLL_PLL_LOCK, 5)) 1027 1027 drm_err(&dev_priv->drm, "DPLL0 not locked\n"); 1028 1028 1029 - dev_priv->cdclk.hw.vco = vco; 1029 + dev_priv->display.cdclk.hw.vco = vco; 1030 1030 1031 1031 /* We'll want to keep using the current vco from now on. */ 1032 1032 skl_set_preferred_cdclk_vco(dev_priv, vco); ··· 1040 1040 if (intel_de_wait_for_clear(dev_priv, LCPLL1_CTL, LCPLL_PLL_LOCK, 1)) 1041 1041 drm_err(&dev_priv->drm, "Couldn't disable DPLL0\n"); 1042 1042 1043 - dev_priv->cdclk.hw.vco = 0; 1043 + dev_priv->display.cdclk.hw.vco = 0; 1044 1044 } 1045 1045 1046 1046 static u32 skl_cdclk_freq_sel(struct drm_i915_private *dev_priv, ··· 1049 1049 switch (cdclk) { 1050 1050 default: 1051 1051 drm_WARN_ON(&dev_priv->drm, 1052 - cdclk != dev_priv->cdclk.hw.bypass); 1052 + cdclk != dev_priv->display.cdclk.hw.bypass); 1053 1053 drm_WARN_ON(&dev_priv->drm, vco != 0); 1054 1054 fallthrough; 1055 1055 case 308571: ··· 1098 1098 1099 1099 freq_select = skl_cdclk_freq_sel(dev_priv, cdclk, vco); 1100 1100 1101 - if (dev_priv->cdclk.hw.vco != 0 && 1102 - dev_priv->cdclk.hw.vco != vco) 1101 + if (dev_priv->display.cdclk.hw.vco != 0 && 1102 + dev_priv->display.cdclk.hw.vco != vco) 1103 1103 skl_dpll0_disable(dev_priv); 1104 1104 1105 1105 cdclk_ctl = intel_de_read(dev_priv, CDCLK_CTL); 1106 1106 1107 - if (dev_priv->cdclk.hw.vco != vco) { 1107 + if (dev_priv->display.cdclk.hw.vco != vco) { 1108 1108 /* Wa Display #1183: skl,kbl,cfl */ 1109 1109 cdclk_ctl &= ~(CDCLK_FREQ_SEL_MASK | CDCLK_FREQ_DECIMAL_MASK); 1110 1110 cdclk_ctl |= freq_select | skl_cdclk_decimal(cdclk); ··· 1116 1116 intel_de_write(dev_priv, CDCLK_CTL, cdclk_ctl); 1117 1117 intel_de_posting_read(dev_priv, CDCLK_CTL); 1118 1118 1119 - if (dev_priv->cdclk.hw.vco != vco) 1119 + if (dev_priv->display.cdclk.hw.vco != vco) 1120 1120 skl_dpll0_enable(dev_priv, vco); 1121 1121 1122 1122 /* Wa Display #1183: skl,kbl,cfl */ ··· 1151 1151 goto sanitize; 1152 1152 1153 1153 intel_update_cdclk(dev_priv); 1154 - intel_cdclk_dump_config(dev_priv, &dev_priv->cdclk.hw, "Current CDCLK"); 1154 + intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "Current CDCLK"); 1155 1155 1156 1156 /* Is PLL enabled and locked ? */ 1157 - if (dev_priv->cdclk.hw.vco == 0 || 1158 - dev_priv->cdclk.hw.cdclk == dev_priv->cdclk.hw.bypass) 1157 + if (dev_priv->display.cdclk.hw.vco == 0 || 1158 + dev_priv->display.cdclk.hw.cdclk == dev_priv->display.cdclk.hw.bypass) 1159 1159 goto sanitize; 1160 1160 1161 1161 /* DPLL okay; verify the cdclock ··· 1166 1166 */ 1167 1167 cdctl = intel_de_read(dev_priv, CDCLK_CTL); 1168 1168 expected = (cdctl & CDCLK_FREQ_SEL_MASK) | 1169 - skl_cdclk_decimal(dev_priv->cdclk.hw.cdclk); 1169 + skl_cdclk_decimal(dev_priv->display.cdclk.hw.cdclk); 1170 1170 if (cdctl == expected) 1171 1171 /* All well; nothing to sanitize */ 1172 1172 return; ··· 1175 1175 drm_dbg_kms(&dev_priv->drm, "Sanitizing cdclk programmed by pre-os\n"); 1176 1176 1177 1177 /* force cdclk programming */ 1178 - dev_priv->cdclk.hw.cdclk = 0; 1178 + dev_priv->display.cdclk.hw.cdclk = 0; 1179 1179 /* force full PLL disable + enable */ 1180 - dev_priv->cdclk.hw.vco = -1; 1180 + dev_priv->display.cdclk.hw.vco = -1; 1181 1181 } 1182 1182 1183 1183 static void skl_cdclk_init_hw(struct drm_i915_private *dev_priv) ··· 1186 1186 1187 1187 skl_sanitize_cdclk(dev_priv); 1188 1188 1189 - if (dev_priv->cdclk.hw.cdclk != 0 && 1190 - dev_priv->cdclk.hw.vco != 0) { 1189 + if (dev_priv->display.cdclk.hw.cdclk != 0 && 1190 + dev_priv->display.cdclk.hw.vco != 0) { 1191 1191 /* 1192 1192 * Use the current vco as our initial 1193 1193 * guess as to what the preferred vco is. 1194 1194 */ 1195 1195 if (dev_priv->skl_preferred_vco_freq == 0) 1196 1196 skl_set_preferred_cdclk_vco(dev_priv, 1197 - dev_priv->cdclk.hw.vco); 1197 + dev_priv->display.cdclk.hw.vco); 1198 1198 return; 1199 1199 } 1200 1200 1201 - cdclk_config = dev_priv->cdclk.hw; 1201 + cdclk_config = dev_priv->display.cdclk.hw; 1202 1202 1203 1203 cdclk_config.vco = dev_priv->skl_preferred_vco_freq; 1204 1204 if (cdclk_config.vco == 0) ··· 1211 1211 1212 1212 static void skl_cdclk_uninit_hw(struct drm_i915_private *dev_priv) 1213 1213 { 1214 - struct intel_cdclk_config cdclk_config = dev_priv->cdclk.hw; 1214 + struct intel_cdclk_config cdclk_config = dev_priv->display.cdclk.hw; 1215 1215 1216 1216 cdclk_config.cdclk = cdclk_config.bypass; 1217 1217 cdclk_config.vco = 0; ··· 1352 1352 1353 1353 static int bxt_calc_cdclk(struct drm_i915_private *dev_priv, int min_cdclk) 1354 1354 { 1355 - const struct intel_cdclk_vals *table = dev_priv->cdclk.table; 1355 + const struct intel_cdclk_vals *table = dev_priv->display.cdclk.table; 1356 1356 int i; 1357 1357 1358 1358 for (i = 0; table[i].refclk; i++) 1359 - if (table[i].refclk == dev_priv->cdclk.hw.ref && 1359 + if (table[i].refclk == dev_priv->display.cdclk.hw.ref && 1360 1360 table[i].cdclk >= min_cdclk) 1361 1361 return table[i].cdclk; 1362 1362 1363 1363 drm_WARN(&dev_priv->drm, 1, 1364 1364 "Cannot satisfy minimum cdclk %d with refclk %u\n", 1365 - min_cdclk, dev_priv->cdclk.hw.ref); 1365 + min_cdclk, dev_priv->display.cdclk.hw.ref); 1366 1366 return 0; 1367 1367 } 1368 1368 1369 1369 static int bxt_calc_cdclk_pll_vco(struct drm_i915_private *dev_priv, int cdclk) 1370 1370 { 1371 - const struct intel_cdclk_vals *table = dev_priv->cdclk.table; 1371 + const struct intel_cdclk_vals *table = dev_priv->display.cdclk.table; 1372 1372 int i; 1373 1373 1374 - if (cdclk == dev_priv->cdclk.hw.bypass) 1374 + if (cdclk == dev_priv->display.cdclk.hw.bypass) 1375 1375 return 0; 1376 1376 1377 1377 for (i = 0; table[i].refclk; i++) 1378 - if (table[i].refclk == dev_priv->cdclk.hw.ref && 1378 + if (table[i].refclk == dev_priv->display.cdclk.hw.ref && 1379 1379 table[i].cdclk == cdclk) 1380 - return dev_priv->cdclk.hw.ref * table[i].ratio; 1380 + return dev_priv->display.cdclk.hw.ref * table[i].ratio; 1381 1381 1382 1382 drm_WARN(&dev_priv->drm, 1, "cdclk %d not valid for refclk %u\n", 1383 - cdclk, dev_priv->cdclk.hw.ref); 1383 + cdclk, dev_priv->display.cdclk.hw.ref); 1384 1384 return 0; 1385 1385 } 1386 1386 ··· 1554 1554 BXT_DE_PLL_ENABLE, BXT_DE_PLL_LOCK, 1)) 1555 1555 drm_err(&dev_priv->drm, "timeout waiting for DE PLL unlock\n"); 1556 1556 1557 - dev_priv->cdclk.hw.vco = 0; 1557 + dev_priv->display.cdclk.hw.vco = 0; 1558 1558 } 1559 1559 1560 1560 static void bxt_de_pll_enable(struct drm_i915_private *dev_priv, int vco) 1561 1561 { 1562 - int ratio = DIV_ROUND_CLOSEST(vco, dev_priv->cdclk.hw.ref); 1562 + int ratio = DIV_ROUND_CLOSEST(vco, dev_priv->display.cdclk.hw.ref); 1563 1563 1564 1564 intel_de_rmw(dev_priv, BXT_DE_PLL_CTL, 1565 1565 BXT_DE_PLL_RATIO_MASK, BXT_DE_PLL_RATIO(ratio)); ··· 1571 1571 BXT_DE_PLL_ENABLE, BXT_DE_PLL_LOCK, 1)) 1572 1572 drm_err(&dev_priv->drm, "timeout waiting for DE PLL lock\n"); 1573 1573 1574 - dev_priv->cdclk.hw.vco = vco; 1574 + dev_priv->display.cdclk.hw.vco = vco; 1575 1575 } 1576 1576 1577 1577 static void icl_cdclk_pll_disable(struct drm_i915_private *dev_priv) ··· 1583 1583 if (intel_de_wait_for_clear(dev_priv, BXT_DE_PLL_ENABLE, BXT_DE_PLL_LOCK, 1)) 1584 1584 drm_err(&dev_priv->drm, "timeout waiting for CDCLK PLL unlock\n"); 1585 1585 1586 - dev_priv->cdclk.hw.vco = 0; 1586 + dev_priv->display.cdclk.hw.vco = 0; 1587 1587 } 1588 1588 1589 1589 static void icl_cdclk_pll_enable(struct drm_i915_private *dev_priv, int vco) 1590 1590 { 1591 - int ratio = DIV_ROUND_CLOSEST(vco, dev_priv->cdclk.hw.ref); 1591 + int ratio = DIV_ROUND_CLOSEST(vco, dev_priv->display.cdclk.hw.ref); 1592 1592 u32 val; 1593 1593 1594 1594 val = ICL_CDCLK_PLL_RATIO(ratio); ··· 1601 1601 if (intel_de_wait_for_set(dev_priv, BXT_DE_PLL_ENABLE, BXT_DE_PLL_LOCK, 1)) 1602 1602 drm_err(&dev_priv->drm, "timeout waiting for CDCLK PLL lock\n"); 1603 1603 1604 - dev_priv->cdclk.hw.vco = vco; 1604 + dev_priv->display.cdclk.hw.vco = vco; 1605 1605 } 1606 1606 1607 1607 static void adlp_cdclk_pll_crawl(struct drm_i915_private *dev_priv, int vco) 1608 1608 { 1609 - int ratio = DIV_ROUND_CLOSEST(vco, dev_priv->cdclk.hw.ref); 1609 + int ratio = DIV_ROUND_CLOSEST(vco, dev_priv->display.cdclk.hw.ref); 1610 1610 u32 val; 1611 1611 1612 1612 /* Write PLL ratio without disabling */ ··· 1625 1625 val &= ~BXT_DE_PLL_FREQ_REQ; 1626 1626 intel_de_write(dev_priv, BXT_DE_PLL_ENABLE, val); 1627 1627 1628 - dev_priv->cdclk.hw.vco = vco; 1628 + dev_priv->display.cdclk.hw.vco = vco; 1629 1629 } 1630 1630 1631 1631 static u32 bxt_cdclk_cd2x_pipe(struct drm_i915_private *dev_priv, enum pipe pipe) ··· 1655 1655 switch (DIV_ROUND_CLOSEST(vco, cdclk)) { 1656 1656 default: 1657 1657 drm_WARN_ON(&dev_priv->drm, 1658 - cdclk != dev_priv->cdclk.hw.bypass); 1658 + cdclk != dev_priv->display.cdclk.hw.bypass); 1659 1659 drm_WARN_ON(&dev_priv->drm, vco != 0); 1660 1660 fallthrough; 1661 1661 case 2: ··· 1672 1672 static u32 cdclk_squash_waveform(struct drm_i915_private *dev_priv, 1673 1673 int cdclk) 1674 1674 { 1675 - const struct intel_cdclk_vals *table = dev_priv->cdclk.table; 1675 + const struct intel_cdclk_vals *table = dev_priv->display.cdclk.table; 1676 1676 int i; 1677 1677 1678 - if (cdclk == dev_priv->cdclk.hw.bypass) 1678 + if (cdclk == dev_priv->display.cdclk.hw.bypass) 1679 1679 return 0; 1680 1680 1681 1681 for (i = 0; table[i].refclk; i++) 1682 - if (table[i].refclk == dev_priv->cdclk.hw.ref && 1682 + if (table[i].refclk == dev_priv->display.cdclk.hw.ref && 1683 1683 table[i].cdclk == cdclk) 1684 1684 return table[i].waveform; 1685 1685 1686 1686 drm_WARN(&dev_priv->drm, 1, "cdclk %d not valid for refclk %u\n", 1687 - cdclk, dev_priv->cdclk.hw.ref); 1687 + cdclk, dev_priv->display.cdclk.hw.ref); 1688 1688 1689 1689 return 0xffff; 1690 1690 } ··· 1721 1721 return; 1722 1722 } 1723 1723 1724 - if (HAS_CDCLK_CRAWL(dev_priv) && dev_priv->cdclk.hw.vco > 0 && vco > 0) { 1725 - if (dev_priv->cdclk.hw.vco != vco) 1724 + if (HAS_CDCLK_CRAWL(dev_priv) && dev_priv->display.cdclk.hw.vco > 0 && vco > 0) { 1725 + if (dev_priv->display.cdclk.hw.vco != vco) 1726 1726 adlp_cdclk_pll_crawl(dev_priv, vco); 1727 1727 } else if (DISPLAY_VER(dev_priv) >= 11) { 1728 - if (dev_priv->cdclk.hw.vco != 0 && 1729 - dev_priv->cdclk.hw.vco != vco) 1728 + if (dev_priv->display.cdclk.hw.vco != 0 && 1729 + dev_priv->display.cdclk.hw.vco != vco) 1730 1730 icl_cdclk_pll_disable(dev_priv); 1731 1731 1732 - if (dev_priv->cdclk.hw.vco != vco) 1732 + if (dev_priv->display.cdclk.hw.vco != vco) 1733 1733 icl_cdclk_pll_enable(dev_priv, vco); 1734 1734 } else { 1735 - if (dev_priv->cdclk.hw.vco != 0 && 1736 - dev_priv->cdclk.hw.vco != vco) 1735 + if (dev_priv->display.cdclk.hw.vco != 0 && 1736 + dev_priv->display.cdclk.hw.vco != vco) 1737 1737 bxt_de_pll_disable(dev_priv); 1738 1738 1739 - if (dev_priv->cdclk.hw.vco != vco) 1739 + if (dev_priv->display.cdclk.hw.vco != vco) 1740 1740 bxt_de_pll_enable(dev_priv, vco); 1741 1741 } 1742 1742 ··· 1803 1803 * Can't read out the voltage level :( 1804 1804 * Let's just assume everything is as expected. 1805 1805 */ 1806 - dev_priv->cdclk.hw.voltage_level = cdclk_config->voltage_level; 1806 + dev_priv->display.cdclk.hw.voltage_level = cdclk_config->voltage_level; 1807 1807 } 1808 1808 1809 1809 static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv) ··· 1812 1812 int cdclk, clock, vco; 1813 1813 1814 1814 intel_update_cdclk(dev_priv); 1815 - intel_cdclk_dump_config(dev_priv, &dev_priv->cdclk.hw, "Current CDCLK"); 1815 + intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "Current CDCLK"); 1816 1816 1817 - if (dev_priv->cdclk.hw.vco == 0 || 1818 - dev_priv->cdclk.hw.cdclk == dev_priv->cdclk.hw.bypass) 1817 + if (dev_priv->display.cdclk.hw.vco == 0 || 1818 + dev_priv->display.cdclk.hw.cdclk == dev_priv->display.cdclk.hw.bypass) 1819 1819 goto sanitize; 1820 1820 1821 1821 /* DPLL okay; verify the cdclock ··· 1833 1833 cdctl &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE); 1834 1834 1835 1835 /* Make sure this is a legal cdclk value for the platform */ 1836 - cdclk = bxt_calc_cdclk(dev_priv, dev_priv->cdclk.hw.cdclk); 1837 - if (cdclk != dev_priv->cdclk.hw.cdclk) 1836 + cdclk = bxt_calc_cdclk(dev_priv, dev_priv->display.cdclk.hw.cdclk); 1837 + if (cdclk != dev_priv->display.cdclk.hw.cdclk) 1838 1838 goto sanitize; 1839 1839 1840 1840 /* Make sure the VCO is correct for the cdclk */ 1841 1841 vco = bxt_calc_cdclk_pll_vco(dev_priv, cdclk); 1842 - if (vco != dev_priv->cdclk.hw.vco) 1842 + if (vco != dev_priv->display.cdclk.hw.vco) 1843 1843 goto sanitize; 1844 1844 1845 1845 expected = skl_cdclk_decimal(cdclk); 1846 1846 1847 1847 /* Figure out what CD2X divider we should be using for this cdclk */ 1848 1848 if (has_cdclk_squasher(dev_priv)) 1849 - clock = dev_priv->cdclk.hw.vco / 2; 1849 + clock = dev_priv->display.cdclk.hw.vco / 2; 1850 1850 else 1851 - clock = dev_priv->cdclk.hw.cdclk; 1851 + clock = dev_priv->display.cdclk.hw.cdclk; 1852 1852 1853 1853 expected |= bxt_cdclk_cd2x_div_sel(dev_priv, clock, 1854 - dev_priv->cdclk.hw.vco); 1854 + dev_priv->display.cdclk.hw.vco); 1855 1855 1856 1856 /* 1857 1857 * Disable SSA Precharge when CD clock frequency < 500 MHz, 1858 1858 * enable otherwise. 1859 1859 */ 1860 1860 if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) && 1861 - dev_priv->cdclk.hw.cdclk >= 500000) 1861 + dev_priv->display.cdclk.hw.cdclk >= 500000) 1862 1862 expected |= BXT_CDCLK_SSA_PRECHARGE_ENABLE; 1863 1863 1864 1864 if (cdctl == expected) ··· 1869 1869 drm_dbg_kms(&dev_priv->drm, "Sanitizing cdclk programmed by pre-os\n"); 1870 1870 1871 1871 /* force cdclk programming */ 1872 - dev_priv->cdclk.hw.cdclk = 0; 1872 + dev_priv->display.cdclk.hw.cdclk = 0; 1873 1873 1874 1874 /* force full PLL disable + enable */ 1875 - dev_priv->cdclk.hw.vco = -1; 1875 + dev_priv->display.cdclk.hw.vco = -1; 1876 1876 } 1877 1877 1878 1878 static void bxt_cdclk_init_hw(struct drm_i915_private *dev_priv) ··· 1881 1881 1882 1882 bxt_sanitize_cdclk(dev_priv); 1883 1883 1884 - if (dev_priv->cdclk.hw.cdclk != 0 && 1885 - dev_priv->cdclk.hw.vco != 0) 1884 + if (dev_priv->display.cdclk.hw.cdclk != 0 && 1885 + dev_priv->display.cdclk.hw.vco != 0) 1886 1886 return; 1887 1887 1888 - cdclk_config = dev_priv->cdclk.hw; 1888 + cdclk_config = dev_priv->display.cdclk.hw; 1889 1889 1890 1890 /* 1891 1891 * FIXME: ··· 1902 1902 1903 1903 static void bxt_cdclk_uninit_hw(struct drm_i915_private *dev_priv) 1904 1904 { 1905 - struct intel_cdclk_config cdclk_config = dev_priv->cdclk.hw; 1905 + struct intel_cdclk_config cdclk_config = dev_priv->display.cdclk.hw; 1906 1906 1907 1907 cdclk_config.cdclk = cdclk_config.bypass; 1908 1908 cdclk_config.vco = 0; ··· 1916 1916 * intel_cdclk_init_hw - Initialize CDCLK hardware 1917 1917 * @i915: i915 device 1918 1918 * 1919 - * Initialize CDCLK. This consists mainly of initializing dev_priv->cdclk.hw and 1919 + * Initialize CDCLK. This consists mainly of initializing dev_priv->display.cdclk.hw and 1920 1920 * sanitizing the state of the hardware if needed. This is generally done only 1921 1921 * during the display core initialization sequence, after which the DMC will 1922 1922 * take care of turning CDCLK off/on as needed. ··· 2077 2077 { 2078 2078 struct intel_encoder *encoder; 2079 2079 2080 - if (!intel_cdclk_changed(&dev_priv->cdclk.hw, cdclk_config)) 2080 + if (!intel_cdclk_changed(&dev_priv->display.cdclk.hw, cdclk_config)) 2081 2081 return; 2082 2082 2083 2083 if (drm_WARN_ON_ONCE(&dev_priv->drm, !dev_priv->display.funcs.cdclk->set_cdclk)) ··· 2124 2124 intel_audio_cdclk_change_post(dev_priv); 2125 2125 2126 2126 if (drm_WARN(&dev_priv->drm, 2127 - intel_cdclk_changed(&dev_priv->cdclk.hw, cdclk_config), 2127 + intel_cdclk_changed(&dev_priv->display.cdclk.hw, cdclk_config), 2128 2128 "cdclk state doesn't match!\n")) { 2129 - intel_cdclk_dump_config(dev_priv, &dev_priv->cdclk.hw, "[hw state]"); 2129 + intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "[hw state]"); 2130 2130 intel_cdclk_dump_config(dev_priv, cdclk_config, "[sw state]"); 2131 2131 } 2132 2132 } ··· 2315 2315 */ 2316 2316 min_cdclk = max_t(int, min_cdclk, 2317 2317 min_t(int, crtc_state->pixel_rate, 2318 - dev_priv->max_cdclk_freq)); 2318 + dev_priv->display.cdclk.max_cdclk_freq)); 2319 2319 } 2320 2320 2321 2321 return min_cdclk; ··· 2368 2368 for_each_pipe(dev_priv, pipe) 2369 2369 min_cdclk = max(cdclk_state->min_cdclk[pipe], min_cdclk); 2370 2370 2371 - if (min_cdclk > dev_priv->max_cdclk_freq) { 2371 + if (min_cdclk > dev_priv->display.cdclk.max_cdclk_freq) { 2372 2372 drm_dbg_kms(&dev_priv->drm, 2373 2373 "required cdclk (%d kHz) exceeds max (%d kHz)\n", 2374 - min_cdclk, dev_priv->max_cdclk_freq); 2374 + min_cdclk, dev_priv->display.cdclk.max_cdclk_freq); 2375 2375 return -EINVAL; 2376 2376 } 2377 2377 ··· 2643 2643 struct drm_i915_private *dev_priv = to_i915(state->base.dev); 2644 2644 struct intel_global_state *cdclk_state; 2645 2645 2646 - cdclk_state = intel_atomic_get_global_obj_state(state, &dev_priv->cdclk.obj); 2646 + cdclk_state = intel_atomic_get_global_obj_state(state, &dev_priv->display.cdclk.obj); 2647 2647 if (IS_ERR(cdclk_state)) 2648 2648 return ERR_CAST(cdclk_state); 2649 2649 ··· 2693 2693 if (!cdclk_state) 2694 2694 return -ENOMEM; 2695 2695 2696 - intel_atomic_global_obj_init(dev_priv, &dev_priv->cdclk.obj, 2696 + intel_atomic_global_obj_init(dev_priv, &dev_priv->display.cdclk.obj, 2697 2697 &cdclk_state->base, &intel_cdclk_funcs); 2698 2698 2699 2699 return 0; ··· 2799 2799 2800 2800 static int intel_compute_max_dotclk(struct drm_i915_private *dev_priv) 2801 2801 { 2802 - int max_cdclk_freq = dev_priv->max_cdclk_freq; 2802 + int max_cdclk_freq = dev_priv->display.cdclk.max_cdclk_freq; 2803 2803 2804 2804 if (DISPLAY_VER(dev_priv) >= 10) 2805 2805 return 2 * max_cdclk_freq; ··· 2825 2825 void intel_update_max_cdclk(struct drm_i915_private *dev_priv) 2826 2826 { 2827 2827 if (IS_JSL_EHL(dev_priv)) { 2828 - if (dev_priv->cdclk.hw.ref == 24000) 2829 - dev_priv->max_cdclk_freq = 552000; 2828 + if (dev_priv->display.cdclk.hw.ref == 24000) 2829 + dev_priv->display.cdclk.max_cdclk_freq = 552000; 2830 2830 else 2831 - dev_priv->max_cdclk_freq = 556800; 2831 + dev_priv->display.cdclk.max_cdclk_freq = 556800; 2832 2832 } else if (DISPLAY_VER(dev_priv) >= 11) { 2833 - if (dev_priv->cdclk.hw.ref == 24000) 2834 - dev_priv->max_cdclk_freq = 648000; 2833 + if (dev_priv->display.cdclk.hw.ref == 24000) 2834 + dev_priv->display.cdclk.max_cdclk_freq = 648000; 2835 2835 else 2836 - dev_priv->max_cdclk_freq = 652800; 2836 + dev_priv->display.cdclk.max_cdclk_freq = 652800; 2837 2837 } else if (IS_GEMINILAKE(dev_priv)) { 2838 - dev_priv->max_cdclk_freq = 316800; 2838 + dev_priv->display.cdclk.max_cdclk_freq = 316800; 2839 2839 } else if (IS_BROXTON(dev_priv)) { 2840 - dev_priv->max_cdclk_freq = 624000; 2840 + dev_priv->display.cdclk.max_cdclk_freq = 624000; 2841 2841 } else if (DISPLAY_VER(dev_priv) == 9) { 2842 2842 u32 limit = intel_de_read(dev_priv, SKL_DFSM) & SKL_DFSM_CDCLK_LIMIT_MASK; 2843 2843 int max_cdclk, vco; ··· 2859 2859 else 2860 2860 max_cdclk = 308571; 2861 2861 2862 - dev_priv->max_cdclk_freq = skl_calc_cdclk(max_cdclk, vco); 2862 + dev_priv->display.cdclk.max_cdclk_freq = skl_calc_cdclk(max_cdclk, vco); 2863 2863 } else if (IS_BROADWELL(dev_priv)) { 2864 2864 /* 2865 2865 * FIXME with extra cooling we can allow ··· 2868 2868 * available? PCI ID, VTB, something else? 2869 2869 */ 2870 2870 if (intel_de_read(dev_priv, FUSE_STRAP) & HSW_CDCLK_LIMIT) 2871 - dev_priv->max_cdclk_freq = 450000; 2871 + dev_priv->display.cdclk.max_cdclk_freq = 450000; 2872 2872 else if (IS_BDW_ULX(dev_priv)) 2873 - dev_priv->max_cdclk_freq = 450000; 2873 + dev_priv->display.cdclk.max_cdclk_freq = 450000; 2874 2874 else if (IS_BDW_ULT(dev_priv)) 2875 - dev_priv->max_cdclk_freq = 540000; 2875 + dev_priv->display.cdclk.max_cdclk_freq = 540000; 2876 2876 else 2877 - dev_priv->max_cdclk_freq = 675000; 2877 + dev_priv->display.cdclk.max_cdclk_freq = 675000; 2878 2878 } else if (IS_CHERRYVIEW(dev_priv)) { 2879 - dev_priv->max_cdclk_freq = 320000; 2879 + dev_priv->display.cdclk.max_cdclk_freq = 320000; 2880 2880 } else if (IS_VALLEYVIEW(dev_priv)) { 2881 - dev_priv->max_cdclk_freq = 400000; 2881 + dev_priv->display.cdclk.max_cdclk_freq = 400000; 2882 2882 } else { 2883 2883 /* otherwise assume cdclk is fixed */ 2884 - dev_priv->max_cdclk_freq = dev_priv->cdclk.hw.cdclk; 2884 + dev_priv->display.cdclk.max_cdclk_freq = dev_priv->display.cdclk.hw.cdclk; 2885 2885 } 2886 2886 2887 2887 dev_priv->max_dotclk_freq = intel_compute_max_dotclk(dev_priv); 2888 2888 2889 2889 drm_dbg(&dev_priv->drm, "Max CD clock rate: %d kHz\n", 2890 - dev_priv->max_cdclk_freq); 2890 + dev_priv->display.cdclk.max_cdclk_freq); 2891 2891 2892 2892 drm_dbg(&dev_priv->drm, "Max dotclock rate: %d kHz\n", 2893 2893 dev_priv->max_dotclk_freq); ··· 2901 2901 */ 2902 2902 void intel_update_cdclk(struct drm_i915_private *dev_priv) 2903 2903 { 2904 - intel_cdclk_get_cdclk(dev_priv, &dev_priv->cdclk.hw); 2904 + intel_cdclk_get_cdclk(dev_priv, &dev_priv->display.cdclk.hw); 2905 2905 2906 2906 /* 2907 2907 * 9:0 CMBUS [sic] CDCLK frequency (cdfreq): ··· 2911 2911 */ 2912 2912 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) 2913 2913 intel_de_write(dev_priv, GMBUSFREQ_VLV, 2914 - DIV_ROUND_UP(dev_priv->cdclk.hw.cdclk, 1000)); 2914 + DIV_ROUND_UP(dev_priv->display.cdclk.hw.cdclk, 1000)); 2915 2915 } 2916 2916 2917 2917 static int dg1_rawclk(struct drm_i915_private *dev_priv) ··· 3195 3195 { 3196 3196 if (IS_DG2(dev_priv)) { 3197 3197 dev_priv->display.funcs.cdclk = &tgl_cdclk_funcs; 3198 - dev_priv->cdclk.table = dg2_cdclk_table; 3198 + dev_priv->display.cdclk.table = dg2_cdclk_table; 3199 3199 } else if (IS_ALDERLAKE_P(dev_priv)) { 3200 3200 dev_priv->display.funcs.cdclk = &tgl_cdclk_funcs; 3201 3201 /* Wa_22011320316:adl-p[a0] */ 3202 3202 if (IS_ADLP_DISPLAY_STEP(dev_priv, STEP_A0, STEP_B0)) 3203 - dev_priv->cdclk.table = adlp_a_step_cdclk_table; 3203 + dev_priv->display.cdclk.table = adlp_a_step_cdclk_table; 3204 3204 else 3205 - dev_priv->cdclk.table = adlp_cdclk_table; 3205 + dev_priv->display.cdclk.table = adlp_cdclk_table; 3206 3206 } else if (IS_ROCKETLAKE(dev_priv)) { 3207 3207 dev_priv->display.funcs.cdclk = &tgl_cdclk_funcs; 3208 - dev_priv->cdclk.table = rkl_cdclk_table; 3208 + dev_priv->display.cdclk.table = rkl_cdclk_table; 3209 3209 } else if (DISPLAY_VER(dev_priv) >= 12) { 3210 3210 dev_priv->display.funcs.cdclk = &tgl_cdclk_funcs; 3211 - dev_priv->cdclk.table = icl_cdclk_table; 3211 + dev_priv->display.cdclk.table = icl_cdclk_table; 3212 3212 } else if (IS_JSL_EHL(dev_priv)) { 3213 3213 dev_priv->display.funcs.cdclk = &ehl_cdclk_funcs; 3214 - dev_priv->cdclk.table = icl_cdclk_table; 3214 + dev_priv->display.cdclk.table = icl_cdclk_table; 3215 3215 } else if (DISPLAY_VER(dev_priv) >= 11) { 3216 3216 dev_priv->display.funcs.cdclk = &icl_cdclk_funcs; 3217 - dev_priv->cdclk.table = icl_cdclk_table; 3217 + dev_priv->display.cdclk.table = icl_cdclk_table; 3218 3218 } else if (IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) { 3219 3219 dev_priv->display.funcs.cdclk = &bxt_cdclk_funcs; 3220 3220 if (IS_GEMINILAKE(dev_priv)) 3221 - dev_priv->cdclk.table = glk_cdclk_table; 3221 + dev_priv->display.cdclk.table = glk_cdclk_table; 3222 3222 else 3223 - dev_priv->cdclk.table = bxt_cdclk_table; 3223 + dev_priv->display.cdclk.table = bxt_cdclk_table; 3224 3224 } else if (DISPLAY_VER(dev_priv) == 9) { 3225 3225 dev_priv->display.funcs.cdclk = &skl_cdclk_funcs; 3226 3226 } else if (IS_BROADWELL(dev_priv)) {
+2 -2
drivers/gpu/drm/i915/display/intel_cdclk.h
··· 77 77 78 78 #define to_intel_cdclk_state(x) container_of((x), struct intel_cdclk_state, base) 79 79 #define intel_atomic_get_old_cdclk_state(state) \ 80 - to_intel_cdclk_state(intel_atomic_get_old_global_obj_state(state, &to_i915(state->base.dev)->cdclk.obj)) 80 + to_intel_cdclk_state(intel_atomic_get_old_global_obj_state(state, &to_i915(state->base.dev)->display.cdclk.obj)) 81 81 #define intel_atomic_get_new_cdclk_state(state) \ 82 - to_intel_cdclk_state(intel_atomic_get_new_global_obj_state(state, &to_i915(state->base.dev)->cdclk.obj)) 82 + to_intel_cdclk_state(intel_atomic_get_new_global_obj_state(state, &to_i915(state->base.dev)->display.cdclk.obj)) 83 83 84 84 int intel_cdclk_init(struct drm_i915_private *dev_priv); 85 85
+1
drivers/gpu/drm/i915/display/intel_color.c
··· 26 26 #include "intel_de.h" 27 27 #include "intel_display_types.h" 28 28 #include "intel_dpll.h" 29 + #include "intel_dsb.h" 29 30 #include "vlv_dsi_pll.h" 30 31 31 32 struct intel_color_funcs {
+4 -4
drivers/gpu/drm/i915/display/intel_connector.c
··· 229 229 struct drm_i915_private *dev_priv = to_i915(dev); 230 230 struct drm_property *prop; 231 231 232 - prop = dev_priv->force_audio_property; 232 + prop = dev_priv->display.properties.force_audio; 233 233 if (prop == NULL) { 234 234 prop = drm_property_create_enum(dev, 0, 235 235 "audio", ··· 238 238 if (prop == NULL) 239 239 return; 240 240 241 - dev_priv->force_audio_property = prop; 241 + dev_priv->display.properties.force_audio = prop; 242 242 } 243 243 drm_object_attach_property(&connector->base, prop, 0); 244 244 } ··· 256 256 struct drm_i915_private *dev_priv = to_i915(dev); 257 257 struct drm_property *prop; 258 258 259 - prop = dev_priv->broadcast_rgb_property; 259 + prop = dev_priv->display.properties.broadcast_rgb; 260 260 if (prop == NULL) { 261 261 prop = drm_property_create_enum(dev, DRM_MODE_PROP_ENUM, 262 262 "Broadcast RGB", ··· 265 265 if (prop == NULL) 266 266 return; 267 267 268 - dev_priv->broadcast_rgb_property = prop; 268 + dev_priv->display.properties.broadcast_rgb = prop; 269 269 } 270 270 271 271 drm_object_attach_property(&connector->base, prop, 0);
+7 -6
drivers/gpu/drm/i915/display/intel_crt.c
··· 46 46 #include "intel_gmbus.h" 47 47 #include "intel_hotplug.h" 48 48 #include "intel_pch_display.h" 49 + #include "intel_pch_refclk.h" 49 50 50 51 /* Here's the desired hotplug mode */ 51 52 #define ADPA_HOTPLUG_BITS (ADPA_CRT_HOTPLUG_PERIOD_128 | \ ··· 445 444 /* FDI must always be 2.7 GHz */ 446 445 pipe_config->port_clock = 135000 * 2; 447 446 447 + adjusted_mode->crtc_clock = lpt_iclkip(pipe_config); 448 + 448 449 return 0; 449 450 } 450 451 ··· 646 643 struct i2c_adapter *i2c; 647 644 bool ret = false; 648 645 649 - BUG_ON(crt->base.type != INTEL_OUTPUT_ANALOG); 650 - 651 - i2c = intel_gmbus_get_adapter(dev_priv, dev_priv->vbt.crt_ddc_pin); 646 + i2c = intel_gmbus_get_adapter(dev_priv, dev_priv->display.vbt.crt_ddc_pin); 652 647 edid = intel_crt_get_edid(connector, i2c); 653 648 654 649 if (edid) { ··· 932 931 wakeref = intel_display_power_get(dev_priv, 933 932 intel_encoder->power_domain); 934 933 935 - i2c = intel_gmbus_get_adapter(dev_priv, dev_priv->vbt.crt_ddc_pin); 934 + i2c = intel_gmbus_get_adapter(dev_priv, dev_priv->display.vbt.crt_ddc_pin); 936 935 ret = intel_crt_ddc_get_modes(connector, i2c); 937 936 if (ret || !IS_G4X(dev_priv)) 938 937 goto out; ··· 1111 1110 u32 fdi_config = FDI_RX_POLARITY_REVERSED_LPT | 1112 1111 FDI_RX_LINK_REVERSAL_OVERRIDE; 1113 1112 1114 - dev_priv->fdi_rx_config = intel_de_read(dev_priv, 1115 - FDI_RX_CTL(PIPE_A)) & fdi_config; 1113 + dev_priv->display.fdi.rx_config = intel_de_read(dev_priv, 1114 + FDI_RX_CTL(PIPE_A)) & fdi_config; 1116 1115 } 1117 1116 1118 1117 intel_crt_reset(&crt->base.base);
+1 -1
drivers/gpu/drm/i915/display/intel_cursor.c
··· 19 19 #include "intel_fb.h" 20 20 #include "intel_fb_pin.h" 21 21 #include "intel_frontbuffer.h" 22 - #include "intel_pm.h" 23 22 #include "intel_psr.h" 24 23 #include "intel_sprite.h" 24 + #include "skl_watermark.h" 25 25 26 26 /* Cursor formats */ 27 27 static const u32 intel_cursor_formats[] = {
+2 -23
drivers/gpu/drm/i915/display/intel_ddi.c
··· 57 57 #include "intel_lspcon.h" 58 58 #include "intel_pps.h" 59 59 #include "intel_psr.h" 60 + #include "intel_quirks.h" 60 61 #include "intel_snps_phy.h" 61 62 #include "intel_sprite.h" 62 63 #include "intel_tc.h" ··· 322 321 MISSING_CASE(val); 323 322 return 0; 324 323 } 325 - } 326 - 327 - int intel_crtc_dotclock(const struct intel_crtc_state *pipe_config) 328 - { 329 - int dotclock; 330 - 331 - if (intel_crtc_has_dp_encoder(pipe_config)) 332 - dotclock = intel_dotclock_calculate(pipe_config->port_clock, 333 - &pipe_config->dp_m_n); 334 - else if (pipe_config->has_hdmi_sink && pipe_config->pipe_bpp > 24) 335 - dotclock = pipe_config->port_clock * 24 / pipe_config->pipe_bpp; 336 - else 337 - dotclock = pipe_config->port_clock; 338 - 339 - if (pipe_config->output_format == INTEL_OUTPUT_FORMAT_YCBCR420 && 340 - !intel_crtc_has_dp_encoder(pipe_config)) 341 - dotclock *= 2; 342 - 343 - if (pipe_config->pixel_multiplier) 344 - dotclock /= pipe_config->pixel_multiplier; 345 - 346 - return dotclock; 347 324 } 348 325 349 326 static void ddi_dotclock_get(struct intel_crtc_state *pipe_config) ··· 610 631 611 632 intel_de_write(dev_priv, TRANS_DDI_FUNC_CTL(cpu_transcoder), ctl); 612 633 613 - if (dev_priv->quirks & QUIRK_INCREASE_DDI_DISABLED_TIME && 634 + if (intel_has_quirk(dev_priv, QUIRK_INCREASE_DDI_DISABLED_TIME) && 614 635 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) { 615 636 drm_dbg_kms(&dev_priv->drm, 616 637 "Quirk Increase DDI disabled time\n");
+126 -166
drivers/gpu/drm/i915/display/intel_display.c
··· 91 91 #include "intel_dmc.h" 92 92 #include "intel_dp_link_training.h" 93 93 #include "intel_dpt.h" 94 + #include "intel_dsb.h" 94 95 #include "intel_fbc.h" 95 96 #include "intel_fbdev.h" 96 97 #include "intel_fdi.h" ··· 118 117 #include "i9xx_plane.h" 119 118 #include "skl_scaler.h" 120 119 #include "skl_universal_plane.h" 120 + #include "skl_watermark.h" 121 121 #include "vlv_dsi.h" 122 122 #include "vlv_dsi_pll.h" 123 123 #include "vlv_dsi_regs.h" ··· 620 618 if (!IS_I830(dev_priv)) 621 619 val &= ~PIPECONF_ENABLE; 622 620 623 - if (DISPLAY_VER(dev_priv) >= 12) 621 + if (DISPLAY_VER(dev_priv) >= 14) 622 + intel_de_rmw(dev_priv, MTL_CHICKEN_TRANS(cpu_transcoder), 623 + FECSTALL_DIS_DPTSTREAM_DPTTG, 0); 624 + else if (DISPLAY_VER(dev_priv) >= 12) 624 625 intel_de_rmw(dev_priv, CHICKEN_TRANS(cpu_transcoder), 625 626 FECSTALL_DIS_DPTSTREAM_DPTTG, 0); 626 627 ··· 1843 1838 { 1844 1839 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 1845 1840 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 1846 - i915_reg_t reg = CHICKEN_TRANS(crtc_state->cpu_transcoder); 1841 + enum transcoder transcoder = crtc_state->cpu_transcoder; 1842 + i915_reg_t reg = DISPLAY_VER(dev_priv) >= 14 ? MTL_CHICKEN_TRANS(transcoder) : 1843 + CHICKEN_TRANS(transcoder); 1847 1844 u32 val; 1848 1845 1849 1846 val = intel_de_read(dev_priv, reg); ··· 2665 2658 intel_mode_from_crtc_timings(pipe_mode, pipe_mode); 2666 2659 2667 2660 if (DISPLAY_VER(i915) < 4) { 2668 - clock_limit = i915->max_cdclk_freq * 9 / 10; 2661 + clock_limit = i915->display.cdclk.max_cdclk_freq * 9 / 10; 2669 2662 2670 2663 /* 2671 2664 * Enable double wide mode when the dot clock ··· 2697 2690 intel_atomic_get_new_crtc_state(state, crtc); 2698 2691 int ret; 2699 2692 2693 + ret = intel_dpll_crtc_compute_clock(state, crtc); 2694 + if (ret) 2695 + return ret; 2696 + 2700 2697 ret = intel_crtc_compute_pipe_src(crtc_state); 2701 2698 if (ret) 2702 2699 return ret; ··· 2727 2716 } 2728 2717 } 2729 2718 2730 - static void compute_m_n(unsigned int m, unsigned int n, 2731 - u32 *ret_m, u32 *ret_n, 2732 - bool constant_n) 2719 + static void compute_m_n(u32 *ret_m, u32 *ret_n, 2720 + u32 m, u32 n, u32 constant_n) 2733 2721 { 2734 - /* 2735 - * Several DP dongles in particular seem to be fussy about 2736 - * too large link M/N values. Give N value as 0x8000 that 2737 - * should be acceptable by specific devices. 0x8000 is the 2738 - * specified fixed N value for asynchronous clock mode, 2739 - * which the devices expect also in synchronous clock mode. 2740 - */ 2741 2722 if (constant_n) 2742 - *ret_n = DP_LINK_CONSTANT_N_VALUE; 2723 + *ret_n = constant_n; 2743 2724 else 2744 2725 *ret_n = min_t(unsigned int, roundup_pow_of_two(n), DATA_LINK_N_MAX); 2745 2726 ··· 2743 2740 intel_link_compute_m_n(u16 bits_per_pixel, int nlanes, 2744 2741 int pixel_clock, int link_clock, 2745 2742 struct intel_link_m_n *m_n, 2746 - bool constant_n, bool fec_enable) 2743 + bool fec_enable) 2747 2744 { 2748 2745 u32 data_clock = bits_per_pixel * pixel_clock; 2749 2746 2750 2747 if (fec_enable) 2751 2748 data_clock = intel_dp_mode_to_fec_clock(data_clock); 2752 2749 2750 + /* 2751 + * Windows/BIOS uses fixed M/N values always. Follow suit. 2752 + * 2753 + * Also several DP dongles in particular seem to be fussy 2754 + * about too large link M/N values. Presumably the 20bit 2755 + * value used by Windows/BIOS is acceptable to everyone. 2756 + */ 2753 2757 m_n->tu = 64; 2754 - compute_m_n(data_clock, 2755 - link_clock * nlanes * 8, 2756 - &m_n->data_m, &m_n->data_n, 2757 - constant_n); 2758 + compute_m_n(&m_n->data_m, &m_n->data_n, 2759 + data_clock, link_clock * nlanes * 8, 2760 + 0x8000000); 2758 2761 2759 - compute_m_n(pixel_clock, link_clock, 2760 - &m_n->link_m, &m_n->link_n, 2761 - constant_n); 2762 + compute_m_n(&m_n->link_m, &m_n->link_n, 2763 + pixel_clock, link_clock, 2764 + 0x80000); 2762 2765 } 2763 2766 2764 2767 static void intel_panel_sanitize_ssc(struct drm_i915_private *dev_priv) ··· 2780 2771 PCH_DREF_CONTROL) & 2781 2772 DREF_SSC1_ENABLE; 2782 2773 2783 - if (dev_priv->vbt.lvds_use_ssc != bios_lvds_use_ssc) { 2774 + if (dev_priv->display.vbt.lvds_use_ssc != bios_lvds_use_ssc) { 2784 2775 drm_dbg_kms(&dev_priv->drm, 2785 2776 "SSC %s by BIOS, overriding VBT which says %s\n", 2786 2777 str_enabled_disabled(bios_lvds_use_ssc), 2787 - str_enabled_disabled(dev_priv->vbt.lvds_use_ssc)); 2788 - dev_priv->vbt.lvds_use_ssc = bios_lvds_use_ssc; 2778 + str_enabled_disabled(dev_priv->display.vbt.lvds_use_ssc)); 2779 + dev_priv->display.vbt.lvds_use_ssc = bios_lvds_use_ssc; 2789 2780 } 2790 2781 } 2791 2782 } ··· 4133 4124 } 4134 4125 4135 4126 if (!transcoder_is_dsi(pipe_config->cpu_transcoder)) { 4136 - tmp = intel_de_read(dev_priv, CHICKEN_TRANS(pipe_config->cpu_transcoder)); 4127 + tmp = intel_de_read(dev_priv, DISPLAY_VER(dev_priv) >= 14 ? 4128 + MTL_CHICKEN_TRANS(pipe_config->cpu_transcoder) : 4129 + CHICKEN_TRANS(pipe_config->cpu_transcoder)); 4137 4130 4138 4131 pipe_config->framestart_delay = REG_FIELD_GET(HSW_FRAME_START_DELAY_MASK, tmp) + 1; 4139 4132 } else { ··· 4383 4372 u32 dpll = pipe_config->dpll_hw_state.dpll; 4384 4373 4385 4374 if ((dpll & PLL_REF_INPUT_MASK) == PLLB_REF_INPUT_SPREADSPECTRUMIN) 4386 - return dev_priv->vbt.lvds_ssc_freq; 4375 + return dev_priv->display.vbt.lvds_ssc_freq; 4387 4376 else if (HAS_PCH_SPLIT(dev_priv)) 4388 4377 return 120000; 4389 4378 else if (DISPLAY_VER(dev_priv) != 2) ··· 4501 4490 if (!m_n->link_n) 4502 4491 return 0; 4503 4492 4504 - return div_u64(mul_u32_u32(m_n->link_m, link_freq), m_n->link_n); 4493 + return DIV_ROUND_UP_ULL(mul_u32_u32(m_n->link_m, link_freq), 4494 + m_n->link_n); 4495 + } 4496 + 4497 + int intel_crtc_dotclock(const struct intel_crtc_state *pipe_config) 4498 + { 4499 + int dotclock; 4500 + 4501 + if (intel_crtc_has_dp_encoder(pipe_config)) 4502 + dotclock = intel_dotclock_calculate(pipe_config->port_clock, 4503 + &pipe_config->dp_m_n); 4504 + else if (pipe_config->has_hdmi_sink && pipe_config->pipe_bpp > 24) 4505 + dotclock = DIV_ROUND_CLOSEST(pipe_config->port_clock * 24, 4506 + pipe_config->pipe_bpp); 4507 + else 4508 + dotclock = pipe_config->port_clock; 4509 + 4510 + if (pipe_config->output_format == INTEL_OUTPUT_FORMAT_YCBCR420 && 4511 + !intel_crtc_has_dp_encoder(pipe_config)) 4512 + dotclock *= 2; 4513 + 4514 + if (pipe_config->pixel_multiplier) 4515 + dotclock /= pipe_config->pixel_multiplier; 4516 + 4517 + return dotclock; 4505 4518 } 4506 4519 4507 4520 /* Returns the currently programmed mode of the given encoder. */ ··· 4786 4751 4787 4752 /* Display WA #1135: BXT:ALL GLK:ALL */ 4788 4753 if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) && 4789 - dev_priv->ipc_enabled) 4754 + skl_watermark_ipc_enabled(dev_priv)) 4790 4755 linetime_wm /= 2; 4791 4756 4792 4757 return min(linetime_wm, 0x1ff); ··· 4832 4797 crtc_state->update_wm_post = true; 4833 4798 4834 4799 if (mode_changed) { 4835 - ret = intel_dpll_crtc_compute_clock(state, crtc); 4836 - if (ret) 4837 - return ret; 4838 - 4839 4800 ret = intel_dpll_crtc_get_shared_dpll(state, crtc); 4840 4801 if (ret) 4841 4802 return ret; ··· 5396 5365 } 5397 5366 5398 5367 static bool 5399 - intel_compare_m_n(unsigned int m, unsigned int n, 5400 - unsigned int m2, unsigned int n2, 5401 - bool exact) 5402 - { 5403 - if (m == m2 && n == n2) 5404 - return true; 5405 - 5406 - if (exact || !m || !n || !m2 || !n2) 5407 - return false; 5408 - 5409 - BUILD_BUG_ON(DATA_LINK_M_N_MASK > INT_MAX); 5410 - 5411 - if (n > n2) { 5412 - while (n > n2) { 5413 - m2 <<= 1; 5414 - n2 <<= 1; 5415 - } 5416 - } else if (n < n2) { 5417 - while (n < n2) { 5418 - m <<= 1; 5419 - n <<= 1; 5420 - } 5421 - } 5422 - 5423 - if (n != n2) 5424 - return false; 5425 - 5426 - return intel_fuzzy_clock_check(m, m2); 5427 - } 5428 - 5429 - static bool 5430 5368 intel_compare_link_m_n(const struct intel_link_m_n *m_n, 5431 - const struct intel_link_m_n *m2_n2, 5432 - bool exact) 5369 + const struct intel_link_m_n *m2_n2) 5433 5370 { 5434 5371 return m_n->tu == m2_n2->tu && 5435 - intel_compare_m_n(m_n->data_m, m_n->data_n, 5436 - m2_n2->data_m, m2_n2->data_n, exact) && 5437 - intel_compare_m_n(m_n->link_m, m_n->link_n, 5438 - m2_n2->link_m, m2_n2->link_n, exact); 5372 + m_n->data_m == m2_n2->data_m && 5373 + m_n->data_n == m2_n2->data_n && 5374 + m_n->link_m == m2_n2->link_m && 5375 + m_n->link_n == m2_n2->link_n; 5439 5376 } 5440 5377 5441 5378 static bool ··· 5597 5598 5598 5599 #define PIPE_CONF_CHECK_M_N(name) do { \ 5599 5600 if (!intel_compare_link_m_n(&current_config->name, \ 5600 - &pipe_config->name,\ 5601 - !fastset)) { \ 5601 + &pipe_config->name)) { \ 5602 5602 pipe_config_mismatch(fastset, crtc, __stringify(name), \ 5603 5603 "(expected tu %i data %i/%i link %i/%i, " \ 5604 5604 "found tu %i, data %i/%i link %i/%i)", \ ··· 5644 5646 */ 5645 5647 #define PIPE_CONF_CHECK_M_N_ALT(name, alt_name) do { \ 5646 5648 if (!intel_compare_link_m_n(&current_config->name, \ 5647 - &pipe_config->name, !fastset) && \ 5649 + &pipe_config->name) && \ 5648 5650 !intel_compare_link_m_n(&current_config->alt_name, \ 5649 - &pipe_config->name, !fastset)) { \ 5651 + &pipe_config->name)) { \ 5650 5652 pipe_config_mismatch(fastset, crtc, __stringify(name), \ 5651 5653 "(expected tu %i data %i/%i link %i/%i, " \ 5652 5654 "or tu %i data %i/%i link %i/%i, " \ ··· 5677 5679 (mask), \ 5678 5680 current_config->name & (mask), \ 5679 5681 pipe_config->name & (mask)); \ 5680 - ret = false; \ 5681 - } \ 5682 - } while (0) 5683 - 5684 - #define PIPE_CONF_CHECK_CLOCK_FUZZY(name) do { \ 5685 - if (!intel_fuzzy_clock_check(current_config->name, pipe_config->name)) { \ 5686 - pipe_config_mismatch(fastset, crtc, __stringify(name), \ 5687 - "(expected %i, found %i)", \ 5688 - current_config->name, \ 5689 - pipe_config->name); \ 5690 5682 ret = false; \ 5691 5683 } \ 5692 5684 } while (0) ··· 5736 5748 PIPE_CONF_CHECK_I(lane_count); 5737 5749 PIPE_CONF_CHECK_X(lane_lat_optim_mask); 5738 5750 5739 - if (DISPLAY_VER(dev_priv) >= 9 || IS_BROADWELL(dev_priv)) { 5740 - PIPE_CONF_CHECK_M_N_ALT(dp_m_n, dp_m2_n2); 5751 + if (HAS_DOUBLE_BUFFERED_M_N(dev_priv)) { 5752 + if (!fastset || !pipe_config->seamless_m_n) 5753 + PIPE_CONF_CHECK_M_N_ALT(dp_m_n, dp_m2_n2); 5741 5754 } else { 5742 5755 PIPE_CONF_CHECK_M_N(dp_m_n); 5743 5756 PIPE_CONF_CHECK_M_N(dp_m2_n2); ··· 5800 5811 PIPE_CONF_CHECK_RECT(pch_pfit.dst); 5801 5812 5802 5813 PIPE_CONF_CHECK_I(scaler_state.scaler_id); 5803 - PIPE_CONF_CHECK_CLOCK_FUZZY(pixel_rate); 5814 + PIPE_CONF_CHECK_I(pixel_rate); 5804 5815 5805 5816 PIPE_CONF_CHECK_X(gamma_mode); 5806 5817 if (IS_CHERRYVIEW(dev_priv)) ··· 5870 5881 if (IS_G4X(dev_priv) || DISPLAY_VER(dev_priv) >= 5) 5871 5882 PIPE_CONF_CHECK_I(pipe_bpp); 5872 5883 5873 - PIPE_CONF_CHECK_CLOCK_FUZZY(hw.pipe_mode.crtc_clock); 5874 - PIPE_CONF_CHECK_CLOCK_FUZZY(hw.adjusted_mode.crtc_clock); 5875 - PIPE_CONF_CHECK_CLOCK_FUZZY(port_clock); 5884 + if (!fastset || !pipe_config->seamless_m_n) { 5885 + PIPE_CONF_CHECK_I(hw.pipe_mode.crtc_clock); 5886 + PIPE_CONF_CHECK_I(hw.adjusted_mode.crtc_clock); 5887 + } 5888 + PIPE_CONF_CHECK_I(port_clock); 5876 5889 5877 5890 PIPE_CONF_CHECK_I(min_voltage_level); 5878 5891 ··· 5916 5925 #undef PIPE_CONF_CHECK_BOOL_INCOMPLETE 5917 5926 #undef PIPE_CONF_CHECK_P 5918 5927 #undef PIPE_CONF_CHECK_FLAGS 5919 - #undef PIPE_CONF_CHECK_CLOCK_FUZZY 5920 5928 #undef PIPE_CONF_CHECK_COLOR_LUT 5921 5929 #undef PIPE_CONF_CHECK_TIMINGS 5922 5930 #undef PIPE_CONF_CHECK_RECT ··· 6037 6047 } 6038 6048 } 6039 6049 6040 - static void intel_modeset_clear_plls(struct intel_atomic_state *state) 6041 - { 6042 - struct intel_crtc_state *new_crtc_state; 6043 - struct intel_crtc *crtc; 6044 - int i; 6045 - 6046 - for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 6047 - if (!intel_crtc_needs_modeset(new_crtc_state)) 6048 - continue; 6049 - 6050 - intel_release_shared_dplls(state, crtc); 6051 - } 6052 - } 6053 - 6054 6050 /* 6055 6051 * This implements the workaround described in the "notes" section of the mode 6056 6052 * set sequence documentation. When going from no pipes or single pipe to ··· 6135 6159 6136 6160 new_crtc_state->uapi.mode_changed = false; 6137 6161 new_crtc_state->update_pipe = true; 6138 - } 6139 - 6140 - static void intel_crtc_copy_fastset(const struct intel_crtc_state *old_crtc_state, 6141 - struct intel_crtc_state *new_crtc_state) 6142 - { 6143 - /* 6144 - * If we're not doing the full modeset we want to 6145 - * keep the current M/N values as they may be 6146 - * sufficiently different to the computed values 6147 - * to cause problems. 6148 - * 6149 - * FIXME: should really copy more fuzzy state here 6150 - */ 6151 - new_crtc_state->fdi_m_n = old_crtc_state->fdi_m_n; 6152 - new_crtc_state->dp_m_n = old_crtc_state->dp_m_n; 6153 - new_crtc_state->dp_m2_n2 = old_crtc_state->dp_m2_n2; 6154 - new_crtc_state->has_drrs = old_crtc_state->has_drrs; 6155 6162 } 6156 6163 6157 6164 static int intel_crtc_add_planes_to_state(struct intel_atomic_state *state, ··· 6793 6834 if (!intel_crtc_needs_modeset(new_crtc_state)) 6794 6835 continue; 6795 6836 6796 - ret = intel_modeset_pipe_config_late(state, crtc); 6797 - if (ret) 6798 - goto fail; 6837 + if (new_crtc_state->hw.enable) { 6838 + ret = intel_modeset_pipe_config_late(state, crtc); 6839 + if (ret) 6840 + goto fail; 6841 + } 6799 6842 6800 6843 intel_crtc_check_fastset(old_crtc_state, new_crtc_state); 6801 6844 } ··· 6848 6887 6849 6888 for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, 6850 6889 new_crtc_state, i) { 6851 - if (intel_crtc_needs_modeset(new_crtc_state)) { 6852 - any_ms = true; 6853 - continue; 6854 - } 6855 - 6856 - if (!new_crtc_state->update_pipe) 6890 + if (!intel_crtc_needs_modeset(new_crtc_state)) 6857 6891 continue; 6858 6892 6859 - intel_crtc_copy_fastset(old_crtc_state, new_crtc_state); 6893 + any_ms = true; 6894 + 6895 + intel_release_shared_dplls(state, crtc); 6860 6896 } 6861 6897 6862 6898 if (any_ms && !check_digital_port_conflicts(state)) { ··· 6894 6936 ret = intel_modeset_calc_cdclk(state); 6895 6937 if (ret) 6896 6938 return ret; 6897 - 6898 - intel_modeset_clear_plls(state); 6899 6939 } 6900 6940 6901 6941 ret = intel_atomic_check_crtcs(state); ··· 7012 7056 if (DISPLAY_VER(dev_priv) >= 9 || 7013 7057 IS_BROADWELL(dev_priv) || IS_HASWELL(dev_priv)) 7014 7058 hsw_set_linetime_wm(new_crtc_state); 7059 + 7060 + if (new_crtc_state->seamless_m_n) 7061 + intel_cpu_transcoder_set_m1_n1(crtc, new_crtc_state->cpu_transcoder, 7062 + &new_crtc_state->dp_m_n); 7015 7063 } 7016 7064 7017 7065 static void commit_pipe_pre_planes(struct intel_atomic_state *state, ··· 7368 7408 struct intel_atomic_state *state, *next; 7369 7409 struct llist_node *freed; 7370 7410 7371 - freed = llist_del_all(&dev_priv->atomic_helper.free_list); 7411 + freed = llist_del_all(&dev_priv->display.atomic_helper.free_list); 7372 7412 llist_for_each_entry_safe(state, next, freed, freed) 7373 7413 drm_atomic_state_put(&state->base); 7374 7414 } ··· 7376 7416 static void intel_atomic_helper_free_state_worker(struct work_struct *work) 7377 7417 { 7378 7418 struct drm_i915_private *dev_priv = 7379 - container_of(work, typeof(*dev_priv), atomic_helper.free_work); 7419 + container_of(work, typeof(*dev_priv), display.atomic_helper.free_work); 7380 7420 7381 7421 intel_atomic_helper_free_state(dev_priv); 7382 7422 } ··· 7669 7709 case FENCE_FREE: 7670 7710 { 7671 7711 struct intel_atomic_helper *helper = 7672 - &to_i915(state->base.dev)->atomic_helper; 7712 + &to_i915(state->base.dev)->display.atomic_helper; 7673 7713 7674 7714 if (llist_add(&state->freed, &helper->free_list)) 7675 7715 schedule_work(&helper->free_work); ··· 7772 7812 7773 7813 i915_sw_fence_commit(&state->commit_ready); 7774 7814 if (nonblock && state->modeset) { 7775 - queue_work(dev_priv->modeset_wq, &state->base.commit_work); 7815 + queue_work(dev_priv->display.wq.modeset, &state->base.commit_work); 7776 7816 } else if (nonblock) { 7777 - queue_work(dev_priv->flip_wq, &state->base.commit_work); 7817 + queue_work(dev_priv->display.wq.flip, &state->base.commit_work); 7778 7818 } else { 7779 7819 if (state->modeset) 7780 - flush_workqueue(dev_priv->modeset_wq); 7820 + flush_workqueue(dev_priv->display.wq.modeset); 7781 7821 intel_atomic_commit_tail(state); 7782 7822 } 7783 7823 ··· 7883 7923 if (intel_de_read(dev_priv, DDI_BUF_CTL(PORT_A)) & DDI_A_4_LANES) 7884 7924 return false; 7885 7925 7886 - if (!dev_priv->vbt.int_crt_support) 7926 + if (!dev_priv->display.vbt.int_crt_support) 7887 7927 return false; 7888 7928 7889 7929 return true; ··· 8018 8058 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { 8019 8059 bool has_edp, has_port; 8020 8060 8021 - if (IS_VALLEYVIEW(dev_priv) && dev_priv->vbt.int_crt_support) 8061 + if (IS_VALLEYVIEW(dev_priv) && dev_priv->display.vbt.int_crt_support) 8022 8062 intel_crt_init(dev_priv); 8023 8063 8024 8064 /* ··· 8354 8394 if (!HAS_DISPLAY(i915)) 8355 8395 return; 8356 8396 8357 - cdclk_state = to_intel_cdclk_state(i915->cdclk.obj.state); 8397 + cdclk_state = to_intel_cdclk_state(i915->display.cdclk.obj.state); 8358 8398 8359 8399 intel_update_cdclk(i915); 8360 - intel_cdclk_dump_config(i915, &i915->cdclk.hw, "Current CDCLK"); 8361 - cdclk_state->logical = cdclk_state->actual = i915->cdclk.hw; 8400 + intel_cdclk_dump_config(i915, &i915->display.cdclk.hw, "Current CDCLK"); 8401 + cdclk_state->logical = cdclk_state->actual = i915->display.cdclk.hw; 8362 8402 } 8363 8403 8364 8404 static int sanitize_watermarks_add_affected(struct drm_atomic_state *state) ··· 8646 8686 8647 8687 intel_dmc_ucode_init(i915); 8648 8688 8649 - i915->modeset_wq = alloc_ordered_workqueue("i915_modeset", 0); 8650 - i915->flip_wq = alloc_workqueue("i915_flip", WQ_HIGHPRI | 8651 - WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE); 8689 + i915->display.wq.modeset = alloc_ordered_workqueue("i915_modeset", 0); 8690 + i915->display.wq.flip = alloc_workqueue("i915_flip", WQ_HIGHPRI | 8691 + WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE); 8652 8692 8653 8693 intel_mode_config_init(i915); 8654 8694 ··· 8664 8704 if (ret) 8665 8705 goto cleanup_vga_client_pw_domain_dmc; 8666 8706 8667 - init_llist_head(&i915->atomic_helper.free_list); 8668 - INIT_WORK(&i915->atomic_helper.free_work, 8707 + init_llist_head(&i915->display.atomic_helper.free_list); 8708 + INIT_WORK(&i915->display.atomic_helper.free_work, 8669 8709 intel_atomic_helper_free_state_worker); 8670 8710 8671 8711 intel_init_quirks(i915); ··· 8725 8765 8726 8766 intel_hdcp_component_init(i915); 8727 8767 8728 - if (i915->max_cdclk_freq == 0) 8768 + if (i915->display.cdclk.max_cdclk_freq == 0) 8729 8769 intel_update_max_cdclk(i915); 8730 8770 8731 8771 /* ··· 8789 8829 intel_hpd_init(i915); 8790 8830 intel_hpd_poll_disable(i915); 8791 8831 8792 - intel_init_ipc(i915); 8832 + skl_watermark_ipc_init(i915); 8793 8833 8794 8834 return 0; 8795 8835 } ··· 8920 8960 if (!ret) 8921 8961 ret = __intel_display_resume(i915, state, &ctx); 8922 8962 8923 - intel_enable_ipc(i915); 8963 + skl_watermark_ipc_update(i915); 8924 8964 drm_modeset_drop_locks(&ctx); 8925 8965 drm_modeset_acquire_fini(&ctx); 8926 8966 ··· 8955 8995 if (!HAS_DISPLAY(i915)) 8956 8996 return; 8957 8997 8958 - flush_workqueue(i915->flip_wq); 8959 - flush_workqueue(i915->modeset_wq); 8998 + flush_workqueue(i915->display.wq.flip); 8999 + flush_workqueue(i915->display.wq.modeset); 8960 9000 8961 - flush_work(&i915->atomic_helper.free_work); 8962 - drm_WARN_ON(&i915->drm, !llist_empty(&i915->atomic_helper.free_list)); 9001 + flush_work(&i915->display.atomic_helper.free_work); 9002 + drm_WARN_ON(&i915->drm, !llist_empty(&i915->display.atomic_helper.free_list)); 9003 + 9004 + /* 9005 + * MST topology needs to be suspended so we don't have any calls to 9006 + * fbdev after it's finalized. MST will be destroyed later as part of 9007 + * drm_mode_config_cleanup() 9008 + */ 9009 + intel_dp_mst_suspend(i915); 8963 9010 } 8964 9011 8965 9012 /* part #2: call after irq uninstall */ ··· 8980 9013 * poll handlers. Hence disable polling after hpd handling is shut down. 8981 9014 */ 8982 9015 intel_hpd_poll_fini(i915); 8983 - 8984 - /* 8985 - * MST topology needs to be suspended so we don't have any calls to 8986 - * fbdev after it's finalized. MST will be destroyed later as part of 8987 - * drm_mode_config_cleanup() 8988 - */ 8989 - intel_dp_mst_suspend(i915); 8990 9016 8991 9017 /* poll work can call into fbdev, hence clean that up afterwards */ 8992 9018 intel_fbdev_fini(i915); ··· 8997 9037 8998 9038 intel_gmbus_teardown(i915); 8999 9039 9000 - destroy_workqueue(i915->flip_wq); 9001 - destroy_workqueue(i915->modeset_wq); 9040 + destroy_workqueue(i915->display.wq.flip); 9041 + destroy_workqueue(i915->display.wq.modeset); 9002 9042 9003 9043 intel_fbc_cleanup(i915); 9004 9044 }
+1 -1
drivers/gpu/drm/i915/display/intel_display.h
··· 547 547 void intel_link_compute_m_n(u16 bpp, int nlanes, 548 548 int pixel_clock, int link_clock, 549 549 struct intel_link_m_n *m_n, 550 - bool constant_n, bool fec_enable); 550 + bool fec_enable); 551 551 u32 intel_plane_fb_max_stride(struct drm_i915_private *dev_priv, 552 552 u32 pixel_format, u64 modifier); 553 553 enum drm_mode_status
+157
drivers/gpu/drm/i915/display/intel_display_core.h
··· 6 6 #ifndef __INTEL_DISPLAY_CORE_H__ 7 7 #define __INTEL_DISPLAY_CORE_H__ 8 8 9 + #include <linux/list.h> 10 + #include <linux/llist.h> 9 11 #include <linux/mutex.h> 10 12 #include <linux/types.h> 11 13 #include <linux/wait.h> 12 14 #include <linux/workqueue.h> 13 15 16 + #include <drm/drm_connector.h> 17 + 18 + #include "intel_cdclk.h" 14 19 #include "intel_display.h" 20 + #include "intel_display_power.h" 15 21 #include "intel_dmc.h" 16 22 #include "intel_dpll_mgr.h" 23 + #include "intel_fbc.h" 24 + #include "intel_global_state.h" 17 25 #include "intel_gmbus.h" 26 + #include "intel_opregion.h" 18 27 #include "intel_pm_types.h" 19 28 20 29 struct drm_i915_private; 30 + struct drm_property; 21 31 struct i915_audio_component; 32 + struct i915_hdcp_comp_master; 22 33 struct intel_atomic_state; 23 34 struct intel_audio_funcs; 35 + struct intel_bios_encoder_data; 24 36 struct intel_cdclk_funcs; 37 + struct intel_cdclk_vals; 25 38 struct intel_color_funcs; 26 39 struct intel_crtc; 27 40 struct intel_crtc_state; ··· 45 32 struct intel_hotplug_funcs; 46 33 struct intel_initial_plane_config; 47 34 struct intel_overlay; 35 + 36 + /* Amount of SAGV/QGV points, BSpec precisely defines this */ 37 + #define I915_NUM_QGV_POINTS 8 38 + 39 + /* Amount of PSF GV points, BSpec precisely defines this */ 40 + #define I915_NUM_PSF_GV_POINTS 3 48 41 49 42 struct intel_display_funcs { 50 43 /* ··· 122 103 } ref_clks; 123 104 }; 124 105 106 + struct intel_frontbuffer_tracking { 107 + spinlock_t lock; 108 + 109 + /* 110 + * Tracking bits for delayed frontbuffer flushing du to gpu activity or 111 + * scheduled flips. 112 + */ 113 + unsigned busy_bits; 114 + unsigned flip_bits; 115 + }; 116 + 125 117 struct intel_hotplug { 126 118 struct delayed_work hotplug_work; 127 119 ··· 172 142 struct workqueue_struct *dp_wq; 173 143 }; 174 144 145 + struct intel_vbt_data { 146 + /* bdb version */ 147 + u16 version; 148 + 149 + /* Feature bits */ 150 + unsigned int int_tv_support:1; 151 + unsigned int int_crt_support:1; 152 + unsigned int lvds_use_ssc:1; 153 + unsigned int int_lvds_support:1; 154 + unsigned int display_clock_mode:1; 155 + unsigned int fdi_rx_polarity_inverted:1; 156 + int lvds_ssc_freq; 157 + enum drm_panel_orientation orientation; 158 + 159 + bool override_afc_startup; 160 + u8 override_afc_startup_val; 161 + 162 + int crt_ddc_pin; 163 + 164 + struct list_head display_devices; 165 + struct list_head bdb_blocks; 166 + 167 + struct intel_bios_encoder_data *ports[I915_MAX_PORTS]; /* Non-NULL if port present. */ 168 + struct sdvo_device_mapping { 169 + u8 initialized; 170 + u8 dvo_port; 171 + u8 slave_addr; 172 + u8 dvo_wiring; 173 + u8 i2c_pin; 174 + u8 ddc_pin; 175 + } sdvo_mappings[2]; 176 + }; 177 + 175 178 struct intel_wm { 176 179 /* 177 180 * Raw watermark latency values: ··· 239 176 * crtc_state->wm.need_postvbl_update. 240 177 */ 241 178 struct mutex wm_mutex; 179 + 180 + bool ipc_enabled; 242 181 }; 243 182 244 183 struct intel_display { ··· 272 207 } funcs; 273 208 274 209 /* Grouping using anonymous structs. Keep sorted. */ 210 + struct intel_atomic_helper { 211 + struct llist_head free_list; 212 + struct work_struct free_work; 213 + } atomic_helper; 214 + 215 + struct { 216 + /* backlight registers and fields in struct intel_panel */ 217 + struct mutex lock; 218 + } backlight; 219 + 220 + struct { 221 + struct intel_global_obj obj; 222 + 223 + struct intel_bw_info { 224 + /* for each QGV point */ 225 + unsigned int deratedbw[I915_NUM_QGV_POINTS]; 226 + /* for each PSF GV point */ 227 + unsigned int psf_bw[I915_NUM_PSF_GV_POINTS]; 228 + u8 num_qgv_points; 229 + u8 num_psf_gv_points; 230 + u8 num_planes; 231 + } max[6]; 232 + } bw; 233 + 234 + struct { 235 + /* The current hardware cdclk configuration */ 236 + struct intel_cdclk_config hw; 237 + 238 + /* cdclk, divider, and ratio table from bspec */ 239 + const struct intel_cdclk_vals *table; 240 + 241 + struct intel_global_obj obj; 242 + 243 + unsigned int max_cdclk_freq; 244 + } cdclk; 245 + 246 + struct { 247 + /* The current hardware dbuf configuration */ 248 + u8 enabled_slices; 249 + 250 + struct intel_global_obj obj; 251 + } dbuf; 252 + 253 + struct { 254 + /* VLV/CHV/BXT/GLK DSI MMIO register base address */ 255 + u32 mmio_base; 256 + } dsi; 257 + 275 258 struct { 276 259 /* list of fbdev register on this device */ 277 260 struct intel_fbdev *fbdev; 278 261 struct work_struct suspend_work; 279 262 } fbdev; 263 + 264 + struct { 265 + unsigned int pll_freq; 266 + u32 rx_config; 267 + } fdi; 280 268 281 269 struct { 282 270 /* ··· 350 232 } gmbus; 351 233 352 234 struct { 235 + struct i915_hdcp_comp_master *master; 236 + bool comp_added; 237 + 238 + /* Mutex to protect the above hdcp component related values. */ 239 + struct mutex comp_mutex; 240 + } hdcp; 241 + 242 + struct { 243 + struct i915_power_domains domains; 244 + 245 + /* Shadow for DISPLAY_PHY_CONTROL which can't be safely read */ 246 + u32 chv_phy_control; 247 + 248 + /* perform PHY state sanity checks? */ 249 + bool chv_phy_assert[2]; 250 + } power; 251 + 252 + struct { 353 253 u32 mmio_base; 354 254 355 255 /* protects panel power sequencer state */ 356 256 struct mutex mutex; 357 257 } pps; 258 + 259 + struct { 260 + struct drm_property *broadcast_rgb; 261 + struct drm_property *force_audio; 262 + } properties; 263 + 264 + struct { 265 + unsigned long mask; 266 + } quirks; 358 267 359 268 struct { 360 269 enum { ··· 394 249 u32 block_time_us; 395 250 } sagv; 396 251 252 + struct { 253 + /* ordered wq for modesets */ 254 + struct workqueue_struct *modeset; 255 + 256 + /* unbound hipri wq for page flips/plane updates */ 257 + struct workqueue_struct *flip; 258 + } wq; 259 + 397 260 /* Grouping using named structs. Keep sorted. */ 398 261 struct intel_audio audio; 399 262 struct intel_dmc dmc; 400 263 struct intel_dpll dpll; 264 + struct intel_fbc *fbc[I915_MAX_FBCS]; 265 + struct intel_frontbuffer_tracking fb_tracking; 401 266 struct intel_hotplug hotplug; 267 + struct intel_opregion opregion; 402 268 struct intel_overlay *overlay; 269 + struct intel_vbt_data vbt; 403 270 struct intel_wm wm; 404 271 }; 405 272
+21 -71
drivers/gpu/drm/i915/display/intel_display_debugfs.c
··· 26 26 #include "intel_pm.h" 27 27 #include "intel_psr.h" 28 28 #include "intel_sprite.h" 29 + #include "skl_watermark.h" 29 30 30 31 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node) 31 32 { ··· 38 37 struct drm_i915_private *dev_priv = node_to_i915(m->private); 39 38 40 39 seq_printf(m, "FB tracking busy bits: 0x%08x\n", 41 - dev_priv->fb_tracking.busy_bits); 40 + dev_priv->display.fb_tracking.busy_bits); 42 41 43 42 seq_printf(m, "FB tracking flip bits: 0x%08x\n", 44 - dev_priv->fb_tracking.flip_bits); 43 + dev_priv->display.fb_tracking.flip_bits); 45 44 46 45 return 0; 47 46 } ··· 104 103 105 104 static int i915_opregion(struct seq_file *m, void *unused) 106 105 { 107 - struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; 106 + struct drm_i915_private *i915 = node_to_i915(m->private); 107 + struct intel_opregion *opregion = &i915->display.opregion; 108 108 109 109 if (opregion->header) 110 110 seq_write(m, opregion->header, OPREGION_SIZE); ··· 115 113 116 114 static int i915_vbt(struct seq_file *m, void *unused) 117 115 { 118 - struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; 116 + struct drm_i915_private *i915 = node_to_i915(m->private); 117 + struct intel_opregion *opregion = &i915->display.opregion; 119 118 120 119 if (opregion->vbt) 121 120 seq_write(m, opregion->vbt, opregion->vbt_size); ··· 982 979 983 980 return 0; 984 981 } 985 - 986 - static int i915_ipc_status_show(struct seq_file *m, void *data) 987 - { 988 - struct drm_i915_private *dev_priv = m->private; 989 - 990 - seq_printf(m, "Isochronous Priority Control: %s\n", 991 - str_yes_no(dev_priv->ipc_enabled)); 992 - return 0; 993 - } 994 - 995 - static int i915_ipc_status_open(struct inode *inode, struct file *file) 996 - { 997 - struct drm_i915_private *dev_priv = inode->i_private; 998 - 999 - if (!HAS_IPC(dev_priv)) 1000 - return -ENODEV; 1001 - 1002 - return single_open(file, i915_ipc_status_show, dev_priv); 1003 - } 1004 - 1005 - static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf, 1006 - size_t len, loff_t *offp) 1007 - { 1008 - struct seq_file *m = file->private_data; 1009 - struct drm_i915_private *dev_priv = m->private; 1010 - intel_wakeref_t wakeref; 1011 - bool enable; 1012 - int ret; 1013 - 1014 - ret = kstrtobool_from_user(ubuf, len, &enable); 1015 - if (ret < 0) 1016 - return ret; 1017 - 1018 - with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) { 1019 - if (!dev_priv->ipc_enabled && enable) 1020 - drm_info(&dev_priv->drm, 1021 - "Enabling IPC: WM will be proper only after next commit\n"); 1022 - dev_priv->ipc_enabled = enable; 1023 - intel_enable_ipc(dev_priv); 1024 - } 1025 - 1026 - return len; 1027 - } 1028 - 1029 - static const struct file_operations i915_ipc_status_fops = { 1030 - .owner = THIS_MODULE, 1031 - .open = i915_ipc_status_open, 1032 - .read = seq_read, 1033 - .llseek = seq_lseek, 1034 - .release = single_release, 1035 - .write = i915_ipc_status_write 1036 - }; 1037 982 1038 983 static int i915_ddb_info(struct seq_file *m, void *unused) 1039 984 { ··· 1859 1908 {"i915_dp_test_active", &i915_displayport_test_active_fops}, 1860 1909 {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}, 1861 1910 {"i915_hpd_short_storm_ctl", &i915_hpd_short_storm_ctl_fops}, 1862 - {"i915_ipc_status", &i915_ipc_status_fops}, 1863 1911 {"i915_drrs_ctl", &i915_drrs_ctl_fops}, 1864 1912 {"i915_edp_psr_debug", &i915_edp_psr_debug_fops}, 1865 1913 }; ··· 1882 1932 1883 1933 intel_dmc_debugfs_register(i915); 1884 1934 intel_fbc_debugfs_register(i915); 1935 + skl_watermark_ipc_debugfs_register(i915); 1885 1936 } 1886 1937 1887 1938 static int i915_panel_show(struct seq_file *m, void *data) ··· 2089 2138 .write = i915_dsc_fec_support_write 2090 2139 }; 2091 2140 2092 - static int i915_dsc_bpp_show(struct seq_file *m, void *data) 2141 + static int i915_dsc_bpc_show(struct seq_file *m, void *data) 2093 2142 { 2094 2143 struct drm_connector *connector = m->private; 2095 2144 struct drm_device *dev = connector->dev; ··· 2112 2161 } 2113 2162 2114 2163 crtc_state = to_intel_crtc_state(crtc->state); 2115 - seq_printf(m, "Compressed_BPP: %d\n", crtc_state->dsc.compressed_bpp); 2164 + seq_printf(m, "Input_BPC: %d\n", crtc_state->dsc.config.bits_per_component); 2116 2165 2117 2166 out: drm_modeset_unlock(&dev->mode_config.connection_mutex); 2118 2167 2119 2168 return ret; 2120 2169 } 2121 2170 2122 - static ssize_t i915_dsc_bpp_write(struct file *file, 2171 + static ssize_t i915_dsc_bpc_write(struct file *file, 2123 2172 const char __user *ubuf, 2124 2173 size_t len, loff_t *offp) 2125 2174 { ··· 2127 2176 ((struct seq_file *)file->private_data)->private; 2128 2177 struct intel_encoder *encoder = intel_attached_encoder(to_intel_connector(connector)); 2129 2178 struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 2130 - int dsc_bpp = 0; 2179 + int dsc_bpc = 0; 2131 2180 int ret; 2132 2181 2133 - ret = kstrtoint_from_user(ubuf, len, 0, &dsc_bpp); 2182 + ret = kstrtoint_from_user(ubuf, len, 0, &dsc_bpc); 2134 2183 if (ret < 0) 2135 2184 return ret; 2136 2185 2137 - intel_dp->force_dsc_bpp = dsc_bpp; 2186 + intel_dp->force_dsc_bpc = dsc_bpc; 2138 2187 *offp += len; 2139 2188 2140 2189 return len; 2141 2190 } 2142 2191 2143 - static int i915_dsc_bpp_open(struct inode *inode, 2192 + static int i915_dsc_bpc_open(struct inode *inode, 2144 2193 struct file *file) 2145 2194 { 2146 - return single_open(file, i915_dsc_bpp_show, 2147 - inode->i_private); 2195 + return single_open(file, i915_dsc_bpc_show, inode->i_private); 2148 2196 } 2149 2197 2150 - static const struct file_operations i915_dsc_bpp_fops = { 2198 + static const struct file_operations i915_dsc_bpc_fops = { 2151 2199 .owner = THIS_MODULE, 2152 - .open = i915_dsc_bpp_open, 2200 + .open = i915_dsc_bpc_open, 2153 2201 .read = seq_read, 2154 2202 .llseek = seq_lseek, 2155 2203 .release = single_release, 2156 - .write = i915_dsc_bpp_write 2204 + .write = i915_dsc_bpc_write 2157 2205 }; 2158 2206 2159 2207 /* ··· 2222 2272 debugfs_create_file("i915_dsc_fec_support", 0644, root, 2223 2273 connector, &i915_dsc_fec_support_fops); 2224 2274 2225 - debugfs_create_file("i915_dsc_bpp", 0644, root, 2226 - connector, &i915_dsc_bpp_fops); 2275 + debugfs_create_file("i915_dsc_bpc", 0644, root, 2276 + connector, &i915_dsc_bpc_fops); 2227 2277 } 2228 2278 2229 2279 if (connector->connector_type == DRM_MODE_CONNECTOR_DSI ||
+62 -62
drivers/gpu/drm/i915/display/intel_display_power.c
··· 19 19 #include "intel_mchbar_regs.h" 20 20 #include "intel_pch_refclk.h" 21 21 #include "intel_pcode.h" 22 - #include "intel_pm.h" 23 22 #include "intel_snps_phy.h" 23 + #include "skl_watermark.h" 24 24 #include "vlv_sideband.h" 25 25 26 26 #define for_each_power_domain_well(__dev_priv, __power_well, __domain) \ ··· 244 244 struct i915_power_domains *power_domains; 245 245 bool ret; 246 246 247 - power_domains = &dev_priv->power_domains; 247 + power_domains = &dev_priv->display.power.domains; 248 248 249 249 mutex_lock(&power_domains->lock); 250 250 ret = __intel_display_power_is_enabled(dev_priv, domain); ··· 292 292 { 293 293 struct i915_power_well *power_well; 294 294 bool dc_off_enabled; 295 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 295 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 296 296 297 297 mutex_lock(&power_domains->lock); 298 298 power_well = lookup_power_well(dev_priv, SKL_DISP_DC_OFF); ··· 340 340 { 341 341 struct drm_i915_private *i915 = container_of(power_domains, 342 342 struct drm_i915_private, 343 - power_domains); 343 + display.power.domains); 344 344 345 345 return !drm_WARN_ON(&i915->drm, 346 346 bitmap_intersects(power_domains->async_put_domains[0].bits, ··· 353 353 { 354 354 struct drm_i915_private *i915 = container_of(power_domains, 355 355 struct drm_i915_private, 356 - power_domains); 356 + display.power.domains); 357 357 struct intel_power_domain_mask async_put_mask; 358 358 enum intel_display_power_domain domain; 359 359 bool err = false; ··· 376 376 { 377 377 struct drm_i915_private *i915 = container_of(power_domains, 378 378 struct drm_i915_private, 379 - power_domains); 379 + display.power.domains); 380 380 enum intel_display_power_domain domain; 381 381 382 382 drm_dbg(&i915->drm, "%s (%d):\n", prefix, bitmap_weight(mask->bits, POWER_DOMAIN_NUM)); ··· 391 391 { 392 392 struct drm_i915_private *i915 = container_of(power_domains, 393 393 struct drm_i915_private, 394 - power_domains); 394 + display.power.domains); 395 395 396 396 drm_dbg(&i915->drm, "async_put_wakeref %u\n", 397 397 power_domains->async_put_wakeref); ··· 446 446 intel_display_power_grab_async_put_ref(struct drm_i915_private *dev_priv, 447 447 enum intel_display_power_domain domain) 448 448 { 449 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 449 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 450 450 struct intel_power_domain_mask async_put_mask; 451 451 bool ret = false; 452 452 ··· 475 475 __intel_display_power_get_domain(struct drm_i915_private *dev_priv, 476 476 enum intel_display_power_domain domain) 477 477 { 478 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 478 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 479 479 struct i915_power_well *power_well; 480 480 481 481 if (intel_display_power_grab_async_put_ref(dev_priv, domain)) ··· 502 502 intel_wakeref_t intel_display_power_get(struct drm_i915_private *dev_priv, 503 503 enum intel_display_power_domain domain) 504 504 { 505 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 505 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 506 506 intel_wakeref_t wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm); 507 507 508 508 mutex_lock(&power_domains->lock); ··· 528 528 intel_display_power_get_if_enabled(struct drm_i915_private *dev_priv, 529 529 enum intel_display_power_domain domain) 530 530 { 531 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 531 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 532 532 intel_wakeref_t wakeref; 533 533 bool is_enabled; 534 534 ··· 564 564 const char *name = intel_display_power_domain_str(domain); 565 565 struct intel_power_domain_mask async_put_mask; 566 566 567 - power_domains = &dev_priv->power_domains; 567 + power_domains = &dev_priv->display.power.domains; 568 568 569 569 drm_WARN(&dev_priv->drm, !power_domains->domain_use_count[domain], 570 570 "Use count on domain %s is already zero\n", ··· 584 584 static void __intel_display_power_put(struct drm_i915_private *dev_priv, 585 585 enum intel_display_power_domain domain) 586 586 { 587 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 587 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 588 588 589 589 mutex_lock(&power_domains->lock); 590 590 __intel_display_power_put_domain(dev_priv, domain); ··· 597 597 { 598 598 struct drm_i915_private *i915 = container_of(power_domains, 599 599 struct drm_i915_private, 600 - power_domains); 600 + display.power.domains); 601 601 drm_WARN_ON(&i915->drm, power_domains->async_put_wakeref); 602 602 power_domains->async_put_wakeref = wakeref; 603 603 drm_WARN_ON(&i915->drm, !queue_delayed_work(system_unbound_wq, ··· 611 611 { 612 612 struct drm_i915_private *dev_priv = 613 613 container_of(power_domains, struct drm_i915_private, 614 - power_domains); 614 + display.power.domains); 615 615 struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; 616 616 enum intel_display_power_domain domain; 617 617 intel_wakeref_t wakeref; ··· 638 638 { 639 639 struct drm_i915_private *dev_priv = 640 640 container_of(work, struct drm_i915_private, 641 - power_domains.async_put_work.work); 642 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 641 + display.power.domains.async_put_work.work); 642 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 643 643 struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; 644 644 intel_wakeref_t new_work_wakeref = intel_runtime_pm_get_raw(rpm); 645 645 intel_wakeref_t old_work_wakeref = 0; ··· 699 699 enum intel_display_power_domain domain, 700 700 intel_wakeref_t wakeref) 701 701 { 702 - struct i915_power_domains *power_domains = &i915->power_domains; 702 + struct i915_power_domains *power_domains = &i915->display.power.domains; 703 703 struct intel_runtime_pm *rpm = &i915->runtime_pm; 704 704 intel_wakeref_t work_wakeref = intel_runtime_pm_get_raw(rpm); 705 705 ··· 747 747 */ 748 748 void intel_display_power_flush_work(struct drm_i915_private *i915) 749 749 { 750 - struct i915_power_domains *power_domains = &i915->power_domains; 750 + struct i915_power_domains *power_domains = &i915->display.power.domains; 751 751 struct intel_power_domain_mask async_put_mask; 752 752 intel_wakeref_t work_wakeref; 753 753 ··· 780 780 static void 781 781 intel_display_power_flush_work_sync(struct drm_i915_private *i915) 782 782 { 783 - struct i915_power_domains *power_domains = &i915->power_domains; 783 + struct i915_power_domains *power_domains = &i915->display.power.domains; 784 784 785 785 intel_display_power_flush_work(i915); 786 786 cancel_delayed_work_sync(&power_domains->async_put_work); ··· 977 977 */ 978 978 int intel_power_domains_init(struct drm_i915_private *dev_priv) 979 979 { 980 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 980 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 981 981 982 982 dev_priv->params.disable_power_well = 983 983 sanitize_disable_power_well_option(dev_priv, ··· 1004 1004 */ 1005 1005 void intel_power_domains_cleanup(struct drm_i915_private *dev_priv) 1006 1006 { 1007 - intel_display_power_map_cleanup(&dev_priv->power_domains); 1007 + intel_display_power_map_cleanup(&dev_priv->display.power.domains); 1008 1008 } 1009 1009 1010 1010 static void intel_power_domains_sync_hw(struct drm_i915_private *dev_priv) 1011 1011 { 1012 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1012 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1013 1013 struct i915_power_well *power_well; 1014 1014 1015 1015 mutex_lock(&power_domains->lock); ··· 1038 1038 void gen9_dbuf_slices_update(struct drm_i915_private *dev_priv, 1039 1039 u8 req_slices) 1040 1040 { 1041 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1041 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1042 1042 u8 slice_mask = INTEL_INFO(dev_priv)->display.dbuf.slice_mask; 1043 1043 enum dbuf_slice slice; 1044 1044 ··· 1061 1061 for_each_dbuf_slice(dev_priv, slice) 1062 1062 gen9_dbuf_slice_set(dev_priv, slice, req_slices & BIT(slice)); 1063 1063 1064 - dev_priv->dbuf.enabled_slices = req_slices; 1064 + dev_priv->display.dbuf.enabled_slices = req_slices; 1065 1065 1066 1066 mutex_unlock(&power_domains->lock); 1067 1067 } 1068 1068 1069 1069 static void gen9_dbuf_enable(struct drm_i915_private *dev_priv) 1070 1070 { 1071 - dev_priv->dbuf.enabled_slices = 1071 + dev_priv->display.dbuf.enabled_slices = 1072 1072 intel_enabled_dbuf_slices_mask(dev_priv); 1073 1073 1074 1074 /* ··· 1076 1076 * figure out later which slices we have and what we need. 1077 1077 */ 1078 1078 gen9_dbuf_slices_update(dev_priv, BIT(DBUF_S1) | 1079 - dev_priv->dbuf.enabled_slices); 1079 + dev_priv->display.dbuf.enabled_slices); 1080 1080 } 1081 1081 1082 1082 static void gen9_dbuf_disable(struct drm_i915_private *dev_priv) ··· 1310 1310 intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL); 1311 1311 1312 1312 intel_update_cdclk(dev_priv); 1313 - intel_cdclk_dump_config(dev_priv, &dev_priv->cdclk.hw, "Current CDCLK"); 1313 + intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "Current CDCLK"); 1314 1314 } 1315 1315 1316 1316 /* ··· 1398 1398 static void skl_display_core_init(struct drm_i915_private *dev_priv, 1399 1399 bool resume) 1400 1400 { 1401 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1401 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1402 1402 struct i915_power_well *well; 1403 1403 1404 1404 gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); ··· 1430 1430 1431 1431 static void skl_display_core_uninit(struct drm_i915_private *dev_priv) 1432 1432 { 1433 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1433 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1434 1434 struct i915_power_well *well; 1435 1435 1436 1436 if (!HAS_DISPLAY(dev_priv)) ··· 1464 1464 1465 1465 static void bxt_display_core_init(struct drm_i915_private *dev_priv, bool resume) 1466 1466 { 1467 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1467 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1468 1468 struct i915_power_well *well; 1469 1469 1470 1470 gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); ··· 1498 1498 1499 1499 static void bxt_display_core_uninit(struct drm_i915_private *dev_priv) 1500 1500 { 1501 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1501 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1502 1502 struct i915_power_well *well; 1503 1503 1504 1504 if (!HAS_DISPLAY(dev_priv)) ··· 1607 1607 static void icl_display_core_init(struct drm_i915_private *dev_priv, 1608 1608 bool resume) 1609 1609 { 1610 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1610 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1611 1611 struct i915_power_well *well; 1612 1612 u32 val; 1613 1613 ··· 1674 1674 1675 1675 static void icl_display_core_uninit(struct drm_i915_private *dev_priv) 1676 1676 { 1677 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1677 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1678 1678 struct i915_power_well *well; 1679 1679 1680 1680 if (!HAS_DISPLAY(dev_priv)) ··· 1719 1719 * power well state and lane status to reconstruct the 1720 1720 * expected initial value. 1721 1721 */ 1722 - dev_priv->chv_phy_control = 1722 + dev_priv->display.power.chv_phy_control = 1723 1723 PHY_LDO_SEQ_DELAY(PHY_LDO_DELAY_600NS, DPIO_PHY0) | 1724 1724 PHY_LDO_SEQ_DELAY(PHY_LDO_DELAY_600NS, DPIO_PHY1) | 1725 1725 PHY_CH_POWER_MODE(PHY_CH_DEEP_PSR, DPIO_PHY0, DPIO_CH0) | ··· 1741 1741 if (mask == 0xf) 1742 1742 mask = 0x0; 1743 1743 else 1744 - dev_priv->chv_phy_control |= 1744 + dev_priv->display.power.chv_phy_control |= 1745 1745 PHY_CH_POWER_DOWN_OVRD_EN(DPIO_PHY0, DPIO_CH0); 1746 1746 1747 - dev_priv->chv_phy_control |= 1747 + dev_priv->display.power.chv_phy_control |= 1748 1748 PHY_CH_POWER_DOWN_OVRD(mask, DPIO_PHY0, DPIO_CH0); 1749 1749 1750 1750 mask = (status & DPLL_PORTC_READY_MASK) >> 4; 1751 1751 if (mask == 0xf) 1752 1752 mask = 0x0; 1753 1753 else 1754 - dev_priv->chv_phy_control |= 1754 + dev_priv->display.power.chv_phy_control |= 1755 1755 PHY_CH_POWER_DOWN_OVRD_EN(DPIO_PHY0, DPIO_CH1); 1756 1756 1757 - dev_priv->chv_phy_control |= 1757 + dev_priv->display.power.chv_phy_control |= 1758 1758 PHY_CH_POWER_DOWN_OVRD(mask, DPIO_PHY0, DPIO_CH1); 1759 1759 1760 - dev_priv->chv_phy_control |= PHY_COM_LANE_RESET_DEASSERT(DPIO_PHY0); 1760 + dev_priv->display.power.chv_phy_control |= PHY_COM_LANE_RESET_DEASSERT(DPIO_PHY0); 1761 1761 1762 - dev_priv->chv_phy_assert[DPIO_PHY0] = false; 1762 + dev_priv->display.power.chv_phy_assert[DPIO_PHY0] = false; 1763 1763 } else { 1764 - dev_priv->chv_phy_assert[DPIO_PHY0] = true; 1764 + dev_priv->display.power.chv_phy_assert[DPIO_PHY0] = true; 1765 1765 } 1766 1766 1767 1767 if (intel_power_well_is_enabled(dev_priv, cmn_d)) { ··· 1773 1773 if (mask == 0xf) 1774 1774 mask = 0x0; 1775 1775 else 1776 - dev_priv->chv_phy_control |= 1776 + dev_priv->display.power.chv_phy_control |= 1777 1777 PHY_CH_POWER_DOWN_OVRD_EN(DPIO_PHY1, DPIO_CH0); 1778 1778 1779 - dev_priv->chv_phy_control |= 1779 + dev_priv->display.power.chv_phy_control |= 1780 1780 PHY_CH_POWER_DOWN_OVRD(mask, DPIO_PHY1, DPIO_CH0); 1781 1781 1782 - dev_priv->chv_phy_control |= PHY_COM_LANE_RESET_DEASSERT(DPIO_PHY1); 1782 + dev_priv->display.power.chv_phy_control |= PHY_COM_LANE_RESET_DEASSERT(DPIO_PHY1); 1783 1783 1784 - dev_priv->chv_phy_assert[DPIO_PHY1] = false; 1784 + dev_priv->display.power.chv_phy_assert[DPIO_PHY1] = false; 1785 1785 } else { 1786 - dev_priv->chv_phy_assert[DPIO_PHY1] = true; 1786 + dev_priv->display.power.chv_phy_assert[DPIO_PHY1] = true; 1787 1787 } 1788 1788 1789 1789 drm_dbg_kms(&dev_priv->drm, "Initial PHY_CONTROL=0x%08x\n", 1790 - dev_priv->chv_phy_control); 1790 + dev_priv->display.power.chv_phy_control); 1791 1791 1792 1792 /* Defer application of initial phy_control to enabling the powerwell */ 1793 1793 } ··· 1871 1871 */ 1872 1872 void intel_power_domains_init_hw(struct drm_i915_private *i915, bool resume) 1873 1873 { 1874 - struct i915_power_domains *power_domains = &i915->power_domains; 1874 + struct i915_power_domains *power_domains = &i915->display.power.domains; 1875 1875 1876 1876 power_domains->initializing = true; 1877 1877 ··· 1912 1912 /* Disable power support if the user asked so. */ 1913 1913 if (!i915->params.disable_power_well) { 1914 1914 drm_WARN_ON(&i915->drm, power_domains->disable_wakeref); 1915 - i915->power_domains.disable_wakeref = intel_display_power_get(i915, 1916 - POWER_DOMAIN_INIT); 1915 + i915->display.power.domains.disable_wakeref = intel_display_power_get(i915, 1916 + POWER_DOMAIN_INIT); 1917 1917 } 1918 1918 intel_power_domains_sync_hw(i915); 1919 1919 ··· 1934 1934 void intel_power_domains_driver_remove(struct drm_i915_private *i915) 1935 1935 { 1936 1936 intel_wakeref_t wakeref __maybe_unused = 1937 - fetch_and_zero(&i915->power_domains.init_wakeref); 1937 + fetch_and_zero(&i915->display.power.domains.init_wakeref); 1938 1938 1939 1939 /* Remove the refcount we took to keep power well support disabled. */ 1940 1940 if (!i915->params.disable_power_well) 1941 1941 intel_display_power_put(i915, POWER_DOMAIN_INIT, 1942 - fetch_and_zero(&i915->power_domains.disable_wakeref)); 1942 + fetch_and_zero(&i915->display.power.domains.disable_wakeref)); 1943 1943 1944 1944 intel_display_power_flush_work_sync(i915); 1945 1945 ··· 1961 1961 */ 1962 1962 void intel_power_domains_sanitize_state(struct drm_i915_private *i915) 1963 1963 { 1964 - struct i915_power_domains *power_domains = &i915->power_domains; 1964 + struct i915_power_domains *power_domains = &i915->display.power.domains; 1965 1965 struct i915_power_well *power_well; 1966 1966 1967 1967 mutex_lock(&power_domains->lock); ··· 1995 1995 void intel_power_domains_enable(struct drm_i915_private *i915) 1996 1996 { 1997 1997 intel_wakeref_t wakeref __maybe_unused = 1998 - fetch_and_zero(&i915->power_domains.init_wakeref); 1998 + fetch_and_zero(&i915->display.power.domains.init_wakeref); 1999 1999 2000 2000 intel_display_power_put(i915, POWER_DOMAIN_INIT, wakeref); 2001 2001 intel_power_domains_verify_state(i915); ··· 2010 2010 */ 2011 2011 void intel_power_domains_disable(struct drm_i915_private *i915) 2012 2012 { 2013 - struct i915_power_domains *power_domains = &i915->power_domains; 2013 + struct i915_power_domains *power_domains = &i915->display.power.domains; 2014 2014 2015 2015 drm_WARN_ON(&i915->drm, power_domains->init_wakeref); 2016 2016 power_domains->init_wakeref = ··· 2033 2033 void intel_power_domains_suspend(struct drm_i915_private *i915, 2034 2034 enum i915_drm_suspend_mode suspend_mode) 2035 2035 { 2036 - struct i915_power_domains *power_domains = &i915->power_domains; 2036 + struct i915_power_domains *power_domains = &i915->display.power.domains; 2037 2037 intel_wakeref_t wakeref __maybe_unused = 2038 2038 fetch_and_zero(&power_domains->init_wakeref); 2039 2039 ··· 2060 2060 */ 2061 2061 if (!i915->params.disable_power_well) 2062 2062 intel_display_power_put(i915, POWER_DOMAIN_INIT, 2063 - fetch_and_zero(&i915->power_domains.disable_wakeref)); 2063 + fetch_and_zero(&i915->display.power.domains.disable_wakeref)); 2064 2064 2065 2065 intel_display_power_flush_work(i915); 2066 2066 intel_power_domains_verify_state(i915); ··· 2087 2087 */ 2088 2088 void intel_power_domains_resume(struct drm_i915_private *i915) 2089 2089 { 2090 - struct i915_power_domains *power_domains = &i915->power_domains; 2090 + struct i915_power_domains *power_domains = &i915->display.power.domains; 2091 2091 2092 2092 if (power_domains->display_core_suspended) { 2093 2093 intel_power_domains_init_hw(i915, true); ··· 2105 2105 2106 2106 static void intel_power_domains_dump_info(struct drm_i915_private *i915) 2107 2107 { 2108 - struct i915_power_domains *power_domains = &i915->power_domains; 2108 + struct i915_power_domains *power_domains = &i915->display.power.domains; 2109 2109 struct i915_power_well *power_well; 2110 2110 2111 2111 for_each_power_well(i915, power_well) { ··· 2133 2133 */ 2134 2134 static void intel_power_domains_verify_state(struct drm_i915_private *i915) 2135 2135 { 2136 - struct i915_power_domains *power_domains = &i915->power_domains; 2136 + struct i915_power_domains *power_domains = &i915->display.power.domains; 2137 2137 struct i915_power_well *power_well; 2138 2138 bool dump_domain_info; 2139 2139 ··· 2259 2259 2260 2260 void intel_display_power_debug(struct drm_i915_private *i915, struct seq_file *m) 2261 2261 { 2262 - struct i915_power_domains *power_domains = &i915->power_domains; 2262 + struct i915_power_domains *power_domains = &i915->display.power.domains; 2263 2263 int i; 2264 2264 2265 2265 mutex_lock(&power_domains->lock);
+116 -3
drivers/gpu/drm/i915/display/intel_display_power_map.c
··· 1350 1350 I915_PW_DESCRIPTORS(xelpd_power_wells_main), 1351 1351 }; 1352 1352 1353 + /* 1354 + * MTL is based on XELPD power domains with the exception of power gating for: 1355 + * - DDI_IO (moved to PLL logic) 1356 + * - AUX and AUX_IO functionality and register access for USBC1-4 (PICA always-on) 1357 + */ 1358 + #define XELPDP_PW_2_POWER_DOMAINS \ 1359 + XELPD_PW_B_POWER_DOMAINS, \ 1360 + XELPD_PW_C_POWER_DOMAINS, \ 1361 + XELPD_PW_D_POWER_DOMAINS, \ 1362 + POWER_DOMAIN_AUDIO_PLAYBACK, \ 1363 + POWER_DOMAIN_VGA, \ 1364 + POWER_DOMAIN_PORT_DDI_LANES_TC1, \ 1365 + POWER_DOMAIN_PORT_DDI_LANES_TC2, \ 1366 + POWER_DOMAIN_PORT_DDI_LANES_TC3, \ 1367 + POWER_DOMAIN_PORT_DDI_LANES_TC4 1368 + 1369 + I915_DECL_PW_DOMAINS(xelpdp_pwdoms_pw_2, 1370 + XELPDP_PW_2_POWER_DOMAINS, 1371 + POWER_DOMAIN_INIT); 1372 + 1373 + I915_DECL_PW_DOMAINS(xelpdp_pwdoms_dc_off, 1374 + XELPDP_PW_2_POWER_DOMAINS, 1375 + POWER_DOMAIN_AUDIO_MMIO, 1376 + POWER_DOMAIN_MODESET, 1377 + POWER_DOMAIN_AUX_A, 1378 + POWER_DOMAIN_AUX_B, 1379 + POWER_DOMAIN_INIT); 1380 + 1381 + I915_DECL_PW_DOMAINS(xelpdp_pwdoms_aux_tc1, 1382 + POWER_DOMAIN_AUX_USBC1, 1383 + POWER_DOMAIN_AUX_TBT1); 1384 + 1385 + I915_DECL_PW_DOMAINS(xelpdp_pwdoms_aux_tc2, 1386 + POWER_DOMAIN_AUX_USBC2, 1387 + POWER_DOMAIN_AUX_TBT2); 1388 + 1389 + I915_DECL_PW_DOMAINS(xelpdp_pwdoms_aux_tc3, 1390 + POWER_DOMAIN_AUX_USBC3, 1391 + POWER_DOMAIN_AUX_TBT3); 1392 + 1393 + I915_DECL_PW_DOMAINS(xelpdp_pwdoms_aux_tc4, 1394 + POWER_DOMAIN_AUX_USBC4, 1395 + POWER_DOMAIN_AUX_TBT4); 1396 + 1397 + static const struct i915_power_well_desc xelpdp_power_wells_main[] = { 1398 + { 1399 + .instances = &I915_PW_INSTANCES( 1400 + I915_PW("DC_off", &xelpdp_pwdoms_dc_off, 1401 + .id = SKL_DISP_DC_OFF), 1402 + ), 1403 + .ops = &gen9_dc_off_power_well_ops, 1404 + }, { 1405 + .instances = &I915_PW_INSTANCES( 1406 + I915_PW("PW_2", &xelpdp_pwdoms_pw_2, 1407 + .hsw.idx = ICL_PW_CTL_IDX_PW_2, 1408 + .id = SKL_DISP_PW_2), 1409 + ), 1410 + .ops = &hsw_power_well_ops, 1411 + .has_vga = true, 1412 + .has_fuses = true, 1413 + }, { 1414 + .instances = &I915_PW_INSTANCES( 1415 + I915_PW("PW_A", &xelpd_pwdoms_pw_a, 1416 + .hsw.idx = XELPD_PW_CTL_IDX_PW_A), 1417 + ), 1418 + .ops = &hsw_power_well_ops, 1419 + .irq_pipe_mask = BIT(PIPE_A), 1420 + .has_fuses = true, 1421 + }, { 1422 + .instances = &I915_PW_INSTANCES( 1423 + I915_PW("PW_B", &xelpd_pwdoms_pw_b, 1424 + .hsw.idx = XELPD_PW_CTL_IDX_PW_B), 1425 + ), 1426 + .ops = &hsw_power_well_ops, 1427 + .irq_pipe_mask = BIT(PIPE_B), 1428 + .has_fuses = true, 1429 + }, { 1430 + .instances = &I915_PW_INSTANCES( 1431 + I915_PW("PW_C", &xelpd_pwdoms_pw_c, 1432 + .hsw.idx = XELPD_PW_CTL_IDX_PW_C), 1433 + ), 1434 + .ops = &hsw_power_well_ops, 1435 + .irq_pipe_mask = BIT(PIPE_C), 1436 + .has_fuses = true, 1437 + }, { 1438 + .instances = &I915_PW_INSTANCES( 1439 + I915_PW("PW_D", &xelpd_pwdoms_pw_d, 1440 + .hsw.idx = XELPD_PW_CTL_IDX_PW_D), 1441 + ), 1442 + .ops = &hsw_power_well_ops, 1443 + .irq_pipe_mask = BIT(PIPE_D), 1444 + .has_fuses = true, 1445 + }, { 1446 + .instances = &I915_PW_INSTANCES( 1447 + I915_PW("AUX_A", &icl_pwdoms_aux_a, .xelpdp.aux_ch = AUX_CH_A), 1448 + I915_PW("AUX_B", &icl_pwdoms_aux_b, .xelpdp.aux_ch = AUX_CH_B), 1449 + I915_PW("AUX_TC1", &xelpdp_pwdoms_aux_tc1, .xelpdp.aux_ch = AUX_CH_USBC1), 1450 + I915_PW("AUX_TC2", &xelpdp_pwdoms_aux_tc2, .xelpdp.aux_ch = AUX_CH_USBC2), 1451 + I915_PW("AUX_TC3", &xelpdp_pwdoms_aux_tc3, .xelpdp.aux_ch = AUX_CH_USBC3), 1452 + I915_PW("AUX_TC4", &xelpdp_pwdoms_aux_tc4, .xelpdp.aux_ch = AUX_CH_USBC4), 1453 + ), 1454 + .ops = &xelpdp_aux_power_well_ops, 1455 + }, 1456 + }; 1457 + 1458 + static const struct i915_power_well_desc_list xelpdp_power_wells[] = { 1459 + I915_PW_DESCRIPTORS(i9xx_power_wells_always_on), 1460 + I915_PW_DESCRIPTORS(icl_power_wells_pw_1), 1461 + I915_PW_DESCRIPTORS(xelpdp_power_wells_main), 1462 + }; 1463 + 1353 1464 static void init_power_well_domains(const struct i915_power_well_instance *inst, 1354 1465 struct i915_power_well *power_well) 1355 1466 { ··· 1499 1388 { 1500 1389 struct drm_i915_private *i915 = container_of(power_domains, 1501 1390 struct drm_i915_private, 1502 - power_domains); 1391 + display.power.domains); 1503 1392 u64 power_well_ids = 0; 1504 1393 const struct i915_power_well_desc_list *desc_list; 1505 1394 const struct i915_power_well_desc *desc; ··· 1558 1447 { 1559 1448 struct drm_i915_private *i915 = container_of(power_domains, 1560 1449 struct drm_i915_private, 1561 - power_domains); 1450 + display.power.domains); 1562 1451 /* 1563 1452 * The enabling order will be from lower to higher indexed wells, 1564 1453 * the disabling order is reversed. ··· 1568 1457 return 0; 1569 1458 } 1570 1459 1571 - if (DISPLAY_VER(i915) >= 13) 1460 + if (DISPLAY_VER(i915) >= 14) 1461 + return set_power_wells(power_domains, xelpdp_power_wells); 1462 + else if (DISPLAY_VER(i915) >= 13) 1572 1463 return set_power_wells(power_domains, xelpd_power_wells); 1573 1464 else if (IS_DG1(i915)) 1574 1465 return set_power_wells(power_domains, dg1_power_wells);
+77 -33
drivers/gpu/drm/i915/display/intel_display_power_well.c
··· 17 17 #include "intel_dpll.h" 18 18 #include "intel_hotplug.h" 19 19 #include "intel_pcode.h" 20 - #include "intel_pm.h" 21 20 #include "intel_pps.h" 22 21 #include "intel_tc.h" 23 22 #include "intel_vga.h" 23 + #include "skl_watermark.h" 24 24 #include "vlv_sideband.h" 25 25 #include "vlv_sideband_reg.h" 26 26 ··· 85 85 drm_WARN(&i915->drm, 1, 86 86 "Power well %d not defined for this platform\n", 87 87 power_well_id); 88 - return &i915->power_domains.power_wells[0]; 88 + return &i915->display.power.domains.power_wells[0]; 89 89 } 90 90 91 91 void intel_power_well_enable(struct drm_i915_private *i915, ··· 946 946 static void gen9_assert_dbuf_enabled(struct drm_i915_private *dev_priv) 947 947 { 948 948 u8 hw_enabled_dbuf_slices = intel_enabled_dbuf_slices_mask(dev_priv); 949 - u8 enabled_dbuf_slices = dev_priv->dbuf.enabled_slices; 949 + u8 enabled_dbuf_slices = dev_priv->display.dbuf.enabled_slices; 950 950 951 951 drm_WARN(&dev_priv->drm, 952 952 hw_enabled_dbuf_slices != enabled_dbuf_slices, ··· 972 972 intel_cdclk_get_cdclk(dev_priv, &cdclk_config); 973 973 /* Can't read out voltage_level so can't use intel_cdclk_changed() */ 974 974 drm_WARN_ON(&dev_priv->drm, 975 - intel_cdclk_needs_modeset(&dev_priv->cdclk.hw, 975 + intel_cdclk_needs_modeset(&dev_priv->display.cdclk.hw, 976 976 &cdclk_config)); 977 977 978 978 gen9_assert_dbuf_enabled(dev_priv); ··· 1157 1157 * (and never recovering) in this case. intel_dsi_post_disable() will 1158 1158 * clear it when we turn off the display. 1159 1159 */ 1160 - val = intel_de_read(dev_priv, DSPCLK_GATE_D); 1160 + val = intel_de_read(dev_priv, DSPCLK_GATE_D(dev_priv)); 1161 1161 val &= DPOUNIT_CLOCK_GATE_DISABLE; 1162 1162 val |= VRHUNIT_CLOCK_GATE_DISABLE; 1163 - intel_de_write(dev_priv, DSPCLK_GATE_D, val); 1163 + intel_de_write(dev_priv, DSPCLK_GATE_D(dev_priv), val); 1164 1164 1165 1165 /* 1166 1166 * Disable trickle feed and enable pnd deadline calculation ··· 1208 1208 * During driver initialization/resume we can avoid restoring the 1209 1209 * part of the HW/SW state that will be inited anyway explicitly. 1210 1210 */ 1211 - if (dev_priv->power_domains.initializing) 1211 + if (dev_priv->display.power.domains.initializing) 1212 1212 return; 1213 1213 1214 1214 intel_hpd_init(dev_priv); ··· 1303 1303 lookup_power_well(dev_priv, VLV_DISP_PW_DPIO_CMN_BC); 1304 1304 struct i915_power_well *cmn_d = 1305 1305 lookup_power_well(dev_priv, CHV_DISP_PW_DPIO_CMN_D); 1306 - u32 phy_control = dev_priv->chv_phy_control; 1306 + u32 phy_control = dev_priv->display.power.chv_phy_control; 1307 1307 u32 phy_status = 0; 1308 1308 u32 phy_status_mask = 0xffffffff; 1309 1309 ··· 1314 1314 * reset (ie. the power well has been disabled at 1315 1315 * least once). 1316 1316 */ 1317 - if (!dev_priv->chv_phy_assert[DPIO_PHY0]) 1317 + if (!dev_priv->display.power.chv_phy_assert[DPIO_PHY0]) 1318 1318 phy_status_mask &= ~(PHY_STATUS_CMN_LDO(DPIO_PHY0, DPIO_CH0) | 1319 1319 PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH0, 0) | 1320 1320 PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH0, 1) | ··· 1322 1322 PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH1, 0) | 1323 1323 PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH1, 1)); 1324 1324 1325 - if (!dev_priv->chv_phy_assert[DPIO_PHY1]) 1325 + if (!dev_priv->display.power.chv_phy_assert[DPIO_PHY1]) 1326 1326 phy_status_mask &= ~(PHY_STATUS_CMN_LDO(DPIO_PHY1, DPIO_CH0) | 1327 1327 PHY_STATUS_SPLINE_LDO(DPIO_PHY1, DPIO_CH0, 0) | 1328 1328 PHY_STATUS_SPLINE_LDO(DPIO_PHY1, DPIO_CH0, 1)); ··· 1398 1398 drm_err(&dev_priv->drm, 1399 1399 "Unexpected PHY_STATUS 0x%08x, expected 0x%08x (PHY_CONTROL=0x%08x)\n", 1400 1400 intel_de_read(dev_priv, DISPLAY_PHY_STATUS) & phy_status_mask, 1401 - phy_status, dev_priv->chv_phy_control); 1401 + phy_status, dev_priv->display.power.chv_phy_control); 1402 1402 } 1403 1403 1404 1404 #undef BITS_SET ··· 1458 1458 1459 1459 vlv_dpio_put(dev_priv); 1460 1460 1461 - dev_priv->chv_phy_control |= PHY_COM_LANE_RESET_DEASSERT(phy); 1461 + dev_priv->display.power.chv_phy_control |= PHY_COM_LANE_RESET_DEASSERT(phy); 1462 1462 intel_de_write(dev_priv, DISPLAY_PHY_CONTROL, 1463 - dev_priv->chv_phy_control); 1463 + dev_priv->display.power.chv_phy_control); 1464 1464 1465 1465 drm_dbg_kms(&dev_priv->drm, 1466 1466 "Enabled DPIO PHY%d (PHY_CONTROL=0x%08x)\n", 1467 - phy, dev_priv->chv_phy_control); 1467 + phy, dev_priv->display.power.chv_phy_control); 1468 1468 1469 1469 assert_chv_phy_status(dev_priv); 1470 1470 } ··· 1488 1488 assert_pll_disabled(dev_priv, PIPE_C); 1489 1489 } 1490 1490 1491 - dev_priv->chv_phy_control &= ~PHY_COM_LANE_RESET_DEASSERT(phy); 1491 + dev_priv->display.power.chv_phy_control &= ~PHY_COM_LANE_RESET_DEASSERT(phy); 1492 1492 intel_de_write(dev_priv, DISPLAY_PHY_CONTROL, 1493 - dev_priv->chv_phy_control); 1493 + dev_priv->display.power.chv_phy_control); 1494 1494 1495 1495 vlv_set_power_well(dev_priv, power_well, false); 1496 1496 1497 1497 drm_dbg_kms(&dev_priv->drm, 1498 1498 "Disabled DPIO PHY%d (PHY_CONTROL=0x%08x)\n", 1499 - phy, dev_priv->chv_phy_control); 1499 + phy, dev_priv->display.power.chv_phy_control); 1500 1500 1501 1501 /* PHY is fully reset now, so we can enable the PHY state asserts */ 1502 - dev_priv->chv_phy_assert[phy] = true; 1502 + dev_priv->display.power.chv_phy_assert[phy] = true; 1503 1503 1504 1504 assert_chv_phy_status(dev_priv); 1505 1505 } ··· 1517 1517 * reset (ie. the power well has been disabled at 1518 1518 * least once). 1519 1519 */ 1520 - if (!dev_priv->chv_phy_assert[phy]) 1520 + if (!dev_priv->display.power.chv_phy_assert[phy]) 1521 1521 return; 1522 1522 1523 1523 if (ch == DPIO_CH0) ··· 1571 1571 bool chv_phy_powergate_ch(struct drm_i915_private *dev_priv, enum dpio_phy phy, 1572 1572 enum dpio_channel ch, bool override) 1573 1573 { 1574 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1574 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1575 1575 bool was_override; 1576 1576 1577 1577 mutex_lock(&power_domains->lock); 1578 1578 1579 - was_override = dev_priv->chv_phy_control & PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1579 + was_override = dev_priv->display.power.chv_phy_control & PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1580 1580 1581 1581 if (override == was_override) 1582 1582 goto out; 1583 1583 1584 1584 if (override) 1585 - dev_priv->chv_phy_control |= PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1585 + dev_priv->display.power.chv_phy_control |= PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1586 1586 else 1587 - dev_priv->chv_phy_control &= ~PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1587 + dev_priv->display.power.chv_phy_control &= ~PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1588 1588 1589 1589 intel_de_write(dev_priv, DISPLAY_PHY_CONTROL, 1590 - dev_priv->chv_phy_control); 1590 + dev_priv->display.power.chv_phy_control); 1591 1591 1592 1592 drm_dbg_kms(&dev_priv->drm, 1593 1593 "Power gating DPIO PHY%d CH%d (DPIO_PHY_CONTROL=0x%08x)\n", 1594 - phy, ch, dev_priv->chv_phy_control); 1594 + phy, ch, dev_priv->display.power.chv_phy_control); 1595 1595 1596 1596 assert_chv_phy_status(dev_priv); 1597 1597 ··· 1605 1605 bool override, unsigned int mask) 1606 1606 { 1607 1607 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 1608 - struct i915_power_domains *power_domains = &dev_priv->power_domains; 1608 + struct i915_power_domains *power_domains = &dev_priv->display.power.domains; 1609 1609 enum dpio_phy phy = vlv_dig_port_to_phy(enc_to_dig_port(encoder)); 1610 1610 enum dpio_channel ch = vlv_dig_port_to_channel(enc_to_dig_port(encoder)); 1611 1611 1612 1612 mutex_lock(&power_domains->lock); 1613 1613 1614 - dev_priv->chv_phy_control &= ~PHY_CH_POWER_DOWN_OVRD(0xf, phy, ch); 1615 - dev_priv->chv_phy_control |= PHY_CH_POWER_DOWN_OVRD(mask, phy, ch); 1614 + dev_priv->display.power.chv_phy_control &= ~PHY_CH_POWER_DOWN_OVRD(0xf, phy, ch); 1615 + dev_priv->display.power.chv_phy_control |= PHY_CH_POWER_DOWN_OVRD(mask, phy, ch); 1616 1616 1617 1617 if (override) 1618 - dev_priv->chv_phy_control |= PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1618 + dev_priv->display.power.chv_phy_control |= PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1619 1619 else 1620 - dev_priv->chv_phy_control &= ~PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1620 + dev_priv->display.power.chv_phy_control &= ~PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); 1621 1621 1622 1622 intel_de_write(dev_priv, DISPLAY_PHY_CONTROL, 1623 - dev_priv->chv_phy_control); 1623 + dev_priv->display.power.chv_phy_control); 1624 1624 1625 1625 drm_dbg_kms(&dev_priv->drm, 1626 1626 "Power gating DPIO PHY%d CH%d lanes 0x%x (PHY_CONTROL=0x%08x)\n", 1627 - phy, ch, mask, dev_priv->chv_phy_control); 1627 + phy, ch, mask, dev_priv->display.power.chv_phy_control); 1628 1628 1629 1629 assert_chv_phy_status(dev_priv); 1630 1630 ··· 1702 1702 struct i915_power_well *power_well) 1703 1703 { 1704 1704 intel_de_write(dev_priv, DISPLAY_PHY_CONTROL, 1705 - dev_priv->chv_phy_control); 1705 + dev_priv->display.power.chv_phy_control); 1706 1706 } 1707 1707 1708 1708 static void chv_pipe_power_well_enable(struct drm_i915_private *dev_priv, ··· 1798 1798 return intel_power_well_refcount(power_well); 1799 1799 } 1800 1800 1801 + static void xelpdp_aux_power_well_enable(struct drm_i915_private *dev_priv, 1802 + struct i915_power_well *power_well) 1803 + { 1804 + enum aux_ch aux_ch = i915_power_well_instance(power_well)->xelpdp.aux_ch; 1805 + 1806 + intel_de_rmw(dev_priv, XELPDP_DP_AUX_CH_CTL(aux_ch), 1807 + XELPDP_DP_AUX_CH_CTL_POWER_REQUEST, 1808 + XELPDP_DP_AUX_CH_CTL_POWER_REQUEST); 1809 + 1810 + /* 1811 + * The power status flag cannot be used to determine whether aux 1812 + * power wells have finished powering up. Instead we're 1813 + * expected to just wait a fixed 600us after raising the request 1814 + * bit. 1815 + */ 1816 + usleep_range(600, 1200); 1817 + } 1818 + 1819 + static void xelpdp_aux_power_well_disable(struct drm_i915_private *dev_priv, 1820 + struct i915_power_well *power_well) 1821 + { 1822 + enum aux_ch aux_ch = i915_power_well_instance(power_well)->xelpdp.aux_ch; 1823 + 1824 + intel_de_rmw(dev_priv, XELPDP_DP_AUX_CH_CTL(aux_ch), 1825 + XELPDP_DP_AUX_CH_CTL_POWER_REQUEST, 1826 + 0); 1827 + usleep_range(10, 30); 1828 + } 1829 + 1830 + static bool xelpdp_aux_power_well_enabled(struct drm_i915_private *dev_priv, 1831 + struct i915_power_well *power_well) 1832 + { 1833 + enum aux_ch aux_ch = i915_power_well_instance(power_well)->xelpdp.aux_ch; 1834 + 1835 + return intel_de_read(dev_priv, XELPDP_DP_AUX_CH_CTL(aux_ch)) & 1836 + XELPDP_DP_AUX_CH_CTL_POWER_STATUS; 1837 + } 1801 1838 1802 1839 const struct i915_power_well_ops i9xx_always_on_power_well_ops = { 1803 1840 .sync_hw = i9xx_power_well_sync_hw_noop, ··· 1947 1910 .enable = tgl_tc_cold_off_power_well_enable, 1948 1911 .disable = tgl_tc_cold_off_power_well_disable, 1949 1912 .is_enabled = tgl_tc_cold_off_power_well_is_enabled, 1913 + }; 1914 + 1915 + const struct i915_power_well_ops xelpdp_aux_power_well_ops = { 1916 + .sync_hw = i9xx_power_well_sync_hw_noop, 1917 + .enable = xelpdp_aux_power_well_enable, 1918 + .disable = xelpdp_aux_power_well_disable, 1919 + .is_enabled = xelpdp_aux_power_well_enabled, 1950 1920 };
+10 -6
drivers/gpu/drm/i915/display/intel_display_power_well.h
··· 14 14 struct i915_power_well; 15 15 16 16 #define for_each_power_well(__dev_priv, __power_well) \ 17 - for ((__power_well) = (__dev_priv)->power_domains.power_wells; \ 18 - (__power_well) - (__dev_priv)->power_domains.power_wells < \ 19 - (__dev_priv)->power_domains.power_well_count; \ 17 + for ((__power_well) = (__dev_priv)->display.power.domains.power_wells; \ 18 + (__power_well) - (__dev_priv)->display.power.domains.power_wells < \ 19 + (__dev_priv)->display.power.domains.power_well_count; \ 20 20 (__power_well)++) 21 21 22 22 #define for_each_power_well_reverse(__dev_priv, __power_well) \ 23 - for ((__power_well) = (__dev_priv)->power_domains.power_wells + \ 24 - (__dev_priv)->power_domains.power_well_count - 1; \ 25 - (__power_well) - (__dev_priv)->power_domains.power_wells >= 0; \ 23 + for ((__power_well) = (__dev_priv)->display.power.domains.power_wells + \ 24 + (__dev_priv)->display.power.domains.power_well_count - 1; \ 25 + (__power_well) - (__dev_priv)->display.power.domains.power_wells >= 0; \ 26 26 (__power_well)--) 27 27 28 28 /* ··· 80 80 */ 81 81 u8 idx; 82 82 } hsw; 83 + struct { 84 + u8 aux_ch; 85 + } xelpdp; 83 86 }; 84 87 }; 85 88 ··· 172 169 extern const struct i915_power_well_ops icl_aux_power_well_ops; 173 170 extern const struct i915_power_well_ops icl_ddi_power_well_ops; 174 171 extern const struct i915_power_well_ops tgl_tc_cold_off_ops; 172 + extern const struct i915_power_well_ops xelpdp_aux_power_well_ops; 175 173 176 174 #endif
+2 -1
drivers/gpu/drm/i915/display/intel_display_types.h
··· 1130 1130 /* m2_n2 for eDP downclock */ 1131 1131 struct intel_link_m_n dp_m2_n2; 1132 1132 bool has_drrs; 1133 + bool seamless_m_n; 1133 1134 1134 1135 /* PSR is supported but might not be enabled due the lack of enabled planes */ 1135 1136 bool has_psr; ··· 1713 1712 1714 1713 /* Display stream compression testing */ 1715 1714 bool force_dsc_en; 1716 - int force_dsc_bpp; 1715 + int force_dsc_bpc; 1717 1716 1718 1717 bool hobl_failed; 1719 1718 bool hobl_active;
+61 -62
drivers/gpu/drm/i915/display/intel_dp.c
··· 286 286 return intel_dp_common_rate(intel_dp, intel_dp->num_common_rates - 1); 287 287 } 288 288 289 + static int intel_dp_max_source_lane_count(struct intel_digital_port *dig_port) 290 + { 291 + int vbt_max_lanes = intel_bios_dp_max_lane_count(&dig_port->base); 292 + int max_lanes = dig_port->max_lanes; 293 + 294 + if (vbt_max_lanes) 295 + max_lanes = min(max_lanes, vbt_max_lanes); 296 + 297 + return max_lanes; 298 + } 299 + 289 300 /* Theoretical max between source and sink */ 290 301 static int intel_dp_max_common_lane_count(struct intel_dp *intel_dp) 291 302 { 292 303 struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); 293 - int source_max = dig_port->max_lanes; 304 + int source_max = intel_dp_max_source_lane_count(dig_port); 294 305 int sink_max = intel_dp->max_sink_lane_count; 295 306 int fia_max = intel_tc_port_fia_max_lane_count(dig_port); 296 307 int lttpr_max = drm_dp_lttpr_max_lane_count(intel_dp->lttpr_common_caps); ··· 400 389 return intel_dp_is_edp(intel_dp) ? 810000 : 1350000; 401 390 } 402 391 403 - static bool is_low_voltage_sku(struct drm_i915_private *i915, enum phy phy) 404 - { 405 - u32 voltage; 406 - 407 - voltage = intel_de_read(i915, ICL_PORT_COMP_DW3(phy)) & VOLTAGE_INFO_MASK; 408 - 409 - return voltage == VOLTAGE_INFO_0_85V; 410 - } 411 - 412 392 static int icl_max_source_rate(struct intel_dp *intel_dp) 413 393 { 414 394 struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); 415 395 struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev); 416 396 enum phy phy = intel_port_to_phy(dev_priv, dig_port->base.port); 417 397 418 - if (intel_phy_is_combo(dev_priv, phy) && 419 - (is_low_voltage_sku(dev_priv, phy) || !intel_dp_is_edp(intel_dp))) 398 + if (intel_phy_is_combo(dev_priv, phy) && !intel_dp_is_edp(intel_dp)) 420 399 return 540000; 421 400 422 401 return 810000; ··· 414 413 415 414 static int ehl_max_source_rate(struct intel_dp *intel_dp) 416 415 { 417 - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); 418 - struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev); 419 - enum phy phy = intel_port_to_phy(dev_priv, dig_port->base.port); 420 - 421 - if (intel_dp_is_edp(intel_dp) || is_low_voltage_sku(dev_priv, phy)) 422 - return 540000; 423 - 424 - return 810000; 425 - } 426 - 427 - static int dg1_max_source_rate(struct intel_dp *intel_dp) 428 - { 429 - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); 430 - struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev); 431 - enum phy phy = intel_port_to_phy(i915, dig_port->base.port); 432 - 433 - if (intel_phy_is_combo(i915, phy) && is_low_voltage_sku(i915, phy)) 416 + if (intel_dp_is_edp(intel_dp)) 434 417 return 540000; 435 418 436 419 return 810000; ··· 476 491 max_rate = dg2_max_source_rate(intel_dp); 477 492 else if (IS_ALDERLAKE_P(dev_priv) || IS_ALDERLAKE_S(dev_priv) || 478 493 IS_DG1(dev_priv) || IS_ROCKETLAKE(dev_priv)) 479 - max_rate = dg1_max_source_rate(intel_dp); 494 + max_rate = 810000; 480 495 else if (IS_JSL_EHL(dev_priv)) 481 496 max_rate = ehl_max_source_rate(intel_dp); 482 497 else ··· 705 720 706 721 if (bigjoiner) { 707 722 u32 max_bpp_bigjoiner = 708 - i915->max_cdclk_freq * 48 / 723 + i915->display.cdclk.max_cdclk_freq * 48 / 709 724 intel_dp_mode_to_fec_clock(mode_clock); 710 725 711 726 bits_per_pixel = min(bits_per_pixel, max_bpp_bigjoiner); ··· 1297 1312 } 1298 1313 } 1299 1314 1315 + static bool has_seamless_m_n(struct intel_connector *connector) 1316 + { 1317 + struct drm_i915_private *i915 = to_i915(connector->base.dev); 1318 + 1319 + /* 1320 + * Seamless M/N reprogramming only implemented 1321 + * for BDW+ double buffered M/N registers so far. 1322 + */ 1323 + return HAS_DOUBLE_BUFFERED_M_N(i915) && 1324 + intel_panel_drrs_type(connector) == DRRS_TYPE_SEAMLESS; 1325 + } 1326 + 1327 + static int intel_dp_mode_clock(const struct intel_crtc_state *crtc_state, 1328 + const struct drm_connector_state *conn_state) 1329 + { 1330 + struct intel_connector *connector = to_intel_connector(conn_state->connector); 1331 + const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; 1332 + 1333 + /* FIXME a bit of a mess wrt clock vs. crtc_clock */ 1334 + if (has_seamless_m_n(connector)) 1335 + return intel_panel_highest_mode(connector, adjusted_mode)->clock; 1336 + else 1337 + return adjusted_mode->crtc_clock; 1338 + } 1339 + 1300 1340 /* Optimize link config in order: max bpp, min clock, min lanes */ 1301 1341 static int 1302 1342 intel_dp_compute_link_config_wide(struct intel_dp *intel_dp, 1303 1343 struct intel_crtc_state *pipe_config, 1344 + const struct drm_connector_state *conn_state, 1304 1345 const struct link_config_limits *limits) 1305 1346 { 1306 - struct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode; 1307 - int bpp, i, lane_count; 1347 + int bpp, i, lane_count, clock = intel_dp_mode_clock(pipe_config, conn_state); 1308 1348 int mode_rate, link_rate, link_avail; 1309 1349 1310 1350 for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -= 2 * 3) { 1311 1351 int output_bpp = intel_dp_output_bpp(pipe_config->output_format, bpp); 1312 1352 1313 - mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock, 1314 - output_bpp); 1353 + mode_rate = intel_dp_link_required(clock, output_bpp); 1315 1354 1316 1355 for (i = 0; i < intel_dp->num_common_rates; i++) { 1317 1356 link_rate = intel_dp_common_rate(intel_dp, i); ··· 1415 1406 * DP_DSC_RC_BUF_SIZE for this. 1416 1407 */ 1417 1408 vdsc_cfg->rc_model_size = DSC_RC_MODEL_SIZE_CONST; 1409 + vdsc_cfg->pic_height = crtc_state->hw.adjusted_mode.crtc_vdisplay; 1418 1410 1419 1411 /* 1420 1412 * Slice Height of 8 works for all currently available panels. So start ··· 1484 1474 1485 1475 pipe_bpp = intel_dp_dsc_compute_bpp(intel_dp, conn_state->max_requested_bpc); 1486 1476 1477 + if (intel_dp->force_dsc_bpc) { 1478 + pipe_bpp = intel_dp->force_dsc_bpc * 3; 1479 + drm_dbg_kms(&dev_priv->drm, "Input DSC BPP forced to %d", pipe_bpp); 1480 + } 1481 + 1487 1482 /* Min Input BPC for ICL+ is 8 */ 1488 1483 if (pipe_bpp < 8 * 3) { 1489 1484 drm_dbg_kms(&dev_priv->drm, ··· 1540 1525 pipe_config->dsc.slice_count = dsc_dp_slice_count; 1541 1526 } 1542 1527 1543 - /* As of today we support DSC for only RGB */ 1544 - if (intel_dp->force_dsc_bpp) { 1545 - if (intel_dp->force_dsc_bpp >= 8 && 1546 - intel_dp->force_dsc_bpp < pipe_bpp) { 1547 - drm_dbg_kms(&dev_priv->drm, 1548 - "DSC BPP forced to %d", 1549 - intel_dp->force_dsc_bpp); 1550 - pipe_config->dsc.compressed_bpp = 1551 - intel_dp->force_dsc_bpp; 1552 - } else { 1553 - drm_dbg_kms(&dev_priv->drm, 1554 - "Invalid DSC BPP %d", 1555 - intel_dp->force_dsc_bpp); 1556 - } 1557 - } 1558 - 1559 1528 /* 1560 1529 * VDSC engine operates at 1 Pixel per clock, so if peak pixel rate 1561 1530 * is greater than the maximum Cdclock and if slice count is even 1562 1531 * then we need to use 2 VDSC instances. 1563 1532 */ 1564 - if (adjusted_mode->crtc_clock > dev_priv->max_cdclk_freq || 1533 + if (adjusted_mode->crtc_clock > dev_priv->display.cdclk.max_cdclk_freq || 1565 1534 pipe_config->bigjoiner_pipes) { 1566 1535 if (pipe_config->dsc.slice_count < 2) { 1567 1536 drm_dbg_kms(&dev_priv->drm, ··· 1635 1636 * Optimize for slow and wide for everything, because there are some 1636 1637 * eDP 1.3 and 1.4 panels don't work well with fast and narrow. 1637 1638 */ 1638 - ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config, &limits); 1639 + ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config, conn_state, &limits); 1639 1640 1640 1641 if (ret || joiner_needs_dsc || intel_dp->force_dsc_en) { 1641 1642 drm_dbg_kms(&i915->drm, "Try DSC (fallback=%s, joiner=%s, force=%s)\n", ··· 1878 1879 static bool cpu_transcoder_has_drrs(struct drm_i915_private *i915, 1879 1880 enum transcoder cpu_transcoder) 1880 1881 { 1881 - /* M1/N1 is double buffered */ 1882 - if (DISPLAY_VER(i915) >= 9 || IS_BROADWELL(i915)) 1882 + if (HAS_DOUBLE_BUFFERED_M_N(i915)) 1883 1883 return true; 1884 1884 1885 1885 return intel_cpu_transcoder_has_m2_n2(i915, cpu_transcoder); ··· 1916 1918 static void 1917 1919 intel_dp_drrs_compute_config(struct intel_connector *connector, 1918 1920 struct intel_crtc_state *pipe_config, 1919 - int output_bpp, bool constant_n) 1921 + int output_bpp) 1920 1922 { 1921 1923 struct drm_i915_private *i915 = to_i915(connector->base.dev); 1922 1924 const struct drm_display_mode *downclock_mode = 1923 1925 intel_panel_downclock_mode(connector, &pipe_config->hw.adjusted_mode); 1924 1926 int pixel_clock; 1927 + 1928 + if (has_seamless_m_n(connector)) 1929 + pipe_config->seamless_m_n = true; 1925 1930 1926 1931 if (!can_enable_drrs(connector, pipe_config, downclock_mode)) { 1927 1932 if (intel_cpu_transcoder_has_m2_n2(i915, pipe_config->cpu_transcoder)) ··· 1943 1942 1944 1943 intel_link_compute_m_n(output_bpp, pipe_config->lane_count, pixel_clock, 1945 1944 pipe_config->port_clock, &pipe_config->dp_m2_n2, 1946 - constant_n, pipe_config->fec_enable); 1945 + pipe_config->fec_enable); 1947 1946 1948 1947 /* FIXME: abstract this better */ 1949 1948 if (pipe_config->splitter.enable) ··· 2018 2017 struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 2019 2018 const struct drm_display_mode *fixed_mode; 2020 2019 struct intel_connector *connector = intel_dp->attached_connector; 2021 - bool constant_n = drm_dp_has_quirk(&intel_dp->desc, DP_DPCD_QUIRK_CONSTANT_N); 2022 2020 int ret = 0, output_bpp; 2023 2021 2024 2022 if (HAS_PCH_SPLIT(dev_priv) && !HAS_DDI(dev_priv) && encoder->port != PORT_A) ··· 2096 2096 adjusted_mode->crtc_clock, 2097 2097 pipe_config->port_clock, 2098 2098 &pipe_config->dp_m_n, 2099 - constant_n, pipe_config->fec_enable); 2099 + pipe_config->fec_enable); 2100 2100 2101 2101 /* FIXME: abstract this better */ 2102 2102 if (pipe_config->splitter.enable) ··· 2107 2107 2108 2108 intel_vrr_compute_config(pipe_config, conn_state); 2109 2109 intel_psr_compute_config(intel_dp, pipe_config, conn_state); 2110 - intel_dp_drrs_compute_config(connector, pipe_config, 2111 - output_bpp, constant_n); 2110 + intel_dp_drrs_compute_config(connector, pipe_config, output_bpp); 2112 2111 intel_dp_compute_vsc_sdp(intel_dp, pipe_config, conn_state); 2113 2112 intel_dp_compute_hdr_metadata_infoframe_sdp(intel_dp, pipe_config, conn_state); 2114 2113 ··· 5201 5202 return; 5202 5203 5203 5204 drm_connector_set_panel_orientation_with_quirk(&connector->base, 5204 - i915->vbt.orientation, 5205 + i915->display.vbt.orientation, 5205 5206 fixed_mode->hdisplay, 5206 5207 fixed_mode->vdisplay); 5207 5208 }
+53 -2
drivers/gpu/drm/i915/display/intel_dp_aux.c
··· 86 86 * divide by 2000 and use that 87 87 */ 88 88 if (dig_port->aux_ch == AUX_CH_A) 89 - freq = dev_priv->cdclk.hw.cdclk; 89 + freq = dev_priv->display.cdclk.hw.cdclk; 90 90 else 91 91 freq = RUNTIME_INFO(dev_priv)->rawclk_freq; 92 92 return DIV_ROUND_CLOSEST(freq, 2000); ··· 150 150 u32 unused) 151 151 { 152 152 struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); 153 + struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev); 153 154 u32 ret; 154 155 155 156 /* ··· 170 169 171 170 if (intel_tc_port_in_tbt_alt_mode(dig_port)) 172 171 ret |= DP_AUX_CH_CTL_TBT_IO; 172 + 173 + /* 174 + * Power request bit is already set during aux power well enable. 175 + * Preserve the bit across aux transactions. 176 + */ 177 + if (DISPLAY_VER(i915) >= 14) 178 + ret |= XELPDP_DP_AUX_CH_CTL_POWER_REQUEST; 173 179 174 180 return ret; 175 181 } ··· 637 629 } 638 630 } 639 631 632 + static i915_reg_t xelpdp_aux_ctl_reg(struct intel_dp *intel_dp) 633 + { 634 + struct drm_i915_private *dev_priv = dp_to_i915(intel_dp); 635 + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); 636 + enum aux_ch aux_ch = dig_port->aux_ch; 637 + 638 + switch (aux_ch) { 639 + case AUX_CH_A: 640 + case AUX_CH_B: 641 + case AUX_CH_USBC1: 642 + case AUX_CH_USBC2: 643 + case AUX_CH_USBC3: 644 + case AUX_CH_USBC4: 645 + return XELPDP_DP_AUX_CH_CTL(aux_ch); 646 + default: 647 + MISSING_CASE(aux_ch); 648 + return XELPDP_DP_AUX_CH_CTL(AUX_CH_A); 649 + } 650 + } 651 + 652 + static i915_reg_t xelpdp_aux_data_reg(struct intel_dp *intel_dp, int index) 653 + { 654 + struct drm_i915_private *dev_priv = dp_to_i915(intel_dp); 655 + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); 656 + enum aux_ch aux_ch = dig_port->aux_ch; 657 + 658 + switch (aux_ch) { 659 + case AUX_CH_A: 660 + case AUX_CH_B: 661 + case AUX_CH_USBC1: 662 + case AUX_CH_USBC2: 663 + case AUX_CH_USBC3: 664 + case AUX_CH_USBC4: 665 + return XELPDP_DP_AUX_CH_DATA(aux_ch, index); 666 + default: 667 + MISSING_CASE(aux_ch); 668 + return XELPDP_DP_AUX_CH_DATA(AUX_CH_A, index); 669 + } 670 + } 671 + 640 672 void intel_dp_aux_fini(struct intel_dp *intel_dp) 641 673 { 642 674 if (cpu_latency_qos_request_active(&intel_dp->pm_qos)) ··· 692 644 struct intel_encoder *encoder = &dig_port->base; 693 645 enum aux_ch aux_ch = dig_port->aux_ch; 694 646 695 - if (DISPLAY_VER(dev_priv) >= 12) { 647 + if (DISPLAY_VER(dev_priv) >= 14) { 648 + intel_dp->aux_ch_ctl_reg = xelpdp_aux_ctl_reg; 649 + intel_dp->aux_ch_data_reg = xelpdp_aux_data_reg; 650 + } else if (DISPLAY_VER(dev_priv) >= 12) { 696 651 intel_dp->aux_ch_ctl_reg = tgl_aux_ctl_reg; 697 652 intel_dp->aux_ch_data_reg = tgl_aux_data_reg; 698 653 } else if (DISPLAY_VER(dev_priv) >= 9) {
+5 -3
drivers/gpu/drm/i915/display/intel_dp_mst.c
··· 58 58 struct drm_i915_private *i915 = to_i915(connector->base.dev); 59 59 const struct drm_display_mode *adjusted_mode = 60 60 &crtc_state->hw.adjusted_mode; 61 - bool constant_n = drm_dp_has_quirk(&intel_dp->desc, DP_DPCD_QUIRK_CONSTANT_N); 62 61 int bpp, slots = -EINVAL; 63 62 64 63 mst_state = drm_atomic_get_mst_topology_state(state, &intel_dp->mst_mgr); ··· 99 100 adjusted_mode->crtc_clock, 100 101 crtc_state->port_clock, 101 102 &crtc_state->dp_m_n, 102 - constant_n, crtc_state->fec_enable); 103 + crtc_state->fec_enable); 103 104 crtc_state->dp_m_n.tu = slots; 104 105 105 106 return 0; ··· 565 566 drm_dp_add_payload_part2(&intel_dp->mst_mgr, &state->base, 566 567 drm_atomic_get_mst_payload_state(mst_state, connector->port)); 567 568 568 - if (DISPLAY_VER(dev_priv) >= 12 && pipe_config->fec_enable) 569 + if (DISPLAY_VER(dev_priv) >= 14 && pipe_config->fec_enable) 570 + intel_de_rmw(dev_priv, MTL_CHICKEN_TRANS(trans), 0, 571 + FECSTALL_DIS_DPTSTREAM_DPTTG); 572 + else if (DISPLAY_VER(dev_priv) >= 12 && pipe_config->fec_enable) 569 573 intel_de_rmw(dev_priv, CHICKEN_TRANS(trans), 0, 570 574 FECSTALL_DIS_DPTSTREAM_DPTTG); 571 575
+1 -1
drivers/gpu/drm/i915/display/intel_dpio_phy.c
··· 484 484 enum dpio_phy rcomp_phy = phy_info->rcomp_phy; 485 485 bool was_enabled; 486 486 487 - lockdep_assert_held(&dev_priv->power_domains.lock); 487 + lockdep_assert_held(&dev_priv->display.power.domains.lock); 488 488 489 489 was_enabled = true; 490 490 if (rcomp_phy != -1)
+70 -17
drivers/gpu/drm/i915/display/intel_dpll.c
··· 938 938 intel_atomic_get_new_crtc_state(state, crtc); 939 939 struct intel_encoder *encoder = 940 940 intel_get_crtc_new_encoder(state, crtc_state); 941 + int ret; 941 942 942 943 if (DISPLAY_VER(dev_priv) < 11 && 943 944 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI)) 944 945 return 0; 945 946 946 - return intel_compute_shared_dplls(state, crtc, encoder); 947 + ret = intel_compute_shared_dplls(state, crtc, encoder); 948 + if (ret) 949 + return ret; 950 + 951 + /* FIXME this is a mess */ 952 + if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI)) 953 + return 0; 954 + 955 + /* CRT dotclock is determined via other means */ 956 + if (!crtc_state->has_pch_encoder) 957 + crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state); 958 + 959 + return 0; 947 960 } 948 961 949 962 static int hsw_crtc_get_shared_dpll(struct intel_atomic_state *state, ··· 982 969 intel_atomic_get_new_crtc_state(state, crtc); 983 970 struct intel_encoder *encoder = 984 971 intel_get_crtc_new_encoder(state, crtc_state); 972 + int ret; 985 973 986 - return intel_mpllb_calc_state(crtc_state, encoder); 974 + ret = intel_mpllb_calc_state(crtc_state, encoder); 975 + if (ret) 976 + return ret; 977 + 978 + crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state); 979 + 980 + return 0; 987 981 } 988 982 989 983 static bool ilk_needs_fb_cb_tune(const struct dpll *dpll, int factor) ··· 1011 991 factor = 21; 1012 992 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) { 1013 993 if ((intel_panel_use_ssc(dev_priv) && 1014 - dev_priv->vbt.lvds_ssc_freq == 100000) || 994 + dev_priv->display.vbt.lvds_ssc_freq == 100000) || 1015 995 (HAS_PCH_IBX(dev_priv) && 1016 996 intel_is_dual_link_lvds(dev_priv))) 1017 997 factor = 25; ··· 1116 1096 intel_atomic_get_new_crtc_state(state, crtc); 1117 1097 const struct intel_limit *limit; 1118 1098 int refclk = 120000; 1099 + int ret; 1119 1100 1120 1101 /* CPU eDP is the only output that doesn't need a PCH PLL of its own. */ 1121 1102 if (!crtc_state->has_pch_encoder) ··· 1126 1105 if (intel_panel_use_ssc(dev_priv)) { 1127 1106 drm_dbg_kms(&dev_priv->drm, 1128 1107 "using SSC reference clock of %d kHz\n", 1129 - dev_priv->vbt.lvds_ssc_freq); 1130 - refclk = dev_priv->vbt.lvds_ssc_freq; 1108 + dev_priv->display.vbt.lvds_ssc_freq); 1109 + refclk = dev_priv->display.vbt.lvds_ssc_freq; 1131 1110 } 1132 1111 1133 1112 if (intel_is_dual_link_lvds(dev_priv)) { ··· 1153 1132 ilk_compute_dpll(crtc_state, &crtc_state->dpll, 1154 1133 &crtc_state->dpll); 1155 1134 1156 - return intel_compute_shared_dplls(state, crtc, NULL); 1135 + ret = intel_compute_shared_dplls(state, crtc, NULL); 1136 + if (ret) 1137 + return ret; 1138 + 1139 + crtc_state->port_clock = crtc_state->dpll.dot; 1140 + crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state); 1141 + 1142 + return ret; 1157 1143 } 1158 1144 1159 1145 static int ilk_crtc_get_shared_dpll(struct intel_atomic_state *state, ··· 1226 1198 1227 1199 chv_compute_dpll(crtc_state); 1228 1200 1201 + /* FIXME this is a mess */ 1202 + if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI)) 1203 + return 0; 1204 + 1205 + crtc_state->port_clock = crtc_state->dpll.dot; 1206 + crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state); 1207 + 1229 1208 return 0; 1230 1209 } 1231 1210 ··· 1252 1217 1253 1218 vlv_compute_dpll(crtc_state); 1254 1219 1220 + /* FIXME this is a mess */ 1221 + if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI)) 1222 + return 0; 1223 + 1224 + crtc_state->port_clock = crtc_state->dpll.dot; 1225 + crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state); 1226 + 1255 1227 return 0; 1256 1228 } 1257 1229 ··· 1273 1231 1274 1232 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) { 1275 1233 if (intel_panel_use_ssc(dev_priv)) { 1276 - refclk = dev_priv->vbt.lvds_ssc_freq; 1234 + refclk = dev_priv->display.vbt.lvds_ssc_freq; 1277 1235 drm_dbg_kms(&dev_priv->drm, 1278 1236 "using SSC reference clock of %d kHz\n", 1279 1237 refclk); ··· 1301 1259 i9xx_compute_dpll(crtc_state, &crtc_state->dpll, 1302 1260 &crtc_state->dpll); 1303 1261 1262 + crtc_state->port_clock = crtc_state->dpll.dot; 1263 + /* FIXME this is a mess */ 1264 + if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_TVOUT)) 1265 + crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state); 1266 + 1304 1267 return 0; 1305 1268 } 1306 1269 ··· 1320 1273 1321 1274 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) { 1322 1275 if (intel_panel_use_ssc(dev_priv)) { 1323 - refclk = dev_priv->vbt.lvds_ssc_freq; 1276 + refclk = dev_priv->display.vbt.lvds_ssc_freq; 1324 1277 drm_dbg_kms(&dev_priv->drm, 1325 1278 "using SSC reference clock of %d kHz\n", 1326 1279 refclk); ··· 1339 1292 i9xx_compute_dpll(crtc_state, &crtc_state->dpll, 1340 1293 &crtc_state->dpll); 1341 1294 1295 + crtc_state->port_clock = crtc_state->dpll.dot; 1296 + crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state); 1297 + 1342 1298 return 0; 1343 1299 } 1344 1300 ··· 1356 1306 1357 1307 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) { 1358 1308 if (intel_panel_use_ssc(dev_priv)) { 1359 - refclk = dev_priv->vbt.lvds_ssc_freq; 1309 + refclk = dev_priv->display.vbt.lvds_ssc_freq; 1360 1310 drm_dbg_kms(&dev_priv->drm, 1361 1311 "using SSC reference clock of %d kHz\n", 1362 1312 refclk); ··· 1375 1325 i9xx_compute_dpll(crtc_state, &crtc_state->dpll, 1376 1326 &crtc_state->dpll); 1377 1327 1328 + crtc_state->port_clock = crtc_state->dpll.dot; 1329 + /* FIXME this is a mess */ 1330 + if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_TVOUT)) 1331 + crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state); 1332 + 1378 1333 return 0; 1379 1334 } 1380 1335 ··· 1394 1339 1395 1340 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) { 1396 1341 if (intel_panel_use_ssc(dev_priv)) { 1397 - refclk = dev_priv->vbt.lvds_ssc_freq; 1342 + refclk = dev_priv->display.vbt.lvds_ssc_freq; 1398 1343 drm_dbg_kms(&dev_priv->drm, 1399 1344 "using SSC reference clock of %d kHz\n", 1400 1345 refclk); ··· 1414 1359 1415 1360 i8xx_compute_dpll(crtc_state, &crtc_state->dpll, 1416 1361 &crtc_state->dpll); 1362 + 1363 + crtc_state->port_clock = crtc_state->dpll.dot; 1364 + crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state); 1417 1365 1418 1366 return 0; 1419 1367 } ··· 1469 1411 1470 1412 drm_WARN_ON(&i915->drm, !intel_crtc_needs_modeset(crtc_state)); 1471 1413 1472 - if (drm_WARN_ON(&i915->drm, crtc_state->shared_dpll)) 1473 - return 0; 1474 - 1475 1414 memset(&crtc_state->dpll_hw_state, 0, 1476 1415 sizeof(crtc_state->dpll_hw_state)); 1477 1416 ··· 1494 1439 int ret; 1495 1440 1496 1441 drm_WARN_ON(&i915->drm, !intel_crtc_needs_modeset(crtc_state)); 1442 + drm_WARN_ON(&i915->drm, !crtc_state->hw.enable && crtc_state->shared_dpll); 1497 1443 1498 - if (drm_WARN_ON(&i915->drm, crtc_state->shared_dpll)) 1499 - return 0; 1500 - 1501 - if (!crtc_state->hw.enable) 1444 + if (!crtc_state->hw.enable || crtc_state->shared_dpll) 1502 1445 return 0; 1503 1446 1504 1447 if (!i915->display.funcs.dpll->crtc_get_shared_dpll)
+131 -101
drivers/gpu/drm/i915/display/intel_dpll_mgr.c
··· 905 905 *r2_out = best.r2; 906 906 } 907 907 908 - static int 909 - hsw_ddi_wrpll_compute_dpll(struct intel_atomic_state *state, 910 - struct intel_crtc *crtc) 911 - { 912 - struct intel_crtc_state *crtc_state = 913 - intel_atomic_get_new_crtc_state(state, crtc); 914 - unsigned int p, n2, r2; 915 - 916 - hsw_ddi_calculate_wrpll(crtc_state->port_clock * 1000, &r2, &n2, &p); 917 - 918 - crtc_state->dpll_hw_state.wrpll = 919 - WRPLL_PLL_ENABLE | WRPLL_REF_LCPLL | 920 - WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) | 921 - WRPLL_DIVIDER_POST(p); 922 - 923 - return 0; 924 - } 925 - 926 - static struct intel_shared_dpll * 927 - hsw_ddi_wrpll_get_dpll(struct intel_atomic_state *state, 928 - struct intel_crtc *crtc) 929 - { 930 - struct intel_crtc_state *crtc_state = 931 - intel_atomic_get_new_crtc_state(state, crtc); 932 - 933 - return intel_find_shared_dpll(state, crtc, 934 - &crtc_state->dpll_hw_state, 935 - BIT(DPLL_ID_WRPLL2) | 936 - BIT(DPLL_ID_WRPLL1)); 937 - } 938 - 939 908 static int hsw_ddi_wrpll_get_freq(struct drm_i915_private *dev_priv, 940 909 const struct intel_shared_dpll *pll, 941 910 const struct intel_dpll_hw_state *pll_state) ··· 943 974 944 975 /* Convert to KHz, p & r have a fixed point portion */ 945 976 return (refclk * n / 10) / (p * r) * 2; 977 + } 978 + 979 + static int 980 + hsw_ddi_wrpll_compute_dpll(struct intel_atomic_state *state, 981 + struct intel_crtc *crtc) 982 + { 983 + struct drm_i915_private *i915 = to_i915(state->base.dev); 984 + struct intel_crtc_state *crtc_state = 985 + intel_atomic_get_new_crtc_state(state, crtc); 986 + unsigned int p, n2, r2; 987 + 988 + hsw_ddi_calculate_wrpll(crtc_state->port_clock * 1000, &r2, &n2, &p); 989 + 990 + crtc_state->dpll_hw_state.wrpll = 991 + WRPLL_PLL_ENABLE | WRPLL_REF_LCPLL | 992 + WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) | 993 + WRPLL_DIVIDER_POST(p); 994 + 995 + crtc_state->port_clock = hsw_ddi_wrpll_get_freq(i915, NULL, 996 + &crtc_state->dpll_hw_state); 997 + 998 + return 0; 999 + } 1000 + 1001 + static struct intel_shared_dpll * 1002 + hsw_ddi_wrpll_get_dpll(struct intel_atomic_state *state, 1003 + struct intel_crtc *crtc) 1004 + { 1005 + struct intel_crtc_state *crtc_state = 1006 + intel_atomic_get_new_crtc_state(state, crtc); 1007 + 1008 + return intel_find_shared_dpll(state, crtc, 1009 + &crtc_state->dpll_hw_state, 1010 + BIT(DPLL_ID_WRPLL2) | 1011 + BIT(DPLL_ID_WRPLL1)); 946 1012 } 947 1013 948 1014 static int ··· 1622 1618 return 0; 1623 1619 } 1624 1620 1625 - static int skl_ddi_hdmi_pll_dividers(struct intel_crtc_state *crtc_state) 1626 - { 1627 - struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); 1628 - struct skl_wrpll_params wrpll_params = {}; 1629 - u32 ctrl1, cfgcr1, cfgcr2; 1630 - int ret; 1631 - 1632 - /* 1633 - * See comment in intel_dpll_hw_state to understand why we always use 0 1634 - * as the DPLL id in this function. 1635 - */ 1636 - ctrl1 = DPLL_CTRL1_OVERRIDE(0); 1637 - 1638 - ctrl1 |= DPLL_CTRL1_HDMI_MODE(0); 1639 - 1640 - ret = skl_ddi_calculate_wrpll(crtc_state->port_clock * 1000, 1641 - i915->display.dpll.ref_clks.nssc, &wrpll_params); 1642 - if (ret) 1643 - return ret; 1644 - 1645 - cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE | 1646 - DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) | 1647 - wrpll_params.dco_integer; 1648 - 1649 - cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) | 1650 - DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) | 1651 - DPLL_CFGCR2_KDIV(wrpll_params.kdiv) | 1652 - DPLL_CFGCR2_PDIV(wrpll_params.pdiv) | 1653 - wrpll_params.central_freq; 1654 - 1655 - crtc_state->dpll_hw_state.ctrl1 = ctrl1; 1656 - crtc_state->dpll_hw_state.cfgcr1 = cfgcr1; 1657 - crtc_state->dpll_hw_state.cfgcr2 = cfgcr2; 1658 - 1659 - return 0; 1660 - } 1661 - 1662 1621 static int skl_ddi_wrpll_get_freq(struct drm_i915_private *i915, 1663 1622 const struct intel_shared_dpll *pll, 1664 1623 const struct intel_dpll_hw_state *pll_state) ··· 1691 1724 return 0; 1692 1725 1693 1726 return dco_freq / (p0 * p1 * p2 * 5); 1727 + } 1728 + 1729 + static int skl_ddi_hdmi_pll_dividers(struct intel_crtc_state *crtc_state) 1730 + { 1731 + struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); 1732 + struct skl_wrpll_params wrpll_params = {}; 1733 + u32 ctrl1, cfgcr1, cfgcr2; 1734 + int ret; 1735 + 1736 + /* 1737 + * See comment in intel_dpll_hw_state to understand why we always use 0 1738 + * as the DPLL id in this function. 1739 + */ 1740 + ctrl1 = DPLL_CTRL1_OVERRIDE(0); 1741 + 1742 + ctrl1 |= DPLL_CTRL1_HDMI_MODE(0); 1743 + 1744 + ret = skl_ddi_calculate_wrpll(crtc_state->port_clock * 1000, 1745 + i915->display.dpll.ref_clks.nssc, &wrpll_params); 1746 + if (ret) 1747 + return ret; 1748 + 1749 + cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE | 1750 + DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) | 1751 + wrpll_params.dco_integer; 1752 + 1753 + cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) | 1754 + DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) | 1755 + DPLL_CFGCR2_KDIV(wrpll_params.kdiv) | 1756 + DPLL_CFGCR2_PDIV(wrpll_params.pdiv) | 1757 + wrpll_params.central_freq; 1758 + 1759 + crtc_state->dpll_hw_state.ctrl1 = ctrl1; 1760 + crtc_state->dpll_hw_state.cfgcr1 = cfgcr1; 1761 + crtc_state->dpll_hw_state.cfgcr2 = cfgcr2; 1762 + 1763 + crtc_state->port_clock = skl_ddi_wrpll_get_freq(i915, NULL, 1764 + &crtc_state->dpll_hw_state); 1765 + 1766 + return 0; 1694 1767 } 1695 1768 1696 1769 static int ··· 1865 1858 static void skl_update_dpll_ref_clks(struct drm_i915_private *i915) 1866 1859 { 1867 1860 /* No SSC ref */ 1868 - i915->display.dpll.ref_clks.nssc = i915->cdclk.hw.ref; 1861 + i915->display.dpll.ref_clks.nssc = i915->display.cdclk.hw.ref; 1869 1862 } 1870 1863 1871 1864 static void skl_dump_hw_state(struct drm_i915_private *dev_priv, ··· 2252 2245 return 0; 2253 2246 } 2254 2247 2255 - static int 2256 - bxt_ddi_dp_set_dpll_hw_state(struct intel_crtc_state *crtc_state) 2257 - { 2258 - struct dpll clk_div = {}; 2259 - 2260 - bxt_ddi_dp_pll_dividers(crtc_state, &clk_div); 2261 - 2262 - return bxt_ddi_set_dpll_hw_state(crtc_state, &clk_div); 2263 - } 2264 - 2265 - static int 2266 - bxt_ddi_hdmi_set_dpll_hw_state(struct intel_crtc_state *crtc_state) 2267 - { 2268 - struct dpll clk_div = {}; 2269 - 2270 - bxt_ddi_hdmi_pll_dividers(crtc_state, &clk_div); 2271 - 2272 - return bxt_ddi_set_dpll_hw_state(crtc_state, &clk_div); 2273 - } 2274 - 2275 2248 static int bxt_ddi_pll_get_freq(struct drm_i915_private *i915, 2276 2249 const struct intel_shared_dpll *pll, 2277 2250 const struct intel_dpll_hw_state *pll_state) ··· 2267 2280 clock.p2 = REG_FIELD_GET(PORT_PLL_P2_MASK, pll_state->ebb0); 2268 2281 2269 2282 return chv_calc_dpll_params(i915->display.dpll.ref_clks.nssc, &clock); 2283 + } 2284 + 2285 + static int 2286 + bxt_ddi_dp_set_dpll_hw_state(struct intel_crtc_state *crtc_state) 2287 + { 2288 + struct dpll clk_div = {}; 2289 + 2290 + bxt_ddi_dp_pll_dividers(crtc_state, &clk_div); 2291 + 2292 + return bxt_ddi_set_dpll_hw_state(crtc_state, &clk_div); 2293 + } 2294 + 2295 + static int 2296 + bxt_ddi_hdmi_set_dpll_hw_state(struct intel_crtc_state *crtc_state) 2297 + { 2298 + struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); 2299 + struct dpll clk_div = {}; 2300 + int ret; 2301 + 2302 + bxt_ddi_hdmi_pll_dividers(crtc_state, &clk_div); 2303 + 2304 + ret = bxt_ddi_set_dpll_hw_state(crtc_state, &clk_div); 2305 + if (ret) 2306 + return ret; 2307 + 2308 + crtc_state->port_clock = bxt_ddi_pll_get_freq(i915, NULL, 2309 + &crtc_state->dpll_hw_state); 2310 + 2311 + return 0; 2270 2312 } 2271 2313 2272 2314 static int bxt_compute_dpll(struct intel_atomic_state *state, ··· 2785 2769 else 2786 2770 pll_state->cfgcr1 |= DPLL_CFGCR1_CENTRAL_FREQ_8400; 2787 2771 2788 - if (i915->vbt.override_afc_startup) 2789 - pll_state->div0 = TGL_DPLL0_DIV0_AFC_STARTUP(i915->vbt.override_afc_startup_val); 2772 + if (i915->display.vbt.override_afc_startup) 2773 + pll_state->div0 = TGL_DPLL0_DIV0_AFC_STARTUP(i915->display.vbt.override_afc_startup_val); 2790 2774 } 2791 2775 2792 2776 static int icl_mg_pll_find_divisors(int clock_khz, bool is_dp, bool use_ssc, ··· 2981 2965 DKL_PLL_DIV0_PROP_COEFF(prop_coeff) | 2982 2966 DKL_PLL_DIV0_FBPREDIV(m1div) | 2983 2967 DKL_PLL_DIV0_FBDIV_INT(m2div_int); 2984 - if (dev_priv->vbt.override_afc_startup) { 2985 - u8 val = dev_priv->vbt.override_afc_startup_val; 2968 + if (dev_priv->display.vbt.override_afc_startup) { 2969 + u8 val = dev_priv->display.vbt.override_afc_startup_val; 2986 2970 2987 2971 pll_state->mg_pll_div0 |= DKL_PLL_DIV0_AFC_STARTUP(val); 2988 2972 } ··· 3213 3197 3214 3198 icl_calc_dpll_state(dev_priv, &pll_params, &port_dpll->hw_state); 3215 3199 3200 + /* this is mainly for the fastset check */ 3201 + icl_set_active_port_dpll(crtc_state, ICL_PORT_DPLL_DEFAULT); 3202 + 3203 + crtc_state->port_clock = icl_ddi_combo_pll_get_freq(dev_priv, NULL, 3204 + &port_dpll->hw_state); 3205 + 3216 3206 return 0; 3217 3207 } 3218 3208 ··· 3303 3281 ret = icl_calc_mg_pll_state(crtc_state, &port_dpll->hw_state); 3304 3282 if (ret) 3305 3283 return ret; 3284 + 3285 + /* this is mainly for the fastset check */ 3286 + icl_set_active_port_dpll(crtc_state, ICL_PORT_DPLL_MG_PHY); 3287 + 3288 + crtc_state->port_clock = icl_ddi_mg_pll_get_freq(dev_priv, NULL, 3289 + &port_dpll->hw_state); 3306 3290 3307 3291 return 0; 3308 3292 } ··· 3530 3502 3531 3503 hw_state->mg_pll_div0 = intel_de_read(dev_priv, DKL_PLL_DIV0(tc_port)); 3532 3504 val = DKL_PLL_DIV0_MASK; 3533 - if (dev_priv->vbt.override_afc_startup) 3505 + if (dev_priv->display.vbt.override_afc_startup) 3534 3506 val |= DKL_PLL_DIV0_AFC_STARTUP_MASK; 3535 3507 hw_state->mg_pll_div0 &= val; 3536 3508 ··· 3594 3566 TGL_DPLL_CFGCR0(id)); 3595 3567 hw_state->cfgcr1 = intel_de_read(dev_priv, 3596 3568 TGL_DPLL_CFGCR1(id)); 3597 - if (dev_priv->vbt.override_afc_startup) { 3569 + if (dev_priv->display.vbt.override_afc_startup) { 3598 3570 hw_state->div0 = intel_de_read(dev_priv, TGL_DPLL0_DIV0(id)); 3599 3571 hw_state->div0 &= TGL_DPLL0_DIV0_AFC_STARTUP_MASK; 3600 3572 } ··· 3666 3638 3667 3639 intel_de_write(dev_priv, cfgcr0_reg, hw_state->cfgcr0); 3668 3640 intel_de_write(dev_priv, cfgcr1_reg, hw_state->cfgcr1); 3669 - drm_WARN_ON_ONCE(&dev_priv->drm, dev_priv->vbt.override_afc_startup && 3641 + drm_WARN_ON_ONCE(&dev_priv->drm, dev_priv->display.vbt.override_afc_startup && 3670 3642 !i915_mmio_reg_valid(div0_reg)); 3671 - if (dev_priv->vbt.override_afc_startup && 3643 + if (dev_priv->display.vbt.override_afc_startup && 3672 3644 i915_mmio_reg_valid(div0_reg)) 3673 3645 intel_de_rmw(dev_priv, div0_reg, TGL_DPLL0_DIV0_AFC_STARTUP_MASK, 3674 3646 hw_state->div0); ··· 3760 3732 intel_de_write(dev_priv, DKL_CLKTOP2_HSCLKCTL(tc_port), val); 3761 3733 3762 3734 val = DKL_PLL_DIV0_MASK; 3763 - if (dev_priv->vbt.override_afc_startup) 3735 + if (dev_priv->display.vbt.override_afc_startup) 3764 3736 val |= DKL_PLL_DIV0_AFC_STARTUP_MASK; 3765 3737 intel_de_rmw(dev_priv, DKL_PLL_DIV0(tc_port), val, 3766 3738 hw_state->mg_pll_div0); ··· 3995 3967 static void icl_update_dpll_ref_clks(struct drm_i915_private *i915) 3996 3968 { 3997 3969 /* No SSC ref */ 3998 - i915->display.dpll.ref_clks.nssc = i915->cdclk.hw.ref; 3970 + i915->display.dpll.ref_clks.nssc = i915->display.cdclk.hw.ref; 3999 3971 } 4000 3972 4001 3973 static void icl_dump_hw_state(struct drm_i915_private *dev_priv, ··· 4227 4199 dpll_info = dpll_mgr->dpll_info; 4228 4200 4229 4201 for (i = 0; dpll_info[i].name; i++) { 4202 + if (drm_WARN_ON(&dev_priv->drm, 4203 + i >= ARRAY_SIZE(dev_priv->display.dpll.shared_dplls))) 4204 + break; 4205 + 4230 4206 drm_WARN_ON(&dev_priv->drm, i != dpll_info[i].id); 4231 4207 dev_priv->display.dpll.shared_dplls[i].info = &dpll_info[i]; 4232 4208 } ··· 4238 4206 dev_priv->display.dpll.mgr = dpll_mgr; 4239 4207 dev_priv->display.dpll.num_shared_dpll = i; 4240 4208 mutex_init(&dev_priv->display.dpll.lock); 4241 - 4242 - BUG_ON(dev_priv->display.dpll.num_shared_dpll > I915_NUM_PLLS); 4243 4209 } 4244 4210 4245 4211 /**
+30
drivers/gpu/drm/i915/display/intel_dsb.c
··· 9 9 #include "i915_drv.h" 10 10 #include "intel_de.h" 11 11 #include "intel_display_types.h" 12 + #include "intel_dsb.h" 13 + 14 + struct i915_vma; 15 + 16 + enum dsb_id { 17 + INVALID_DSB = -1, 18 + DSB1, 19 + DSB2, 20 + DSB3, 21 + MAX_DSB_PER_PIPE 22 + }; 23 + 24 + struct intel_dsb { 25 + enum dsb_id id; 26 + u32 *cmd_buf; 27 + struct i915_vma *vma; 28 + 29 + /* 30 + * free_pos will point the first free entry position 31 + * and help in calculating tail of command buffer. 32 + */ 33 + int free_pos; 34 + 35 + /* 36 + * ins_start_offset will help to store start address of the dsb 37 + * instuction and help in identifying the batch of auto-increment 38 + * register. 39 + */ 40 + u32 ins_start_offset; 41 + }; 12 42 13 43 #define DSB_BUF_SIZE (2 * PAGE_SIZE) 14 44
-28
drivers/gpu/drm/i915/display/intel_dsb.h
··· 11 11 #include "i915_reg_defs.h" 12 12 13 13 struct intel_crtc_state; 14 - struct i915_vma; 15 - 16 - enum dsb_id { 17 - INVALID_DSB = -1, 18 - DSB1, 19 - DSB2, 20 - DSB3, 21 - MAX_DSB_PER_PIPE 22 - }; 23 - 24 - struct intel_dsb { 25 - enum dsb_id id; 26 - u32 *cmd_buf; 27 - struct i915_vma *vma; 28 - 29 - /* 30 - * free_pos will point the first free entry position 31 - * and help in calculating tail of command buffer. 32 - */ 33 - int free_pos; 34 - 35 - /* 36 - * ins_start_offset will help to store start address of the dsb 37 - * instuction and help in identifying the batch of auto-increment 38 - * register. 39 - */ 40 - u32 ins_start_offset; 41 - }; 42 14 43 15 void intel_dsb_prepare(struct intel_crtc_state *crtc_state); 44 16 void intel_dsb_cleanup(struct intel_crtc_state *crtc_state);
+1 -1
drivers/gpu/drm/i915/display/intel_dsi.c
··· 106 106 if (orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN) 107 107 return orientation; 108 108 109 - orientation = dev_priv->vbt.orientation; 109 + orientation = dev_priv->display.vbt.orientation; 110 110 if (orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN) 111 111 return orientation; 112 112
+2 -2
drivers/gpu/drm/i915/display/intel_dvo_dev.h
··· 75 75 * 76 76 * \return MODE_OK if the mode is valid, or another MODE_* otherwise. 77 77 */ 78 - int (*mode_valid)(struct intel_dvo_device *dvo, 79 - struct drm_display_mode *mode); 78 + enum drm_mode_status (*mode_valid)(struct intel_dvo_device *dvo, 79 + struct drm_display_mode *mode); 80 80 81 81 /* 82 82 * Callback for preparing mode changes on an output
+3 -3
drivers/gpu/drm/i915/display/intel_fbc.c
··· 59 59 60 60 #define for_each_intel_fbc(__dev_priv, __fbc, __fbc_id) \ 61 61 for_each_fbc_id((__dev_priv), (__fbc_id)) \ 62 - for_each_if((__fbc) = (__dev_priv)->fbc[(__fbc_id)]) 62 + for_each_if((__fbc) = (__dev_priv)->display.fbc[(__fbc_id)]) 63 63 64 64 struct intel_fbc_funcs { 65 65 void (*activate)(struct intel_fbc *fbc); ··· 1720 1720 i915->params.enable_fbc); 1721 1721 1722 1722 for_each_fbc_id(i915, fbc_id) 1723 - i915->fbc[fbc_id] = intel_fbc_create(i915, fbc_id); 1723 + i915->display.fbc[fbc_id] = intel_fbc_create(i915, fbc_id); 1724 1724 } 1725 1725 1726 1726 /** ··· 1840 1840 struct drm_minor *minor = i915->drm.primary; 1841 1841 struct intel_fbc *fbc; 1842 1842 1843 - fbc = i915->fbc[INTEL_FBC_A]; 1843 + fbc = i915->display.fbc[INTEL_FBC_A]; 1844 1844 if (fbc) 1845 1845 intel_fbc_debugfs_add(fbc, minor->debugfs_root); 1846 1846 }
+10 -2
drivers/gpu/drm/i915/display/intel_fbdev.c
··· 210 210 struct drm_i915_gem_object *obj; 211 211 int ret; 212 212 213 + mutex_lock(&ifbdev->hpd_lock); 214 + ret = ifbdev->hpd_suspended ? -EAGAIN : 0; 215 + mutex_unlock(&ifbdev->hpd_lock); 216 + if (ret) 217 + return ret; 218 + 213 219 if (intel_fb && 214 220 (sizes->fb_width > intel_fb->base.width || 215 221 sizes->fb_height > intel_fb->base.height)) { ··· 579 573 if (!ifbdev) 580 574 return; 581 575 582 - cancel_work_sync(&dev_priv->display.fbdev.suspend_work); 576 + intel_fbdev_set_suspend(&dev_priv->drm, FBINFO_STATE_SUSPENDED, true); 577 + 583 578 if (!current_is_async()) 584 579 intel_fbdev_sync(ifbdev); 585 580 ··· 625 618 struct fb_info *info; 626 619 627 620 if (!ifbdev || !ifbdev->vma) 628 - return; 621 + goto set_suspend; 629 622 630 623 info = ifbdev->helper.fbdev; 631 624 ··· 668 661 drm_fb_helper_set_suspend(&ifbdev->helper, state); 669 662 console_unlock(); 670 663 664 + set_suspend: 671 665 intel_fbdev_hpd_set_suspend(dev_priv, state); 672 666 } 673 667
+6 -6
drivers/gpu/drm/i915/display/intel_fdi.c
··· 210 210 u32 fdi_pll_clk = 211 211 intel_de_read(i915, FDI_PLL_BIOS_0) & FDI_PLL_FB_CLOCK_MASK; 212 212 213 - i915->fdi_pll_freq = (fdi_pll_clk + 2) * 10000; 213 + i915->display.fdi.pll_freq = (fdi_pll_clk + 2) * 10000; 214 214 } else if (IS_SANDYBRIDGE(i915) || IS_IVYBRIDGE(i915)) { 215 - i915->fdi_pll_freq = 270000; 215 + i915->display.fdi.pll_freq = 270000; 216 216 } else { 217 217 return; 218 218 } 219 219 220 - drm_dbg(&i915->drm, "FDI PLL freq=%d\n", i915->fdi_pll_freq); 220 + drm_dbg(&i915->drm, "FDI PLL freq=%d\n", i915->display.fdi.pll_freq); 221 221 } 222 222 223 223 int intel_fdi_link_freq(struct drm_i915_private *i915, ··· 226 226 if (HAS_DDI(i915)) 227 227 return pipe_config->port_clock; /* SPLL */ 228 228 else 229 - return i915->fdi_pll_freq; 229 + return i915->display.fdi.pll_freq; 230 230 } 231 231 232 232 int ilk_fdi_compute_config(struct intel_crtc *crtc, ··· 256 256 pipe_config->fdi_lanes = lane; 257 257 258 258 intel_link_compute_m_n(pipe_config->pipe_bpp, lane, fdi_dotclock, 259 - link_bw, &pipe_config->fdi_m_n, false, false); 259 + link_bw, &pipe_config->fdi_m_n, false); 260 260 261 261 ret = ilk_check_fdi_lanes(dev, crtc->pipe, pipe_config); 262 262 if (ret == -EDEADLK) ··· 789 789 FDI_RX_PWRDN_LANE1_VAL(2) | FDI_RX_PWRDN_LANE0_VAL(2) | FDI_RX_TP1_TO_TP2_48 | FDI_RX_FDI_DELAY_90); 790 790 791 791 /* Enable the PCH Receiver FDI PLL */ 792 - rx_ctl_val = dev_priv->fdi_rx_config | FDI_RX_ENHANCE_FRAME_ENABLE | 792 + rx_ctl_val = dev_priv->display.fdi.rx_config | FDI_RX_ENHANCE_FRAME_ENABLE | 793 793 FDI_RX_PLL_ENABLE | 794 794 FDI_DP_PORT_WIDTH(crtc_state->fdi_lanes); 795 795 intel_de_write(dev_priv, FDI_RX_CTL(PIPE_A), rx_ctl_val);
+27 -27
drivers/gpu/drm/i915/display/intel_frontbuffer.c
··· 81 81 enum fb_op_origin origin) 82 82 { 83 83 /* Delay flushing when rings are still busy.*/ 84 - spin_lock(&i915->fb_tracking.lock); 85 - frontbuffer_bits &= ~i915->fb_tracking.busy_bits; 86 - spin_unlock(&i915->fb_tracking.lock); 84 + spin_lock(&i915->display.fb_tracking.lock); 85 + frontbuffer_bits &= ~i915->display.fb_tracking.busy_bits; 86 + spin_unlock(&i915->display.fb_tracking.lock); 87 87 88 88 if (!frontbuffer_bits) 89 89 return; ··· 111 111 void intel_frontbuffer_flip_prepare(struct drm_i915_private *i915, 112 112 unsigned frontbuffer_bits) 113 113 { 114 - spin_lock(&i915->fb_tracking.lock); 115 - i915->fb_tracking.flip_bits |= frontbuffer_bits; 114 + spin_lock(&i915->display.fb_tracking.lock); 115 + i915->display.fb_tracking.flip_bits |= frontbuffer_bits; 116 116 /* Remove stale busy bits due to the old buffer. */ 117 - i915->fb_tracking.busy_bits &= ~frontbuffer_bits; 118 - spin_unlock(&i915->fb_tracking.lock); 117 + i915->display.fb_tracking.busy_bits &= ~frontbuffer_bits; 118 + spin_unlock(&i915->display.fb_tracking.lock); 119 119 } 120 120 121 121 /** ··· 131 131 void intel_frontbuffer_flip_complete(struct drm_i915_private *i915, 132 132 unsigned frontbuffer_bits) 133 133 { 134 - spin_lock(&i915->fb_tracking.lock); 134 + spin_lock(&i915->display.fb_tracking.lock); 135 135 /* Mask any cancelled flips. */ 136 - frontbuffer_bits &= i915->fb_tracking.flip_bits; 137 - i915->fb_tracking.flip_bits &= ~frontbuffer_bits; 138 - spin_unlock(&i915->fb_tracking.lock); 136 + frontbuffer_bits &= i915->display.fb_tracking.flip_bits; 137 + i915->display.fb_tracking.flip_bits &= ~frontbuffer_bits; 138 + spin_unlock(&i915->display.fb_tracking.lock); 139 139 140 140 if (frontbuffer_bits) 141 141 frontbuffer_flush(i915, frontbuffer_bits, ORIGIN_FLIP); ··· 155 155 void intel_frontbuffer_flip(struct drm_i915_private *i915, 156 156 unsigned frontbuffer_bits) 157 157 { 158 - spin_lock(&i915->fb_tracking.lock); 158 + spin_lock(&i915->display.fb_tracking.lock); 159 159 /* Remove stale busy bits due to the old buffer. */ 160 - i915->fb_tracking.busy_bits &= ~frontbuffer_bits; 161 - spin_unlock(&i915->fb_tracking.lock); 160 + i915->display.fb_tracking.busy_bits &= ~frontbuffer_bits; 161 + spin_unlock(&i915->display.fb_tracking.lock); 162 162 163 163 frontbuffer_flush(i915, frontbuffer_bits, ORIGIN_FLIP); 164 164 } ··· 170 170 struct drm_i915_private *i915 = to_i915(front->obj->base.dev); 171 171 172 172 if (origin == ORIGIN_CS) { 173 - spin_lock(&i915->fb_tracking.lock); 174 - i915->fb_tracking.busy_bits |= frontbuffer_bits; 175 - i915->fb_tracking.flip_bits &= ~frontbuffer_bits; 176 - spin_unlock(&i915->fb_tracking.lock); 173 + spin_lock(&i915->display.fb_tracking.lock); 174 + i915->display.fb_tracking.busy_bits |= frontbuffer_bits; 175 + i915->display.fb_tracking.flip_bits &= ~frontbuffer_bits; 176 + spin_unlock(&i915->display.fb_tracking.lock); 177 177 } 178 178 179 179 trace_intel_frontbuffer_invalidate(frontbuffer_bits, origin); ··· 191 191 struct drm_i915_private *i915 = to_i915(front->obj->base.dev); 192 192 193 193 if (origin == ORIGIN_CS) { 194 - spin_lock(&i915->fb_tracking.lock); 194 + spin_lock(&i915->display.fb_tracking.lock); 195 195 /* Filter out new bits since rendering started. */ 196 - frontbuffer_bits &= i915->fb_tracking.busy_bits; 197 - i915->fb_tracking.busy_bits &= ~frontbuffer_bits; 198 - spin_unlock(&i915->fb_tracking.lock); 196 + frontbuffer_bits &= i915->display.fb_tracking.busy_bits; 197 + i915->display.fb_tracking.busy_bits &= ~frontbuffer_bits; 198 + spin_unlock(&i915->display.fb_tracking.lock); 199 199 } 200 200 201 201 if (frontbuffer_bits) ··· 221 221 } 222 222 223 223 static void frontbuffer_release(struct kref *ref) 224 - __releases(&to_i915(front->obj->base.dev)->fb_tracking.lock) 224 + __releases(&to_i915(front->obj->base.dev)->display.fb_tracking.lock) 225 225 { 226 226 struct intel_frontbuffer *front = 227 227 container_of(ref, typeof(*front), ref); ··· 238 238 spin_unlock(&obj->vma.lock); 239 239 240 240 RCU_INIT_POINTER(obj->frontbuffer, NULL); 241 - spin_unlock(&to_i915(obj->base.dev)->fb_tracking.lock); 241 + spin_unlock(&to_i915(obj->base.dev)->display.fb_tracking.lock); 242 242 243 243 i915_active_fini(&front->write); 244 244 ··· 268 268 frontbuffer_retire, 269 269 I915_ACTIVE_RETIRE_SLEEPS); 270 270 271 - spin_lock(&i915->fb_tracking.lock); 271 + spin_lock(&i915->display.fb_tracking.lock); 272 272 if (rcu_access_pointer(obj->frontbuffer)) { 273 273 kfree(front); 274 274 front = rcu_dereference_protected(obj->frontbuffer, true); ··· 277 277 i915_gem_object_get(obj); 278 278 rcu_assign_pointer(obj->frontbuffer, front); 279 279 } 280 - spin_unlock(&i915->fb_tracking.lock); 280 + spin_unlock(&i915->display.fb_tracking.lock); 281 281 282 282 return front; 283 283 } ··· 286 286 { 287 287 kref_put_lock(&front->ref, 288 288 frontbuffer_release, 289 - &to_i915(front->obj->base.dev)->fb_tracking.lock); 289 + &to_i915(front->obj->base.dev)->display.fb_tracking.lock); 290 290 } 291 291 292 292 /**
+153 -137
drivers/gpu/drm/i915/display/intel_gmbus.c
··· 37 37 #include "intel_de.h" 38 38 #include "intel_display_types.h" 39 39 #include "intel_gmbus.h" 40 + #include "intel_gmbus_regs.h" 40 41 41 42 struct intel_gmbus { 42 43 struct i2c_adapter adapter; ··· 46 45 u32 reg0; 47 46 i915_reg_t gpio_reg; 48 47 struct i2c_algo_bit_data bit_algo; 49 - struct drm_i915_private *dev_priv; 48 + struct drm_i915_private *i915; 50 49 }; 51 50 52 51 struct gmbus_pin { ··· 117 116 [GMBUS_PIN_9_TC1_ICP] = { "tc1", GPIOJ }, 118 117 }; 119 118 119 + static const struct gmbus_pin gmbus_pins_mtp[] = { 120 + [GMBUS_PIN_1_BXT] = { "dpa", GPIOB }, 121 + [GMBUS_PIN_2_BXT] = { "dpb", GPIOC }, 122 + [GMBUS_PIN_3_BXT] = { "dpc", GPIOD }, 123 + [GMBUS_PIN_4_CNP] = { "dpd", GPIOE }, 124 + [GMBUS_PIN_5_MTP] = { "dpe", GPIOF }, 125 + [GMBUS_PIN_9_TC1_ICP] = { "tc1", GPIOJ }, 126 + [GMBUS_PIN_10_TC2_ICP] = { "tc2", GPIOK }, 127 + [GMBUS_PIN_11_TC3_ICP] = { "tc3", GPIOL }, 128 + [GMBUS_PIN_12_TC4_ICP] = { "tc4", GPIOM }, 129 + }; 130 + 120 131 static const struct gmbus_pin *get_gmbus_pin(struct drm_i915_private *i915, 121 132 unsigned int pin) 122 133 { ··· 141 128 } else if (INTEL_PCH_TYPE(i915) >= PCH_DG1) { 142 129 pins = gmbus_pins_dg1; 143 130 size = ARRAY_SIZE(gmbus_pins_dg1); 131 + } else if (INTEL_PCH_TYPE(i915) >= PCH_MTP) { 132 + pins = gmbus_pins_mtp; 133 + size = ARRAY_SIZE(gmbus_pins_mtp); 144 134 } else if (INTEL_PCH_TYPE(i915) >= PCH_ICP) { 145 135 pins = gmbus_pins_icp; 146 136 size = ARRAY_SIZE(gmbus_pins_icp); ··· 186 170 } 187 171 188 172 void 189 - intel_gmbus_reset(struct drm_i915_private *dev_priv) 173 + intel_gmbus_reset(struct drm_i915_private *i915) 190 174 { 191 - intel_de_write(dev_priv, GMBUS0, 0); 192 - intel_de_write(dev_priv, GMBUS4, 0); 175 + intel_de_write(i915, GMBUS0(i915), 0); 176 + intel_de_write(i915, GMBUS4(i915), 0); 193 177 } 194 178 195 - static void pnv_gmbus_clock_gating(struct drm_i915_private *dev_priv, 179 + static void pnv_gmbus_clock_gating(struct drm_i915_private *i915, 196 180 bool enable) 197 181 { 198 182 u32 val; 199 183 200 184 /* When using bit bashing for I2C, this bit needs to be set to 1 */ 201 - val = intel_de_read(dev_priv, DSPCLK_GATE_D); 185 + val = intel_de_read(i915, DSPCLK_GATE_D(i915)); 202 186 if (!enable) 203 187 val |= PNV_GMBUSUNIT_CLOCK_GATE_DISABLE; 204 188 else 205 189 val &= ~PNV_GMBUSUNIT_CLOCK_GATE_DISABLE; 206 - intel_de_write(dev_priv, DSPCLK_GATE_D, val); 190 + intel_de_write(i915, DSPCLK_GATE_D(i915), val); 207 191 } 208 192 209 - static void pch_gmbus_clock_gating(struct drm_i915_private *dev_priv, 193 + static void pch_gmbus_clock_gating(struct drm_i915_private *i915, 210 194 bool enable) 211 195 { 212 196 u32 val; 213 197 214 - val = intel_de_read(dev_priv, SOUTH_DSPCLK_GATE_D); 198 + val = intel_de_read(i915, SOUTH_DSPCLK_GATE_D); 215 199 if (!enable) 216 200 val |= PCH_GMBUSUNIT_CLOCK_GATE_DISABLE; 217 201 else 218 202 val &= ~PCH_GMBUSUNIT_CLOCK_GATE_DISABLE; 219 - intel_de_write(dev_priv, SOUTH_DSPCLK_GATE_D, val); 203 + intel_de_write(i915, SOUTH_DSPCLK_GATE_D, val); 220 204 } 221 205 222 - static void bxt_gmbus_clock_gating(struct drm_i915_private *dev_priv, 206 + static void bxt_gmbus_clock_gating(struct drm_i915_private *i915, 223 207 bool enable) 224 208 { 225 209 u32 val; 226 210 227 - val = intel_de_read(dev_priv, GEN9_CLKGATE_DIS_4); 211 + val = intel_de_read(i915, GEN9_CLKGATE_DIS_4); 228 212 if (!enable) 229 213 val |= BXT_GMBUS_GATING_DIS; 230 214 else 231 215 val &= ~BXT_GMBUS_GATING_DIS; 232 - intel_de_write(dev_priv, GEN9_CLKGATE_DIS_4, val); 216 + intel_de_write(i915, GEN9_CLKGATE_DIS_4, val); 233 217 } 234 218 235 219 static u32 get_reserved(struct intel_gmbus *bus) 236 220 { 237 - struct drm_i915_private *i915 = bus->dev_priv; 221 + struct drm_i915_private *i915 = bus->i915; 238 222 struct intel_uncore *uncore = &i915->uncore; 239 223 u32 reserved = 0; 240 224 ··· 250 234 static int get_clock(void *data) 251 235 { 252 236 struct intel_gmbus *bus = data; 253 - struct intel_uncore *uncore = &bus->dev_priv->uncore; 237 + struct intel_uncore *uncore = &bus->i915->uncore; 254 238 u32 reserved = get_reserved(bus); 255 239 256 240 intel_uncore_write_notrace(uncore, ··· 265 249 static int get_data(void *data) 266 250 { 267 251 struct intel_gmbus *bus = data; 268 - struct intel_uncore *uncore = &bus->dev_priv->uncore; 252 + struct intel_uncore *uncore = &bus->i915->uncore; 269 253 u32 reserved = get_reserved(bus); 270 254 271 255 intel_uncore_write_notrace(uncore, ··· 280 264 static void set_clock(void *data, int state_high) 281 265 { 282 266 struct intel_gmbus *bus = data; 283 - struct intel_uncore *uncore = &bus->dev_priv->uncore; 267 + struct intel_uncore *uncore = &bus->i915->uncore; 284 268 u32 reserved = get_reserved(bus); 285 269 u32 clock_bits; 286 270 ··· 299 283 static void set_data(void *data, int state_high) 300 284 { 301 285 struct intel_gmbus *bus = data; 302 - struct intel_uncore *uncore = &bus->dev_priv->uncore; 286 + struct intel_uncore *uncore = &bus->i915->uncore; 303 287 u32 reserved = get_reserved(bus); 304 288 u32 data_bits; 305 289 ··· 317 301 intel_gpio_pre_xfer(struct i2c_adapter *adapter) 318 302 { 319 303 struct intel_gmbus *bus = to_intel_gmbus(adapter); 320 - struct drm_i915_private *dev_priv = bus->dev_priv; 304 + struct drm_i915_private *i915 = bus->i915; 321 305 322 - intel_gmbus_reset(dev_priv); 306 + intel_gmbus_reset(i915); 323 307 324 - if (IS_PINEVIEW(dev_priv)) 325 - pnv_gmbus_clock_gating(dev_priv, false); 308 + if (IS_PINEVIEW(i915)) 309 + pnv_gmbus_clock_gating(i915, false); 326 310 327 311 set_data(bus, 1); 328 312 set_clock(bus, 1); ··· 334 318 intel_gpio_post_xfer(struct i2c_adapter *adapter) 335 319 { 336 320 struct intel_gmbus *bus = to_intel_gmbus(adapter); 337 - struct drm_i915_private *dev_priv = bus->dev_priv; 321 + struct drm_i915_private *i915 = bus->i915; 338 322 339 323 set_data(bus, 1); 340 324 set_clock(bus, 1); 341 325 342 - if (IS_PINEVIEW(dev_priv)) 343 - pnv_gmbus_clock_gating(dev_priv, true); 326 + if (IS_PINEVIEW(i915)) 327 + pnv_gmbus_clock_gating(i915, true); 344 328 } 345 329 346 330 static void ··· 372 356 return HAS_GMBUS_IRQ(i915) && intel_irqs_enabled(i915); 373 357 } 374 358 375 - static int gmbus_wait(struct drm_i915_private *dev_priv, u32 status, u32 irq_en) 359 + static int gmbus_wait(struct drm_i915_private *i915, u32 status, u32 irq_en) 376 360 { 377 361 DEFINE_WAIT(wait); 378 362 u32 gmbus2; ··· 382 366 * we also need to check for NAKs besides the hw ready/idle signal, we 383 367 * need to wake up periodically and check that ourselves. 384 368 */ 385 - if (!has_gmbus_irq(dev_priv)) 369 + if (!has_gmbus_irq(i915)) 386 370 irq_en = 0; 387 371 388 - add_wait_queue(&dev_priv->display.gmbus.wait_queue, &wait); 389 - intel_de_write_fw(dev_priv, GMBUS4, irq_en); 372 + add_wait_queue(&i915->display.gmbus.wait_queue, &wait); 373 + intel_de_write_fw(i915, GMBUS4(i915), irq_en); 390 374 391 375 status |= GMBUS_SATOER; 392 - ret = wait_for_us((gmbus2 = intel_de_read_fw(dev_priv, GMBUS2)) & status, 376 + ret = wait_for_us((gmbus2 = intel_de_read_fw(i915, GMBUS2(i915))) & status, 393 377 2); 394 378 if (ret) 395 - ret = wait_for((gmbus2 = intel_de_read_fw(dev_priv, GMBUS2)) & status, 379 + ret = wait_for((gmbus2 = intel_de_read_fw(i915, GMBUS2(i915))) & status, 396 380 50); 397 381 398 - intel_de_write_fw(dev_priv, GMBUS4, 0); 399 - remove_wait_queue(&dev_priv->display.gmbus.wait_queue, &wait); 382 + intel_de_write_fw(i915, GMBUS4(i915), 0); 383 + remove_wait_queue(&i915->display.gmbus.wait_queue, &wait); 400 384 401 385 if (gmbus2 & GMBUS_SATOER) 402 386 return -ENXIO; ··· 405 389 } 406 390 407 391 static int 408 - gmbus_wait_idle(struct drm_i915_private *dev_priv) 392 + gmbus_wait_idle(struct drm_i915_private *i915) 409 393 { 410 394 DEFINE_WAIT(wait); 411 395 u32 irq_enable; ··· 413 397 414 398 /* Important: The hw handles only the first bit, so set only one! */ 415 399 irq_enable = 0; 416 - if (has_gmbus_irq(dev_priv)) 400 + if (has_gmbus_irq(i915)) 417 401 irq_enable = GMBUS_IDLE_EN; 418 402 419 - add_wait_queue(&dev_priv->display.gmbus.wait_queue, &wait); 420 - intel_de_write_fw(dev_priv, GMBUS4, irq_enable); 403 + add_wait_queue(&i915->display.gmbus.wait_queue, &wait); 404 + intel_de_write_fw(i915, GMBUS4(i915), irq_enable); 421 405 422 - ret = intel_wait_for_register_fw(&dev_priv->uncore, 423 - GMBUS2, GMBUS_ACTIVE, 0, 406 + ret = intel_wait_for_register_fw(&i915->uncore, 407 + GMBUS2(i915), GMBUS_ACTIVE, 0, 424 408 10); 425 409 426 - intel_de_write_fw(dev_priv, GMBUS4, 0); 427 - remove_wait_queue(&dev_priv->display.gmbus.wait_queue, &wait); 410 + intel_de_write_fw(i915, GMBUS4(i915), 0); 411 + remove_wait_queue(&i915->display.gmbus.wait_queue, &wait); 428 412 429 413 return ret; 430 414 } 431 415 432 - static unsigned int gmbus_max_xfer_size(struct drm_i915_private *dev_priv) 416 + static unsigned int gmbus_max_xfer_size(struct drm_i915_private *i915) 433 417 { 434 - return DISPLAY_VER(dev_priv) >= 9 ? GEN9_GMBUS_BYTE_COUNT_MAX : 418 + return DISPLAY_VER(i915) >= 9 ? GEN9_GMBUS_BYTE_COUNT_MAX : 435 419 GMBUS_BYTE_COUNT_MAX; 436 420 } 437 421 438 422 static int 439 - gmbus_xfer_read_chunk(struct drm_i915_private *dev_priv, 423 + gmbus_xfer_read_chunk(struct drm_i915_private *i915, 440 424 unsigned short addr, u8 *buf, unsigned int len, 441 425 u32 gmbus0_reg, u32 gmbus1_index) 442 426 { 443 427 unsigned int size = len; 444 - bool burst_read = len > gmbus_max_xfer_size(dev_priv); 428 + bool burst_read = len > gmbus_max_xfer_size(i915); 445 429 bool extra_byte_added = false; 446 430 447 431 if (burst_read) { ··· 454 438 len++; 455 439 } 456 440 size = len % 256 + 256; 457 - intel_de_write_fw(dev_priv, GMBUS0, 441 + intel_de_write_fw(i915, GMBUS0(i915), 458 442 gmbus0_reg | GMBUS_BYTE_CNT_OVERRIDE); 459 443 } 460 444 461 - intel_de_write_fw(dev_priv, GMBUS1, 445 + intel_de_write_fw(i915, GMBUS1(i915), 462 446 gmbus1_index | GMBUS_CYCLE_WAIT | (size << GMBUS_BYTE_COUNT_SHIFT) | (addr << GMBUS_SLAVE_ADDR_SHIFT) | GMBUS_SLAVE_READ | GMBUS_SW_RDY); 463 447 while (len) { 464 448 int ret; 465 449 u32 val, loop = 0; 466 450 467 - ret = gmbus_wait(dev_priv, GMBUS_HW_RDY, GMBUS_HW_RDY_EN); 451 + ret = gmbus_wait(i915, GMBUS_HW_RDY, GMBUS_HW_RDY_EN); 468 452 if (ret) 469 453 return ret; 470 454 471 - val = intel_de_read_fw(dev_priv, GMBUS3); 455 + val = intel_de_read_fw(i915, GMBUS3(i915)); 472 456 do { 473 457 if (extra_byte_added && len == 1) 474 458 break; ··· 479 463 480 464 if (burst_read && len == size - 4) 481 465 /* Reset the override bit */ 482 - intel_de_write_fw(dev_priv, GMBUS0, gmbus0_reg); 466 + intel_de_write_fw(i915, GMBUS0(i915), gmbus0_reg); 483 467 } 484 468 485 469 return 0; ··· 496 480 #define INTEL_GMBUS_BURST_READ_MAX_LEN 767U 497 481 498 482 static int 499 - gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg, 483 + gmbus_xfer_read(struct drm_i915_private *i915, struct i2c_msg *msg, 500 484 u32 gmbus0_reg, u32 gmbus1_index) 501 485 { 502 486 u8 *buf = msg->buf; ··· 505 489 int ret; 506 490 507 491 do { 508 - if (HAS_GMBUS_BURST_READ(dev_priv)) 492 + if (HAS_GMBUS_BURST_READ(i915)) 509 493 len = min(rx_size, INTEL_GMBUS_BURST_READ_MAX_LEN); 510 494 else 511 - len = min(rx_size, gmbus_max_xfer_size(dev_priv)); 495 + len = min(rx_size, gmbus_max_xfer_size(i915)); 512 496 513 - ret = gmbus_xfer_read_chunk(dev_priv, msg->addr, buf, len, 497 + ret = gmbus_xfer_read_chunk(i915, msg->addr, buf, len, 514 498 gmbus0_reg, gmbus1_index); 515 499 if (ret) 516 500 return ret; ··· 523 507 } 524 508 525 509 static int 526 - gmbus_xfer_write_chunk(struct drm_i915_private *dev_priv, 510 + gmbus_xfer_write_chunk(struct drm_i915_private *i915, 527 511 unsigned short addr, u8 *buf, unsigned int len, 528 512 u32 gmbus1_index) 529 513 { ··· 536 520 len -= 1; 537 521 } 538 522 539 - intel_de_write_fw(dev_priv, GMBUS3, val); 540 - intel_de_write_fw(dev_priv, GMBUS1, 523 + intel_de_write_fw(i915, GMBUS3(i915), val); 524 + intel_de_write_fw(i915, GMBUS1(i915), 541 525 gmbus1_index | GMBUS_CYCLE_WAIT | (chunk_size << GMBUS_BYTE_COUNT_SHIFT) | (addr << GMBUS_SLAVE_ADDR_SHIFT) | GMBUS_SLAVE_WRITE | GMBUS_SW_RDY); 542 526 while (len) { 543 527 int ret; ··· 547 531 val |= *buf++ << (8 * loop); 548 532 } while (--len && ++loop < 4); 549 533 550 - intel_de_write_fw(dev_priv, GMBUS3, val); 534 + intel_de_write_fw(i915, GMBUS3(i915), val); 551 535 552 - ret = gmbus_wait(dev_priv, GMBUS_HW_RDY, GMBUS_HW_RDY_EN); 536 + ret = gmbus_wait(i915, GMBUS_HW_RDY, GMBUS_HW_RDY_EN); 553 537 if (ret) 554 538 return ret; 555 539 } ··· 558 542 } 559 543 560 544 static int 561 - gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg, 545 + gmbus_xfer_write(struct drm_i915_private *i915, struct i2c_msg *msg, 562 546 u32 gmbus1_index) 563 547 { 564 548 u8 *buf = msg->buf; ··· 567 551 int ret; 568 552 569 553 do { 570 - len = min(tx_size, gmbus_max_xfer_size(dev_priv)); 554 + len = min(tx_size, gmbus_max_xfer_size(i915)); 571 555 572 - ret = gmbus_xfer_write_chunk(dev_priv, msg->addr, buf, len, 556 + ret = gmbus_xfer_write_chunk(i915, msg->addr, buf, len, 573 557 gmbus1_index); 574 558 if (ret) 575 559 return ret; ··· 596 580 } 597 581 598 582 static int 599 - gmbus_index_xfer(struct drm_i915_private *dev_priv, struct i2c_msg *msgs, 583 + gmbus_index_xfer(struct drm_i915_private *i915, struct i2c_msg *msgs, 600 584 u32 gmbus0_reg) 601 585 { 602 586 u32 gmbus1_index = 0; ··· 612 596 613 597 /* GMBUS5 holds 16-bit index */ 614 598 if (gmbus5) 615 - intel_de_write_fw(dev_priv, GMBUS5, gmbus5); 599 + intel_de_write_fw(i915, GMBUS5(i915), gmbus5); 616 600 617 601 if (msgs[1].flags & I2C_M_RD) 618 - ret = gmbus_xfer_read(dev_priv, &msgs[1], gmbus0_reg, 602 + ret = gmbus_xfer_read(i915, &msgs[1], gmbus0_reg, 619 603 gmbus1_index); 620 604 else 621 - ret = gmbus_xfer_write(dev_priv, &msgs[1], gmbus1_index); 605 + ret = gmbus_xfer_write(i915, &msgs[1], gmbus1_index); 622 606 623 607 /* Clear GMBUS5 after each index transfer */ 624 608 if (gmbus5) 625 - intel_de_write_fw(dev_priv, GMBUS5, 0); 609 + intel_de_write_fw(i915, GMBUS5(i915), 0); 626 610 627 611 return ret; 628 612 } ··· 632 616 u32 gmbus0_source) 633 617 { 634 618 struct intel_gmbus *bus = to_intel_gmbus(adapter); 635 - struct drm_i915_private *dev_priv = bus->dev_priv; 619 + struct drm_i915_private *i915 = bus->i915; 636 620 int i = 0, inc, try = 0; 637 621 int ret = 0; 638 622 639 623 /* Display WA #0868: skl,bxt,kbl,cfl,glk */ 640 - if (IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) 641 - bxt_gmbus_clock_gating(dev_priv, false); 642 - else if (HAS_PCH_SPT(dev_priv) || HAS_PCH_CNP(dev_priv)) 643 - pch_gmbus_clock_gating(dev_priv, false); 624 + if (IS_GEMINILAKE(i915) || IS_BROXTON(i915)) 625 + bxt_gmbus_clock_gating(i915, false); 626 + else if (HAS_PCH_SPT(i915) || HAS_PCH_CNP(i915)) 627 + pch_gmbus_clock_gating(i915, false); 644 628 645 629 retry: 646 - intel_de_write_fw(dev_priv, GMBUS0, gmbus0_source | bus->reg0); 630 + intel_de_write_fw(i915, GMBUS0(i915), gmbus0_source | bus->reg0); 647 631 648 632 for (; i < num; i += inc) { 649 633 inc = 1; 650 634 if (gmbus_is_index_xfer(msgs, i, num)) { 651 - ret = gmbus_index_xfer(dev_priv, &msgs[i], 635 + ret = gmbus_index_xfer(i915, &msgs[i], 652 636 gmbus0_source | bus->reg0); 653 637 inc = 2; /* an index transmission is two msgs */ 654 638 } else if (msgs[i].flags & I2C_M_RD) { 655 - ret = gmbus_xfer_read(dev_priv, &msgs[i], 639 + ret = gmbus_xfer_read(i915, &msgs[i], 656 640 gmbus0_source | bus->reg0, 0); 657 641 } else { 658 - ret = gmbus_xfer_write(dev_priv, &msgs[i], 0); 642 + ret = gmbus_xfer_write(i915, &msgs[i], 0); 659 643 } 660 644 661 645 if (!ret) 662 - ret = gmbus_wait(dev_priv, 646 + ret = gmbus_wait(i915, 663 647 GMBUS_HW_WAIT_PHASE, GMBUS_HW_WAIT_EN); 664 648 if (ret == -ETIMEDOUT) 665 649 goto timeout; ··· 671 655 * a STOP on the very first cycle. To simplify the code we 672 656 * unconditionally generate the STOP condition with an additional gmbus 673 657 * cycle. */ 674 - intel_de_write_fw(dev_priv, GMBUS1, GMBUS_CYCLE_STOP | GMBUS_SW_RDY); 658 + intel_de_write_fw(i915, GMBUS1(i915), GMBUS_CYCLE_STOP | GMBUS_SW_RDY); 675 659 676 660 /* Mark the GMBUS interface as disabled after waiting for idle. 677 661 * We will re-enable it at the start of the next xfer, 678 662 * till then let it sleep. 679 663 */ 680 - if (gmbus_wait_idle(dev_priv)) { 681 - drm_dbg_kms(&dev_priv->drm, 664 + if (gmbus_wait_idle(i915)) { 665 + drm_dbg_kms(&i915->drm, 682 666 "GMBUS [%s] timed out waiting for idle\n", 683 667 adapter->name); 684 668 ret = -ETIMEDOUT; 685 669 } 686 - intel_de_write_fw(dev_priv, GMBUS0, 0); 670 + intel_de_write_fw(i915, GMBUS0(i915), 0); 687 671 ret = ret ?: i; 688 672 goto out; 689 673 ··· 702 686 * it's slow responding and only answers on the 2nd retry. 703 687 */ 704 688 ret = -ENXIO; 705 - if (gmbus_wait_idle(dev_priv)) { 706 - drm_dbg_kms(&dev_priv->drm, 689 + if (gmbus_wait_idle(i915)) { 690 + drm_dbg_kms(&i915->drm, 707 691 "GMBUS [%s] timed out after NAK\n", 708 692 adapter->name); 709 693 ret = -ETIMEDOUT; ··· 713 697 * of resetting the GMBUS controller and so clearing the 714 698 * BUS_ERROR raised by the slave's NAK. 715 699 */ 716 - intel_de_write_fw(dev_priv, GMBUS1, GMBUS_SW_CLR_INT); 717 - intel_de_write_fw(dev_priv, GMBUS1, 0); 718 - intel_de_write_fw(dev_priv, GMBUS0, 0); 700 + intel_de_write_fw(i915, GMBUS1(i915), GMBUS_SW_CLR_INT); 701 + intel_de_write_fw(i915, GMBUS1(i915), 0); 702 + intel_de_write_fw(i915, GMBUS0(i915), 0); 719 703 720 - drm_dbg_kms(&dev_priv->drm, "GMBUS [%s] NAK for addr: %04x %c(%d)\n", 704 + drm_dbg_kms(&i915->drm, "GMBUS [%s] NAK for addr: %04x %c(%d)\n", 721 705 adapter->name, msgs[i].addr, 722 706 (msgs[i].flags & I2C_M_RD) ? 'r' : 'w', msgs[i].len); 723 707 ··· 728 712 * drm_do_probe_ddc_edid, which bails out on the first -ENXIO. 729 713 */ 730 714 if (ret == -ENXIO && i == 0 && try++ == 0) { 731 - drm_dbg_kms(&dev_priv->drm, 715 + drm_dbg_kms(&i915->drm, 732 716 "GMBUS [%s] NAK on first message, retry\n", 733 717 adapter->name); 734 718 goto retry; ··· 737 721 goto out; 738 722 739 723 timeout: 740 - drm_dbg_kms(&dev_priv->drm, 724 + drm_dbg_kms(&i915->drm, 741 725 "GMBUS [%s] timed out, falling back to bit banging on pin %d\n", 742 726 bus->adapter.name, bus->reg0 & 0xff); 743 - intel_de_write_fw(dev_priv, GMBUS0, 0); 727 + intel_de_write_fw(i915, GMBUS0(i915), 0); 744 728 745 729 /* 746 730 * Hardware may not support GMBUS over these pins? Try GPIO bitbanging ··· 750 734 751 735 out: 752 736 /* Display WA #0868: skl,bxt,kbl,cfl,glk */ 753 - if (IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) 754 - bxt_gmbus_clock_gating(dev_priv, true); 755 - else if (HAS_PCH_SPT(dev_priv) || HAS_PCH_CNP(dev_priv)) 756 - pch_gmbus_clock_gating(dev_priv, true); 737 + if (IS_GEMINILAKE(i915) || IS_BROXTON(i915)) 738 + bxt_gmbus_clock_gating(i915, true); 739 + else if (HAS_PCH_SPT(i915) || HAS_PCH_CNP(i915)) 740 + pch_gmbus_clock_gating(i915, true); 757 741 758 742 return ret; 759 743 } ··· 762 746 gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) 763 747 { 764 748 struct intel_gmbus *bus = to_intel_gmbus(adapter); 765 - struct drm_i915_private *dev_priv = bus->dev_priv; 749 + struct drm_i915_private *i915 = bus->i915; 766 750 intel_wakeref_t wakeref; 767 751 int ret; 768 752 769 - wakeref = intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS); 753 + wakeref = intel_display_power_get(i915, POWER_DOMAIN_GMBUS); 770 754 771 755 if (bus->force_bit) { 772 756 ret = i2c_bit_algo.master_xfer(adapter, msgs, num); ··· 778 762 bus->force_bit |= GMBUS_FORCE_BIT_RETRY; 779 763 } 780 764 781 - intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS, wakeref); 765 + intel_display_power_put(i915, POWER_DOMAIN_GMBUS, wakeref); 782 766 783 767 return ret; 784 768 } ··· 786 770 int intel_gmbus_output_aksv(struct i2c_adapter *adapter) 787 771 { 788 772 struct intel_gmbus *bus = to_intel_gmbus(adapter); 789 - struct drm_i915_private *dev_priv = bus->dev_priv; 773 + struct drm_i915_private *i915 = bus->i915; 790 774 u8 cmd = DRM_HDCP_DDC_AKSV; 791 775 u8 buf[DRM_HDCP_KSV_LEN] = { 0 }; 792 776 struct i2c_msg msgs[] = { ··· 806 790 intel_wakeref_t wakeref; 807 791 int ret; 808 792 809 - wakeref = intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS); 810 - mutex_lock(&dev_priv->display.gmbus.mutex); 793 + wakeref = intel_display_power_get(i915, POWER_DOMAIN_GMBUS); 794 + mutex_lock(&i915->display.gmbus.mutex); 811 795 812 796 /* 813 797 * In order to output Aksv to the receiver, use an indexed write to ··· 816 800 */ 817 801 ret = do_gmbus_xfer(adapter, msgs, ARRAY_SIZE(msgs), GMBUS_AKSV_SELECT); 818 802 819 - mutex_unlock(&dev_priv->display.gmbus.mutex); 820 - intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS, wakeref); 803 + mutex_unlock(&i915->display.gmbus.mutex); 804 + intel_display_power_put(i915, POWER_DOMAIN_GMBUS, wakeref); 821 805 822 806 return ret; 823 807 } ··· 840 824 unsigned int flags) 841 825 { 842 826 struct intel_gmbus *bus = to_intel_gmbus(adapter); 843 - struct drm_i915_private *dev_priv = bus->dev_priv; 827 + struct drm_i915_private *i915 = bus->i915; 844 828 845 - mutex_lock(&dev_priv->display.gmbus.mutex); 829 + mutex_lock(&i915->display.gmbus.mutex); 846 830 } 847 831 848 832 static int gmbus_trylock_bus(struct i2c_adapter *adapter, 849 833 unsigned int flags) 850 834 { 851 835 struct intel_gmbus *bus = to_intel_gmbus(adapter); 852 - struct drm_i915_private *dev_priv = bus->dev_priv; 836 + struct drm_i915_private *i915 = bus->i915; 853 837 854 - return mutex_trylock(&dev_priv->display.gmbus.mutex); 838 + return mutex_trylock(&i915->display.gmbus.mutex); 855 839 } 856 840 857 841 static void gmbus_unlock_bus(struct i2c_adapter *adapter, 858 842 unsigned int flags) 859 843 { 860 844 struct intel_gmbus *bus = to_intel_gmbus(adapter); 861 - struct drm_i915_private *dev_priv = bus->dev_priv; 845 + struct drm_i915_private *i915 = bus->i915; 862 846 863 - mutex_unlock(&dev_priv->display.gmbus.mutex); 847 + mutex_unlock(&i915->display.gmbus.mutex); 864 848 } 865 849 866 850 static const struct i2c_lock_operations gmbus_lock_ops = { ··· 871 855 872 856 /** 873 857 * intel_gmbus_setup - instantiate all Intel i2c GMBuses 874 - * @dev_priv: i915 device private 858 + * @i915: i915 device private 875 859 */ 876 - int intel_gmbus_setup(struct drm_i915_private *dev_priv) 860 + int intel_gmbus_setup(struct drm_i915_private *i915) 877 861 { 878 - struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); 862 + struct pci_dev *pdev = to_pci_dev(i915->drm.dev); 879 863 unsigned int pin; 880 864 int ret; 881 865 882 - if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) 883 - dev_priv->display.gmbus.mmio_base = VLV_DISPLAY_BASE; 884 - else if (!HAS_GMCH(dev_priv)) 866 + if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) 867 + i915->display.gmbus.mmio_base = VLV_DISPLAY_BASE; 868 + else if (!HAS_GMCH(i915)) 885 869 /* 886 870 * Broxton uses the same PCH offsets for South Display Engine, 887 871 * even though it doesn't have a PCH. 888 872 */ 889 - dev_priv->display.gmbus.mmio_base = PCH_DISPLAY_BASE; 873 + i915->display.gmbus.mmio_base = PCH_DISPLAY_BASE; 890 874 891 - mutex_init(&dev_priv->display.gmbus.mutex); 892 - init_waitqueue_head(&dev_priv->display.gmbus.wait_queue); 875 + mutex_init(&i915->display.gmbus.mutex); 876 + init_waitqueue_head(&i915->display.gmbus.wait_queue); 893 877 894 - for (pin = 0; pin < ARRAY_SIZE(dev_priv->display.gmbus.bus); pin++) { 878 + for (pin = 0; pin < ARRAY_SIZE(i915->display.gmbus.bus); pin++) { 895 879 const struct gmbus_pin *gmbus_pin; 896 880 struct intel_gmbus *bus; 897 881 898 - gmbus_pin = get_gmbus_pin(dev_priv, pin); 882 + gmbus_pin = get_gmbus_pin(i915, pin); 899 883 if (!gmbus_pin) 900 884 continue; 901 885 ··· 912 896 "i915 gmbus %s", gmbus_pin->name); 913 897 914 898 bus->adapter.dev.parent = &pdev->dev; 915 - bus->dev_priv = dev_priv; 899 + bus->i915 = i915; 916 900 917 901 bus->adapter.algo = &gmbus_algorithm; 918 902 bus->adapter.lock_ops = &gmbus_lock_ops; ··· 927 911 bus->reg0 = pin | GMBUS_RATE_100KHZ; 928 912 929 913 /* gmbus seems to be broken on i830 */ 930 - if (IS_I830(dev_priv)) 914 + if (IS_I830(i915)) 931 915 bus->force_bit = 1; 932 916 933 - intel_gpio_setup(bus, GPIO(gmbus_pin->gpio)); 917 + intel_gpio_setup(bus, GPIO(i915, gmbus_pin->gpio)); 934 918 935 919 ret = i2c_add_adapter(&bus->adapter); 936 920 if (ret) { ··· 938 922 goto err; 939 923 } 940 924 941 - dev_priv->display.gmbus.bus[pin] = bus; 925 + i915->display.gmbus.bus[pin] = bus; 942 926 } 943 927 944 - intel_gmbus_reset(dev_priv); 928 + intel_gmbus_reset(i915); 945 929 946 930 return 0; 947 931 948 932 err: 949 - intel_gmbus_teardown(dev_priv); 933 + intel_gmbus_teardown(i915); 950 934 951 935 return ret; 952 936 } 953 937 954 - struct i2c_adapter *intel_gmbus_get_adapter(struct drm_i915_private *dev_priv, 938 + struct i2c_adapter *intel_gmbus_get_adapter(struct drm_i915_private *i915, 955 939 unsigned int pin) 956 940 { 957 - if (drm_WARN_ON(&dev_priv->drm, pin >= ARRAY_SIZE(dev_priv->display.gmbus.bus) || 958 - !dev_priv->display.gmbus.bus[pin])) 941 + if (drm_WARN_ON(&i915->drm, pin >= ARRAY_SIZE(i915->display.gmbus.bus) || 942 + !i915->display.gmbus.bus[pin])) 959 943 return NULL; 960 944 961 - return &dev_priv->display.gmbus.bus[pin]->adapter; 945 + return &i915->display.gmbus.bus[pin]->adapter; 962 946 } 963 947 964 948 void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit) 965 949 { 966 950 struct intel_gmbus *bus = to_intel_gmbus(adapter); 967 - struct drm_i915_private *dev_priv = bus->dev_priv; 951 + struct drm_i915_private *i915 = bus->i915; 968 952 969 - mutex_lock(&dev_priv->display.gmbus.mutex); 953 + mutex_lock(&i915->display.gmbus.mutex); 970 954 971 955 bus->force_bit += force_bit ? 1 : -1; 972 - drm_dbg_kms(&dev_priv->drm, 956 + drm_dbg_kms(&i915->drm, 973 957 "%sabling bit-banging on %s. force bit now %d\n", 974 958 force_bit ? "en" : "dis", adapter->name, 975 959 bus->force_bit); 976 960 977 - mutex_unlock(&dev_priv->display.gmbus.mutex); 961 + mutex_unlock(&i915->display.gmbus.mutex); 978 962 } 979 963 980 964 bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter) ··· 984 968 return bus->force_bit; 985 969 } 986 970 987 - void intel_gmbus_teardown(struct drm_i915_private *dev_priv) 971 + void intel_gmbus_teardown(struct drm_i915_private *i915) 988 972 { 989 973 unsigned int pin; 990 974 991 - for (pin = 0; pin < ARRAY_SIZE(dev_priv->display.gmbus.bus); pin++) { 975 + for (pin = 0; pin < ARRAY_SIZE(i915->display.gmbus.bus); pin++) { 992 976 struct intel_gmbus *bus; 993 977 994 - bus = dev_priv->display.gmbus.bus[pin]; 978 + bus = i915->display.gmbus.bus[pin]; 995 979 if (!bus) 996 980 continue; 997 981 998 982 i2c_del_adapter(&bus->adapter); 999 983 1000 984 kfree(bus); 1001 - dev_priv->display.gmbus.bus[pin] = NULL; 985 + i915->display.gmbus.bus[pin] = NULL; 1002 986 } 1003 987 }
+1
drivers/gpu/drm/i915/display/intel_gmbus.h
··· 24 24 #define GMBUS_PIN_2_BXT 2 25 25 #define GMBUS_PIN_3_BXT 3 26 26 #define GMBUS_PIN_4_CNP 4 27 + #define GMBUS_PIN_5_MTP 5 27 28 #define GMBUS_PIN_9_TC1_ICP 9 28 29 #define GMBUS_PIN_10_TC2_ICP 10 29 30 #define GMBUS_PIN_11_TC3_ICP 11
+81
drivers/gpu/drm/i915/display/intel_gmbus_regs.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2022 Intel Corporation 4 + */ 5 + 6 + #ifndef __INTEL_GMBUS_REGS_H__ 7 + #define __INTEL_GMBUS_REGS_H__ 8 + 9 + #include "i915_reg_defs.h" 10 + 11 + #define GMBUS_MMIO_BASE(__i915) ((__i915)->display.gmbus.mmio_base) 12 + 13 + #define GPIO(__i915, gpio) _MMIO(GMBUS_MMIO_BASE(__i915) + 0x5010 + 4 * (gpio)) 14 + #define GPIO_CLOCK_DIR_MASK (1 << 0) 15 + #define GPIO_CLOCK_DIR_IN (0 << 1) 16 + #define GPIO_CLOCK_DIR_OUT (1 << 1) 17 + #define GPIO_CLOCK_VAL_MASK (1 << 2) 18 + #define GPIO_CLOCK_VAL_OUT (1 << 3) 19 + #define GPIO_CLOCK_VAL_IN (1 << 4) 20 + #define GPIO_CLOCK_PULLUP_DISABLE (1 << 5) 21 + #define GPIO_DATA_DIR_MASK (1 << 8) 22 + #define GPIO_DATA_DIR_IN (0 << 9) 23 + #define GPIO_DATA_DIR_OUT (1 << 9) 24 + #define GPIO_DATA_VAL_MASK (1 << 10) 25 + #define GPIO_DATA_VAL_OUT (1 << 11) 26 + #define GPIO_DATA_VAL_IN (1 << 12) 27 + #define GPIO_DATA_PULLUP_DISABLE (1 << 13) 28 + 29 + /* clock/port select */ 30 + #define GMBUS0(__i915) _MMIO(GMBUS_MMIO_BASE(__i915) + 0x5100) 31 + #define GMBUS_AKSV_SELECT (1 << 11) 32 + #define GMBUS_RATE_100KHZ (0 << 8) 33 + #define GMBUS_RATE_50KHZ (1 << 8) 34 + #define GMBUS_RATE_400KHZ (2 << 8) /* reserved on Pineview */ 35 + #define GMBUS_RATE_1MHZ (3 << 8) /* reserved on Pineview */ 36 + #define GMBUS_HOLD_EXT (1 << 7) /* 300ns hold time, rsvd on Pineview */ 37 + #define GMBUS_BYTE_CNT_OVERRIDE (1 << 6) 38 + 39 + /* command/status */ 40 + #define GMBUS1(__i915) _MMIO(GMBUS_MMIO_BASE(__i915) + 0x5104) 41 + #define GMBUS_SW_CLR_INT (1 << 31) 42 + #define GMBUS_SW_RDY (1 << 30) 43 + #define GMBUS_ENT (1 << 29) /* enable timeout */ 44 + #define GMBUS_CYCLE_NONE (0 << 25) 45 + #define GMBUS_CYCLE_WAIT (1 << 25) 46 + #define GMBUS_CYCLE_INDEX (2 << 25) 47 + #define GMBUS_CYCLE_STOP (4 << 25) 48 + #define GMBUS_BYTE_COUNT_SHIFT 16 49 + #define GMBUS_BYTE_COUNT_MAX 256U 50 + #define GEN9_GMBUS_BYTE_COUNT_MAX 511U 51 + #define GMBUS_SLAVE_INDEX_SHIFT 8 52 + #define GMBUS_SLAVE_ADDR_SHIFT 1 53 + #define GMBUS_SLAVE_READ (1 << 0) 54 + #define GMBUS_SLAVE_WRITE (0 << 0) 55 + 56 + /* status */ 57 + #define GMBUS2(__i915) _MMIO(GMBUS_MMIO_BASE(__i915) + 0x5108) 58 + #define GMBUS_INUSE (1 << 15) 59 + #define GMBUS_HW_WAIT_PHASE (1 << 14) 60 + #define GMBUS_STALL_TIMEOUT (1 << 13) 61 + #define GMBUS_INT (1 << 12) 62 + #define GMBUS_HW_RDY (1 << 11) 63 + #define GMBUS_SATOER (1 << 10) 64 + #define GMBUS_ACTIVE (1 << 9) 65 + 66 + /* data buffer bytes 3-0 */ 67 + #define GMBUS3(__i915) _MMIO(GMBUS_MMIO_BASE(__i915) + 0x510c) 68 + 69 + /* interrupt mask (Pineview+) */ 70 + #define GMBUS4(__i915) _MMIO(GMBUS_MMIO_BASE(__i915) + 0x5110) 71 + #define GMBUS_SLAVE_TIMEOUT_EN (1 << 4) 72 + #define GMBUS_NAK_EN (1 << 3) 73 + #define GMBUS_IDLE_EN (1 << 2) 74 + #define GMBUS_HW_WAIT_EN (1 << 1) 75 + #define GMBUS_HW_RDY_EN (1 << 0) 76 + 77 + /* byte index */ 78 + #define GMBUS5(__i915) _MMIO(GMBUS_MMIO_BASE(__i915) + 0x5120) 79 + #define GMBUS_2BYTE_INDEX_EN (1 << 31) 80 + 81 + #endif /* __INTEL_GMBUS_REGS_H__ */
+67 -67
drivers/gpu/drm/i915/display/intel_hdcp.c
··· 210 210 return false; 211 211 212 212 /* MEI interface is solid */ 213 - mutex_lock(&dev_priv->hdcp_comp_mutex); 214 - if (!dev_priv->hdcp_comp_added || !dev_priv->hdcp_master) { 215 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 213 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 214 + if (!dev_priv->display.hdcp.comp_added || !dev_priv->display.hdcp.master) { 215 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 216 216 return false; 217 217 } 218 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 218 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 219 219 220 220 /* Sink's capability for HDCP2.2 */ 221 221 hdcp->shim->hdcp_2_2_capable(dig_port, &capable); ··· 1146 1146 struct i915_hdcp_comp_master *comp; 1147 1147 int ret; 1148 1148 1149 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1150 - comp = dev_priv->hdcp_master; 1149 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1150 + comp = dev_priv->display.hdcp.master; 1151 1151 1152 1152 if (!comp || !comp->ops) { 1153 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1153 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1154 1154 return -EINVAL; 1155 1155 } 1156 1156 ··· 1158 1158 if (ret) 1159 1159 drm_dbg_kms(&dev_priv->drm, "Prepare_ake_init failed. %d\n", 1160 1160 ret); 1161 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1161 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1162 1162 1163 1163 return ret; 1164 1164 } ··· 1176 1176 struct i915_hdcp_comp_master *comp; 1177 1177 int ret; 1178 1178 1179 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1180 - comp = dev_priv->hdcp_master; 1179 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1180 + comp = dev_priv->display.hdcp.master; 1181 1181 1182 1182 if (!comp || !comp->ops) { 1183 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1183 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1184 1184 return -EINVAL; 1185 1185 } 1186 1186 ··· 1190 1190 if (ret < 0) 1191 1191 drm_dbg_kms(&dev_priv->drm, "Verify rx_cert failed. %d\n", 1192 1192 ret); 1193 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1193 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1194 1194 1195 1195 return ret; 1196 1196 } ··· 1204 1204 struct i915_hdcp_comp_master *comp; 1205 1205 int ret; 1206 1206 1207 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1208 - comp = dev_priv->hdcp_master; 1207 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1208 + comp = dev_priv->display.hdcp.master; 1209 1209 1210 1210 if (!comp || !comp->ops) { 1211 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1211 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1212 1212 return -EINVAL; 1213 1213 } 1214 1214 1215 1215 ret = comp->ops->verify_hprime(comp->mei_dev, data, rx_hprime); 1216 1216 if (ret < 0) 1217 1217 drm_dbg_kms(&dev_priv->drm, "Verify hprime failed. %d\n", ret); 1218 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1218 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1219 1219 1220 1220 return ret; 1221 1221 } ··· 1230 1230 struct i915_hdcp_comp_master *comp; 1231 1231 int ret; 1232 1232 1233 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1234 - comp = dev_priv->hdcp_master; 1233 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1234 + comp = dev_priv->display.hdcp.master; 1235 1235 1236 1236 if (!comp || !comp->ops) { 1237 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1237 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1238 1238 return -EINVAL; 1239 1239 } 1240 1240 ··· 1242 1242 if (ret < 0) 1243 1243 drm_dbg_kms(&dev_priv->drm, "Store pairing info failed. %d\n", 1244 1244 ret); 1245 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1245 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1246 1246 1247 1247 return ret; 1248 1248 } ··· 1257 1257 struct i915_hdcp_comp_master *comp; 1258 1258 int ret; 1259 1259 1260 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1261 - comp = dev_priv->hdcp_master; 1260 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1261 + comp = dev_priv->display.hdcp.master; 1262 1262 1263 1263 if (!comp || !comp->ops) { 1264 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1264 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1265 1265 return -EINVAL; 1266 1266 } 1267 1267 ··· 1269 1269 if (ret < 0) 1270 1270 drm_dbg_kms(&dev_priv->drm, "Prepare lc_init failed. %d\n", 1271 1271 ret); 1272 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1272 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1273 1273 1274 1274 return ret; 1275 1275 } ··· 1284 1284 struct i915_hdcp_comp_master *comp; 1285 1285 int ret; 1286 1286 1287 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1288 - comp = dev_priv->hdcp_master; 1287 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1288 + comp = dev_priv->display.hdcp.master; 1289 1289 1290 1290 if (!comp || !comp->ops) { 1291 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1291 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1292 1292 return -EINVAL; 1293 1293 } 1294 1294 ··· 1296 1296 if (ret < 0) 1297 1297 drm_dbg_kms(&dev_priv->drm, "Verify L_Prime failed. %d\n", 1298 1298 ret); 1299 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1299 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1300 1300 1301 1301 return ret; 1302 1302 } ··· 1310 1310 struct i915_hdcp_comp_master *comp; 1311 1311 int ret; 1312 1312 1313 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1314 - comp = dev_priv->hdcp_master; 1313 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1314 + comp = dev_priv->display.hdcp.master; 1315 1315 1316 1316 if (!comp || !comp->ops) { 1317 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1317 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1318 1318 return -EINVAL; 1319 1319 } 1320 1320 ··· 1322 1322 if (ret < 0) 1323 1323 drm_dbg_kms(&dev_priv->drm, "Get session key failed. %d\n", 1324 1324 ret); 1325 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1325 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1326 1326 1327 1327 return ret; 1328 1328 } ··· 1339 1339 struct i915_hdcp_comp_master *comp; 1340 1340 int ret; 1341 1341 1342 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1343 - comp = dev_priv->hdcp_master; 1342 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1343 + comp = dev_priv->display.hdcp.master; 1344 1344 1345 1345 if (!comp || !comp->ops) { 1346 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1346 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1347 1347 return -EINVAL; 1348 1348 } 1349 1349 ··· 1353 1353 if (ret < 0) 1354 1354 drm_dbg_kms(&dev_priv->drm, 1355 1355 "Verify rep topology failed. %d\n", ret); 1356 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1356 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1357 1357 1358 1358 return ret; 1359 1359 } ··· 1368 1368 struct i915_hdcp_comp_master *comp; 1369 1369 int ret; 1370 1370 1371 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1372 - comp = dev_priv->hdcp_master; 1371 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1372 + comp = dev_priv->display.hdcp.master; 1373 1373 1374 1374 if (!comp || !comp->ops) { 1375 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1375 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1376 1376 return -EINVAL; 1377 1377 } 1378 1378 1379 1379 ret = comp->ops->verify_mprime(comp->mei_dev, data, stream_ready); 1380 1380 if (ret < 0) 1381 1381 drm_dbg_kms(&dev_priv->drm, "Verify mprime failed. %d\n", ret); 1382 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1382 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1383 1383 1384 1384 return ret; 1385 1385 } ··· 1392 1392 struct i915_hdcp_comp_master *comp; 1393 1393 int ret; 1394 1394 1395 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1396 - comp = dev_priv->hdcp_master; 1395 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1396 + comp = dev_priv->display.hdcp.master; 1397 1397 1398 1398 if (!comp || !comp->ops) { 1399 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1399 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1400 1400 return -EINVAL; 1401 1401 } 1402 1402 ··· 1404 1404 if (ret < 0) 1405 1405 drm_dbg_kms(&dev_priv->drm, "Enable hdcp auth failed. %d\n", 1406 1406 ret); 1407 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1407 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1408 1408 1409 1409 return ret; 1410 1410 } ··· 1416 1416 struct i915_hdcp_comp_master *comp; 1417 1417 int ret; 1418 1418 1419 - mutex_lock(&dev_priv->hdcp_comp_mutex); 1420 - comp = dev_priv->hdcp_master; 1419 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 1420 + comp = dev_priv->display.hdcp.master; 1421 1421 1422 1422 if (!comp || !comp->ops) { 1423 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1423 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1424 1424 return -EINVAL; 1425 1425 } 1426 1426 1427 1427 ret = comp->ops->close_hdcp_session(comp->mei_dev, 1428 1428 &dig_port->hdcp_port_data); 1429 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 1429 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 1430 1430 1431 1431 return ret; 1432 1432 } ··· 2144 2144 struct drm_i915_private *dev_priv = kdev_to_i915(i915_kdev); 2145 2145 2146 2146 drm_dbg(&dev_priv->drm, "I915 HDCP comp bind\n"); 2147 - mutex_lock(&dev_priv->hdcp_comp_mutex); 2148 - dev_priv->hdcp_master = (struct i915_hdcp_comp_master *)data; 2149 - dev_priv->hdcp_master->mei_dev = mei_kdev; 2150 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 2147 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 2148 + dev_priv->display.hdcp.master = (struct i915_hdcp_comp_master *)data; 2149 + dev_priv->display.hdcp.master->mei_dev = mei_kdev; 2150 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 2151 2151 2152 2152 return 0; 2153 2153 } ··· 2158 2158 struct drm_i915_private *dev_priv = kdev_to_i915(i915_kdev); 2159 2159 2160 2160 drm_dbg(&dev_priv->drm, "I915 HDCP comp unbind\n"); 2161 - mutex_lock(&dev_priv->hdcp_comp_mutex); 2162 - dev_priv->hdcp_master = NULL; 2163 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 2161 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 2162 + dev_priv->display.hdcp.master = NULL; 2163 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 2164 2164 } 2165 2165 2166 2166 static const struct component_ops i915_hdcp_component_ops = { ··· 2251 2251 if (!is_hdcp2_supported(dev_priv)) 2252 2252 return; 2253 2253 2254 - mutex_lock(&dev_priv->hdcp_comp_mutex); 2255 - drm_WARN_ON(&dev_priv->drm, dev_priv->hdcp_comp_added); 2254 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 2255 + drm_WARN_ON(&dev_priv->drm, dev_priv->display.hdcp.comp_added); 2256 2256 2257 - dev_priv->hdcp_comp_added = true; 2258 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 2257 + dev_priv->display.hdcp.comp_added = true; 2258 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 2259 2259 ret = component_add_typed(dev_priv->drm.dev, &i915_hdcp_component_ops, 2260 2260 I915_COMPONENT_HDCP); 2261 2261 if (ret < 0) { 2262 2262 drm_dbg_kms(&dev_priv->drm, "Failed at component add(%d)\n", 2263 2263 ret); 2264 - mutex_lock(&dev_priv->hdcp_comp_mutex); 2265 - dev_priv->hdcp_comp_added = false; 2266 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 2264 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 2265 + dev_priv->display.hdcp.comp_added = false; 2266 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 2267 2267 return; 2268 2268 } 2269 2269 } ··· 2476 2476 2477 2477 void intel_hdcp_component_fini(struct drm_i915_private *dev_priv) 2478 2478 { 2479 - mutex_lock(&dev_priv->hdcp_comp_mutex); 2480 - if (!dev_priv->hdcp_comp_added) { 2481 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 2479 + mutex_lock(&dev_priv->display.hdcp.comp_mutex); 2480 + if (!dev_priv->display.hdcp.comp_added) { 2481 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 2482 2482 return; 2483 2483 } 2484 2484 2485 - dev_priv->hdcp_comp_added = false; 2486 - mutex_unlock(&dev_priv->hdcp_comp_mutex); 2485 + dev_priv->display.hdcp.comp_added = false; 2486 + mutex_unlock(&dev_priv->display.hdcp.comp_mutex); 2487 2487 2488 2488 component_del(dev_priv->drm.dev, &i915_hdcp_component_ops); 2489 2489 }
+1 -1
drivers/gpu/drm/i915/display/intel_hdmi.c
··· 1892 1892 * 1.5x for 12bpc 1893 1893 * 1.25x for 10bpc 1894 1894 */ 1895 - return clock * bpc / 8; 1895 + return DIV_ROUND_CLOSEST(clock * bpc, 8); 1896 1896 } 1897 1897 1898 1898 static bool intel_hdmi_source_bpc_possible(struct drm_i915_private *i915, int bpc)
+2 -2
drivers/gpu/drm/i915/display/intel_lvds.c
··· 837 837 838 838 /* Skip init on machines we know falsely report LVDS */ 839 839 if (dmi_check_system(intel_no_lvds)) { 840 - drm_WARN(dev, !dev_priv->vbt.int_lvds_support, 840 + drm_WARN(dev, !dev_priv->display.vbt.int_lvds_support, 841 841 "Useless DMI match. Internal LVDS support disabled by VBT\n"); 842 842 return; 843 843 } 844 844 845 - if (!dev_priv->vbt.int_lvds_support) { 845 + if (!dev_priv->display.vbt.int_lvds_support) { 846 846 drm_dbg_kms(&dev_priv->drm, 847 847 "Internal LVDS support disabled by VBT\n"); 848 848 return;
+7 -6
drivers/gpu/drm/i915/display/intel_modeset_setup.c
··· 23 23 #include "intel_modeset_setup.h" 24 24 #include "intel_pch_display.h" 25 25 #include "intel_pm.h" 26 + #include "skl_watermark.h" 26 27 27 28 static void intel_crtc_disable_noatomic(struct intel_crtc *crtc, 28 29 struct drm_modeset_acquire_ctx *ctx) ··· 31 30 struct intel_encoder *encoder; 32 31 struct drm_i915_private *i915 = to_i915(crtc->base.dev); 33 32 struct intel_bw_state *bw_state = 34 - to_intel_bw_state(i915->bw_obj.state); 33 + to_intel_bw_state(i915->display.bw.obj.state); 35 34 struct intel_cdclk_state *cdclk_state = 36 - to_intel_cdclk_state(i915->cdclk.obj.state); 35 + to_intel_cdclk_state(i915->display.cdclk.obj.state); 37 36 struct intel_dbuf_state *dbuf_state = 38 - to_intel_dbuf_state(i915->dbuf.obj.state); 37 + to_intel_dbuf_state(i915->display.dbuf.obj.state); 39 38 struct intel_crtc_state *crtc_state = 40 39 to_intel_crtc_state(crtc->base.state); 41 40 struct intel_plane *plane; ··· 416 415 static void intel_modeset_readout_hw_state(struct drm_i915_private *i915) 417 416 { 418 417 struct intel_cdclk_state *cdclk_state = 419 - to_intel_cdclk_state(i915->cdclk.obj.state); 418 + to_intel_cdclk_state(i915->display.cdclk.obj.state); 420 419 struct intel_dbuf_state *dbuf_state = 421 - to_intel_dbuf_state(i915->dbuf.obj.state); 420 + to_intel_dbuf_state(i915->display.dbuf.obj.state); 422 421 enum pipe pipe; 423 422 struct intel_crtc *crtc; 424 423 struct intel_encoder *encoder; ··· 536 535 537 536 for_each_intel_crtc(&i915->drm, crtc) { 538 537 struct intel_bw_state *bw_state = 539 - to_intel_bw_state(i915->bw_obj.state); 538 + to_intel_bw_state(i915->display.bw.obj.state); 540 539 struct intel_crtc_state *crtc_state = 541 540 to_intel_crtc_state(crtc->base.state); 542 541 struct intel_plane *plane;
+4 -4
drivers/gpu/drm/i915/display/intel_modeset_verify.c
··· 15 15 #include "intel_display_types.h" 16 16 #include "intel_fdi.h" 17 17 #include "intel_modeset_verify.h" 18 - #include "intel_pm.h" 19 18 #include "intel_snps_phy.h" 19 + #include "skl_watermark.h" 20 20 21 21 /* 22 22 * Cross check the actual hw state with our own modeset state tracking (and its ··· 94 94 95 95 /* 96 96 * FDI already provided one idea for the dotclock. 97 - * Yell if the encoder disagrees. 97 + * Yell if the encoder disagrees. Allow for slight 98 + * rounding differences. 98 99 */ 99 - drm_WARN(&dev_priv->drm, 100 - !intel_fuzzy_clock_check(fdi_dotclock, dotclock), 100 + drm_WARN(&dev_priv->drm, abs(fdi_dotclock - dotclock) > 1, 101 101 "FDI dotclock and encoder dotclock mismatch, fdi: %i, encoder: %i\n", 102 102 fdi_dotclock, dotclock); 103 103 }
+21 -21
drivers/gpu/drm/i915/display/intel_opregion.c
··· 252 252 253 253 static int check_swsci_function(struct drm_i915_private *i915, u32 function) 254 254 { 255 - struct opregion_swsci *swsci = i915->opregion.swsci; 255 + struct opregion_swsci *swsci = i915->display.opregion.swsci; 256 256 u32 main_function, sub_function; 257 257 258 258 if (!swsci) ··· 265 265 266 266 /* Check if we can call the function. See swsci_setup for details. */ 267 267 if (main_function == SWSCI_SBCB) { 268 - if ((i915->opregion.swsci_sbcb_sub_functions & 268 + if ((i915->display.opregion.swsci_sbcb_sub_functions & 269 269 (1 << sub_function)) == 0) 270 270 return -EINVAL; 271 271 } else if (main_function == SWSCI_GBDA) { 272 - if ((i915->opregion.swsci_gbda_sub_functions & 272 + if ((i915->display.opregion.swsci_gbda_sub_functions & 273 273 (1 << sub_function)) == 0) 274 274 return -EINVAL; 275 275 } ··· 280 280 static int swsci(struct drm_i915_private *dev_priv, 281 281 u32 function, u32 parm, u32 *parm_out) 282 282 { 283 - struct opregion_swsci *swsci = dev_priv->opregion.swsci; 283 + struct opregion_swsci *swsci = dev_priv->display.opregion.swsci; 284 284 struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); 285 285 u32 scic, dslp; 286 286 u16 swsci_val; ··· 462 462 { 463 463 struct intel_connector *connector; 464 464 struct drm_connector_list_iter conn_iter; 465 - struct opregion_asle *asle = dev_priv->opregion.asle; 465 + struct opregion_asle *asle = dev_priv->display.opregion.asle; 466 466 struct drm_device *dev = &dev_priv->drm; 467 467 468 468 drm_dbg(&dev_priv->drm, "bclp = 0x%08x\n", bclp); ··· 586 586 struct intel_opregion *opregion = 587 587 container_of(work, struct intel_opregion, asle_work); 588 588 struct drm_i915_private *dev_priv = 589 - container_of(opregion, struct drm_i915_private, opregion); 590 - struct opregion_asle *asle = dev_priv->opregion.asle; 589 + container_of(opregion, struct drm_i915_private, display.opregion); 590 + struct opregion_asle *asle = dev_priv->display.opregion.asle; 591 591 u32 aslc_stat = 0; 592 592 u32 aslc_req; 593 593 ··· 635 635 636 636 void intel_opregion_asle_intr(struct drm_i915_private *dev_priv) 637 637 { 638 - if (dev_priv->opregion.asle) 639 - schedule_work(&dev_priv->opregion.asle_work); 638 + if (dev_priv->display.opregion.asle) 639 + schedule_work(&dev_priv->display.opregion.asle_work); 640 640 } 641 641 642 642 #define ACPI_EV_DISPLAY_SWITCH (1<<0) ··· 692 692 693 693 static void intel_didl_outputs(struct drm_i915_private *dev_priv) 694 694 { 695 - struct intel_opregion *opregion = &dev_priv->opregion; 695 + struct intel_opregion *opregion = &dev_priv->display.opregion; 696 696 struct intel_connector *connector; 697 697 struct drm_connector_list_iter conn_iter; 698 698 int i = 0, max_outputs; ··· 731 731 732 732 static void intel_setup_cadls(struct drm_i915_private *dev_priv) 733 733 { 734 - struct intel_opregion *opregion = &dev_priv->opregion; 734 + struct intel_opregion *opregion = &dev_priv->display.opregion; 735 735 struct intel_connector *connector; 736 736 struct drm_connector_list_iter conn_iter; 737 737 int i = 0; ··· 761 761 762 762 static void swsci_setup(struct drm_i915_private *dev_priv) 763 763 { 764 - struct intel_opregion *opregion = &dev_priv->opregion; 764 + struct intel_opregion *opregion = &dev_priv->display.opregion; 765 765 bool requested_callbacks = false; 766 766 u32 tmp; 767 767 ··· 839 839 840 840 static int intel_load_vbt_firmware(struct drm_i915_private *dev_priv) 841 841 { 842 - struct intel_opregion *opregion = &dev_priv->opregion; 842 + struct intel_opregion *opregion = &dev_priv->display.opregion; 843 843 const struct firmware *fw = NULL; 844 844 const char *name = dev_priv->params.vbt_firmware; 845 845 int ret; ··· 879 879 880 880 int intel_opregion_setup(struct drm_i915_private *dev_priv) 881 881 { 882 - struct intel_opregion *opregion = &dev_priv->opregion; 882 + struct intel_opregion *opregion = &dev_priv->display.opregion; 883 883 struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); 884 884 u32 asls, mboxes; 885 885 char buf[sizeof(OPREGION_SIGNATURE)]; ··· 1106 1106 { 1107 1107 struct drm_connector *connector = &intel_connector->base; 1108 1108 struct drm_i915_private *i915 = to_i915(connector->dev); 1109 - struct intel_opregion *opregion = &i915->opregion; 1109 + struct intel_opregion *opregion = &i915->display.opregion; 1110 1110 const void *in_edid; 1111 1111 const struct edid *edid; 1112 1112 struct edid *new_edid; ··· 1141 1141 1142 1142 bool intel_opregion_headless_sku(struct drm_i915_private *i915) 1143 1143 { 1144 - struct intel_opregion *opregion = &i915->opregion; 1144 + struct intel_opregion *opregion = &i915->display.opregion; 1145 1145 struct opregion_header *header = opregion->header; 1146 1146 1147 1147 if (!header || header->over.major < 2 || ··· 1153 1153 1154 1154 void intel_opregion_register(struct drm_i915_private *i915) 1155 1155 { 1156 - struct intel_opregion *opregion = &i915->opregion; 1156 + struct intel_opregion *opregion = &i915->display.opregion; 1157 1157 1158 1158 if (!opregion->header) 1159 1159 return; ··· 1169 1169 1170 1170 void intel_opregion_resume(struct drm_i915_private *i915) 1171 1171 { 1172 - struct intel_opregion *opregion = &i915->opregion; 1172 + struct intel_opregion *opregion = &i915->display.opregion; 1173 1173 1174 1174 if (!opregion->header) 1175 1175 return; ··· 1200 1200 1201 1201 void intel_opregion_suspend(struct drm_i915_private *i915, pci_power_t state) 1202 1202 { 1203 - struct intel_opregion *opregion = &i915->opregion; 1203 + struct intel_opregion *opregion = &i915->display.opregion; 1204 1204 1205 1205 if (!opregion->header) 1206 1206 return; ··· 1210 1210 if (opregion->asle) 1211 1211 opregion->asle->ardy = ASLE_ARDY_NOT_READY; 1212 1212 1213 - cancel_work_sync(&i915->opregion.asle_work); 1213 + cancel_work_sync(&i915->display.opregion.asle_work); 1214 1214 1215 1215 if (opregion->acpi) 1216 1216 opregion->acpi->drdy = 0; ··· 1218 1218 1219 1219 void intel_opregion_unregister(struct drm_i915_private *i915) 1220 1220 { 1221 - struct intel_opregion *opregion = &i915->opregion; 1221 + struct intel_opregion *opregion = &i915->display.opregion; 1222 1222 1223 1223 intel_opregion_suspend(i915, PCI_D1); 1224 1224
+2 -2
drivers/gpu/drm/i915/display/intel_overlay.c
··· 211 211 212 212 /* WA_OVERLAY_CLKGATE:alm */ 213 213 if (enable) 214 - intel_de_write(dev_priv, DSPCLK_GATE_D, 0); 214 + intel_de_write(dev_priv, DSPCLK_GATE_D(dev_priv), 0); 215 215 else 216 - intel_de_write(dev_priv, DSPCLK_GATE_D, 216 + intel_de_write(dev_priv, DSPCLK_GATE_D(dev_priv), 217 217 OVRUNIT_CLOCK_GATE_DISABLE); 218 218 219 219 /* WA_DISABLE_L2CACHE_CLOCK_GATING:alm */
+24 -21
drivers/gpu/drm/i915/display/intel_panel.c
··· 37 37 #include "intel_display_types.h" 38 38 #include "intel_drrs.h" 39 39 #include "intel_panel.h" 40 + #include "intel_quirks.h" 40 41 41 42 bool intel_panel_use_ssc(struct drm_i915_private *i915) 42 43 { 43 44 if (i915->params.panel_use_ssc >= 0) 44 45 return i915->params.panel_use_ssc != 0; 45 - return i915->vbt.lvds_use_ssc 46 - && !(i915->quirks & QUIRK_LVDS_SSC_DISABLE); 46 + return i915->display.vbt.lvds_use_ssc && 47 + !intel_has_quirk(i915, QUIRK_LVDS_SSC_DISABLE); 47 48 } 48 49 49 50 const struct drm_display_mode * ··· 82 81 mode->clock != preferred_mode->clock; 83 82 } 84 83 85 - static bool is_alt_vrr_mode(const struct drm_display_mode *mode, 86 - const struct drm_display_mode *preferred_mode) 84 + static bool is_alt_fixed_mode(const struct drm_display_mode *mode, 85 + const struct drm_display_mode *preferred_mode) 87 86 { 88 87 return drm_mode_match(mode, preferred_mode, 89 88 DRM_MODE_MATCH_FLAGS | 90 89 DRM_MODE_MATCH_3D_FLAGS) && 91 90 mode->hdisplay == preferred_mode->hdisplay && 92 - mode->vdisplay == preferred_mode->vdisplay && 93 - mode->clock != preferred_mode->clock; 91 + mode->vdisplay == preferred_mode->vdisplay; 94 92 } 95 93 96 94 const struct drm_display_mode * ··· 109 109 max_vrefresh = vrefresh; 110 110 best_mode = fixed_mode; 111 111 } 112 + } 113 + 114 + return best_mode; 115 + } 116 + 117 + const struct drm_display_mode * 118 + intel_panel_highest_mode(struct intel_connector *connector, 119 + const struct drm_display_mode *adjusted_mode) 120 + { 121 + const struct drm_display_mode *fixed_mode, *best_mode = adjusted_mode; 122 + 123 + /* pick the fixed_mode that has the highest clock */ 124 + list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head) { 125 + if (fixed_mode->clock > best_mode->clock) 126 + best_mode = fixed_mode; 112 127 } 113 128 114 129 return best_mode; ··· 187 172 return 0; 188 173 } 189 174 190 - static bool is_alt_fixed_mode(const struct drm_display_mode *mode, 191 - const struct drm_display_mode *preferred_mode, 192 - bool has_vrr) 193 - { 194 - /* is_alt_drrs_mode() is a subset of is_alt_vrr_mode() */ 195 - if (has_vrr) 196 - return is_alt_vrr_mode(mode, preferred_mode); 197 - else 198 - return is_alt_drrs_mode(mode, preferred_mode); 199 - } 200 - 201 - static void intel_panel_add_edid_alt_fixed_modes(struct intel_connector *connector, 202 - bool has_vrr) 175 + static void intel_panel_add_edid_alt_fixed_modes(struct intel_connector *connector) 203 176 { 204 177 struct drm_i915_private *dev_priv = to_i915(connector->base.dev); 205 178 const struct drm_display_mode *preferred_mode = ··· 195 192 struct drm_display_mode *mode, *next; 196 193 197 194 list_for_each_entry_safe(mode, next, &connector->base.probed_modes, head) { 198 - if (!is_alt_fixed_mode(mode, preferred_mode, has_vrr)) 195 + if (!is_alt_fixed_mode(mode, preferred_mode)) 199 196 continue; 200 197 201 198 drm_dbg_kms(&dev_priv->drm, ··· 258 255 { 259 256 intel_panel_add_edid_preferred_mode(connector); 260 257 if (intel_panel_preferred_fixed_mode(connector) && (has_drrs || has_vrr)) 261 - intel_panel_add_edid_alt_fixed_modes(connector, has_vrr); 258 + intel_panel_add_edid_alt_fixed_modes(connector); 262 259 intel_panel_destroy_probed_modes(connector); 263 260 } 264 261
+3
drivers/gpu/drm/i915/display/intel_panel.h
··· 31 31 const struct drm_display_mode * 32 32 intel_panel_downclock_mode(struct intel_connector *connector, 33 33 const struct drm_display_mode *adjusted_mode); 34 + const struct drm_display_mode * 35 + intel_panel_highest_mode(struct intel_connector *connector, 36 + const struct drm_display_mode *adjusted_mode); 34 37 int intel_panel_get_modes(struct intel_connector *connector); 35 38 enum drrs_type intel_panel_drrs_type(struct intel_connector *connector); 36 39 enum drm_mode_status
+12 -2
drivers/gpu/drm/i915/display/intel_pch_refclk.c
··· 167 167 } 168 168 } 169 169 170 + int lpt_iclkip(const struct intel_crtc_state *crtc_state) 171 + { 172 + struct iclkip_params p; 173 + 174 + lpt_compute_iclkip(&p, crtc_state->hw.adjusted_mode.crtc_clock); 175 + 176 + return lpt_iclkip_freq(&p); 177 + } 178 + 170 179 /* Program iCLKIP clock to the desired frequency */ 171 180 void lpt_program_iclkip(const struct intel_crtc_state *crtc_state) 172 181 { ··· 188 179 lpt_disable_iclkip(dev_priv); 189 180 190 181 lpt_compute_iclkip(&p, clock); 182 + drm_WARN_ON(&dev_priv->drm, lpt_iclkip_freq(&p) != clock); 191 183 192 184 /* This should not happen with any sane values */ 193 185 drm_WARN_ON(&dev_priv->drm, SBI_SSCDIVINTPHASE_DIVSEL(p.divsel) & ··· 524 514 } 525 515 526 516 if (HAS_PCH_IBX(dev_priv)) { 527 - has_ck505 = dev_priv->vbt.display_clock_mode; 517 + has_ck505 = dev_priv->display.vbt.display_clock_mode; 528 518 can_ssc = has_ck505; 529 519 } else { 530 520 has_ck505 = false; ··· 664 654 } 665 655 } 666 656 667 - BUG_ON(val != final); 657 + drm_WARN_ON(&dev_priv->drm, val != final); 668 658 } 669 659 670 660 /*
+1
drivers/gpu/drm/i915/display/intel_pch_refclk.h
··· 14 14 void lpt_program_iclkip(const struct intel_crtc_state *crtc_state); 15 15 void lpt_disable_iclkip(struct drm_i915_private *dev_priv); 16 16 int lpt_get_iclkip(struct drm_i915_private *dev_priv); 17 + int lpt_iclkip(const struct intel_crtc_state *crtc_state); 17 18 18 19 void intel_init_pch_refclk(struct drm_i915_private *dev_priv); 19 20 void lpt_disable_clkout_dp(struct drm_i915_private *dev_priv);
+2 -1
drivers/gpu/drm/i915/display/intel_pps.c
··· 12 12 #include "intel_dpll.h" 13 13 #include "intel_lvds.h" 14 14 #include "intel_pps.h" 15 + #include "intel_quirks.h" 15 16 16 17 static void vlv_steal_power_sequencer(struct drm_i915_private *dev_priv, 17 18 enum pipe pipe); ··· 1203 1202 * just fails to power back on. Increasing the delay to 800ms 1204 1203 * seems sufficient to avoid this problem. 1205 1204 */ 1206 - if (dev_priv->quirks & QUIRK_INCREASE_T12_DELAY) { 1205 + if (intel_has_quirk(dev_priv, QUIRK_INCREASE_T12_DELAY)) { 1207 1206 vbt->t11_t12 = max_t(u16, vbt->t11_t12, 1300 * 10); 1208 1207 drm_dbg_kms(&dev_priv->drm, 1209 1208 "Increasing T12 panel delay as per the quirk to %d\n",
+11 -16
drivers/gpu/drm/i915/display/intel_psr.c
··· 805 805 hblank_total = adjusted_mode->crtc_hblank_end - adjusted_mode->crtc_hblank_start; 806 806 hblank_ns = div_u64(1000000ULL * hblank_total, adjusted_mode->crtc_clock); 807 807 808 - /* From spec: (72 / number of lanes) * 1000 / symbol clock frequency MHz */ 809 - req_ns = (72 / crtc_state->lane_count) * 1000 / (crtc_state->port_clock / 1000); 808 + /* From spec: ((60 / number of lanes) + 11) * 1000 / symbol clock frequency MHz */ 809 + req_ns = ((60 / crtc_state->lane_count) + 11) * 1000 / (crtc_state->port_clock / 1000); 810 810 811 811 if ((hblank_ns - req_ns) > 100) 812 812 return true; 813 813 814 - if (DISPLAY_VER(dev_priv) < 13 || intel_dp->edp_dpcd[0] < DP_EDP_14b) 814 + /* Not supported <13 / Wa_22012279113:adl-p */ 815 + if (DISPLAY_VER(dev_priv) <= 13 || intel_dp->edp_dpcd[0] < DP_EDP_14b) 815 816 return false; 816 817 817 818 crtc_state->req_psr2_sdp_prior_scanline = true; ··· 1722 1721 new_plane_state, i) { 1723 1722 struct drm_rect src, damaged_area = { .x1 = 0, .y1 = -1, 1724 1723 .x2 = INT_MAX }; 1725 - struct drm_atomic_helper_damage_iter iter; 1726 - struct drm_rect clip; 1727 1724 1728 1725 if (new_plane_state->uapi.crtc != crtc_state->uapi.crtc) 1729 1726 continue; ··· 1766 1767 continue; 1767 1768 } 1768 1769 1769 - drm_rect_fp_to_int(&src, &new_plane_state->uapi.src); 1770 + src = drm_plane_state_src(&new_plane_state->uapi); 1771 + drm_rect_fp_to_int(&src, &src); 1770 1772 1771 - drm_atomic_helper_damage_iter_init(&iter, 1772 - &old_plane_state->uapi, 1773 - &new_plane_state->uapi); 1774 - drm_atomic_for_each_plane_damage(&iter, &clip) { 1775 - if (drm_rect_intersect(&clip, &src)) 1776 - clip_area_update(&damaged_area, &clip, 1777 - &crtc_state->pipe_src); 1778 - } 1779 - 1780 - if (damaged_area.y1 == -1) 1773 + if (!drm_atomic_helper_damage_merged(&old_plane_state->uapi, 1774 + &new_plane_state->uapi, &damaged_area)) 1781 1775 continue; 1782 1776 1783 1777 damaged_area.y1 += new_plane_state->uapi.dst.y1 - src.y1; 1784 1778 damaged_area.y2 += new_plane_state->uapi.dst.y1 - src.y1; 1779 + damaged_area.x1 += new_plane_state->uapi.dst.x1 - src.x1; 1780 + damaged_area.x2 += new_plane_state->uapi.dst.x1 - src.x1; 1781 + 1785 1782 clip_area_update(&pipe_clip, &damaged_area, &crtc_state->pipe_src); 1786 1783 } 1787 1784
+16 -6
drivers/gpu/drm/i915/display/intel_quirks.c
··· 9 9 #include "intel_display_types.h" 10 10 #include "intel_quirks.h" 11 11 12 + static void intel_set_quirk(struct drm_i915_private *i915, enum intel_quirk_id quirk) 13 + { 14 + i915->display.quirks.mask |= BIT(quirk); 15 + } 16 + 12 17 /* 13 18 * Some machines (Lenovo U160) do not work with SSC on LVDS for some reason 14 19 */ 15 20 static void quirk_ssc_force_disable(struct drm_i915_private *i915) 16 21 { 17 - i915->quirks |= QUIRK_LVDS_SSC_DISABLE; 22 + intel_set_quirk(i915, QUIRK_LVDS_SSC_DISABLE); 18 23 drm_info(&i915->drm, "applying lvds SSC disable quirk\n"); 19 24 } 20 25 ··· 29 24 */ 30 25 static void quirk_invert_brightness(struct drm_i915_private *i915) 31 26 { 32 - i915->quirks |= QUIRK_INVERT_BRIGHTNESS; 27 + intel_set_quirk(i915, QUIRK_INVERT_BRIGHTNESS); 33 28 drm_info(&i915->drm, "applying inverted panel brightness quirk\n"); 34 29 } 35 30 36 31 /* Some VBT's incorrectly indicate no backlight is present */ 37 32 static void quirk_backlight_present(struct drm_i915_private *i915) 38 33 { 39 - i915->quirks |= QUIRK_BACKLIGHT_PRESENT; 34 + intel_set_quirk(i915, QUIRK_BACKLIGHT_PRESENT); 40 35 drm_info(&i915->drm, "applying backlight present quirk\n"); 41 36 } 42 37 ··· 45 40 */ 46 41 static void quirk_increase_t12_delay(struct drm_i915_private *i915) 47 42 { 48 - i915->quirks |= QUIRK_INCREASE_T12_DELAY; 43 + intel_set_quirk(i915, QUIRK_INCREASE_T12_DELAY); 49 44 drm_info(&i915->drm, "Applying T12 delay quirk\n"); 50 45 } 51 46 ··· 55 50 */ 56 51 static void quirk_increase_ddi_disabled_time(struct drm_i915_private *i915) 57 52 { 58 - i915->quirks |= QUIRK_INCREASE_DDI_DISABLED_TIME; 53 + intel_set_quirk(i915, QUIRK_INCREASE_DDI_DISABLED_TIME); 59 54 drm_info(&i915->drm, "Applying Increase DDI Disabled quirk\n"); 60 55 } 61 56 62 57 static void quirk_no_pps_backlight_power_hook(struct drm_i915_private *i915) 63 58 { 64 - i915->quirks |= QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK; 59 + intel_set_quirk(i915, QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK); 65 60 drm_info(&i915->drm, "Applying no pps backlight power quirk\n"); 66 61 } 67 62 ··· 220 215 if (dmi_check_system(*intel_dmi_quirks[i].dmi_id_list) != 0) 221 216 intel_dmi_quirks[i].hook(i915); 222 217 } 218 + } 219 + 220 + bool intel_has_quirk(struct drm_i915_private *i915, enum intel_quirk_id quirk) 221 + { 222 + return i915->display.quirks.mask & BIT(quirk); 223 223 }
+13 -1
drivers/gpu/drm/i915/display/intel_quirks.h
··· 6 6 #ifndef __INTEL_QUIRKS_H__ 7 7 #define __INTEL_QUIRKS_H__ 8 8 9 + #include <linux/types.h> 10 + 9 11 struct drm_i915_private; 10 12 11 - void intel_init_quirks(struct drm_i915_private *dev_priv); 13 + enum intel_quirk_id { 14 + QUIRK_BACKLIGHT_PRESENT, 15 + QUIRK_INCREASE_DDI_DISABLED_TIME, 16 + QUIRK_INCREASE_T12_DELAY, 17 + QUIRK_INVERT_BRIGHTNESS, 18 + QUIRK_LVDS_SSC_DISABLE, 19 + QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK, 20 + }; 21 + 22 + void intel_init_quirks(struct drm_i915_private *i915); 23 + bool intel_has_quirk(struct drm_i915_private *i915, enum intel_quirk_id quirk); 12 24 13 25 #endif /* __INTEL_QUIRKS_H__ */
+9 -9
drivers/gpu/drm/i915/display/intel_sdvo.c
··· 2016 2016 2017 2017 return drm_get_edid(connector, 2018 2018 intel_gmbus_get_adapter(dev_priv, 2019 - dev_priv->vbt.crt_ddc_pin)); 2019 + dev_priv->display.vbt.crt_ddc_pin)); 2020 2020 } 2021 2021 2022 2022 static enum drm_connector_status ··· 2581 2581 struct sdvo_device_mapping *mapping; 2582 2582 2583 2583 if (sdvo->port == PORT_B) 2584 - mapping = &dev_priv->vbt.sdvo_mappings[0]; 2584 + mapping = &dev_priv->display.vbt.sdvo_mappings[0]; 2585 2585 else 2586 - mapping = &dev_priv->vbt.sdvo_mappings[1]; 2586 + mapping = &dev_priv->display.vbt.sdvo_mappings[1]; 2587 2587 2588 2588 if (mapping->initialized) 2589 2589 sdvo->ddc_bus = 1 << ((mapping->ddc_pin & 0xf0) >> 4); ··· 2599 2599 u8 pin; 2600 2600 2601 2601 if (sdvo->port == PORT_B) 2602 - mapping = &dev_priv->vbt.sdvo_mappings[0]; 2602 + mapping = &dev_priv->display.vbt.sdvo_mappings[0]; 2603 2603 else 2604 - mapping = &dev_priv->vbt.sdvo_mappings[1]; 2604 + mapping = &dev_priv->display.vbt.sdvo_mappings[1]; 2605 2605 2606 2606 if (mapping->initialized && 2607 2607 intel_gmbus_is_valid_pin(dev_priv, mapping->i2c_pin)) ··· 2639 2639 struct sdvo_device_mapping *my_mapping, *other_mapping; 2640 2640 2641 2641 if (sdvo->port == PORT_B) { 2642 - my_mapping = &dev_priv->vbt.sdvo_mappings[0]; 2643 - other_mapping = &dev_priv->vbt.sdvo_mappings[1]; 2642 + my_mapping = &dev_priv->display.vbt.sdvo_mappings[0]; 2643 + other_mapping = &dev_priv->display.vbt.sdvo_mappings[1]; 2644 2644 } else { 2645 - my_mapping = &dev_priv->vbt.sdvo_mappings[1]; 2646 - other_mapping = &dev_priv->vbt.sdvo_mappings[0]; 2645 + my_mapping = &dev_priv->display.vbt.sdvo_mappings[1]; 2646 + other_mapping = &dev_priv->display.vbt.sdvo_mappings[0]; 2647 2647 } 2648 2648 2649 2649 /* If the BIOS described our SDVO device, take advantage of it. */
+17 -6
drivers/gpu/drm/i915/display/intel_tv.c
··· 39 39 #include "intel_crtc.h" 40 40 #include "intel_de.h" 41 41 #include "intel_display_types.h" 42 + #include "intel_dpll.h" 42 43 #include "intel_hotplug.h" 43 44 #include "intel_tv.h" 44 45 ··· 983 982 984 983 static void 985 984 intel_tv_mode_to_mode(struct drm_display_mode *mode, 986 - const struct tv_mode *tv_mode) 985 + const struct tv_mode *tv_mode, 986 + int clock) 987 987 { 988 - mode->clock = tv_mode->clock / 989 - (tv_mode->oversample >> !tv_mode->progressive); 988 + mode->clock = clock / (tv_mode->oversample >> !tv_mode->progressive); 990 989 991 990 /* 992 991 * tv_mode horizontal timings: ··· 1144 1143 xsize = tmp >> 16; 1145 1144 ysize = tmp & 0xffff; 1146 1145 1147 - intel_tv_mode_to_mode(&mode, &tv_mode); 1146 + intel_tv_mode_to_mode(&mode, &tv_mode, pipe_config->port_clock); 1148 1147 1149 1148 drm_dbg_kms(&dev_priv->drm, "TV mode: " DRM_MODE_FMT "\n", 1150 1149 DRM_MODE_ARG(&mode)); ··· 1185 1184 struct intel_crtc_state *pipe_config, 1186 1185 struct drm_connector_state *conn_state) 1187 1186 { 1187 + struct intel_atomic_state *state = 1188 + to_intel_atomic_state(pipe_config->uapi.state); 1189 + struct intel_crtc *crtc = to_intel_crtc(pipe_config->uapi.crtc); 1188 1190 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 1189 1191 struct intel_tv_connector_state *tv_conn_state = 1190 1192 to_intel_tv_connector_state(conn_state); ··· 1196 1192 &pipe_config->hw.adjusted_mode; 1197 1193 int hdisplay = adjusted_mode->crtc_hdisplay; 1198 1194 int vdisplay = adjusted_mode->crtc_vdisplay; 1195 + int ret; 1199 1196 1200 1197 if (!tv_mode) 1201 1198 return -EINVAL; ··· 1211 1206 1212 1207 pipe_config->port_clock = tv_mode->clock; 1213 1208 1214 - intel_tv_mode_to_mode(adjusted_mode, tv_mode); 1209 + ret = intel_dpll_crtc_compute_clock(state, crtc); 1210 + if (ret) 1211 + return ret; 1212 + 1213 + pipe_config->clock_set = true; 1214 + 1215 + intel_tv_mode_to_mode(adjusted_mode, tv_mode, pipe_config->port_clock); 1215 1216 drm_mode_set_crtcinfo(adjusted_mode, 0); 1216 1217 1217 1218 if (intel_tv_source_too_wide(dev_priv, hdisplay) || ··· 1815 1804 * about the actual timings of the mode. We 1816 1805 * do ignore the margins though. 1817 1806 */ 1818 - intel_tv_mode_to_mode(mode, tv_mode); 1807 + intel_tv_mode_to_mode(mode, tv_mode, tv_mode->clock); 1819 1808 if (count == 0) { 1820 1809 drm_dbg_kms(&dev_priv->drm, "TV mode: " DRM_MODE_FMT "\n", 1821 1810 DRM_MODE_ARG(mode));
+195 -149
drivers/gpu/drm/i915/display/intel_vbt_defs.h
··· 76 76 } __packed; 77 77 78 78 /* 79 + * BDB version number dependencies are documented as: 80 + * 81 + * <start>+ 82 + * indicates the field was introduced in version <start> 83 + * and is still valid 84 + * 85 + * <start>-<end> 86 + * indicates the field was introduced in version <start> 87 + * and obsoleted in version <end>+1. 88 + * 89 + * ??? indicates the specific version number is unknown 90 + */ 91 + 92 + /* 79 93 * There are several types of BIOS data blocks (BDBs), each block has 80 94 * an ID and size in the first 3 bytes (ID in first, size in next 2). 81 95 * Known types are listed below. ··· 158 144 /* bits 3 */ 159 145 u8 disable_smooth_vision:1; 160 146 u8 single_dvi:1; 161 - u8 rotate_180:1; /* 181 */ 147 + u8 rotate_180:1; /* 181+ */ 162 148 u8 fdi_rx_polarity_inverted:1; 163 - u8 vbios_extended_mode:1; /* 160 */ 164 - u8 copy_ilfp_dtd_to_sdvo_lvds_dtd:1; /* 160 */ 165 - u8 panel_best_fit_timing:1; /* 160 */ 166 - u8 ignore_strap_state:1; /* 160 */ 149 + u8 vbios_extended_mode:1; /* 160+ */ 150 + u8 copy_ilfp_dtd_to_sdvo_lvds_dtd:1; /* 160+ */ 151 + u8 panel_best_fit_timing:1; /* 160+ */ 152 + u8 ignore_strap_state:1; /* 160+ */ 167 153 168 154 /* bits 4 */ 169 155 u8 legacy_monitor_detect; ··· 178 164 u8 rsvd11:2; /* finish byte */ 179 165 180 166 /* bits 6 */ 181 - u8 tc_hpd_retry_timeout:7; /* 242 */ 167 + u8 tc_hpd_retry_timeout:7; /* 242+ */ 182 168 u8 rsvd12:1; 183 169 184 170 /* bits 7 */ 185 - u8 afc_startup_config:2;/* 249 */ 171 + u8 afc_startup_config:2; /* 249+ */ 186 172 u8 rsvd13:6; 187 173 } __packed; 188 174 ··· 197 183 #define GPIO_PIN_ADD_DDC_I2C 0x06 /* "ADDCARD DDC/I2C GPIO pins" */ 198 184 199 185 /* Device handle */ 186 + #define DEVICE_HANDLE_CRT 0x0001 187 + #define DEVICE_HANDLE_EFP1 0x0004 188 + #define DEVICE_HANDLE_EFP2 0x0040 189 + #define DEVICE_HANDLE_EFP3 0x0020 190 + #define DEVICE_HANDLE_EFP4 0x0010 /* 194+ */ 191 + #define DEVICE_HANDLE_EFP5 0x0002 /* 215+ */ 192 + #define DEVICE_HANDLE_EFP6 0x0001 /* 217+ */ 193 + #define DEVICE_HANDLE_EFP7 0x0100 /* 217+ */ 194 + #define DEVICE_HANDLE_EFP8 0x0200 /* 217+ */ 200 195 #define DEVICE_HANDLE_LFP1 0x0008 201 196 #define DEVICE_HANDLE_LFP2 0x0080 202 197 ··· 298 275 #define DVO_PORT_DPC 8 299 276 #define DVO_PORT_DPD 9 300 277 #define DVO_PORT_DPA 10 301 - #define DVO_PORT_DPE 11 /* 193 */ 302 - #define DVO_PORT_HDMIE 12 /* 193 */ 278 + #define DVO_PORT_DPE 11 /* 193+ */ 279 + #define DVO_PORT_HDMIE 12 /* 193+ */ 303 280 #define DVO_PORT_DPF 13 /* N/A */ 304 281 #define DVO_PORT_HDMIF 14 /* N/A */ 305 - #define DVO_PORT_DPG 15 /* 217 */ 306 - #define DVO_PORT_HDMIG 16 /* 217 */ 307 - #define DVO_PORT_DPH 17 /* 217 */ 308 - #define DVO_PORT_HDMIH 18 /* 217 */ 309 - #define DVO_PORT_DPI 19 /* 217 */ 310 - #define DVO_PORT_HDMII 20 /* 217 */ 311 - #define DVO_PORT_MIPIA 21 /* 171 */ 312 - #define DVO_PORT_MIPIB 22 /* 171 */ 313 - #define DVO_PORT_MIPIC 23 /* 171 */ 314 - #define DVO_PORT_MIPID 24 /* 171 */ 282 + #define DVO_PORT_DPG 15 /* 217+ */ 283 + #define DVO_PORT_HDMIG 16 /* 217+ */ 284 + #define DVO_PORT_DPH 17 /* 217+ */ 285 + #define DVO_PORT_HDMIH 18 /* 217+ */ 286 + #define DVO_PORT_DPI 19 /* 217+ */ 287 + #define DVO_PORT_HDMII 20 /* 217+ */ 288 + #define DVO_PORT_MIPIA 21 /* 171+ */ 289 + #define DVO_PORT_MIPIB 22 /* 171+ */ 290 + #define DVO_PORT_MIPIC 23 /* 171+ */ 291 + #define DVO_PORT_MIPID 24 /* 171+ */ 315 292 316 - #define HDMI_MAX_DATA_RATE_PLATFORM 0 /* 204 */ 317 - #define HDMI_MAX_DATA_RATE_297 1 /* 204 */ 318 - #define HDMI_MAX_DATA_RATE_165 2 /* 204 */ 319 - #define HDMI_MAX_DATA_RATE_594 3 /* 249 */ 320 - #define HDMI_MAX_DATA_RATE_340 4 /* 249 */ 321 - #define HDMI_MAX_DATA_RATE_300 5 /* 249 */ 293 + #define HDMI_MAX_DATA_RATE_PLATFORM 0 /* 204+ */ 294 + #define HDMI_MAX_DATA_RATE_297 1 /* 204+ */ 295 + #define HDMI_MAX_DATA_RATE_165 2 /* 204+ */ 296 + #define HDMI_MAX_DATA_RATE_594 3 /* 249+ */ 297 + #define HDMI_MAX_DATA_RATE_340 4 /* 249+ */ 298 + #define HDMI_MAX_DATA_RATE_300 5 /* 249+ */ 322 299 323 300 #define LEGACY_CHILD_DEVICE_CONFIG_SIZE 33 324 301 ··· 385 362 * basically any of the fields to ensure the correct interpretation for the BDB 386 363 * version in question. 387 364 * 388 - * When we copy the child device configs to dev_priv->vbt.child_dev, we reserve 389 - * space for the full structure below, and initialize the tail not actually 390 - * present in VBT to zeros. Accessing those fields is fine, as long as the 391 - * default zero is taken into account, again according to the BDB version. 365 + * When we copy the child device configs to dev_priv->display.vbt.child_dev, we 366 + * reserve space for the full structure below, and initialize the tail not 367 + * actually present in VBT to zeros. Accessing those fields is fine, as long as 368 + * the default zero is taken into account, again according to the BDB version. 392 369 * 393 370 * BDB versions 155 and below are considered legacy, and version 155 seems to be 394 371 * a baseline for some of the VBT documentation. When adding new fields, please ··· 402 379 u8 device_id[10]; /* ascii string */ 403 380 struct { 404 381 u8 i2c_speed; 405 - u8 dp_onboard_redriver; /* 158 */ 406 - u8 dp_ondock_redriver; /* 158 */ 407 - u8 hdmi_level_shifter_value:5; /* 169 */ 408 - u8 hdmi_max_data_rate:3; /* 204 */ 409 - u16 dtd_buf_ptr; /* 161 */ 410 - u8 edidless_efp:1; /* 161 */ 411 - u8 compression_enable:1; /* 198 */ 412 - u8 compression_method_cps:1; /* 198 */ 413 - u8 ganged_edp:1; /* 202 */ 414 - u8 reserved0:4; 415 - u8 compression_structure_index:4; /* 198 */ 416 - u8 reserved1:4; 417 - u8 slave_port; /* 202 */ 418 - u8 reserved2; 382 + u8 dp_onboard_redriver_preemph:3; /* 158+ */ 383 + u8 dp_onboard_redriver_vswing:3; /* 158+ */ 384 + u8 dp_onboard_redriver_present:1; /* 158+ */ 385 + u8 reserved0:1; 386 + u8 dp_ondock_redriver_preemph:3; /* 158+ */ 387 + u8 dp_ondock_redriver_vswing:3; /* 158+ */ 388 + u8 dp_ondock_redriver_present:1; /* 158+ */ 389 + u8 reserved1:1; 390 + u8 hdmi_level_shifter_value:5; /* 158+ */ 391 + u8 hdmi_max_data_rate:3; /* 204+ */ 392 + u16 dtd_buf_ptr; /* 161+ */ 393 + u8 edidless_efp:1; /* 161+ */ 394 + u8 compression_enable:1; /* 198+ */ 395 + u8 compression_method_cps:1; /* 198+ */ 396 + u8 ganged_edp:1; /* 202+ */ 397 + u8 lttpr_non_transparent:1; /* 235+ */ 398 + u8 disable_compression_for_ext_disp:1; /* 251+ */ 399 + u8 reserved2:2; 400 + u8 compression_structure_index:4; /* 198+ */ 401 + u8 reserved3:4; 402 + u8 hdmi_max_frl_rate:4; /* 237+ */ 403 + u8 hdmi_max_frl_rate_valid:1; /* 237+ */ 404 + u8 reserved4:3; /* 237+ */ 405 + u8 reserved5; 419 406 } __packed; 420 407 } __packed; 421 408 ··· 445 412 u8 ddc2_pin; 446 413 } __packed; 447 414 struct { 448 - u8 efp_routed:1; /* 158 */ 449 - u8 lane_reversal:1; /* 184 */ 450 - u8 lspcon:1; /* 192 */ 451 - u8 iboost:1; /* 196 */ 452 - u8 hpd_invert:1; /* 196 */ 453 - u8 use_vbt_vswing:1; /* 218 */ 454 - u8 flag_reserved:2; 455 - u8 hdmi_support:1; /* 158 */ 456 - u8 dp_support:1; /* 158 */ 457 - u8 tmds_support:1; /* 158 */ 415 + u8 efp_routed:1; /* 158+ */ 416 + u8 lane_reversal:1; /* 184+ */ 417 + u8 lspcon:1; /* 192+ */ 418 + u8 iboost:1; /* 196+ */ 419 + u8 hpd_invert:1; /* 196+ */ 420 + u8 use_vbt_vswing:1; /* 218+ */ 421 + u8 dp_max_lane_count:2; /* 244+ */ 422 + u8 hdmi_support:1; /* 158+ */ 423 + u8 dp_support:1; /* 158+ */ 424 + u8 tmds_support:1; /* 158+ */ 458 425 u8 support_reserved:5; 459 426 u8 aux_channel; 460 427 u8 dongle_detect; ··· 462 429 } __packed; 463 430 464 431 u8 pipe_cap:2; 465 - u8 sdvo_stall:1; /* 158 */ 432 + u8 sdvo_stall:1; /* 158+ */ 466 433 u8 hpd_status:2; 467 434 u8 integrated_encoder:1; 468 435 u8 capabilities_reserved:2; ··· 470 437 471 438 union { 472 439 u8 dvo2_wiring; 473 - u8 mipi_bridge_type; /* 171 */ 440 + u8 mipi_bridge_type; /* 171+ */ 474 441 } __packed; 475 442 476 443 u16 extended_type; 477 444 u8 dvo_function; 478 - u8 dp_usb_type_c:1; /* 195 */ 479 - u8 tbt:1; /* 209 */ 480 - u8 flags2_reserved:2; /* 195 */ 481 - u8 dp_port_trace_length:4; /* 209 */ 482 - u8 dp_gpio_index; /* 195 */ 483 - u16 dp_gpio_pin_num; /* 195 */ 484 - u8 dp_iboost_level:4; /* 196 */ 485 - u8 hdmi_iboost_level:4; /* 196 */ 486 - u8 dp_max_link_rate:3; /* 216/230 GLK+ */ 487 - u8 dp_max_link_rate_reserved:5; /* 216/230 */ 445 + u8 dp_usb_type_c:1; /* 195+ */ 446 + u8 tbt:1; /* 209+ */ 447 + u8 flags2_reserved:2; /* 195+ */ 448 + u8 dp_port_trace_length:4; /* 209+ */ 449 + u8 dp_gpio_index; /* 195+ */ 450 + u16 dp_gpio_pin_num; /* 195+ */ 451 + u8 dp_iboost_level:4; /* 196+ */ 452 + u8 hdmi_iboost_level:4; /* 196+ */ 453 + u8 dp_max_link_rate:3; /* 216+ */ 454 + u8 dp_max_link_rate_reserved:5; /* 216+ */ 488 455 } __packed; 489 456 490 457 struct bdb_general_definitions { ··· 492 459 u8 crt_ddc_gmbus_pin; 493 460 494 461 /* DPMS bits */ 495 - u8 dpms_acpi:1; 462 + u8 dpms_non_acpi:1; 496 463 u8 skip_boot_crt_detect:1; 497 464 u8 dpms_aim:1; 498 465 u8 rsvd1:5; /* finish byte */ ··· 521 488 522 489 struct psr_table { 523 490 /* Feature bits */ 524 - u8 full_link:1; 525 - u8 require_aux_to_wakeup:1; 491 + u8 full_link:1; /* 165+ */ 492 + u8 require_aux_to_wakeup:1; /* 165+ */ 526 493 u8 feature_bits_rsvd:6; 527 494 528 495 /* Wait times */ 529 - u8 idle_frames:4; 530 - u8 lines_to_wait:3; 496 + u8 idle_frames:4; /* 165+ */ 497 + u8 lines_to_wait:3; /* 165+ */ 531 498 u8 wait_times_rsvd:1; 532 499 533 500 /* TP wake up time in multiple of 100 */ 534 - u16 tp1_wakeup_time; 535 - u16 tp2_tp3_wakeup_time; 501 + u16 tp1_wakeup_time; /* 165+ */ 502 + u16 tp2_tp3_wakeup_time; /* 165+ */ 536 503 } __packed; 537 504 538 505 struct bdb_psr { 539 506 struct psr_table psr_table[16]; 540 507 541 508 /* PSR2 TP2/TP3 wakeup time for 16 panels */ 542 - u32 psr2_tp2_tp3_wakeup_time; 509 + u32 psr2_tp2_tp3_wakeup_time; /* 226+ */ 543 510 } __packed; 544 511 545 512 /* ··· 552 519 #define BDB_DRIVER_FEATURE_INT_SDVO_LVDS 3 553 520 554 521 struct bdb_driver_features { 522 + /* Driver bits */ 555 523 u8 boot_dev_algorithm:1; 556 - u8 block_display_switch:1; 557 - u8 allow_display_switch:1; 524 + u8 allow_display_switch_dvd:1; 525 + u8 allow_display_switch_dos:1; 558 526 u8 hotplug_dvo:1; 559 527 u8 dual_view_zoom:1; 560 528 u8 int15h_hook:1; ··· 567 533 u8 boot_mode_bpp; 568 534 u8 boot_mode_refresh; 569 535 536 + /* Extended Driver Bits 1 */ 570 537 u16 enable_lfp_primary:1; 571 538 u16 selective_mode_pruning:1; 572 539 u16 dual_frequency:1; ··· 583 548 u16 tv_hotplug:1; 584 549 u16 hdmi_config:2; 585 550 586 - u8 static_display:1; 587 - u8 reserved2:7; 551 + /* Driver Flags 1 */ 552 + u8 static_display:1; /* 163+ */ 553 + u8 embedded_platform:1; /* 163+ */ 554 + u8 display_subsystem_enable:1; /* 163+ */ 555 + u8 reserved0:5; 556 + 588 557 u16 legacy_crt_max_x; 589 558 u16 legacy_crt_max_y; 590 559 u8 legacy_crt_max_refresh; 591 560 592 - u8 hdmi_termination; 593 - u8 custom_vbt_version; 594 - /* Driver features data block */ 595 - u16 rmpm_enabled:1; 596 - u16 s2ddt_enabled:1; 597 - u16 dpst_enabled:1; 598 - u16 bltclt_enabled:1; 599 - u16 adb_enabled:1; 600 - u16 drrs_enabled:1; 601 - u16 grs_enabled:1; 602 - u16 gpmt_enabled:1; 603 - u16 tbt_enabled:1; 604 - u16 psr_enabled:1; 605 - u16 ips_enabled:1; 606 - u16 reserved3:1; 607 - u16 dmrrs_enabled:1; 608 - u16 reserved4:2; 561 + /* Extended Driver Bits 2 */ 562 + u8 hdmi_termination:1; 563 + u8 cea861d_hdmi_support:1; 564 + u8 self_refresh_enable:1; 565 + u8 reserved1:5; 566 + 567 + u8 custom_vbt_version; /* 155+ */ 568 + 569 + /* Driver Feature Flags */ 570 + u16 rmpm_enabled:1; /* 165+ */ 571 + u16 s2ddt_enabled:1; /* 165+ */ 572 + u16 dpst_enabled:1; /* 165-227 */ 573 + u16 bltclt_enabled:1; /* 165+ */ 574 + u16 adb_enabled:1; /* 165-227 */ 575 + u16 drrs_enabled:1; /* 165-227 */ 576 + u16 grs_enabled:1; /* 165+ */ 577 + u16 gpmt_enabled:1; /* 165+ */ 578 + u16 tbt_enabled:1; /* 165+ */ 579 + u16 psr_enabled:1; /* 165-227 */ 580 + u16 ips_enabled:1; /* 165+ */ 581 + u16 dpfs_enabled:1; /* 165+ */ 582 + u16 dmrrs_enabled:1; /* 174-227 */ 583 + u16 adt_enabled:1; /* ???-228 */ 584 + u16 hpd_wake:1; /* 201-240 */ 609 585 u16 pc_feature_valid:1; 610 586 } __packed; 611 587 ··· 703 657 704 658 705 659 struct edp_fast_link_params { 706 - u8 rate:4; 660 + u8 rate:4; /* ???-223 */ 707 661 u8 lanes:4; 708 662 u8 preemphasis:4; 709 663 u8 vswing:4; ··· 736 690 u32 sdrrs_msa_timing_delay; 737 691 738 692 /* ith bit indicates enabled/disabled for (i+1)th panel */ 739 - u16 edp_s3d_feature; /* 162 */ 740 - u16 edp_t3_optimization; /* 165 */ 741 - u64 edp_vswing_preemph; /* 173 */ 742 - u16 fast_link_training; /* 182 */ 743 - u16 dpcd_600h_write_required; /* 185 */ 744 - struct edp_pwm_delays pwm_delays[16]; /* 186 */ 745 - u16 full_link_params_provided; /* 199 */ 746 - struct edp_full_link_params full_link_params[16]; /* 199 */ 747 - u16 apical_enable; /* 203 */ 748 - struct edp_apical_params apical_params[16]; /* 203 */ 749 - u16 edp_fast_link_training_rate[16]; /* 224 */ 750 - u16 edp_max_port_link_rate[16]; /* 244 */ 693 + u16 edp_s3d_feature; /* 162+ */ 694 + u16 edp_t3_optimization; /* 165+ */ 695 + u64 edp_vswing_preemph; /* 173+ */ 696 + u16 fast_link_training; /* 182+ */ 697 + u16 dpcd_600h_write_required; /* 185+ */ 698 + struct edp_pwm_delays pwm_delays[16]; /* 186+ */ 699 + u16 full_link_params_provided; /* 199+ */ 700 + struct edp_full_link_params full_link_params[16]; /* 199+ */ 701 + u16 apical_enable; /* 203+ */ 702 + struct edp_apical_params apical_params[16]; /* 203+ */ 703 + u16 edp_fast_link_training_rate[16]; /* 224+ */ 704 + u16 edp_max_port_link_rate[16]; /* 244+ */ 751 705 } __packed; 752 706 753 707 /* ··· 756 710 757 711 struct bdb_lvds_options { 758 712 u8 panel_type; 759 - u8 panel_type2; /* 212 */ 713 + u8 panel_type2; /* 212+ */ 760 714 /* LVDS capabilities, stored in a dword */ 761 715 u8 pfit_mode:2; 762 716 u8 pfit_text_mode_enhanced:1; 763 717 u8 pfit_gfx_mode_enhanced:1; 764 718 u8 pfit_ratio_auto:1; 765 719 u8 pixel_dither:1; 766 - u8 lvds_edid:1; 720 + u8 lvds_edid:1; /* ???-240 */ 767 721 u8 rsvd2:1; 768 722 u8 rsvd4; 769 723 /* LVDS Panel channel bits stored here */ ··· 777 731 /* LVDS panel type bits stored here */ 778 732 u32 dps_panel_type_bits; 779 733 /* LVDS backlight control type bits stored here */ 780 - u32 blt_control_type_bits; 734 + u32 blt_control_type_bits; /* ???-240 */ 781 735 782 - u16 lcdvcc_s0_enable; /* 200 */ 783 - u32 rotation; /* 228 */ 784 - u32 position; /* 240 */ 736 + u16 lcdvcc_s0_enable; /* 200+ */ 737 + u32 rotation; /* 228+ */ 738 + u32 position; /* 240+ */ 785 739 } __packed; 786 740 787 741 /* ··· 802 756 struct bdb_lvds_lfp_data_ptrs { 803 757 u8 lvds_entries; 804 758 struct lvds_lfp_data_ptr ptr[16]; 805 - struct lvds_lfp_data_ptr_table panel_name; /* 156-163? */ 759 + struct lvds_lfp_data_ptr_table panel_name; /* (156-163?)+ */ 806 760 } __packed; 807 761 808 762 /* ··· 854 808 } __packed; 855 809 856 810 struct lvds_lfp_black_border { 857 - u8 top; /* 227 */ 858 - u8 bottom; /* 227 */ 859 - u8 left; /* 238 */ 860 - u8 right; /* 238 */ 811 + u8 top; /* 227+ */ 812 + u8 bottom; /* 227+ */ 813 + u8 left; /* 238+ */ 814 + u8 right; /* 238+ */ 861 815 } __packed; 862 816 863 817 struct bdb_lvds_lfp_data_tail { 864 - struct lvds_lfp_panel_name panel_name[16]; /* 156-163? */ 865 - u16 scaling_enable; /* 187 */ 866 - u8 seamless_drrs_min_refresh_rate[16]; /* 188 */ 867 - u8 pixel_overlap_count[16]; /* 208 */ 868 - struct lvds_lfp_black_border black_border[16]; /* 227 */ 869 - u16 dual_lfp_port_sync_enable; /* 231 */ 870 - u16 gpu_dithering_for_banding_artifacts; /* 245 */ 818 + struct lvds_lfp_panel_name panel_name[16]; /* (156-163?)+ */ 819 + u16 scaling_enable; /* 187+ */ 820 + u8 seamless_drrs_min_refresh_rate[16]; /* 188+ */ 821 + u8 pixel_overlap_count[16]; /* 208+ */ 822 + struct lvds_lfp_black_border black_border[16]; /* 227+ */ 823 + u16 dual_lfp_port_sync_enable; /* 231+ */ 824 + u16 gpu_dithering_for_banding_artifacts; /* 245+ */ 871 825 } __packed; 872 826 873 827 /* ··· 882 836 u8 active_low_pwm:1; 883 837 u8 obsolete1:5; 884 838 u16 pwm_freq_hz; 885 - u8 min_brightness; /* Obsolete from 234+ */ 839 + u8 min_brightness; /* ???-233 */ 886 840 u8 obsolete2; 887 841 u8 obsolete3; 888 842 } __packed; ··· 905 859 struct bdb_lfp_backlight_data { 906 860 u8 entry_size; 907 861 struct lfp_backlight_data_entry data[16]; 908 - u8 level[16]; /* Obsolete from 234+ */ 862 + u8 level[16]; /* ???-233 */ 909 863 struct lfp_backlight_control_method backlight_control[16]; 910 864 struct lfp_brightness_level brightness_level[16]; /* 234+ */ 911 865 struct lfp_brightness_level brightness_min_level[16]; /* 234+ */ ··· 920 874 u8 reserved1:1; 921 875 u8 power_conservation_pref:3; 922 876 u8 reserved2:1; 923 - u8 lace_enabled_status:1; 924 - u8 lace_support:1; 877 + u8 lace_enabled_status:1; /* 210+ */ 878 + u8 lace_support:1; /* 210+ */ 925 879 u8 als_enable:1; 926 880 } __packed; 927 881 ··· 941 895 } __packed; 942 896 943 897 struct bdb_lfp_power { 944 - struct lfp_power_features features; 898 + struct lfp_power_features features; /* ???-227 */ 945 899 struct als_data_entry als[5]; 946 - u8 lace_aggressiveness_profile:3; 900 + u8 lace_aggressiveness_profile:3; /* 210-227 */ 947 901 u8 reserved1:5; 948 - u16 dpst; 949 - u16 psr; 950 - u16 drrs; 951 - u16 lace_support; 952 - u16 adt; 953 - u16 dmrrs; 954 - u16 adb; 955 - u16 lace_enabled_status; 956 - struct aggressiveness_profile_entry aggressiveness[16]; 957 - u16 hobl; /* 232+ */ 958 - u16 vrr_feature_enabled; /* 233+ */ 959 - u16 elp; /* 247+ */ 960 - u16 opst; /* 247+ */ 961 - struct aggressiveness_profile2_entry aggressiveness2[16]; /* 247+ */ 902 + u16 dpst; /* 228+ */ 903 + u16 psr; /* 228+ */ 904 + u16 drrs; /* 228+ */ 905 + u16 lace_support; /* 228+ */ 906 + u16 adt; /* 228+ */ 907 + u16 dmrrs; /* 228+ */ 908 + u16 adb; /* 228+ */ 909 + u16 lace_enabled_status; /* 228+ */ 910 + struct aggressiveness_profile_entry aggressiveness[16]; /* 228+ */ 911 + u16 hobl; /* 232+ */ 912 + u16 vrr_feature_enabled; /* 233+ */ 913 + u16 elp; /* 247+ */ 914 + u16 opst; /* 247+ */ 915 + struct aggressiveness_profile2_entry aggressiveness2[16]; /* 247+ */ 962 916 } __packed; 963 917 964 918 /* ··· 968 922 #define MAX_MIPI_CONFIGURATIONS 6 969 923 970 924 struct bdb_mipi_config { 971 - struct mipi_config config[MAX_MIPI_CONFIGURATIONS]; /* 175 */ 972 - struct mipi_pps_data pps[MAX_MIPI_CONFIGURATIONS]; /* 177 */ 973 - struct edp_pwm_delays pwm_delays[MAX_MIPI_CONFIGURATIONS]; /* 186 */ 974 - u8 pmic_i2c_bus_number[MAX_MIPI_CONFIGURATIONS]; /* 190 */ 925 + struct mipi_config config[MAX_MIPI_CONFIGURATIONS]; /* 175+ */ 926 + struct mipi_pps_data pps[MAX_MIPI_CONFIGURATIONS]; /* 177+ */ 927 + struct edp_pwm_delays pwm_delays[MAX_MIPI_CONFIGURATIONS]; /* 186+ */ 928 + u8 pmic_i2c_bus_number[MAX_MIPI_CONFIGURATIONS]; /* 190+ */ 975 929 } __packed; 976 930 977 931 /*
-1
drivers/gpu/drm/i915/display/intel_vdsc.c
··· 460 460 u8 i = 0; 461 461 462 462 vdsc_cfg->pic_width = pipe_config->hw.adjusted_mode.crtc_hdisplay; 463 - vdsc_cfg->pic_height = pipe_config->hw.adjusted_mode.crtc_vdisplay; 464 463 vdsc_cfg->slice_width = DIV_ROUND_UP(vdsc_cfg->pic_width, 465 464 pipe_config->dsc.slice_count); 466 465
+2 -2
drivers/gpu/drm/i915/display/skl_universal_plane.c
··· 14 14 #include "intel_display_types.h" 15 15 #include "intel_fb.h" 16 16 #include "intel_fbc.h" 17 - #include "intel_pm.h" 18 17 #include "intel_psr.h" 19 18 #include "intel_sprite.h" 20 19 #include "skl_scaler.h" 21 20 #include "skl_universal_plane.h" 21 + #include "skl_watermark.h" 22 22 #include "pxp/intel_pxp.h" 23 23 24 24 static const u32 skl_plane_formats[] = { ··· 1940 1940 enum intel_fbc_id fbc_id = skl_fbc_id_for_pipe(pipe); 1941 1941 1942 1942 if (skl_plane_has_fbc(dev_priv, fbc_id, plane_id)) 1943 - return dev_priv->fbc[fbc_id]; 1943 + return dev_priv->display.fbc[fbc_id]; 1944 1944 else 1945 1945 return NULL; 1946 1946 }
+3562
drivers/gpu/drm/i915/display/skl_watermark.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* 3 + * Copyright © 2022 Intel Corporation 4 + */ 5 + 6 + #include <drm/drm_blend.h> 7 + 8 + #include "intel_atomic.h" 9 + #include "intel_atomic_plane.h" 10 + #include "intel_bw.h" 11 + #include "intel_de.h" 12 + #include "intel_display.h" 13 + #include "intel_display_power.h" 14 + #include "intel_display_types.h" 15 + #include "intel_fb.h" 16 + #include "skl_watermark.h" 17 + 18 + #include "i915_drv.h" 19 + #include "i915_fixed.h" 20 + #include "i915_reg.h" 21 + #include "intel_pcode.h" 22 + #include "intel_pm.h" 23 + 24 + static void skl_sagv_disable(struct drm_i915_private *i915); 25 + 26 + /* Stores plane specific WM parameters */ 27 + struct skl_wm_params { 28 + bool x_tiled, y_tiled; 29 + bool rc_surface; 30 + bool is_planar; 31 + u32 width; 32 + u8 cpp; 33 + u32 plane_pixel_rate; 34 + u32 y_min_scanlines; 35 + u32 plane_bytes_per_line; 36 + uint_fixed_16_16_t plane_blocks_per_line; 37 + uint_fixed_16_16_t y_tile_minimum; 38 + u32 linetime_us; 39 + u32 dbuf_block_size; 40 + }; 41 + 42 + u8 intel_enabled_dbuf_slices_mask(struct drm_i915_private *i915) 43 + { 44 + u8 enabled_slices = 0; 45 + enum dbuf_slice slice; 46 + 47 + for_each_dbuf_slice(i915, slice) { 48 + if (intel_uncore_read(&i915->uncore, 49 + DBUF_CTL_S(slice)) & DBUF_POWER_STATE) 50 + enabled_slices |= BIT(slice); 51 + } 52 + 53 + return enabled_slices; 54 + } 55 + 56 + /* 57 + * FIXME: We still don't have the proper code detect if we need to apply the WA, 58 + * so assume we'll always need it in order to avoid underruns. 59 + */ 60 + static bool skl_needs_memory_bw_wa(struct drm_i915_private *i915) 61 + { 62 + return DISPLAY_VER(i915) == 9; 63 + } 64 + 65 + static bool 66 + intel_has_sagv(struct drm_i915_private *i915) 67 + { 68 + return DISPLAY_VER(i915) >= 9 && !IS_LP(i915) && 69 + i915->display.sagv.status != I915_SAGV_NOT_CONTROLLED; 70 + } 71 + 72 + static u32 73 + intel_sagv_block_time(struct drm_i915_private *i915) 74 + { 75 + if (DISPLAY_VER(i915) >= 14) { 76 + u32 val; 77 + 78 + val = intel_uncore_read(&i915->uncore, MTL_LATENCY_SAGV); 79 + 80 + return REG_FIELD_GET(MTL_LATENCY_QCLK_SAGV, val); 81 + } else if (DISPLAY_VER(i915) >= 12) { 82 + u32 val = 0; 83 + int ret; 84 + 85 + ret = snb_pcode_read(&i915->uncore, 86 + GEN12_PCODE_READ_SAGV_BLOCK_TIME_US, 87 + &val, NULL); 88 + if (ret) { 89 + drm_dbg_kms(&i915->drm, "Couldn't read SAGV block time!\n"); 90 + return 0; 91 + } 92 + 93 + return val; 94 + } else if (DISPLAY_VER(i915) == 11) { 95 + return 10; 96 + } else if (DISPLAY_VER(i915) == 9 && !IS_LP(i915)) { 97 + return 30; 98 + } else { 99 + return 0; 100 + } 101 + } 102 + 103 + static void intel_sagv_init(struct drm_i915_private *i915) 104 + { 105 + if (!intel_has_sagv(i915)) 106 + i915->display.sagv.status = I915_SAGV_NOT_CONTROLLED; 107 + 108 + /* 109 + * Probe to see if we have working SAGV control. 110 + * For icl+ this was already determined by intel_bw_init_hw(). 111 + */ 112 + if (DISPLAY_VER(i915) < 11) 113 + skl_sagv_disable(i915); 114 + 115 + drm_WARN_ON(&i915->drm, i915->display.sagv.status == I915_SAGV_UNKNOWN); 116 + 117 + i915->display.sagv.block_time_us = intel_sagv_block_time(i915); 118 + 119 + drm_dbg_kms(&i915->drm, "SAGV supported: %s, original SAGV block time: %u us\n", 120 + str_yes_no(intel_has_sagv(i915)), i915->display.sagv.block_time_us); 121 + 122 + /* avoid overflow when adding with wm0 latency/etc. */ 123 + if (drm_WARN(&i915->drm, i915->display.sagv.block_time_us > U16_MAX, 124 + "Excessive SAGV block time %u, ignoring\n", 125 + i915->display.sagv.block_time_us)) 126 + i915->display.sagv.block_time_us = 0; 127 + 128 + if (!intel_has_sagv(i915)) 129 + i915->display.sagv.block_time_us = 0; 130 + } 131 + 132 + /* 133 + * SAGV dynamically adjusts the system agent voltage and clock frequencies 134 + * depending on power and performance requirements. The display engine access 135 + * to system memory is blocked during the adjustment time. Because of the 136 + * blocking time, having this enabled can cause full system hangs and/or pipe 137 + * underruns if we don't meet all of the following requirements: 138 + * 139 + * - <= 1 pipe enabled 140 + * - All planes can enable watermarks for latencies >= SAGV engine block time 141 + * - We're not using an interlaced display configuration 142 + */ 143 + static void skl_sagv_enable(struct drm_i915_private *i915) 144 + { 145 + int ret; 146 + 147 + if (!intel_has_sagv(i915)) 148 + return; 149 + 150 + if (i915->display.sagv.status == I915_SAGV_ENABLED) 151 + return; 152 + 153 + drm_dbg_kms(&i915->drm, "Enabling SAGV\n"); 154 + ret = snb_pcode_write(&i915->uncore, GEN9_PCODE_SAGV_CONTROL, 155 + GEN9_SAGV_ENABLE); 156 + 157 + /* We don't need to wait for SAGV when enabling */ 158 + 159 + /* 160 + * Some skl systems, pre-release machines in particular, 161 + * don't actually have SAGV. 162 + */ 163 + if (IS_SKYLAKE(i915) && ret == -ENXIO) { 164 + drm_dbg(&i915->drm, "No SAGV found on system, ignoring\n"); 165 + i915->display.sagv.status = I915_SAGV_NOT_CONTROLLED; 166 + return; 167 + } else if (ret < 0) { 168 + drm_err(&i915->drm, "Failed to enable SAGV\n"); 169 + return; 170 + } 171 + 172 + i915->display.sagv.status = I915_SAGV_ENABLED; 173 + } 174 + 175 + static void skl_sagv_disable(struct drm_i915_private *i915) 176 + { 177 + int ret; 178 + 179 + if (!intel_has_sagv(i915)) 180 + return; 181 + 182 + if (i915->display.sagv.status == I915_SAGV_DISABLED) 183 + return; 184 + 185 + drm_dbg_kms(&i915->drm, "Disabling SAGV\n"); 186 + /* bspec says to keep retrying for at least 1 ms */ 187 + ret = skl_pcode_request(&i915->uncore, GEN9_PCODE_SAGV_CONTROL, 188 + GEN9_SAGV_DISABLE, 189 + GEN9_SAGV_IS_DISABLED, GEN9_SAGV_IS_DISABLED, 190 + 1); 191 + /* 192 + * Some skl systems, pre-release machines in particular, 193 + * don't actually have SAGV. 194 + */ 195 + if (IS_SKYLAKE(i915) && ret == -ENXIO) { 196 + drm_dbg(&i915->drm, "No SAGV found on system, ignoring\n"); 197 + i915->display.sagv.status = I915_SAGV_NOT_CONTROLLED; 198 + return; 199 + } else if (ret < 0) { 200 + drm_err(&i915->drm, "Failed to disable SAGV (%d)\n", ret); 201 + return; 202 + } 203 + 204 + i915->display.sagv.status = I915_SAGV_DISABLED; 205 + } 206 + 207 + static void skl_sagv_pre_plane_update(struct intel_atomic_state *state) 208 + { 209 + struct drm_i915_private *i915 = to_i915(state->base.dev); 210 + const struct intel_bw_state *new_bw_state = 211 + intel_atomic_get_new_bw_state(state); 212 + 213 + if (!new_bw_state) 214 + return; 215 + 216 + if (!intel_can_enable_sagv(i915, new_bw_state)) 217 + skl_sagv_disable(i915); 218 + } 219 + 220 + static void skl_sagv_post_plane_update(struct intel_atomic_state *state) 221 + { 222 + struct drm_i915_private *i915 = to_i915(state->base.dev); 223 + const struct intel_bw_state *new_bw_state = 224 + intel_atomic_get_new_bw_state(state); 225 + 226 + if (!new_bw_state) 227 + return; 228 + 229 + if (intel_can_enable_sagv(i915, new_bw_state)) 230 + skl_sagv_enable(i915); 231 + } 232 + 233 + static void icl_sagv_pre_plane_update(struct intel_atomic_state *state) 234 + { 235 + struct drm_i915_private *i915 = to_i915(state->base.dev); 236 + const struct intel_bw_state *old_bw_state = 237 + intel_atomic_get_old_bw_state(state); 238 + const struct intel_bw_state *new_bw_state = 239 + intel_atomic_get_new_bw_state(state); 240 + u16 old_mask, new_mask; 241 + 242 + if (!new_bw_state) 243 + return; 244 + 245 + old_mask = old_bw_state->qgv_points_mask; 246 + new_mask = old_bw_state->qgv_points_mask | new_bw_state->qgv_points_mask; 247 + 248 + if (old_mask == new_mask) 249 + return; 250 + 251 + WARN_ON(!new_bw_state->base.changed); 252 + 253 + drm_dbg_kms(&i915->drm, "Restricting QGV points: 0x%x -> 0x%x\n", 254 + old_mask, new_mask); 255 + 256 + /* 257 + * Restrict required qgv points before updating the configuration. 258 + * According to BSpec we can't mask and unmask qgv points at the same 259 + * time. Also masking should be done before updating the configuration 260 + * and unmasking afterwards. 261 + */ 262 + icl_pcode_restrict_qgv_points(i915, new_mask); 263 + } 264 + 265 + static void icl_sagv_post_plane_update(struct intel_atomic_state *state) 266 + { 267 + struct drm_i915_private *i915 = to_i915(state->base.dev); 268 + const struct intel_bw_state *old_bw_state = 269 + intel_atomic_get_old_bw_state(state); 270 + const struct intel_bw_state *new_bw_state = 271 + intel_atomic_get_new_bw_state(state); 272 + u16 old_mask, new_mask; 273 + 274 + if (!new_bw_state) 275 + return; 276 + 277 + old_mask = old_bw_state->qgv_points_mask | new_bw_state->qgv_points_mask; 278 + new_mask = new_bw_state->qgv_points_mask; 279 + 280 + if (old_mask == new_mask) 281 + return; 282 + 283 + WARN_ON(!new_bw_state->base.changed); 284 + 285 + drm_dbg_kms(&i915->drm, "Relaxing QGV points: 0x%x -> 0x%x\n", 286 + old_mask, new_mask); 287 + 288 + /* 289 + * Allow required qgv points after updating the configuration. 290 + * According to BSpec we can't mask and unmask qgv points at the same 291 + * time. Also masking should be done before updating the configuration 292 + * and unmasking afterwards. 293 + */ 294 + icl_pcode_restrict_qgv_points(i915, new_mask); 295 + } 296 + 297 + void intel_sagv_pre_plane_update(struct intel_atomic_state *state) 298 + { 299 + struct drm_i915_private *i915 = to_i915(state->base.dev); 300 + 301 + /* 302 + * Just return if we can't control SAGV or don't have it. 303 + * This is different from situation when we have SAGV but just can't 304 + * afford it due to DBuf limitation - in case if SAGV is completely 305 + * disabled in a BIOS, we are not even allowed to send a PCode request, 306 + * as it will throw an error. So have to check it here. 307 + */ 308 + if (!intel_has_sagv(i915)) 309 + return; 310 + 311 + if (DISPLAY_VER(i915) >= 11) 312 + icl_sagv_pre_plane_update(state); 313 + else 314 + skl_sagv_pre_plane_update(state); 315 + } 316 + 317 + void intel_sagv_post_plane_update(struct intel_atomic_state *state) 318 + { 319 + struct drm_i915_private *i915 = to_i915(state->base.dev); 320 + 321 + /* 322 + * Just return if we can't control SAGV or don't have it. 323 + * This is different from situation when we have SAGV but just can't 324 + * afford it due to DBuf limitation - in case if SAGV is completely 325 + * disabled in a BIOS, we are not even allowed to send a PCode request, 326 + * as it will throw an error. So have to check it here. 327 + */ 328 + if (!intel_has_sagv(i915)) 329 + return; 330 + 331 + if (DISPLAY_VER(i915) >= 11) 332 + icl_sagv_post_plane_update(state); 333 + else 334 + skl_sagv_post_plane_update(state); 335 + } 336 + 337 + static bool skl_crtc_can_enable_sagv(const struct intel_crtc_state *crtc_state) 338 + { 339 + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 340 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 341 + enum plane_id plane_id; 342 + int max_level = INT_MAX; 343 + 344 + if (!intel_has_sagv(i915)) 345 + return false; 346 + 347 + if (!crtc_state->hw.active) 348 + return true; 349 + 350 + if (crtc_state->hw.pipe_mode.flags & DRM_MODE_FLAG_INTERLACE) 351 + return false; 352 + 353 + for_each_plane_id_on_crtc(crtc, plane_id) { 354 + const struct skl_plane_wm *wm = 355 + &crtc_state->wm.skl.optimal.planes[plane_id]; 356 + int level; 357 + 358 + /* Skip this plane if it's not enabled */ 359 + if (!wm->wm[0].enable) 360 + continue; 361 + 362 + /* Find the highest enabled wm level for this plane */ 363 + for (level = ilk_wm_max_level(i915); 364 + !wm->wm[level].enable; --level) 365 + { } 366 + 367 + /* Highest common enabled wm level for all planes */ 368 + max_level = min(level, max_level); 369 + } 370 + 371 + /* No enabled planes? */ 372 + if (max_level == INT_MAX) 373 + return true; 374 + 375 + for_each_plane_id_on_crtc(crtc, plane_id) { 376 + const struct skl_plane_wm *wm = 377 + &crtc_state->wm.skl.optimal.planes[plane_id]; 378 + 379 + /* 380 + * All enabled planes must have enabled a common wm level that 381 + * can tolerate memory latencies higher than sagv_block_time_us 382 + */ 383 + if (wm->wm[0].enable && !wm->wm[max_level].can_sagv) 384 + return false; 385 + } 386 + 387 + return true; 388 + } 389 + 390 + static bool tgl_crtc_can_enable_sagv(const struct intel_crtc_state *crtc_state) 391 + { 392 + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 393 + enum plane_id plane_id; 394 + 395 + if (!crtc_state->hw.active) 396 + return true; 397 + 398 + for_each_plane_id_on_crtc(crtc, plane_id) { 399 + const struct skl_plane_wm *wm = 400 + &crtc_state->wm.skl.optimal.planes[plane_id]; 401 + 402 + if (wm->wm[0].enable && !wm->sagv.wm0.enable) 403 + return false; 404 + } 405 + 406 + return true; 407 + } 408 + 409 + static bool intel_crtc_can_enable_sagv(const struct intel_crtc_state *crtc_state) 410 + { 411 + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 412 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 413 + 414 + if (DISPLAY_VER(i915) >= 12) 415 + return tgl_crtc_can_enable_sagv(crtc_state); 416 + else 417 + return skl_crtc_can_enable_sagv(crtc_state); 418 + } 419 + 420 + bool intel_can_enable_sagv(struct drm_i915_private *i915, 421 + const struct intel_bw_state *bw_state) 422 + { 423 + if (DISPLAY_VER(i915) < 11 && 424 + bw_state->active_pipes && !is_power_of_2(bw_state->active_pipes)) 425 + return false; 426 + 427 + return bw_state->pipe_sagv_reject == 0; 428 + } 429 + 430 + static int intel_compute_sagv_mask(struct intel_atomic_state *state) 431 + { 432 + struct drm_i915_private *i915 = to_i915(state->base.dev); 433 + int ret; 434 + struct intel_crtc *crtc; 435 + struct intel_crtc_state *new_crtc_state; 436 + struct intel_bw_state *new_bw_state = NULL; 437 + const struct intel_bw_state *old_bw_state = NULL; 438 + int i; 439 + 440 + for_each_new_intel_crtc_in_state(state, crtc, 441 + new_crtc_state, i) { 442 + new_bw_state = intel_atomic_get_bw_state(state); 443 + if (IS_ERR(new_bw_state)) 444 + return PTR_ERR(new_bw_state); 445 + 446 + old_bw_state = intel_atomic_get_old_bw_state(state); 447 + 448 + if (intel_crtc_can_enable_sagv(new_crtc_state)) 449 + new_bw_state->pipe_sagv_reject &= ~BIT(crtc->pipe); 450 + else 451 + new_bw_state->pipe_sagv_reject |= BIT(crtc->pipe); 452 + } 453 + 454 + if (!new_bw_state) 455 + return 0; 456 + 457 + new_bw_state->active_pipes = 458 + intel_calc_active_pipes(state, old_bw_state->active_pipes); 459 + 460 + if (new_bw_state->active_pipes != old_bw_state->active_pipes) { 461 + ret = intel_atomic_lock_global_state(&new_bw_state->base); 462 + if (ret) 463 + return ret; 464 + } 465 + 466 + if (intel_can_enable_sagv(i915, new_bw_state) != 467 + intel_can_enable_sagv(i915, old_bw_state)) { 468 + ret = intel_atomic_serialize_global_state(&new_bw_state->base); 469 + if (ret) 470 + return ret; 471 + } else if (new_bw_state->pipe_sagv_reject != old_bw_state->pipe_sagv_reject) { 472 + ret = intel_atomic_lock_global_state(&new_bw_state->base); 473 + if (ret) 474 + return ret; 475 + } 476 + 477 + for_each_new_intel_crtc_in_state(state, crtc, 478 + new_crtc_state, i) { 479 + struct skl_pipe_wm *pipe_wm = &new_crtc_state->wm.skl.optimal; 480 + 481 + /* 482 + * We store use_sagv_wm in the crtc state rather than relying on 483 + * that bw state since we have no convenient way to get at the 484 + * latter from the plane commit hooks (especially in the legacy 485 + * cursor case) 486 + */ 487 + pipe_wm->use_sagv_wm = !HAS_HW_SAGV_WM(i915) && 488 + DISPLAY_VER(i915) >= 12 && 489 + intel_can_enable_sagv(i915, new_bw_state); 490 + } 491 + 492 + return 0; 493 + } 494 + 495 + static u16 skl_ddb_entry_init(struct skl_ddb_entry *entry, 496 + u16 start, u16 end) 497 + { 498 + entry->start = start; 499 + entry->end = end; 500 + 501 + return end; 502 + } 503 + 504 + static int intel_dbuf_slice_size(struct drm_i915_private *i915) 505 + { 506 + return INTEL_INFO(i915)->display.dbuf.size / 507 + hweight8(INTEL_INFO(i915)->display.dbuf.slice_mask); 508 + } 509 + 510 + static void 511 + skl_ddb_entry_for_slices(struct drm_i915_private *i915, u8 slice_mask, 512 + struct skl_ddb_entry *ddb) 513 + { 514 + int slice_size = intel_dbuf_slice_size(i915); 515 + 516 + if (!slice_mask) { 517 + ddb->start = 0; 518 + ddb->end = 0; 519 + return; 520 + } 521 + 522 + ddb->start = (ffs(slice_mask) - 1) * slice_size; 523 + ddb->end = fls(slice_mask) * slice_size; 524 + 525 + WARN_ON(ddb->start >= ddb->end); 526 + WARN_ON(ddb->end > INTEL_INFO(i915)->display.dbuf.size); 527 + } 528 + 529 + static unsigned int mbus_ddb_offset(struct drm_i915_private *i915, u8 slice_mask) 530 + { 531 + struct skl_ddb_entry ddb; 532 + 533 + if (slice_mask & (BIT(DBUF_S1) | BIT(DBUF_S2))) 534 + slice_mask = BIT(DBUF_S1); 535 + else if (slice_mask & (BIT(DBUF_S3) | BIT(DBUF_S4))) 536 + slice_mask = BIT(DBUF_S3); 537 + 538 + skl_ddb_entry_for_slices(i915, slice_mask, &ddb); 539 + 540 + return ddb.start; 541 + } 542 + 543 + u32 skl_ddb_dbuf_slice_mask(struct drm_i915_private *i915, 544 + const struct skl_ddb_entry *entry) 545 + { 546 + int slice_size = intel_dbuf_slice_size(i915); 547 + enum dbuf_slice start_slice, end_slice; 548 + u8 slice_mask = 0; 549 + 550 + if (!skl_ddb_entry_size(entry)) 551 + return 0; 552 + 553 + start_slice = entry->start / slice_size; 554 + end_slice = (entry->end - 1) / slice_size; 555 + 556 + /* 557 + * Per plane DDB entry can in a really worst case be on multiple slices 558 + * but single entry is anyway contigious. 559 + */ 560 + while (start_slice <= end_slice) { 561 + slice_mask |= BIT(start_slice); 562 + start_slice++; 563 + } 564 + 565 + return slice_mask; 566 + } 567 + 568 + static unsigned int intel_crtc_ddb_weight(const struct intel_crtc_state *crtc_state) 569 + { 570 + const struct drm_display_mode *pipe_mode = &crtc_state->hw.pipe_mode; 571 + int hdisplay, vdisplay; 572 + 573 + if (!crtc_state->hw.active) 574 + return 0; 575 + 576 + /* 577 + * Watermark/ddb requirement highly depends upon width of the 578 + * framebuffer, So instead of allocating DDB equally among pipes 579 + * distribute DDB based on resolution/width of the display. 580 + */ 581 + drm_mode_get_hv_timing(pipe_mode, &hdisplay, &vdisplay); 582 + 583 + return hdisplay; 584 + } 585 + 586 + static void intel_crtc_dbuf_weights(const struct intel_dbuf_state *dbuf_state, 587 + enum pipe for_pipe, 588 + unsigned int *weight_start, 589 + unsigned int *weight_end, 590 + unsigned int *weight_total) 591 + { 592 + struct drm_i915_private *i915 = 593 + to_i915(dbuf_state->base.state->base.dev); 594 + enum pipe pipe; 595 + 596 + *weight_start = 0; 597 + *weight_end = 0; 598 + *weight_total = 0; 599 + 600 + for_each_pipe(i915, pipe) { 601 + int weight = dbuf_state->weight[pipe]; 602 + 603 + /* 604 + * Do not account pipes using other slice sets 605 + * luckily as of current BSpec slice sets do not partially 606 + * intersect(pipes share either same one slice or same slice set 607 + * i.e no partial intersection), so it is enough to check for 608 + * equality for now. 609 + */ 610 + if (dbuf_state->slices[pipe] != dbuf_state->slices[for_pipe]) 611 + continue; 612 + 613 + *weight_total += weight; 614 + if (pipe < for_pipe) { 615 + *weight_start += weight; 616 + *weight_end += weight; 617 + } else if (pipe == for_pipe) { 618 + *weight_end += weight; 619 + } 620 + } 621 + } 622 + 623 + static int 624 + skl_crtc_allocate_ddb(struct intel_atomic_state *state, struct intel_crtc *crtc) 625 + { 626 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 627 + unsigned int weight_total, weight_start, weight_end; 628 + const struct intel_dbuf_state *old_dbuf_state = 629 + intel_atomic_get_old_dbuf_state(state); 630 + struct intel_dbuf_state *new_dbuf_state = 631 + intel_atomic_get_new_dbuf_state(state); 632 + struct intel_crtc_state *crtc_state; 633 + struct skl_ddb_entry ddb_slices; 634 + enum pipe pipe = crtc->pipe; 635 + unsigned int mbus_offset = 0; 636 + u32 ddb_range_size; 637 + u32 dbuf_slice_mask; 638 + u32 start, end; 639 + int ret; 640 + 641 + if (new_dbuf_state->weight[pipe] == 0) { 642 + skl_ddb_entry_init(&new_dbuf_state->ddb[pipe], 0, 0); 643 + goto out; 644 + } 645 + 646 + dbuf_slice_mask = new_dbuf_state->slices[pipe]; 647 + 648 + skl_ddb_entry_for_slices(i915, dbuf_slice_mask, &ddb_slices); 649 + mbus_offset = mbus_ddb_offset(i915, dbuf_slice_mask); 650 + ddb_range_size = skl_ddb_entry_size(&ddb_slices); 651 + 652 + intel_crtc_dbuf_weights(new_dbuf_state, pipe, 653 + &weight_start, &weight_end, &weight_total); 654 + 655 + start = ddb_range_size * weight_start / weight_total; 656 + end = ddb_range_size * weight_end / weight_total; 657 + 658 + skl_ddb_entry_init(&new_dbuf_state->ddb[pipe], 659 + ddb_slices.start - mbus_offset + start, 660 + ddb_slices.start - mbus_offset + end); 661 + 662 + out: 663 + if (old_dbuf_state->slices[pipe] == new_dbuf_state->slices[pipe] && 664 + skl_ddb_entry_equal(&old_dbuf_state->ddb[pipe], 665 + &new_dbuf_state->ddb[pipe])) 666 + return 0; 667 + 668 + ret = intel_atomic_lock_global_state(&new_dbuf_state->base); 669 + if (ret) 670 + return ret; 671 + 672 + crtc_state = intel_atomic_get_crtc_state(&state->base, crtc); 673 + if (IS_ERR(crtc_state)) 674 + return PTR_ERR(crtc_state); 675 + 676 + /* 677 + * Used for checking overlaps, so we need absolute 678 + * offsets instead of MBUS relative offsets. 679 + */ 680 + crtc_state->wm.skl.ddb.start = mbus_offset + new_dbuf_state->ddb[pipe].start; 681 + crtc_state->wm.skl.ddb.end = mbus_offset + new_dbuf_state->ddb[pipe].end; 682 + 683 + drm_dbg_kms(&i915->drm, 684 + "[CRTC:%d:%s] dbuf slices 0x%x -> 0x%x, ddb (%d - %d) -> (%d - %d), active pipes 0x%x -> 0x%x\n", 685 + crtc->base.base.id, crtc->base.name, 686 + old_dbuf_state->slices[pipe], new_dbuf_state->slices[pipe], 687 + old_dbuf_state->ddb[pipe].start, old_dbuf_state->ddb[pipe].end, 688 + new_dbuf_state->ddb[pipe].start, new_dbuf_state->ddb[pipe].end, 689 + old_dbuf_state->active_pipes, new_dbuf_state->active_pipes); 690 + 691 + return 0; 692 + } 693 + 694 + static int skl_compute_wm_params(const struct intel_crtc_state *crtc_state, 695 + int width, const struct drm_format_info *format, 696 + u64 modifier, unsigned int rotation, 697 + u32 plane_pixel_rate, struct skl_wm_params *wp, 698 + int color_plane); 699 + 700 + static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state, 701 + struct intel_plane *plane, 702 + int level, 703 + unsigned int latency, 704 + const struct skl_wm_params *wp, 705 + const struct skl_wm_level *result_prev, 706 + struct skl_wm_level *result /* out */); 707 + 708 + static unsigned int 709 + skl_cursor_allocation(const struct intel_crtc_state *crtc_state, 710 + int num_active) 711 + { 712 + struct intel_plane *plane = to_intel_plane(crtc_state->uapi.crtc->cursor); 713 + struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); 714 + int level, max_level = ilk_wm_max_level(i915); 715 + struct skl_wm_level wm = {}; 716 + int ret, min_ddb_alloc = 0; 717 + struct skl_wm_params wp; 718 + 719 + ret = skl_compute_wm_params(crtc_state, 256, 720 + drm_format_info(DRM_FORMAT_ARGB8888), 721 + DRM_FORMAT_MOD_LINEAR, 722 + DRM_MODE_ROTATE_0, 723 + crtc_state->pixel_rate, &wp, 0); 724 + drm_WARN_ON(&i915->drm, ret); 725 + 726 + for (level = 0; level <= max_level; level++) { 727 + unsigned int latency = i915->display.wm.skl_latency[level]; 728 + 729 + skl_compute_plane_wm(crtc_state, plane, level, latency, &wp, &wm, &wm); 730 + if (wm.min_ddb_alloc == U16_MAX) 731 + break; 732 + 733 + min_ddb_alloc = wm.min_ddb_alloc; 734 + } 735 + 736 + return max(num_active == 1 ? 32 : 8, min_ddb_alloc); 737 + } 738 + 739 + static void skl_ddb_entry_init_from_hw(struct skl_ddb_entry *entry, u32 reg) 740 + { 741 + skl_ddb_entry_init(entry, 742 + REG_FIELD_GET(PLANE_BUF_START_MASK, reg), 743 + REG_FIELD_GET(PLANE_BUF_END_MASK, reg)); 744 + if (entry->end) 745 + entry->end++; 746 + } 747 + 748 + static void 749 + skl_ddb_get_hw_plane_state(struct drm_i915_private *i915, 750 + const enum pipe pipe, 751 + const enum plane_id plane_id, 752 + struct skl_ddb_entry *ddb, 753 + struct skl_ddb_entry *ddb_y) 754 + { 755 + u32 val; 756 + 757 + /* Cursor doesn't support NV12/planar, so no extra calculation needed */ 758 + if (plane_id == PLANE_CURSOR) { 759 + val = intel_uncore_read(&i915->uncore, CUR_BUF_CFG(pipe)); 760 + skl_ddb_entry_init_from_hw(ddb, val); 761 + return; 762 + } 763 + 764 + val = intel_uncore_read(&i915->uncore, PLANE_BUF_CFG(pipe, plane_id)); 765 + skl_ddb_entry_init_from_hw(ddb, val); 766 + 767 + if (DISPLAY_VER(i915) >= 11) 768 + return; 769 + 770 + val = intel_uncore_read(&i915->uncore, PLANE_NV12_BUF_CFG(pipe, plane_id)); 771 + skl_ddb_entry_init_from_hw(ddb_y, val); 772 + } 773 + 774 + static void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc, 775 + struct skl_ddb_entry *ddb, 776 + struct skl_ddb_entry *ddb_y) 777 + { 778 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 779 + enum intel_display_power_domain power_domain; 780 + enum pipe pipe = crtc->pipe; 781 + intel_wakeref_t wakeref; 782 + enum plane_id plane_id; 783 + 784 + power_domain = POWER_DOMAIN_PIPE(pipe); 785 + wakeref = intel_display_power_get_if_enabled(i915, power_domain); 786 + if (!wakeref) 787 + return; 788 + 789 + for_each_plane_id_on_crtc(crtc, plane_id) 790 + skl_ddb_get_hw_plane_state(i915, pipe, 791 + plane_id, 792 + &ddb[plane_id], 793 + &ddb_y[plane_id]); 794 + 795 + intel_display_power_put(i915, power_domain, wakeref); 796 + } 797 + 798 + struct dbuf_slice_conf_entry { 799 + u8 active_pipes; 800 + u8 dbuf_mask[I915_MAX_PIPES]; 801 + bool join_mbus; 802 + }; 803 + 804 + /* 805 + * Table taken from Bspec 12716 806 + * Pipes do have some preferred DBuf slice affinity, 807 + * plus there are some hardcoded requirements on how 808 + * those should be distributed for multipipe scenarios. 809 + * For more DBuf slices algorithm can get even more messy 810 + * and less readable, so decided to use a table almost 811 + * as is from BSpec itself - that way it is at least easier 812 + * to compare, change and check. 813 + */ 814 + static const struct dbuf_slice_conf_entry icl_allowed_dbufs[] = 815 + /* Autogenerated with igt/tools/intel_dbuf_map tool: */ 816 + { 817 + { 818 + .active_pipes = BIT(PIPE_A), 819 + .dbuf_mask = { 820 + [PIPE_A] = BIT(DBUF_S1), 821 + }, 822 + }, 823 + { 824 + .active_pipes = BIT(PIPE_B), 825 + .dbuf_mask = { 826 + [PIPE_B] = BIT(DBUF_S1), 827 + }, 828 + }, 829 + { 830 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B), 831 + .dbuf_mask = { 832 + [PIPE_A] = BIT(DBUF_S1), 833 + [PIPE_B] = BIT(DBUF_S2), 834 + }, 835 + }, 836 + { 837 + .active_pipes = BIT(PIPE_C), 838 + .dbuf_mask = { 839 + [PIPE_C] = BIT(DBUF_S2), 840 + }, 841 + }, 842 + { 843 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_C), 844 + .dbuf_mask = { 845 + [PIPE_A] = BIT(DBUF_S1), 846 + [PIPE_C] = BIT(DBUF_S2), 847 + }, 848 + }, 849 + { 850 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_C), 851 + .dbuf_mask = { 852 + [PIPE_B] = BIT(DBUF_S1), 853 + [PIPE_C] = BIT(DBUF_S2), 854 + }, 855 + }, 856 + { 857 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), 858 + .dbuf_mask = { 859 + [PIPE_A] = BIT(DBUF_S1), 860 + [PIPE_B] = BIT(DBUF_S1), 861 + [PIPE_C] = BIT(DBUF_S2), 862 + }, 863 + }, 864 + {} 865 + }; 866 + 867 + /* 868 + * Table taken from Bspec 49255 869 + * Pipes do have some preferred DBuf slice affinity, 870 + * plus there are some hardcoded requirements on how 871 + * those should be distributed for multipipe scenarios. 872 + * For more DBuf slices algorithm can get even more messy 873 + * and less readable, so decided to use a table almost 874 + * as is from BSpec itself - that way it is at least easier 875 + * to compare, change and check. 876 + */ 877 + static const struct dbuf_slice_conf_entry tgl_allowed_dbufs[] = 878 + /* Autogenerated with igt/tools/intel_dbuf_map tool: */ 879 + { 880 + { 881 + .active_pipes = BIT(PIPE_A), 882 + .dbuf_mask = { 883 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 884 + }, 885 + }, 886 + { 887 + .active_pipes = BIT(PIPE_B), 888 + .dbuf_mask = { 889 + [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 890 + }, 891 + }, 892 + { 893 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B), 894 + .dbuf_mask = { 895 + [PIPE_A] = BIT(DBUF_S2), 896 + [PIPE_B] = BIT(DBUF_S1), 897 + }, 898 + }, 899 + { 900 + .active_pipes = BIT(PIPE_C), 901 + .dbuf_mask = { 902 + [PIPE_C] = BIT(DBUF_S2) | BIT(DBUF_S1), 903 + }, 904 + }, 905 + { 906 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_C), 907 + .dbuf_mask = { 908 + [PIPE_A] = BIT(DBUF_S1), 909 + [PIPE_C] = BIT(DBUF_S2), 910 + }, 911 + }, 912 + { 913 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_C), 914 + .dbuf_mask = { 915 + [PIPE_B] = BIT(DBUF_S1), 916 + [PIPE_C] = BIT(DBUF_S2), 917 + }, 918 + }, 919 + { 920 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), 921 + .dbuf_mask = { 922 + [PIPE_A] = BIT(DBUF_S1), 923 + [PIPE_B] = BIT(DBUF_S1), 924 + [PIPE_C] = BIT(DBUF_S2), 925 + }, 926 + }, 927 + { 928 + .active_pipes = BIT(PIPE_D), 929 + .dbuf_mask = { 930 + [PIPE_D] = BIT(DBUF_S2) | BIT(DBUF_S1), 931 + }, 932 + }, 933 + { 934 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_D), 935 + .dbuf_mask = { 936 + [PIPE_A] = BIT(DBUF_S1), 937 + [PIPE_D] = BIT(DBUF_S2), 938 + }, 939 + }, 940 + { 941 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_D), 942 + .dbuf_mask = { 943 + [PIPE_B] = BIT(DBUF_S1), 944 + [PIPE_D] = BIT(DBUF_S2), 945 + }, 946 + }, 947 + { 948 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_D), 949 + .dbuf_mask = { 950 + [PIPE_A] = BIT(DBUF_S1), 951 + [PIPE_B] = BIT(DBUF_S1), 952 + [PIPE_D] = BIT(DBUF_S2), 953 + }, 954 + }, 955 + { 956 + .active_pipes = BIT(PIPE_C) | BIT(PIPE_D), 957 + .dbuf_mask = { 958 + [PIPE_C] = BIT(DBUF_S1), 959 + [PIPE_D] = BIT(DBUF_S2), 960 + }, 961 + }, 962 + { 963 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_C) | BIT(PIPE_D), 964 + .dbuf_mask = { 965 + [PIPE_A] = BIT(DBUF_S1), 966 + [PIPE_C] = BIT(DBUF_S2), 967 + [PIPE_D] = BIT(DBUF_S2), 968 + }, 969 + }, 970 + { 971 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 972 + .dbuf_mask = { 973 + [PIPE_B] = BIT(DBUF_S1), 974 + [PIPE_C] = BIT(DBUF_S2), 975 + [PIPE_D] = BIT(DBUF_S2), 976 + }, 977 + }, 978 + { 979 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 980 + .dbuf_mask = { 981 + [PIPE_A] = BIT(DBUF_S1), 982 + [PIPE_B] = BIT(DBUF_S1), 983 + [PIPE_C] = BIT(DBUF_S2), 984 + [PIPE_D] = BIT(DBUF_S2), 985 + }, 986 + }, 987 + {} 988 + }; 989 + 990 + static const struct dbuf_slice_conf_entry dg2_allowed_dbufs[] = { 991 + { 992 + .active_pipes = BIT(PIPE_A), 993 + .dbuf_mask = { 994 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 995 + }, 996 + }, 997 + { 998 + .active_pipes = BIT(PIPE_B), 999 + .dbuf_mask = { 1000 + [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 1001 + }, 1002 + }, 1003 + { 1004 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B), 1005 + .dbuf_mask = { 1006 + [PIPE_A] = BIT(DBUF_S1), 1007 + [PIPE_B] = BIT(DBUF_S2), 1008 + }, 1009 + }, 1010 + { 1011 + .active_pipes = BIT(PIPE_C), 1012 + .dbuf_mask = { 1013 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1014 + }, 1015 + }, 1016 + { 1017 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_C), 1018 + .dbuf_mask = { 1019 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1020 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1021 + }, 1022 + }, 1023 + { 1024 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_C), 1025 + .dbuf_mask = { 1026 + [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 1027 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1028 + }, 1029 + }, 1030 + { 1031 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), 1032 + .dbuf_mask = { 1033 + [PIPE_A] = BIT(DBUF_S1), 1034 + [PIPE_B] = BIT(DBUF_S2), 1035 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1036 + }, 1037 + }, 1038 + { 1039 + .active_pipes = BIT(PIPE_D), 1040 + .dbuf_mask = { 1041 + [PIPE_D] = BIT(DBUF_S3) | BIT(DBUF_S4), 1042 + }, 1043 + }, 1044 + { 1045 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_D), 1046 + .dbuf_mask = { 1047 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1048 + [PIPE_D] = BIT(DBUF_S3) | BIT(DBUF_S4), 1049 + }, 1050 + }, 1051 + { 1052 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_D), 1053 + .dbuf_mask = { 1054 + [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 1055 + [PIPE_D] = BIT(DBUF_S3) | BIT(DBUF_S4), 1056 + }, 1057 + }, 1058 + { 1059 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_D), 1060 + .dbuf_mask = { 1061 + [PIPE_A] = BIT(DBUF_S1), 1062 + [PIPE_B] = BIT(DBUF_S2), 1063 + [PIPE_D] = BIT(DBUF_S3) | BIT(DBUF_S4), 1064 + }, 1065 + }, 1066 + { 1067 + .active_pipes = BIT(PIPE_C) | BIT(PIPE_D), 1068 + .dbuf_mask = { 1069 + [PIPE_C] = BIT(DBUF_S3), 1070 + [PIPE_D] = BIT(DBUF_S4), 1071 + }, 1072 + }, 1073 + { 1074 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_C) | BIT(PIPE_D), 1075 + .dbuf_mask = { 1076 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1077 + [PIPE_C] = BIT(DBUF_S3), 1078 + [PIPE_D] = BIT(DBUF_S4), 1079 + }, 1080 + }, 1081 + { 1082 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 1083 + .dbuf_mask = { 1084 + [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 1085 + [PIPE_C] = BIT(DBUF_S3), 1086 + [PIPE_D] = BIT(DBUF_S4), 1087 + }, 1088 + }, 1089 + { 1090 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 1091 + .dbuf_mask = { 1092 + [PIPE_A] = BIT(DBUF_S1), 1093 + [PIPE_B] = BIT(DBUF_S2), 1094 + [PIPE_C] = BIT(DBUF_S3), 1095 + [PIPE_D] = BIT(DBUF_S4), 1096 + }, 1097 + }, 1098 + {} 1099 + }; 1100 + 1101 + static const struct dbuf_slice_conf_entry adlp_allowed_dbufs[] = { 1102 + /* 1103 + * Keep the join_mbus cases first so check_mbus_joined() 1104 + * will prefer them over the !join_mbus cases. 1105 + */ 1106 + { 1107 + .active_pipes = BIT(PIPE_A), 1108 + .dbuf_mask = { 1109 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2) | BIT(DBUF_S3) | BIT(DBUF_S4), 1110 + }, 1111 + .join_mbus = true, 1112 + }, 1113 + { 1114 + .active_pipes = BIT(PIPE_B), 1115 + .dbuf_mask = { 1116 + [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2) | BIT(DBUF_S3) | BIT(DBUF_S4), 1117 + }, 1118 + .join_mbus = true, 1119 + }, 1120 + { 1121 + .active_pipes = BIT(PIPE_A), 1122 + .dbuf_mask = { 1123 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1124 + }, 1125 + .join_mbus = false, 1126 + }, 1127 + { 1128 + .active_pipes = BIT(PIPE_B), 1129 + .dbuf_mask = { 1130 + [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 1131 + }, 1132 + .join_mbus = false, 1133 + }, 1134 + { 1135 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B), 1136 + .dbuf_mask = { 1137 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1138 + [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 1139 + }, 1140 + }, 1141 + { 1142 + .active_pipes = BIT(PIPE_C), 1143 + .dbuf_mask = { 1144 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1145 + }, 1146 + }, 1147 + { 1148 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_C), 1149 + .dbuf_mask = { 1150 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1151 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1152 + }, 1153 + }, 1154 + { 1155 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_C), 1156 + .dbuf_mask = { 1157 + [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 1158 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1159 + }, 1160 + }, 1161 + { 1162 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), 1163 + .dbuf_mask = { 1164 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1165 + [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 1166 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1167 + }, 1168 + }, 1169 + { 1170 + .active_pipes = BIT(PIPE_D), 1171 + .dbuf_mask = { 1172 + [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 1173 + }, 1174 + }, 1175 + { 1176 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_D), 1177 + .dbuf_mask = { 1178 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1179 + [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 1180 + }, 1181 + }, 1182 + { 1183 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_D), 1184 + .dbuf_mask = { 1185 + [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 1186 + [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 1187 + }, 1188 + }, 1189 + { 1190 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_D), 1191 + .dbuf_mask = { 1192 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1193 + [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 1194 + [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 1195 + }, 1196 + }, 1197 + { 1198 + .active_pipes = BIT(PIPE_C) | BIT(PIPE_D), 1199 + .dbuf_mask = { 1200 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1201 + [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 1202 + }, 1203 + }, 1204 + { 1205 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_C) | BIT(PIPE_D), 1206 + .dbuf_mask = { 1207 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1208 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1209 + [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 1210 + }, 1211 + }, 1212 + { 1213 + .active_pipes = BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 1214 + .dbuf_mask = { 1215 + [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 1216 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1217 + [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 1218 + }, 1219 + }, 1220 + { 1221 + .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 1222 + .dbuf_mask = { 1223 + [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 1224 + [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 1225 + [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 1226 + [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 1227 + }, 1228 + }, 1229 + {} 1230 + 1231 + }; 1232 + 1233 + static bool check_mbus_joined(u8 active_pipes, 1234 + const struct dbuf_slice_conf_entry *dbuf_slices) 1235 + { 1236 + int i; 1237 + 1238 + for (i = 0; dbuf_slices[i].active_pipes != 0; i++) { 1239 + if (dbuf_slices[i].active_pipes == active_pipes) 1240 + return dbuf_slices[i].join_mbus; 1241 + } 1242 + return false; 1243 + } 1244 + 1245 + static bool adlp_check_mbus_joined(u8 active_pipes) 1246 + { 1247 + return check_mbus_joined(active_pipes, adlp_allowed_dbufs); 1248 + } 1249 + 1250 + static u8 compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus, 1251 + const struct dbuf_slice_conf_entry *dbuf_slices) 1252 + { 1253 + int i; 1254 + 1255 + for (i = 0; dbuf_slices[i].active_pipes != 0; i++) { 1256 + if (dbuf_slices[i].active_pipes == active_pipes && 1257 + dbuf_slices[i].join_mbus == join_mbus) 1258 + return dbuf_slices[i].dbuf_mask[pipe]; 1259 + } 1260 + return 0; 1261 + } 1262 + 1263 + /* 1264 + * This function finds an entry with same enabled pipe configuration and 1265 + * returns correspondent DBuf slice mask as stated in BSpec for particular 1266 + * platform. 1267 + */ 1268 + static u8 icl_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus) 1269 + { 1270 + /* 1271 + * FIXME: For ICL this is still a bit unclear as prev BSpec revision 1272 + * required calculating "pipe ratio" in order to determine 1273 + * if one or two slices can be used for single pipe configurations 1274 + * as additional constraint to the existing table. 1275 + * However based on recent info, it should be not "pipe ratio" 1276 + * but rather ratio between pixel_rate and cdclk with additional 1277 + * constants, so for now we are using only table until this is 1278 + * clarified. Also this is the reason why crtc_state param is 1279 + * still here - we will need it once those additional constraints 1280 + * pop up. 1281 + */ 1282 + return compute_dbuf_slices(pipe, active_pipes, join_mbus, 1283 + icl_allowed_dbufs); 1284 + } 1285 + 1286 + static u8 tgl_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus) 1287 + { 1288 + return compute_dbuf_slices(pipe, active_pipes, join_mbus, 1289 + tgl_allowed_dbufs); 1290 + } 1291 + 1292 + static u8 adlp_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus) 1293 + { 1294 + return compute_dbuf_slices(pipe, active_pipes, join_mbus, 1295 + adlp_allowed_dbufs); 1296 + } 1297 + 1298 + static u8 dg2_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus) 1299 + { 1300 + return compute_dbuf_slices(pipe, active_pipes, join_mbus, 1301 + dg2_allowed_dbufs); 1302 + } 1303 + 1304 + static u8 skl_compute_dbuf_slices(struct intel_crtc *crtc, u8 active_pipes, bool join_mbus) 1305 + { 1306 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 1307 + enum pipe pipe = crtc->pipe; 1308 + 1309 + if (IS_DG2(i915)) 1310 + return dg2_compute_dbuf_slices(pipe, active_pipes, join_mbus); 1311 + else if (DISPLAY_VER(i915) >= 13) 1312 + return adlp_compute_dbuf_slices(pipe, active_pipes, join_mbus); 1313 + else if (DISPLAY_VER(i915) == 12) 1314 + return tgl_compute_dbuf_slices(pipe, active_pipes, join_mbus); 1315 + else if (DISPLAY_VER(i915) == 11) 1316 + return icl_compute_dbuf_slices(pipe, active_pipes, join_mbus); 1317 + /* 1318 + * For anything else just return one slice yet. 1319 + * Should be extended for other platforms. 1320 + */ 1321 + return active_pipes & BIT(pipe) ? BIT(DBUF_S1) : 0; 1322 + } 1323 + 1324 + static bool 1325 + use_minimal_wm0_only(const struct intel_crtc_state *crtc_state, 1326 + struct intel_plane *plane) 1327 + { 1328 + struct drm_i915_private *i915 = to_i915(plane->base.dev); 1329 + 1330 + return DISPLAY_VER(i915) >= 13 && 1331 + crtc_state->uapi.async_flip && 1332 + plane->async_flip; 1333 + } 1334 + 1335 + static u64 1336 + skl_total_relative_data_rate(const struct intel_crtc_state *crtc_state) 1337 + { 1338 + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 1339 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 1340 + enum plane_id plane_id; 1341 + u64 data_rate = 0; 1342 + 1343 + for_each_plane_id_on_crtc(crtc, plane_id) { 1344 + if (plane_id == PLANE_CURSOR) 1345 + continue; 1346 + 1347 + data_rate += crtc_state->rel_data_rate[plane_id]; 1348 + 1349 + if (DISPLAY_VER(i915) < 11) 1350 + data_rate += crtc_state->rel_data_rate_y[plane_id]; 1351 + } 1352 + 1353 + return data_rate; 1354 + } 1355 + 1356 + static const struct skl_wm_level * 1357 + skl_plane_wm_level(const struct skl_pipe_wm *pipe_wm, 1358 + enum plane_id plane_id, 1359 + int level) 1360 + { 1361 + const struct skl_plane_wm *wm = &pipe_wm->planes[plane_id]; 1362 + 1363 + if (level == 0 && pipe_wm->use_sagv_wm) 1364 + return &wm->sagv.wm0; 1365 + 1366 + return &wm->wm[level]; 1367 + } 1368 + 1369 + static const struct skl_wm_level * 1370 + skl_plane_trans_wm(const struct skl_pipe_wm *pipe_wm, 1371 + enum plane_id plane_id) 1372 + { 1373 + const struct skl_plane_wm *wm = &pipe_wm->planes[plane_id]; 1374 + 1375 + if (pipe_wm->use_sagv_wm) 1376 + return &wm->sagv.trans_wm; 1377 + 1378 + return &wm->trans_wm; 1379 + } 1380 + 1381 + /* 1382 + * We only disable the watermarks for each plane if 1383 + * they exceed the ddb allocation of said plane. This 1384 + * is done so that we don't end up touching cursor 1385 + * watermarks needlessly when some other plane reduces 1386 + * our max possible watermark level. 1387 + * 1388 + * Bspec has this to say about the PLANE_WM enable bit: 1389 + * "All the watermarks at this level for all enabled 1390 + * planes must be enabled before the level will be used." 1391 + * So this is actually safe to do. 1392 + */ 1393 + static void 1394 + skl_check_wm_level(struct skl_wm_level *wm, const struct skl_ddb_entry *ddb) 1395 + { 1396 + if (wm->min_ddb_alloc > skl_ddb_entry_size(ddb)) 1397 + memset(wm, 0, sizeof(*wm)); 1398 + } 1399 + 1400 + static void 1401 + skl_check_nv12_wm_level(struct skl_wm_level *wm, struct skl_wm_level *uv_wm, 1402 + const struct skl_ddb_entry *ddb_y, const struct skl_ddb_entry *ddb) 1403 + { 1404 + if (wm->min_ddb_alloc > skl_ddb_entry_size(ddb_y) || 1405 + uv_wm->min_ddb_alloc > skl_ddb_entry_size(ddb)) { 1406 + memset(wm, 0, sizeof(*wm)); 1407 + memset(uv_wm, 0, sizeof(*uv_wm)); 1408 + } 1409 + } 1410 + 1411 + static bool icl_need_wm1_wa(struct drm_i915_private *i915, 1412 + enum plane_id plane_id) 1413 + { 1414 + /* 1415 + * Wa_1408961008:icl, ehl 1416 + * Wa_14012656716:tgl, adl 1417 + * Underruns with WM1+ disabled 1418 + */ 1419 + return DISPLAY_VER(i915) == 11 || 1420 + (IS_DISPLAY_VER(i915, 12, 13) && plane_id == PLANE_CURSOR); 1421 + } 1422 + 1423 + struct skl_plane_ddb_iter { 1424 + u64 data_rate; 1425 + u16 start, size; 1426 + }; 1427 + 1428 + static void 1429 + skl_allocate_plane_ddb(struct skl_plane_ddb_iter *iter, 1430 + struct skl_ddb_entry *ddb, 1431 + const struct skl_wm_level *wm, 1432 + u64 data_rate) 1433 + { 1434 + u16 size, extra = 0; 1435 + 1436 + if (data_rate) { 1437 + extra = min_t(u16, iter->size, 1438 + DIV64_U64_ROUND_UP(iter->size * data_rate, 1439 + iter->data_rate)); 1440 + iter->size -= extra; 1441 + iter->data_rate -= data_rate; 1442 + } 1443 + 1444 + /* 1445 + * Keep ddb entry of all disabled planes explicitly zeroed 1446 + * to avoid skl_ddb_add_affected_planes() adding them to 1447 + * the state when other planes change their allocations. 1448 + */ 1449 + size = wm->min_ddb_alloc + extra; 1450 + if (size) 1451 + iter->start = skl_ddb_entry_init(ddb, iter->start, 1452 + iter->start + size); 1453 + } 1454 + 1455 + static int 1456 + skl_crtc_allocate_plane_ddb(struct intel_atomic_state *state, 1457 + struct intel_crtc *crtc) 1458 + { 1459 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 1460 + struct intel_crtc_state *crtc_state = 1461 + intel_atomic_get_new_crtc_state(state, crtc); 1462 + const struct intel_dbuf_state *dbuf_state = 1463 + intel_atomic_get_new_dbuf_state(state); 1464 + const struct skl_ddb_entry *alloc = &dbuf_state->ddb[crtc->pipe]; 1465 + int num_active = hweight8(dbuf_state->active_pipes); 1466 + struct skl_plane_ddb_iter iter; 1467 + enum plane_id plane_id; 1468 + u16 cursor_size; 1469 + u32 blocks; 1470 + int level; 1471 + 1472 + /* Clear the partitioning for disabled planes. */ 1473 + memset(crtc_state->wm.skl.plane_ddb, 0, sizeof(crtc_state->wm.skl.plane_ddb)); 1474 + memset(crtc_state->wm.skl.plane_ddb_y, 0, sizeof(crtc_state->wm.skl.plane_ddb_y)); 1475 + 1476 + if (!crtc_state->hw.active) 1477 + return 0; 1478 + 1479 + iter.start = alloc->start; 1480 + iter.size = skl_ddb_entry_size(alloc); 1481 + if (iter.size == 0) 1482 + return 0; 1483 + 1484 + /* Allocate fixed number of blocks for cursor. */ 1485 + cursor_size = skl_cursor_allocation(crtc_state, num_active); 1486 + iter.size -= cursor_size; 1487 + skl_ddb_entry_init(&crtc_state->wm.skl.plane_ddb[PLANE_CURSOR], 1488 + alloc->end - cursor_size, alloc->end); 1489 + 1490 + iter.data_rate = skl_total_relative_data_rate(crtc_state); 1491 + 1492 + /* 1493 + * Find the highest watermark level for which we can satisfy the block 1494 + * requirement of active planes. 1495 + */ 1496 + for (level = ilk_wm_max_level(i915); level >= 0; level--) { 1497 + blocks = 0; 1498 + for_each_plane_id_on_crtc(crtc, plane_id) { 1499 + const struct skl_plane_wm *wm = 1500 + &crtc_state->wm.skl.optimal.planes[plane_id]; 1501 + 1502 + if (plane_id == PLANE_CURSOR) { 1503 + const struct skl_ddb_entry *ddb = 1504 + &crtc_state->wm.skl.plane_ddb[plane_id]; 1505 + 1506 + if (wm->wm[level].min_ddb_alloc > skl_ddb_entry_size(ddb)) { 1507 + drm_WARN_ON(&i915->drm, 1508 + wm->wm[level].min_ddb_alloc != U16_MAX); 1509 + blocks = U32_MAX; 1510 + break; 1511 + } 1512 + continue; 1513 + } 1514 + 1515 + blocks += wm->wm[level].min_ddb_alloc; 1516 + blocks += wm->uv_wm[level].min_ddb_alloc; 1517 + } 1518 + 1519 + if (blocks <= iter.size) { 1520 + iter.size -= blocks; 1521 + break; 1522 + } 1523 + } 1524 + 1525 + if (level < 0) { 1526 + drm_dbg_kms(&i915->drm, 1527 + "Requested display configuration exceeds system DDB limitations"); 1528 + drm_dbg_kms(&i915->drm, "minimum required %d/%d\n", 1529 + blocks, iter.size); 1530 + return -EINVAL; 1531 + } 1532 + 1533 + /* avoid the WARN later when we don't allocate any extra DDB */ 1534 + if (iter.data_rate == 0) 1535 + iter.size = 0; 1536 + 1537 + /* 1538 + * Grant each plane the blocks it requires at the highest achievable 1539 + * watermark level, plus an extra share of the leftover blocks 1540 + * proportional to its relative data rate. 1541 + */ 1542 + for_each_plane_id_on_crtc(crtc, plane_id) { 1543 + struct skl_ddb_entry *ddb = 1544 + &crtc_state->wm.skl.plane_ddb[plane_id]; 1545 + struct skl_ddb_entry *ddb_y = 1546 + &crtc_state->wm.skl.plane_ddb_y[plane_id]; 1547 + const struct skl_plane_wm *wm = 1548 + &crtc_state->wm.skl.optimal.planes[plane_id]; 1549 + 1550 + if (plane_id == PLANE_CURSOR) 1551 + continue; 1552 + 1553 + if (DISPLAY_VER(i915) < 11 && 1554 + crtc_state->nv12_planes & BIT(plane_id)) { 1555 + skl_allocate_plane_ddb(&iter, ddb_y, &wm->wm[level], 1556 + crtc_state->rel_data_rate_y[plane_id]); 1557 + skl_allocate_plane_ddb(&iter, ddb, &wm->uv_wm[level], 1558 + crtc_state->rel_data_rate[plane_id]); 1559 + } else { 1560 + skl_allocate_plane_ddb(&iter, ddb, &wm->wm[level], 1561 + crtc_state->rel_data_rate[plane_id]); 1562 + } 1563 + } 1564 + drm_WARN_ON(&i915->drm, iter.size != 0 || iter.data_rate != 0); 1565 + 1566 + /* 1567 + * When we calculated watermark values we didn't know how high 1568 + * of a level we'd actually be able to hit, so we just marked 1569 + * all levels as "enabled." Go back now and disable the ones 1570 + * that aren't actually possible. 1571 + */ 1572 + for (level++; level <= ilk_wm_max_level(i915); level++) { 1573 + for_each_plane_id_on_crtc(crtc, plane_id) { 1574 + const struct skl_ddb_entry *ddb = 1575 + &crtc_state->wm.skl.plane_ddb[plane_id]; 1576 + const struct skl_ddb_entry *ddb_y = 1577 + &crtc_state->wm.skl.plane_ddb_y[plane_id]; 1578 + struct skl_plane_wm *wm = 1579 + &crtc_state->wm.skl.optimal.planes[plane_id]; 1580 + 1581 + if (DISPLAY_VER(i915) < 11 && 1582 + crtc_state->nv12_planes & BIT(plane_id)) 1583 + skl_check_nv12_wm_level(&wm->wm[level], 1584 + &wm->uv_wm[level], 1585 + ddb_y, ddb); 1586 + else 1587 + skl_check_wm_level(&wm->wm[level], ddb); 1588 + 1589 + if (icl_need_wm1_wa(i915, plane_id) && 1590 + level == 1 && wm->wm[0].enable) { 1591 + wm->wm[level].blocks = wm->wm[0].blocks; 1592 + wm->wm[level].lines = wm->wm[0].lines; 1593 + wm->wm[level].ignore_lines = wm->wm[0].ignore_lines; 1594 + } 1595 + } 1596 + } 1597 + 1598 + /* 1599 + * Go back and disable the transition and SAGV watermarks 1600 + * if it turns out we don't have enough DDB blocks for them. 1601 + */ 1602 + for_each_plane_id_on_crtc(crtc, plane_id) { 1603 + const struct skl_ddb_entry *ddb = 1604 + &crtc_state->wm.skl.plane_ddb[plane_id]; 1605 + const struct skl_ddb_entry *ddb_y = 1606 + &crtc_state->wm.skl.plane_ddb_y[plane_id]; 1607 + struct skl_plane_wm *wm = 1608 + &crtc_state->wm.skl.optimal.planes[plane_id]; 1609 + 1610 + if (DISPLAY_VER(i915) < 11 && 1611 + crtc_state->nv12_planes & BIT(plane_id)) { 1612 + skl_check_wm_level(&wm->trans_wm, ddb_y); 1613 + } else { 1614 + WARN_ON(skl_ddb_entry_size(ddb_y)); 1615 + 1616 + skl_check_wm_level(&wm->trans_wm, ddb); 1617 + } 1618 + 1619 + skl_check_wm_level(&wm->sagv.wm0, ddb); 1620 + skl_check_wm_level(&wm->sagv.trans_wm, ddb); 1621 + } 1622 + 1623 + return 0; 1624 + } 1625 + 1626 + /* 1627 + * The max latency should be 257 (max the punit can code is 255 and we add 2us 1628 + * for the read latency) and cpp should always be <= 8, so that 1629 + * should allow pixel_rate up to ~2 GHz which seems sufficient since max 1630 + * 2xcdclk is 1350 MHz and the pixel rate should never exceed that. 1631 + */ 1632 + static uint_fixed_16_16_t 1633 + skl_wm_method1(const struct drm_i915_private *i915, u32 pixel_rate, 1634 + u8 cpp, u32 latency, u32 dbuf_block_size) 1635 + { 1636 + u32 wm_intermediate_val; 1637 + uint_fixed_16_16_t ret; 1638 + 1639 + if (latency == 0) 1640 + return FP_16_16_MAX; 1641 + 1642 + wm_intermediate_val = latency * pixel_rate * cpp; 1643 + ret = div_fixed16(wm_intermediate_val, 1000 * dbuf_block_size); 1644 + 1645 + if (DISPLAY_VER(i915) >= 10) 1646 + ret = add_fixed16_u32(ret, 1); 1647 + 1648 + return ret; 1649 + } 1650 + 1651 + static uint_fixed_16_16_t 1652 + skl_wm_method2(u32 pixel_rate, u32 pipe_htotal, u32 latency, 1653 + uint_fixed_16_16_t plane_blocks_per_line) 1654 + { 1655 + u32 wm_intermediate_val; 1656 + uint_fixed_16_16_t ret; 1657 + 1658 + if (latency == 0) 1659 + return FP_16_16_MAX; 1660 + 1661 + wm_intermediate_val = latency * pixel_rate; 1662 + wm_intermediate_val = DIV_ROUND_UP(wm_intermediate_val, 1663 + pipe_htotal * 1000); 1664 + ret = mul_u32_fixed16(wm_intermediate_val, plane_blocks_per_line); 1665 + return ret; 1666 + } 1667 + 1668 + static uint_fixed_16_16_t 1669 + intel_get_linetime_us(const struct intel_crtc_state *crtc_state) 1670 + { 1671 + struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); 1672 + u32 pixel_rate; 1673 + u32 crtc_htotal; 1674 + uint_fixed_16_16_t linetime_us; 1675 + 1676 + if (!crtc_state->hw.active) 1677 + return u32_to_fixed16(0); 1678 + 1679 + pixel_rate = crtc_state->pixel_rate; 1680 + 1681 + if (drm_WARN_ON(&i915->drm, pixel_rate == 0)) 1682 + return u32_to_fixed16(0); 1683 + 1684 + crtc_htotal = crtc_state->hw.pipe_mode.crtc_htotal; 1685 + linetime_us = div_fixed16(crtc_htotal * 1000, pixel_rate); 1686 + 1687 + return linetime_us; 1688 + } 1689 + 1690 + static int 1691 + skl_compute_wm_params(const struct intel_crtc_state *crtc_state, 1692 + int width, const struct drm_format_info *format, 1693 + u64 modifier, unsigned int rotation, 1694 + u32 plane_pixel_rate, struct skl_wm_params *wp, 1695 + int color_plane) 1696 + { 1697 + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 1698 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 1699 + u32 interm_pbpl; 1700 + 1701 + /* only planar format has two planes */ 1702 + if (color_plane == 1 && 1703 + !intel_format_info_is_yuv_semiplanar(format, modifier)) { 1704 + drm_dbg_kms(&i915->drm, 1705 + "Non planar format have single plane\n"); 1706 + return -EINVAL; 1707 + } 1708 + 1709 + wp->y_tiled = modifier == I915_FORMAT_MOD_Y_TILED || 1710 + modifier == I915_FORMAT_MOD_4_TILED || 1711 + modifier == I915_FORMAT_MOD_Yf_TILED || 1712 + modifier == I915_FORMAT_MOD_Y_TILED_CCS || 1713 + modifier == I915_FORMAT_MOD_Yf_TILED_CCS; 1714 + wp->x_tiled = modifier == I915_FORMAT_MOD_X_TILED; 1715 + wp->rc_surface = modifier == I915_FORMAT_MOD_Y_TILED_CCS || 1716 + modifier == I915_FORMAT_MOD_Yf_TILED_CCS; 1717 + wp->is_planar = intel_format_info_is_yuv_semiplanar(format, modifier); 1718 + 1719 + wp->width = width; 1720 + if (color_plane == 1 && wp->is_planar) 1721 + wp->width /= 2; 1722 + 1723 + wp->cpp = format->cpp[color_plane]; 1724 + wp->plane_pixel_rate = plane_pixel_rate; 1725 + 1726 + if (DISPLAY_VER(i915) >= 11 && 1727 + modifier == I915_FORMAT_MOD_Yf_TILED && wp->cpp == 1) 1728 + wp->dbuf_block_size = 256; 1729 + else 1730 + wp->dbuf_block_size = 512; 1731 + 1732 + if (drm_rotation_90_or_270(rotation)) { 1733 + switch (wp->cpp) { 1734 + case 1: 1735 + wp->y_min_scanlines = 16; 1736 + break; 1737 + case 2: 1738 + wp->y_min_scanlines = 8; 1739 + break; 1740 + case 4: 1741 + wp->y_min_scanlines = 4; 1742 + break; 1743 + default: 1744 + MISSING_CASE(wp->cpp); 1745 + return -EINVAL; 1746 + } 1747 + } else { 1748 + wp->y_min_scanlines = 4; 1749 + } 1750 + 1751 + if (skl_needs_memory_bw_wa(i915)) 1752 + wp->y_min_scanlines *= 2; 1753 + 1754 + wp->plane_bytes_per_line = wp->width * wp->cpp; 1755 + if (wp->y_tiled) { 1756 + interm_pbpl = DIV_ROUND_UP(wp->plane_bytes_per_line * 1757 + wp->y_min_scanlines, 1758 + wp->dbuf_block_size); 1759 + 1760 + if (DISPLAY_VER(i915) >= 10) 1761 + interm_pbpl++; 1762 + 1763 + wp->plane_blocks_per_line = div_fixed16(interm_pbpl, 1764 + wp->y_min_scanlines); 1765 + } else { 1766 + interm_pbpl = DIV_ROUND_UP(wp->plane_bytes_per_line, 1767 + wp->dbuf_block_size); 1768 + 1769 + if (!wp->x_tiled || DISPLAY_VER(i915) >= 10) 1770 + interm_pbpl++; 1771 + 1772 + wp->plane_blocks_per_line = u32_to_fixed16(interm_pbpl); 1773 + } 1774 + 1775 + wp->y_tile_minimum = mul_u32_fixed16(wp->y_min_scanlines, 1776 + wp->plane_blocks_per_line); 1777 + 1778 + wp->linetime_us = fixed16_to_u32_round_up(intel_get_linetime_us(crtc_state)); 1779 + 1780 + return 0; 1781 + } 1782 + 1783 + static int 1784 + skl_compute_plane_wm_params(const struct intel_crtc_state *crtc_state, 1785 + const struct intel_plane_state *plane_state, 1786 + struct skl_wm_params *wp, int color_plane) 1787 + { 1788 + const struct drm_framebuffer *fb = plane_state->hw.fb; 1789 + int width; 1790 + 1791 + /* 1792 + * Src coordinates are already rotated by 270 degrees for 1793 + * the 90/270 degree plane rotation cases (to match the 1794 + * GTT mapping), hence no need to account for rotation here. 1795 + */ 1796 + width = drm_rect_width(&plane_state->uapi.src) >> 16; 1797 + 1798 + return skl_compute_wm_params(crtc_state, width, 1799 + fb->format, fb->modifier, 1800 + plane_state->hw.rotation, 1801 + intel_plane_pixel_rate(crtc_state, plane_state), 1802 + wp, color_plane); 1803 + } 1804 + 1805 + static bool skl_wm_has_lines(struct drm_i915_private *i915, int level) 1806 + { 1807 + if (DISPLAY_VER(i915) >= 10) 1808 + return true; 1809 + 1810 + /* The number of lines are ignored for the level 0 watermark. */ 1811 + return level > 0; 1812 + } 1813 + 1814 + static int skl_wm_max_lines(struct drm_i915_private *i915) 1815 + { 1816 + if (DISPLAY_VER(i915) >= 13) 1817 + return 255; 1818 + else 1819 + return 31; 1820 + } 1821 + 1822 + static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state, 1823 + struct intel_plane *plane, 1824 + int level, 1825 + unsigned int latency, 1826 + const struct skl_wm_params *wp, 1827 + const struct skl_wm_level *result_prev, 1828 + struct skl_wm_level *result /* out */) 1829 + { 1830 + struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); 1831 + uint_fixed_16_16_t method1, method2; 1832 + uint_fixed_16_16_t selected_result; 1833 + u32 blocks, lines, min_ddb_alloc = 0; 1834 + 1835 + if (latency == 0 || 1836 + (use_minimal_wm0_only(crtc_state, plane) && level > 0)) { 1837 + /* reject it */ 1838 + result->min_ddb_alloc = U16_MAX; 1839 + return; 1840 + } 1841 + 1842 + /* 1843 + * WaIncreaseLatencyIPCEnabled: kbl,cfl 1844 + * Display WA #1141: kbl,cfl 1845 + */ 1846 + if ((IS_KABYLAKE(i915) || IS_COFFEELAKE(i915) || IS_COMETLAKE(i915)) && 1847 + skl_watermark_ipc_enabled(i915)) 1848 + latency += 4; 1849 + 1850 + if (skl_needs_memory_bw_wa(i915) && wp->x_tiled) 1851 + latency += 15; 1852 + 1853 + method1 = skl_wm_method1(i915, wp->plane_pixel_rate, 1854 + wp->cpp, latency, wp->dbuf_block_size); 1855 + method2 = skl_wm_method2(wp->plane_pixel_rate, 1856 + crtc_state->hw.pipe_mode.crtc_htotal, 1857 + latency, 1858 + wp->plane_blocks_per_line); 1859 + 1860 + if (wp->y_tiled) { 1861 + selected_result = max_fixed16(method2, wp->y_tile_minimum); 1862 + } else { 1863 + if ((wp->cpp * crtc_state->hw.pipe_mode.crtc_htotal / 1864 + wp->dbuf_block_size < 1) && 1865 + (wp->plane_bytes_per_line / wp->dbuf_block_size < 1)) { 1866 + selected_result = method2; 1867 + } else if (latency >= wp->linetime_us) { 1868 + if (DISPLAY_VER(i915) == 9) 1869 + selected_result = min_fixed16(method1, method2); 1870 + else 1871 + selected_result = method2; 1872 + } else { 1873 + selected_result = method1; 1874 + } 1875 + } 1876 + 1877 + blocks = fixed16_to_u32_round_up(selected_result) + 1; 1878 + /* 1879 + * Lets have blocks at minimum equivalent to plane_blocks_per_line 1880 + * as there will be at minimum one line for lines configuration. This 1881 + * is a work around for FIFO underruns observed with resolutions like 1882 + * 4k 60 Hz in single channel DRAM configurations. 1883 + * 1884 + * As per the Bspec 49325, if the ddb allocation can hold at least 1885 + * one plane_blocks_per_line, we should have selected method2 in 1886 + * the above logic. Assuming that modern versions have enough dbuf 1887 + * and method2 guarantees blocks equivalent to at least 1 line, 1888 + * select the blocks as plane_blocks_per_line. 1889 + * 1890 + * TODO: Revisit the logic when we have better understanding on DRAM 1891 + * channels' impact on the level 0 memory latency and the relevant 1892 + * wm calculations. 1893 + */ 1894 + if (skl_wm_has_lines(i915, level)) 1895 + blocks = max(blocks, 1896 + fixed16_to_u32_round_up(wp->plane_blocks_per_line)); 1897 + lines = div_round_up_fixed16(selected_result, 1898 + wp->plane_blocks_per_line); 1899 + 1900 + if (DISPLAY_VER(i915) == 9) { 1901 + /* Display WA #1125: skl,bxt,kbl */ 1902 + if (level == 0 && wp->rc_surface) 1903 + blocks += fixed16_to_u32_round_up(wp->y_tile_minimum); 1904 + 1905 + /* Display WA #1126: skl,bxt,kbl */ 1906 + if (level >= 1 && level <= 7) { 1907 + if (wp->y_tiled) { 1908 + blocks += fixed16_to_u32_round_up(wp->y_tile_minimum); 1909 + lines += wp->y_min_scanlines; 1910 + } else { 1911 + blocks++; 1912 + } 1913 + 1914 + /* 1915 + * Make sure result blocks for higher latency levels are 1916 + * at least as high as level below the current level. 1917 + * Assumption in DDB algorithm optimization for special 1918 + * cases. Also covers Display WA #1125 for RC. 1919 + */ 1920 + if (result_prev->blocks > blocks) 1921 + blocks = result_prev->blocks; 1922 + } 1923 + } 1924 + 1925 + if (DISPLAY_VER(i915) >= 11) { 1926 + if (wp->y_tiled) { 1927 + int extra_lines; 1928 + 1929 + if (lines % wp->y_min_scanlines == 0) 1930 + extra_lines = wp->y_min_scanlines; 1931 + else 1932 + extra_lines = wp->y_min_scanlines * 2 - 1933 + lines % wp->y_min_scanlines; 1934 + 1935 + min_ddb_alloc = mul_round_up_u32_fixed16(lines + extra_lines, 1936 + wp->plane_blocks_per_line); 1937 + } else { 1938 + min_ddb_alloc = blocks + DIV_ROUND_UP(blocks, 10); 1939 + } 1940 + } 1941 + 1942 + if (!skl_wm_has_lines(i915, level)) 1943 + lines = 0; 1944 + 1945 + if (lines > skl_wm_max_lines(i915)) { 1946 + /* reject it */ 1947 + result->min_ddb_alloc = U16_MAX; 1948 + return; 1949 + } 1950 + 1951 + /* 1952 + * If lines is valid, assume we can use this watermark level 1953 + * for now. We'll come back and disable it after we calculate the 1954 + * DDB allocation if it turns out we don't actually have enough 1955 + * blocks to satisfy it. 1956 + */ 1957 + result->blocks = blocks; 1958 + result->lines = lines; 1959 + /* Bspec says: value >= plane ddb allocation -> invalid, hence the +1 here */ 1960 + result->min_ddb_alloc = max(min_ddb_alloc, blocks) + 1; 1961 + result->enable = true; 1962 + 1963 + if (DISPLAY_VER(i915) < 12 && i915->display.sagv.block_time_us) 1964 + result->can_sagv = latency >= i915->display.sagv.block_time_us; 1965 + } 1966 + 1967 + static void 1968 + skl_compute_wm_levels(const struct intel_crtc_state *crtc_state, 1969 + struct intel_plane *plane, 1970 + const struct skl_wm_params *wm_params, 1971 + struct skl_wm_level *levels) 1972 + { 1973 + struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); 1974 + int level, max_level = ilk_wm_max_level(i915); 1975 + struct skl_wm_level *result_prev = &levels[0]; 1976 + 1977 + for (level = 0; level <= max_level; level++) { 1978 + struct skl_wm_level *result = &levels[level]; 1979 + unsigned int latency = i915->display.wm.skl_latency[level]; 1980 + 1981 + skl_compute_plane_wm(crtc_state, plane, level, latency, 1982 + wm_params, result_prev, result); 1983 + 1984 + result_prev = result; 1985 + } 1986 + } 1987 + 1988 + static void tgl_compute_sagv_wm(const struct intel_crtc_state *crtc_state, 1989 + struct intel_plane *plane, 1990 + const struct skl_wm_params *wm_params, 1991 + struct skl_plane_wm *plane_wm) 1992 + { 1993 + struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); 1994 + struct skl_wm_level *sagv_wm = &plane_wm->sagv.wm0; 1995 + struct skl_wm_level *levels = plane_wm->wm; 1996 + unsigned int latency = 0; 1997 + 1998 + if (i915->display.sagv.block_time_us) 1999 + latency = i915->display.sagv.block_time_us + i915->display.wm.skl_latency[0]; 2000 + 2001 + skl_compute_plane_wm(crtc_state, plane, 0, latency, 2002 + wm_params, &levels[0], 2003 + sagv_wm); 2004 + } 2005 + 2006 + static void skl_compute_transition_wm(struct drm_i915_private *i915, 2007 + struct skl_wm_level *trans_wm, 2008 + const struct skl_wm_level *wm0, 2009 + const struct skl_wm_params *wp) 2010 + { 2011 + u16 trans_min, trans_amount, trans_y_tile_min; 2012 + u16 wm0_blocks, trans_offset, blocks; 2013 + 2014 + /* Transition WM don't make any sense if ipc is disabled */ 2015 + if (!skl_watermark_ipc_enabled(i915)) 2016 + return; 2017 + 2018 + /* 2019 + * WaDisableTWM:skl,kbl,cfl,bxt 2020 + * Transition WM are not recommended by HW team for GEN9 2021 + */ 2022 + if (DISPLAY_VER(i915) == 9) 2023 + return; 2024 + 2025 + if (DISPLAY_VER(i915) >= 11) 2026 + trans_min = 4; 2027 + else 2028 + trans_min = 14; 2029 + 2030 + /* Display WA #1140: glk,cnl */ 2031 + if (DISPLAY_VER(i915) == 10) 2032 + trans_amount = 0; 2033 + else 2034 + trans_amount = 10; /* This is configurable amount */ 2035 + 2036 + trans_offset = trans_min + trans_amount; 2037 + 2038 + /* 2039 + * The spec asks for Selected Result Blocks for wm0 (the real value), 2040 + * not Result Blocks (the integer value). Pay attention to the capital 2041 + * letters. The value wm_l0->blocks is actually Result Blocks, but 2042 + * since Result Blocks is the ceiling of Selected Result Blocks plus 1, 2043 + * and since we later will have to get the ceiling of the sum in the 2044 + * transition watermarks calculation, we can just pretend Selected 2045 + * Result Blocks is Result Blocks minus 1 and it should work for the 2046 + * current platforms. 2047 + */ 2048 + wm0_blocks = wm0->blocks - 1; 2049 + 2050 + if (wp->y_tiled) { 2051 + trans_y_tile_min = 2052 + (u16)mul_round_up_u32_fixed16(2, wp->y_tile_minimum); 2053 + blocks = max(wm0_blocks, trans_y_tile_min) + trans_offset; 2054 + } else { 2055 + blocks = wm0_blocks + trans_offset; 2056 + } 2057 + blocks++; 2058 + 2059 + /* 2060 + * Just assume we can enable the transition watermark. After 2061 + * computing the DDB we'll come back and disable it if that 2062 + * assumption turns out to be false. 2063 + */ 2064 + trans_wm->blocks = blocks; 2065 + trans_wm->min_ddb_alloc = max_t(u16, wm0->min_ddb_alloc, blocks + 1); 2066 + trans_wm->enable = true; 2067 + } 2068 + 2069 + static int skl_build_plane_wm_single(struct intel_crtc_state *crtc_state, 2070 + const struct intel_plane_state *plane_state, 2071 + struct intel_plane *plane, int color_plane) 2072 + { 2073 + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 2074 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 2075 + struct skl_plane_wm *wm = &crtc_state->wm.skl.raw.planes[plane->id]; 2076 + struct skl_wm_params wm_params; 2077 + int ret; 2078 + 2079 + ret = skl_compute_plane_wm_params(crtc_state, plane_state, 2080 + &wm_params, color_plane); 2081 + if (ret) 2082 + return ret; 2083 + 2084 + skl_compute_wm_levels(crtc_state, plane, &wm_params, wm->wm); 2085 + 2086 + skl_compute_transition_wm(i915, &wm->trans_wm, 2087 + &wm->wm[0], &wm_params); 2088 + 2089 + if (DISPLAY_VER(i915) >= 12) { 2090 + tgl_compute_sagv_wm(crtc_state, plane, &wm_params, wm); 2091 + 2092 + skl_compute_transition_wm(i915, &wm->sagv.trans_wm, 2093 + &wm->sagv.wm0, &wm_params); 2094 + } 2095 + 2096 + return 0; 2097 + } 2098 + 2099 + static int skl_build_plane_wm_uv(struct intel_crtc_state *crtc_state, 2100 + const struct intel_plane_state *plane_state, 2101 + struct intel_plane *plane) 2102 + { 2103 + struct skl_plane_wm *wm = &crtc_state->wm.skl.raw.planes[plane->id]; 2104 + struct skl_wm_params wm_params; 2105 + int ret; 2106 + 2107 + wm->is_planar = true; 2108 + 2109 + /* uv plane watermarks must also be validated for NV12/Planar */ 2110 + ret = skl_compute_plane_wm_params(crtc_state, plane_state, 2111 + &wm_params, 1); 2112 + if (ret) 2113 + return ret; 2114 + 2115 + skl_compute_wm_levels(crtc_state, plane, &wm_params, wm->uv_wm); 2116 + 2117 + return 0; 2118 + } 2119 + 2120 + static int skl_build_plane_wm(struct intel_crtc_state *crtc_state, 2121 + const struct intel_plane_state *plane_state) 2122 + { 2123 + struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 2124 + enum plane_id plane_id = plane->id; 2125 + struct skl_plane_wm *wm = &crtc_state->wm.skl.raw.planes[plane_id]; 2126 + const struct drm_framebuffer *fb = plane_state->hw.fb; 2127 + int ret; 2128 + 2129 + memset(wm, 0, sizeof(*wm)); 2130 + 2131 + if (!intel_wm_plane_visible(crtc_state, plane_state)) 2132 + return 0; 2133 + 2134 + ret = skl_build_plane_wm_single(crtc_state, plane_state, 2135 + plane, 0); 2136 + if (ret) 2137 + return ret; 2138 + 2139 + if (fb->format->is_yuv && fb->format->num_planes > 1) { 2140 + ret = skl_build_plane_wm_uv(crtc_state, plane_state, 2141 + plane); 2142 + if (ret) 2143 + return ret; 2144 + } 2145 + 2146 + return 0; 2147 + } 2148 + 2149 + static int icl_build_plane_wm(struct intel_crtc_state *crtc_state, 2150 + const struct intel_plane_state *plane_state) 2151 + { 2152 + struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 2153 + struct drm_i915_private *i915 = to_i915(plane->base.dev); 2154 + enum plane_id plane_id = plane->id; 2155 + struct skl_plane_wm *wm = &crtc_state->wm.skl.raw.planes[plane_id]; 2156 + int ret; 2157 + 2158 + /* Watermarks calculated in master */ 2159 + if (plane_state->planar_slave) 2160 + return 0; 2161 + 2162 + memset(wm, 0, sizeof(*wm)); 2163 + 2164 + if (plane_state->planar_linked_plane) { 2165 + const struct drm_framebuffer *fb = plane_state->hw.fb; 2166 + 2167 + drm_WARN_ON(&i915->drm, 2168 + !intel_wm_plane_visible(crtc_state, plane_state)); 2169 + drm_WARN_ON(&i915->drm, !fb->format->is_yuv || 2170 + fb->format->num_planes == 1); 2171 + 2172 + ret = skl_build_plane_wm_single(crtc_state, plane_state, 2173 + plane_state->planar_linked_plane, 0); 2174 + if (ret) 2175 + return ret; 2176 + 2177 + ret = skl_build_plane_wm_single(crtc_state, plane_state, 2178 + plane, 1); 2179 + if (ret) 2180 + return ret; 2181 + } else if (intel_wm_plane_visible(crtc_state, plane_state)) { 2182 + ret = skl_build_plane_wm_single(crtc_state, plane_state, 2183 + plane, 0); 2184 + if (ret) 2185 + return ret; 2186 + } 2187 + 2188 + return 0; 2189 + } 2190 + 2191 + static int skl_build_pipe_wm(struct intel_atomic_state *state, 2192 + struct intel_crtc *crtc) 2193 + { 2194 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 2195 + struct intel_crtc_state *crtc_state = 2196 + intel_atomic_get_new_crtc_state(state, crtc); 2197 + const struct intel_plane_state *plane_state; 2198 + struct intel_plane *plane; 2199 + int ret, i; 2200 + 2201 + for_each_new_intel_plane_in_state(state, plane, plane_state, i) { 2202 + /* 2203 + * FIXME should perhaps check {old,new}_plane_crtc->hw.crtc 2204 + * instead but we don't populate that correctly for NV12 Y 2205 + * planes so for now hack this. 2206 + */ 2207 + if (plane->pipe != crtc->pipe) 2208 + continue; 2209 + 2210 + if (DISPLAY_VER(i915) >= 11) 2211 + ret = icl_build_plane_wm(crtc_state, plane_state); 2212 + else 2213 + ret = skl_build_plane_wm(crtc_state, plane_state); 2214 + if (ret) 2215 + return ret; 2216 + } 2217 + 2218 + crtc_state->wm.skl.optimal = crtc_state->wm.skl.raw; 2219 + 2220 + return 0; 2221 + } 2222 + 2223 + static void skl_ddb_entry_write(struct drm_i915_private *i915, 2224 + i915_reg_t reg, 2225 + const struct skl_ddb_entry *entry) 2226 + { 2227 + if (entry->end) 2228 + intel_de_write_fw(i915, reg, 2229 + PLANE_BUF_END(entry->end - 1) | 2230 + PLANE_BUF_START(entry->start)); 2231 + else 2232 + intel_de_write_fw(i915, reg, 0); 2233 + } 2234 + 2235 + static void skl_write_wm_level(struct drm_i915_private *i915, 2236 + i915_reg_t reg, 2237 + const struct skl_wm_level *level) 2238 + { 2239 + u32 val = 0; 2240 + 2241 + if (level->enable) 2242 + val |= PLANE_WM_EN; 2243 + if (level->ignore_lines) 2244 + val |= PLANE_WM_IGNORE_LINES; 2245 + val |= REG_FIELD_PREP(PLANE_WM_BLOCKS_MASK, level->blocks); 2246 + val |= REG_FIELD_PREP(PLANE_WM_LINES_MASK, level->lines); 2247 + 2248 + intel_de_write_fw(i915, reg, val); 2249 + } 2250 + 2251 + void skl_write_plane_wm(struct intel_plane *plane, 2252 + const struct intel_crtc_state *crtc_state) 2253 + { 2254 + struct drm_i915_private *i915 = to_i915(plane->base.dev); 2255 + int level, max_level = ilk_wm_max_level(i915); 2256 + enum plane_id plane_id = plane->id; 2257 + enum pipe pipe = plane->pipe; 2258 + const struct skl_pipe_wm *pipe_wm = &crtc_state->wm.skl.optimal; 2259 + const struct skl_ddb_entry *ddb = 2260 + &crtc_state->wm.skl.plane_ddb[plane_id]; 2261 + const struct skl_ddb_entry *ddb_y = 2262 + &crtc_state->wm.skl.plane_ddb_y[plane_id]; 2263 + 2264 + for (level = 0; level <= max_level; level++) 2265 + skl_write_wm_level(i915, PLANE_WM(pipe, plane_id, level), 2266 + skl_plane_wm_level(pipe_wm, plane_id, level)); 2267 + 2268 + skl_write_wm_level(i915, PLANE_WM_TRANS(pipe, plane_id), 2269 + skl_plane_trans_wm(pipe_wm, plane_id)); 2270 + 2271 + if (HAS_HW_SAGV_WM(i915)) { 2272 + const struct skl_plane_wm *wm = &pipe_wm->planes[plane_id]; 2273 + 2274 + skl_write_wm_level(i915, PLANE_WM_SAGV(pipe, plane_id), 2275 + &wm->sagv.wm0); 2276 + skl_write_wm_level(i915, PLANE_WM_SAGV_TRANS(pipe, plane_id), 2277 + &wm->sagv.trans_wm); 2278 + } 2279 + 2280 + skl_ddb_entry_write(i915, 2281 + PLANE_BUF_CFG(pipe, plane_id), ddb); 2282 + 2283 + if (DISPLAY_VER(i915) < 11) 2284 + skl_ddb_entry_write(i915, 2285 + PLANE_NV12_BUF_CFG(pipe, plane_id), ddb_y); 2286 + } 2287 + 2288 + void skl_write_cursor_wm(struct intel_plane *plane, 2289 + const struct intel_crtc_state *crtc_state) 2290 + { 2291 + struct drm_i915_private *i915 = to_i915(plane->base.dev); 2292 + int level, max_level = ilk_wm_max_level(i915); 2293 + enum plane_id plane_id = plane->id; 2294 + enum pipe pipe = plane->pipe; 2295 + const struct skl_pipe_wm *pipe_wm = &crtc_state->wm.skl.optimal; 2296 + const struct skl_ddb_entry *ddb = 2297 + &crtc_state->wm.skl.plane_ddb[plane_id]; 2298 + 2299 + for (level = 0; level <= max_level; level++) 2300 + skl_write_wm_level(i915, CUR_WM(pipe, level), 2301 + skl_plane_wm_level(pipe_wm, plane_id, level)); 2302 + 2303 + skl_write_wm_level(i915, CUR_WM_TRANS(pipe), 2304 + skl_plane_trans_wm(pipe_wm, plane_id)); 2305 + 2306 + if (HAS_HW_SAGV_WM(i915)) { 2307 + const struct skl_plane_wm *wm = &pipe_wm->planes[plane_id]; 2308 + 2309 + skl_write_wm_level(i915, CUR_WM_SAGV(pipe), 2310 + &wm->sagv.wm0); 2311 + skl_write_wm_level(i915, CUR_WM_SAGV_TRANS(pipe), 2312 + &wm->sagv.trans_wm); 2313 + } 2314 + 2315 + skl_ddb_entry_write(i915, CUR_BUF_CFG(pipe), ddb); 2316 + } 2317 + 2318 + static bool skl_wm_level_equals(const struct skl_wm_level *l1, 2319 + const struct skl_wm_level *l2) 2320 + { 2321 + return l1->enable == l2->enable && 2322 + l1->ignore_lines == l2->ignore_lines && 2323 + l1->lines == l2->lines && 2324 + l1->blocks == l2->blocks; 2325 + } 2326 + 2327 + static bool skl_plane_wm_equals(struct drm_i915_private *i915, 2328 + const struct skl_plane_wm *wm1, 2329 + const struct skl_plane_wm *wm2) 2330 + { 2331 + int level, max_level = ilk_wm_max_level(i915); 2332 + 2333 + for (level = 0; level <= max_level; level++) { 2334 + /* 2335 + * We don't check uv_wm as the hardware doesn't actually 2336 + * use it. It only gets used for calculating the required 2337 + * ddb allocation. 2338 + */ 2339 + if (!skl_wm_level_equals(&wm1->wm[level], &wm2->wm[level])) 2340 + return false; 2341 + } 2342 + 2343 + return skl_wm_level_equals(&wm1->trans_wm, &wm2->trans_wm) && 2344 + skl_wm_level_equals(&wm1->sagv.wm0, &wm2->sagv.wm0) && 2345 + skl_wm_level_equals(&wm1->sagv.trans_wm, &wm2->sagv.trans_wm); 2346 + } 2347 + 2348 + static bool skl_ddb_entries_overlap(const struct skl_ddb_entry *a, 2349 + const struct skl_ddb_entry *b) 2350 + { 2351 + return a->start < b->end && b->start < a->end; 2352 + } 2353 + 2354 + static void skl_ddb_entry_union(struct skl_ddb_entry *a, 2355 + const struct skl_ddb_entry *b) 2356 + { 2357 + if (a->end && b->end) { 2358 + a->start = min(a->start, b->start); 2359 + a->end = max(a->end, b->end); 2360 + } else if (b->end) { 2361 + a->start = b->start; 2362 + a->end = b->end; 2363 + } 2364 + } 2365 + 2366 + bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry *ddb, 2367 + const struct skl_ddb_entry *entries, 2368 + int num_entries, int ignore_idx) 2369 + { 2370 + int i; 2371 + 2372 + for (i = 0; i < num_entries; i++) { 2373 + if (i != ignore_idx && 2374 + skl_ddb_entries_overlap(ddb, &entries[i])) 2375 + return true; 2376 + } 2377 + 2378 + return false; 2379 + } 2380 + 2381 + static int 2382 + skl_ddb_add_affected_planes(const struct intel_crtc_state *old_crtc_state, 2383 + struct intel_crtc_state *new_crtc_state) 2384 + { 2385 + struct intel_atomic_state *state = to_intel_atomic_state(new_crtc_state->uapi.state); 2386 + struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->uapi.crtc); 2387 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 2388 + struct intel_plane *plane; 2389 + 2390 + for_each_intel_plane_on_crtc(&i915->drm, crtc, plane) { 2391 + struct intel_plane_state *plane_state; 2392 + enum plane_id plane_id = plane->id; 2393 + 2394 + if (skl_ddb_entry_equal(&old_crtc_state->wm.skl.plane_ddb[plane_id], 2395 + &new_crtc_state->wm.skl.plane_ddb[plane_id]) && 2396 + skl_ddb_entry_equal(&old_crtc_state->wm.skl.plane_ddb_y[plane_id], 2397 + &new_crtc_state->wm.skl.plane_ddb_y[plane_id])) 2398 + continue; 2399 + 2400 + plane_state = intel_atomic_get_plane_state(state, plane); 2401 + if (IS_ERR(plane_state)) 2402 + return PTR_ERR(plane_state); 2403 + 2404 + new_crtc_state->update_planes |= BIT(plane_id); 2405 + } 2406 + 2407 + return 0; 2408 + } 2409 + 2410 + static u8 intel_dbuf_enabled_slices(const struct intel_dbuf_state *dbuf_state) 2411 + { 2412 + struct drm_i915_private *i915 = to_i915(dbuf_state->base.state->base.dev); 2413 + u8 enabled_slices; 2414 + enum pipe pipe; 2415 + 2416 + /* 2417 + * FIXME: For now we always enable slice S1 as per 2418 + * the Bspec display initialization sequence. 2419 + */ 2420 + enabled_slices = BIT(DBUF_S1); 2421 + 2422 + for_each_pipe(i915, pipe) 2423 + enabled_slices |= dbuf_state->slices[pipe]; 2424 + 2425 + return enabled_slices; 2426 + } 2427 + 2428 + static int 2429 + skl_compute_ddb(struct intel_atomic_state *state) 2430 + { 2431 + struct drm_i915_private *i915 = to_i915(state->base.dev); 2432 + const struct intel_dbuf_state *old_dbuf_state; 2433 + struct intel_dbuf_state *new_dbuf_state = NULL; 2434 + const struct intel_crtc_state *old_crtc_state; 2435 + struct intel_crtc_state *new_crtc_state; 2436 + struct intel_crtc *crtc; 2437 + int ret, i; 2438 + 2439 + for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 2440 + new_dbuf_state = intel_atomic_get_dbuf_state(state); 2441 + if (IS_ERR(new_dbuf_state)) 2442 + return PTR_ERR(new_dbuf_state); 2443 + 2444 + old_dbuf_state = intel_atomic_get_old_dbuf_state(state); 2445 + break; 2446 + } 2447 + 2448 + if (!new_dbuf_state) 2449 + return 0; 2450 + 2451 + new_dbuf_state->active_pipes = 2452 + intel_calc_active_pipes(state, old_dbuf_state->active_pipes); 2453 + 2454 + if (old_dbuf_state->active_pipes != new_dbuf_state->active_pipes) { 2455 + ret = intel_atomic_lock_global_state(&new_dbuf_state->base); 2456 + if (ret) 2457 + return ret; 2458 + } 2459 + 2460 + if (HAS_MBUS_JOINING(i915)) 2461 + new_dbuf_state->joined_mbus = 2462 + adlp_check_mbus_joined(new_dbuf_state->active_pipes); 2463 + 2464 + for_each_intel_crtc(&i915->drm, crtc) { 2465 + enum pipe pipe = crtc->pipe; 2466 + 2467 + new_dbuf_state->slices[pipe] = 2468 + skl_compute_dbuf_slices(crtc, new_dbuf_state->active_pipes, 2469 + new_dbuf_state->joined_mbus); 2470 + 2471 + if (old_dbuf_state->slices[pipe] == new_dbuf_state->slices[pipe]) 2472 + continue; 2473 + 2474 + ret = intel_atomic_lock_global_state(&new_dbuf_state->base); 2475 + if (ret) 2476 + return ret; 2477 + } 2478 + 2479 + new_dbuf_state->enabled_slices = intel_dbuf_enabled_slices(new_dbuf_state); 2480 + 2481 + if (old_dbuf_state->enabled_slices != new_dbuf_state->enabled_slices || 2482 + old_dbuf_state->joined_mbus != new_dbuf_state->joined_mbus) { 2483 + ret = intel_atomic_serialize_global_state(&new_dbuf_state->base); 2484 + if (ret) 2485 + return ret; 2486 + 2487 + if (old_dbuf_state->joined_mbus != new_dbuf_state->joined_mbus) { 2488 + /* TODO: Implement vblank synchronized MBUS joining changes */ 2489 + ret = intel_modeset_all_pipes(state); 2490 + if (ret) 2491 + return ret; 2492 + } 2493 + 2494 + drm_dbg_kms(&i915->drm, 2495 + "Enabled dbuf slices 0x%x -> 0x%x (total dbuf slices 0x%x), mbus joined? %s->%s\n", 2496 + old_dbuf_state->enabled_slices, 2497 + new_dbuf_state->enabled_slices, 2498 + INTEL_INFO(i915)->display.dbuf.slice_mask, 2499 + str_yes_no(old_dbuf_state->joined_mbus), 2500 + str_yes_no(new_dbuf_state->joined_mbus)); 2501 + } 2502 + 2503 + for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 2504 + enum pipe pipe = crtc->pipe; 2505 + 2506 + new_dbuf_state->weight[pipe] = intel_crtc_ddb_weight(new_crtc_state); 2507 + 2508 + if (old_dbuf_state->weight[pipe] == new_dbuf_state->weight[pipe]) 2509 + continue; 2510 + 2511 + ret = intel_atomic_lock_global_state(&new_dbuf_state->base); 2512 + if (ret) 2513 + return ret; 2514 + } 2515 + 2516 + for_each_intel_crtc(&i915->drm, crtc) { 2517 + ret = skl_crtc_allocate_ddb(state, crtc); 2518 + if (ret) 2519 + return ret; 2520 + } 2521 + 2522 + for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, 2523 + new_crtc_state, i) { 2524 + ret = skl_crtc_allocate_plane_ddb(state, crtc); 2525 + if (ret) 2526 + return ret; 2527 + 2528 + ret = skl_ddb_add_affected_planes(old_crtc_state, 2529 + new_crtc_state); 2530 + if (ret) 2531 + return ret; 2532 + } 2533 + 2534 + return 0; 2535 + } 2536 + 2537 + static char enast(bool enable) 2538 + { 2539 + return enable ? '*' : ' '; 2540 + } 2541 + 2542 + static void 2543 + skl_print_wm_changes(struct intel_atomic_state *state) 2544 + { 2545 + struct drm_i915_private *i915 = to_i915(state->base.dev); 2546 + const struct intel_crtc_state *old_crtc_state; 2547 + const struct intel_crtc_state *new_crtc_state; 2548 + struct intel_plane *plane; 2549 + struct intel_crtc *crtc; 2550 + int i; 2551 + 2552 + if (!drm_debug_enabled(DRM_UT_KMS)) 2553 + return; 2554 + 2555 + for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, 2556 + new_crtc_state, i) { 2557 + const struct skl_pipe_wm *old_pipe_wm, *new_pipe_wm; 2558 + 2559 + old_pipe_wm = &old_crtc_state->wm.skl.optimal; 2560 + new_pipe_wm = &new_crtc_state->wm.skl.optimal; 2561 + 2562 + for_each_intel_plane_on_crtc(&i915->drm, crtc, plane) { 2563 + enum plane_id plane_id = plane->id; 2564 + const struct skl_ddb_entry *old, *new; 2565 + 2566 + old = &old_crtc_state->wm.skl.plane_ddb[plane_id]; 2567 + new = &new_crtc_state->wm.skl.plane_ddb[plane_id]; 2568 + 2569 + if (skl_ddb_entry_equal(old, new)) 2570 + continue; 2571 + 2572 + drm_dbg_kms(&i915->drm, 2573 + "[PLANE:%d:%s] ddb (%4d - %4d) -> (%4d - %4d), size %4d -> %4d\n", 2574 + plane->base.base.id, plane->base.name, 2575 + old->start, old->end, new->start, new->end, 2576 + skl_ddb_entry_size(old), skl_ddb_entry_size(new)); 2577 + } 2578 + 2579 + for_each_intel_plane_on_crtc(&i915->drm, crtc, plane) { 2580 + enum plane_id plane_id = plane->id; 2581 + const struct skl_plane_wm *old_wm, *new_wm; 2582 + 2583 + old_wm = &old_pipe_wm->planes[plane_id]; 2584 + new_wm = &new_pipe_wm->planes[plane_id]; 2585 + 2586 + if (skl_plane_wm_equals(i915, old_wm, new_wm)) 2587 + continue; 2588 + 2589 + drm_dbg_kms(&i915->drm, 2590 + "[PLANE:%d:%s] level %cwm0,%cwm1,%cwm2,%cwm3,%cwm4,%cwm5,%cwm6,%cwm7,%ctwm,%cswm,%cstwm" 2591 + " -> %cwm0,%cwm1,%cwm2,%cwm3,%cwm4,%cwm5,%cwm6,%cwm7,%ctwm,%cswm,%cstwm\n", 2592 + plane->base.base.id, plane->base.name, 2593 + enast(old_wm->wm[0].enable), enast(old_wm->wm[1].enable), 2594 + enast(old_wm->wm[2].enable), enast(old_wm->wm[3].enable), 2595 + enast(old_wm->wm[4].enable), enast(old_wm->wm[5].enable), 2596 + enast(old_wm->wm[6].enable), enast(old_wm->wm[7].enable), 2597 + enast(old_wm->trans_wm.enable), 2598 + enast(old_wm->sagv.wm0.enable), 2599 + enast(old_wm->sagv.trans_wm.enable), 2600 + enast(new_wm->wm[0].enable), enast(new_wm->wm[1].enable), 2601 + enast(new_wm->wm[2].enable), enast(new_wm->wm[3].enable), 2602 + enast(new_wm->wm[4].enable), enast(new_wm->wm[5].enable), 2603 + enast(new_wm->wm[6].enable), enast(new_wm->wm[7].enable), 2604 + enast(new_wm->trans_wm.enable), 2605 + enast(new_wm->sagv.wm0.enable), 2606 + enast(new_wm->sagv.trans_wm.enable)); 2607 + 2608 + drm_dbg_kms(&i915->drm, 2609 + "[PLANE:%d:%s] lines %c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%4d" 2610 + " -> %c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%4d\n", 2611 + plane->base.base.id, plane->base.name, 2612 + enast(old_wm->wm[0].ignore_lines), old_wm->wm[0].lines, 2613 + enast(old_wm->wm[1].ignore_lines), old_wm->wm[1].lines, 2614 + enast(old_wm->wm[2].ignore_lines), old_wm->wm[2].lines, 2615 + enast(old_wm->wm[3].ignore_lines), old_wm->wm[3].lines, 2616 + enast(old_wm->wm[4].ignore_lines), old_wm->wm[4].lines, 2617 + enast(old_wm->wm[5].ignore_lines), old_wm->wm[5].lines, 2618 + enast(old_wm->wm[6].ignore_lines), old_wm->wm[6].lines, 2619 + enast(old_wm->wm[7].ignore_lines), old_wm->wm[7].lines, 2620 + enast(old_wm->trans_wm.ignore_lines), old_wm->trans_wm.lines, 2621 + enast(old_wm->sagv.wm0.ignore_lines), old_wm->sagv.wm0.lines, 2622 + enast(old_wm->sagv.trans_wm.ignore_lines), old_wm->sagv.trans_wm.lines, 2623 + enast(new_wm->wm[0].ignore_lines), new_wm->wm[0].lines, 2624 + enast(new_wm->wm[1].ignore_lines), new_wm->wm[1].lines, 2625 + enast(new_wm->wm[2].ignore_lines), new_wm->wm[2].lines, 2626 + enast(new_wm->wm[3].ignore_lines), new_wm->wm[3].lines, 2627 + enast(new_wm->wm[4].ignore_lines), new_wm->wm[4].lines, 2628 + enast(new_wm->wm[5].ignore_lines), new_wm->wm[5].lines, 2629 + enast(new_wm->wm[6].ignore_lines), new_wm->wm[6].lines, 2630 + enast(new_wm->wm[7].ignore_lines), new_wm->wm[7].lines, 2631 + enast(new_wm->trans_wm.ignore_lines), new_wm->trans_wm.lines, 2632 + enast(new_wm->sagv.wm0.ignore_lines), new_wm->sagv.wm0.lines, 2633 + enast(new_wm->sagv.trans_wm.ignore_lines), new_wm->sagv.trans_wm.lines); 2634 + 2635 + drm_dbg_kms(&i915->drm, 2636 + "[PLANE:%d:%s] blocks %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%5d" 2637 + " -> %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%5d\n", 2638 + plane->base.base.id, plane->base.name, 2639 + old_wm->wm[0].blocks, old_wm->wm[1].blocks, 2640 + old_wm->wm[2].blocks, old_wm->wm[3].blocks, 2641 + old_wm->wm[4].blocks, old_wm->wm[5].blocks, 2642 + old_wm->wm[6].blocks, old_wm->wm[7].blocks, 2643 + old_wm->trans_wm.blocks, 2644 + old_wm->sagv.wm0.blocks, 2645 + old_wm->sagv.trans_wm.blocks, 2646 + new_wm->wm[0].blocks, new_wm->wm[1].blocks, 2647 + new_wm->wm[2].blocks, new_wm->wm[3].blocks, 2648 + new_wm->wm[4].blocks, new_wm->wm[5].blocks, 2649 + new_wm->wm[6].blocks, new_wm->wm[7].blocks, 2650 + new_wm->trans_wm.blocks, 2651 + new_wm->sagv.wm0.blocks, 2652 + new_wm->sagv.trans_wm.blocks); 2653 + 2654 + drm_dbg_kms(&i915->drm, 2655 + "[PLANE:%d:%s] min_ddb %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%5d" 2656 + " -> %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%5d\n", 2657 + plane->base.base.id, plane->base.name, 2658 + old_wm->wm[0].min_ddb_alloc, old_wm->wm[1].min_ddb_alloc, 2659 + old_wm->wm[2].min_ddb_alloc, old_wm->wm[3].min_ddb_alloc, 2660 + old_wm->wm[4].min_ddb_alloc, old_wm->wm[5].min_ddb_alloc, 2661 + old_wm->wm[6].min_ddb_alloc, old_wm->wm[7].min_ddb_alloc, 2662 + old_wm->trans_wm.min_ddb_alloc, 2663 + old_wm->sagv.wm0.min_ddb_alloc, 2664 + old_wm->sagv.trans_wm.min_ddb_alloc, 2665 + new_wm->wm[0].min_ddb_alloc, new_wm->wm[1].min_ddb_alloc, 2666 + new_wm->wm[2].min_ddb_alloc, new_wm->wm[3].min_ddb_alloc, 2667 + new_wm->wm[4].min_ddb_alloc, new_wm->wm[5].min_ddb_alloc, 2668 + new_wm->wm[6].min_ddb_alloc, new_wm->wm[7].min_ddb_alloc, 2669 + new_wm->trans_wm.min_ddb_alloc, 2670 + new_wm->sagv.wm0.min_ddb_alloc, 2671 + new_wm->sagv.trans_wm.min_ddb_alloc); 2672 + } 2673 + } 2674 + } 2675 + 2676 + static bool skl_plane_selected_wm_equals(struct intel_plane *plane, 2677 + const struct skl_pipe_wm *old_pipe_wm, 2678 + const struct skl_pipe_wm *new_pipe_wm) 2679 + { 2680 + struct drm_i915_private *i915 = to_i915(plane->base.dev); 2681 + int level, max_level = ilk_wm_max_level(i915); 2682 + 2683 + for (level = 0; level <= max_level; level++) { 2684 + /* 2685 + * We don't check uv_wm as the hardware doesn't actually 2686 + * use it. It only gets used for calculating the required 2687 + * ddb allocation. 2688 + */ 2689 + if (!skl_wm_level_equals(skl_plane_wm_level(old_pipe_wm, plane->id, level), 2690 + skl_plane_wm_level(new_pipe_wm, plane->id, level))) 2691 + return false; 2692 + } 2693 + 2694 + if (HAS_HW_SAGV_WM(i915)) { 2695 + const struct skl_plane_wm *old_wm = &old_pipe_wm->planes[plane->id]; 2696 + const struct skl_plane_wm *new_wm = &new_pipe_wm->planes[plane->id]; 2697 + 2698 + if (!skl_wm_level_equals(&old_wm->sagv.wm0, &new_wm->sagv.wm0) || 2699 + !skl_wm_level_equals(&old_wm->sagv.trans_wm, &new_wm->sagv.trans_wm)) 2700 + return false; 2701 + } 2702 + 2703 + return skl_wm_level_equals(skl_plane_trans_wm(old_pipe_wm, plane->id), 2704 + skl_plane_trans_wm(new_pipe_wm, plane->id)); 2705 + } 2706 + 2707 + /* 2708 + * To make sure the cursor watermark registers are always consistent 2709 + * with our computed state the following scenario needs special 2710 + * treatment: 2711 + * 2712 + * 1. enable cursor 2713 + * 2. move cursor entirely offscreen 2714 + * 3. disable cursor 2715 + * 2716 + * Step 2. does call .disable_plane() but does not zero the watermarks 2717 + * (since we consider an offscreen cursor still active for the purposes 2718 + * of watermarks). Step 3. would not normally call .disable_plane() 2719 + * because the actual plane visibility isn't changing, and we don't 2720 + * deallocate the cursor ddb until the pipe gets disabled. So we must 2721 + * force step 3. to call .disable_plane() to update the watermark 2722 + * registers properly. 2723 + * 2724 + * Other planes do not suffer from this issues as their watermarks are 2725 + * calculated based on the actual plane visibility. The only time this 2726 + * can trigger for the other planes is during the initial readout as the 2727 + * default value of the watermarks registers is not zero. 2728 + */ 2729 + static int skl_wm_add_affected_planes(struct intel_atomic_state *state, 2730 + struct intel_crtc *crtc) 2731 + { 2732 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 2733 + const struct intel_crtc_state *old_crtc_state = 2734 + intel_atomic_get_old_crtc_state(state, crtc); 2735 + struct intel_crtc_state *new_crtc_state = 2736 + intel_atomic_get_new_crtc_state(state, crtc); 2737 + struct intel_plane *plane; 2738 + 2739 + for_each_intel_plane_on_crtc(&i915->drm, crtc, plane) { 2740 + struct intel_plane_state *plane_state; 2741 + enum plane_id plane_id = plane->id; 2742 + 2743 + /* 2744 + * Force a full wm update for every plane on modeset. 2745 + * Required because the reset value of the wm registers 2746 + * is non-zero, whereas we want all disabled planes to 2747 + * have zero watermarks. So if we turn off the relevant 2748 + * power well the hardware state will go out of sync 2749 + * with the software state. 2750 + */ 2751 + if (!drm_atomic_crtc_needs_modeset(&new_crtc_state->uapi) && 2752 + skl_plane_selected_wm_equals(plane, 2753 + &old_crtc_state->wm.skl.optimal, 2754 + &new_crtc_state->wm.skl.optimal)) 2755 + continue; 2756 + 2757 + plane_state = intel_atomic_get_plane_state(state, plane); 2758 + if (IS_ERR(plane_state)) 2759 + return PTR_ERR(plane_state); 2760 + 2761 + new_crtc_state->update_planes |= BIT(plane_id); 2762 + } 2763 + 2764 + return 0; 2765 + } 2766 + 2767 + static int 2768 + skl_compute_wm(struct intel_atomic_state *state) 2769 + { 2770 + struct intel_crtc *crtc; 2771 + struct intel_crtc_state *new_crtc_state; 2772 + int ret, i; 2773 + 2774 + for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 2775 + ret = skl_build_pipe_wm(state, crtc); 2776 + if (ret) 2777 + return ret; 2778 + } 2779 + 2780 + ret = skl_compute_ddb(state); 2781 + if (ret) 2782 + return ret; 2783 + 2784 + ret = intel_compute_sagv_mask(state); 2785 + if (ret) 2786 + return ret; 2787 + 2788 + /* 2789 + * skl_compute_ddb() will have adjusted the final watermarks 2790 + * based on how much ddb is available. Now we can actually 2791 + * check if the final watermarks changed. 2792 + */ 2793 + for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 2794 + ret = skl_wm_add_affected_planes(state, crtc); 2795 + if (ret) 2796 + return ret; 2797 + } 2798 + 2799 + skl_print_wm_changes(state); 2800 + 2801 + return 0; 2802 + } 2803 + 2804 + static void skl_wm_level_from_reg_val(u32 val, struct skl_wm_level *level) 2805 + { 2806 + level->enable = val & PLANE_WM_EN; 2807 + level->ignore_lines = val & PLANE_WM_IGNORE_LINES; 2808 + level->blocks = REG_FIELD_GET(PLANE_WM_BLOCKS_MASK, val); 2809 + level->lines = REG_FIELD_GET(PLANE_WM_LINES_MASK, val); 2810 + } 2811 + 2812 + static void skl_pipe_wm_get_hw_state(struct intel_crtc *crtc, 2813 + struct skl_pipe_wm *out) 2814 + { 2815 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 2816 + enum pipe pipe = crtc->pipe; 2817 + int level, max_level; 2818 + enum plane_id plane_id; 2819 + u32 val; 2820 + 2821 + max_level = ilk_wm_max_level(i915); 2822 + 2823 + for_each_plane_id_on_crtc(crtc, plane_id) { 2824 + struct skl_plane_wm *wm = &out->planes[plane_id]; 2825 + 2826 + for (level = 0; level <= max_level; level++) { 2827 + if (plane_id != PLANE_CURSOR) 2828 + val = intel_uncore_read(&i915->uncore, PLANE_WM(pipe, plane_id, level)); 2829 + else 2830 + val = intel_uncore_read(&i915->uncore, CUR_WM(pipe, level)); 2831 + 2832 + skl_wm_level_from_reg_val(val, &wm->wm[level]); 2833 + } 2834 + 2835 + if (plane_id != PLANE_CURSOR) 2836 + val = intel_uncore_read(&i915->uncore, PLANE_WM_TRANS(pipe, plane_id)); 2837 + else 2838 + val = intel_uncore_read(&i915->uncore, CUR_WM_TRANS(pipe)); 2839 + 2840 + skl_wm_level_from_reg_val(val, &wm->trans_wm); 2841 + 2842 + if (HAS_HW_SAGV_WM(i915)) { 2843 + if (plane_id != PLANE_CURSOR) 2844 + val = intel_uncore_read(&i915->uncore, 2845 + PLANE_WM_SAGV(pipe, plane_id)); 2846 + else 2847 + val = intel_uncore_read(&i915->uncore, 2848 + CUR_WM_SAGV(pipe)); 2849 + 2850 + skl_wm_level_from_reg_val(val, &wm->sagv.wm0); 2851 + 2852 + if (plane_id != PLANE_CURSOR) 2853 + val = intel_uncore_read(&i915->uncore, 2854 + PLANE_WM_SAGV_TRANS(pipe, plane_id)); 2855 + else 2856 + val = intel_uncore_read(&i915->uncore, 2857 + CUR_WM_SAGV_TRANS(pipe)); 2858 + 2859 + skl_wm_level_from_reg_val(val, &wm->sagv.trans_wm); 2860 + } else if (DISPLAY_VER(i915) >= 12) { 2861 + wm->sagv.wm0 = wm->wm[0]; 2862 + wm->sagv.trans_wm = wm->trans_wm; 2863 + } 2864 + } 2865 + } 2866 + 2867 + void skl_wm_get_hw_state(struct drm_i915_private *i915) 2868 + { 2869 + struct intel_dbuf_state *dbuf_state = 2870 + to_intel_dbuf_state(i915->display.dbuf.obj.state); 2871 + struct intel_crtc *crtc; 2872 + 2873 + if (HAS_MBUS_JOINING(i915)) 2874 + dbuf_state->joined_mbus = intel_de_read(i915, MBUS_CTL) & MBUS_JOIN; 2875 + 2876 + for_each_intel_crtc(&i915->drm, crtc) { 2877 + struct intel_crtc_state *crtc_state = 2878 + to_intel_crtc_state(crtc->base.state); 2879 + enum pipe pipe = crtc->pipe; 2880 + unsigned int mbus_offset; 2881 + enum plane_id plane_id; 2882 + u8 slices; 2883 + 2884 + memset(&crtc_state->wm.skl.optimal, 0, 2885 + sizeof(crtc_state->wm.skl.optimal)); 2886 + if (crtc_state->hw.active) 2887 + skl_pipe_wm_get_hw_state(crtc, &crtc_state->wm.skl.optimal); 2888 + crtc_state->wm.skl.raw = crtc_state->wm.skl.optimal; 2889 + 2890 + memset(&dbuf_state->ddb[pipe], 0, sizeof(dbuf_state->ddb[pipe])); 2891 + 2892 + for_each_plane_id_on_crtc(crtc, plane_id) { 2893 + struct skl_ddb_entry *ddb = 2894 + &crtc_state->wm.skl.plane_ddb[plane_id]; 2895 + struct skl_ddb_entry *ddb_y = 2896 + &crtc_state->wm.skl.plane_ddb_y[plane_id]; 2897 + 2898 + if (!crtc_state->hw.active) 2899 + continue; 2900 + 2901 + skl_ddb_get_hw_plane_state(i915, crtc->pipe, 2902 + plane_id, ddb, ddb_y); 2903 + 2904 + skl_ddb_entry_union(&dbuf_state->ddb[pipe], ddb); 2905 + skl_ddb_entry_union(&dbuf_state->ddb[pipe], ddb_y); 2906 + } 2907 + 2908 + dbuf_state->weight[pipe] = intel_crtc_ddb_weight(crtc_state); 2909 + 2910 + /* 2911 + * Used for checking overlaps, so we need absolute 2912 + * offsets instead of MBUS relative offsets. 2913 + */ 2914 + slices = skl_compute_dbuf_slices(crtc, dbuf_state->active_pipes, 2915 + dbuf_state->joined_mbus); 2916 + mbus_offset = mbus_ddb_offset(i915, slices); 2917 + crtc_state->wm.skl.ddb.start = mbus_offset + dbuf_state->ddb[pipe].start; 2918 + crtc_state->wm.skl.ddb.end = mbus_offset + dbuf_state->ddb[pipe].end; 2919 + 2920 + /* The slices actually used by the planes on the pipe */ 2921 + dbuf_state->slices[pipe] = 2922 + skl_ddb_dbuf_slice_mask(i915, &crtc_state->wm.skl.ddb); 2923 + 2924 + drm_dbg_kms(&i915->drm, 2925 + "[CRTC:%d:%s] dbuf slices 0x%x, ddb (%d - %d), active pipes 0x%x, mbus joined: %s\n", 2926 + crtc->base.base.id, crtc->base.name, 2927 + dbuf_state->slices[pipe], dbuf_state->ddb[pipe].start, 2928 + dbuf_state->ddb[pipe].end, dbuf_state->active_pipes, 2929 + str_yes_no(dbuf_state->joined_mbus)); 2930 + } 2931 + 2932 + dbuf_state->enabled_slices = i915->display.dbuf.enabled_slices; 2933 + } 2934 + 2935 + static bool skl_dbuf_is_misconfigured(struct drm_i915_private *i915) 2936 + { 2937 + const struct intel_dbuf_state *dbuf_state = 2938 + to_intel_dbuf_state(i915->display.dbuf.obj.state); 2939 + struct skl_ddb_entry entries[I915_MAX_PIPES] = {}; 2940 + struct intel_crtc *crtc; 2941 + 2942 + for_each_intel_crtc(&i915->drm, crtc) { 2943 + const struct intel_crtc_state *crtc_state = 2944 + to_intel_crtc_state(crtc->base.state); 2945 + 2946 + entries[crtc->pipe] = crtc_state->wm.skl.ddb; 2947 + } 2948 + 2949 + for_each_intel_crtc(&i915->drm, crtc) { 2950 + const struct intel_crtc_state *crtc_state = 2951 + to_intel_crtc_state(crtc->base.state); 2952 + u8 slices; 2953 + 2954 + slices = skl_compute_dbuf_slices(crtc, dbuf_state->active_pipes, 2955 + dbuf_state->joined_mbus); 2956 + if (dbuf_state->slices[crtc->pipe] & ~slices) 2957 + return true; 2958 + 2959 + if (skl_ddb_allocation_overlaps(&crtc_state->wm.skl.ddb, entries, 2960 + I915_MAX_PIPES, crtc->pipe)) 2961 + return true; 2962 + } 2963 + 2964 + return false; 2965 + } 2966 + 2967 + void skl_wm_sanitize(struct drm_i915_private *i915) 2968 + { 2969 + struct intel_crtc *crtc; 2970 + 2971 + /* 2972 + * On TGL/RKL (at least) the BIOS likes to assign the planes 2973 + * to the wrong DBUF slices. This will cause an infinite loop 2974 + * in skl_commit_modeset_enables() as it can't find a way to 2975 + * transition between the old bogus DBUF layout to the new 2976 + * proper DBUF layout without DBUF allocation overlaps between 2977 + * the planes (which cannot be allowed or else the hardware 2978 + * may hang). If we detect a bogus DBUF layout just turn off 2979 + * all the planes so that skl_commit_modeset_enables() can 2980 + * simply ignore them. 2981 + */ 2982 + if (!skl_dbuf_is_misconfigured(i915)) 2983 + return; 2984 + 2985 + drm_dbg_kms(&i915->drm, "BIOS has misprogrammed the DBUF, disabling all planes\n"); 2986 + 2987 + for_each_intel_crtc(&i915->drm, crtc) { 2988 + struct intel_plane *plane = to_intel_plane(crtc->base.primary); 2989 + const struct intel_plane_state *plane_state = 2990 + to_intel_plane_state(plane->base.state); 2991 + struct intel_crtc_state *crtc_state = 2992 + to_intel_crtc_state(crtc->base.state); 2993 + 2994 + if (plane_state->uapi.visible) 2995 + intel_plane_disable_noatomic(crtc, plane); 2996 + 2997 + drm_WARN_ON(&i915->drm, crtc_state->active_planes != 0); 2998 + 2999 + memset(&crtc_state->wm.skl.ddb, 0, sizeof(crtc_state->wm.skl.ddb)); 3000 + } 3001 + } 3002 + 3003 + void intel_wm_state_verify(struct intel_crtc *crtc, 3004 + struct intel_crtc_state *new_crtc_state) 3005 + { 3006 + struct drm_i915_private *i915 = to_i915(crtc->base.dev); 3007 + struct skl_hw_state { 3008 + struct skl_ddb_entry ddb[I915_MAX_PLANES]; 3009 + struct skl_ddb_entry ddb_y[I915_MAX_PLANES]; 3010 + struct skl_pipe_wm wm; 3011 + } *hw; 3012 + const struct skl_pipe_wm *sw_wm = &new_crtc_state->wm.skl.optimal; 3013 + int level, max_level = ilk_wm_max_level(i915); 3014 + struct intel_plane *plane; 3015 + u8 hw_enabled_slices; 3016 + 3017 + if (DISPLAY_VER(i915) < 9 || !new_crtc_state->hw.active) 3018 + return; 3019 + 3020 + hw = kzalloc(sizeof(*hw), GFP_KERNEL); 3021 + if (!hw) 3022 + return; 3023 + 3024 + skl_pipe_wm_get_hw_state(crtc, &hw->wm); 3025 + 3026 + skl_pipe_ddb_get_hw_state(crtc, hw->ddb, hw->ddb_y); 3027 + 3028 + hw_enabled_slices = intel_enabled_dbuf_slices_mask(i915); 3029 + 3030 + if (DISPLAY_VER(i915) >= 11 && 3031 + hw_enabled_slices != i915->display.dbuf.enabled_slices) 3032 + drm_err(&i915->drm, 3033 + "mismatch in DBUF Slices (expected 0x%x, got 0x%x)\n", 3034 + i915->display.dbuf.enabled_slices, 3035 + hw_enabled_slices); 3036 + 3037 + for_each_intel_plane_on_crtc(&i915->drm, crtc, plane) { 3038 + const struct skl_ddb_entry *hw_ddb_entry, *sw_ddb_entry; 3039 + const struct skl_wm_level *hw_wm_level, *sw_wm_level; 3040 + 3041 + /* Watermarks */ 3042 + for (level = 0; level <= max_level; level++) { 3043 + hw_wm_level = &hw->wm.planes[plane->id].wm[level]; 3044 + sw_wm_level = skl_plane_wm_level(sw_wm, plane->id, level); 3045 + 3046 + if (skl_wm_level_equals(hw_wm_level, sw_wm_level)) 3047 + continue; 3048 + 3049 + drm_err(&i915->drm, 3050 + "[PLANE:%d:%s] mismatch in WM%d (expected e=%d b=%u l=%u, got e=%d b=%u l=%u)\n", 3051 + plane->base.base.id, plane->base.name, level, 3052 + sw_wm_level->enable, 3053 + sw_wm_level->blocks, 3054 + sw_wm_level->lines, 3055 + hw_wm_level->enable, 3056 + hw_wm_level->blocks, 3057 + hw_wm_level->lines); 3058 + } 3059 + 3060 + hw_wm_level = &hw->wm.planes[plane->id].trans_wm; 3061 + sw_wm_level = skl_plane_trans_wm(sw_wm, plane->id); 3062 + 3063 + if (!skl_wm_level_equals(hw_wm_level, sw_wm_level)) { 3064 + drm_err(&i915->drm, 3065 + "[PLANE:%d:%s] mismatch in trans WM (expected e=%d b=%u l=%u, got e=%d b=%u l=%u)\n", 3066 + plane->base.base.id, plane->base.name, 3067 + sw_wm_level->enable, 3068 + sw_wm_level->blocks, 3069 + sw_wm_level->lines, 3070 + hw_wm_level->enable, 3071 + hw_wm_level->blocks, 3072 + hw_wm_level->lines); 3073 + } 3074 + 3075 + hw_wm_level = &hw->wm.planes[plane->id].sagv.wm0; 3076 + sw_wm_level = &sw_wm->planes[plane->id].sagv.wm0; 3077 + 3078 + if (HAS_HW_SAGV_WM(i915) && 3079 + !skl_wm_level_equals(hw_wm_level, sw_wm_level)) { 3080 + drm_err(&i915->drm, 3081 + "[PLANE:%d:%s] mismatch in SAGV WM (expected e=%d b=%u l=%u, got e=%d b=%u l=%u)\n", 3082 + plane->base.base.id, plane->base.name, 3083 + sw_wm_level->enable, 3084 + sw_wm_level->blocks, 3085 + sw_wm_level->lines, 3086 + hw_wm_level->enable, 3087 + hw_wm_level->blocks, 3088 + hw_wm_level->lines); 3089 + } 3090 + 3091 + hw_wm_level = &hw->wm.planes[plane->id].sagv.trans_wm; 3092 + sw_wm_level = &sw_wm->planes[plane->id].sagv.trans_wm; 3093 + 3094 + if (HAS_HW_SAGV_WM(i915) && 3095 + !skl_wm_level_equals(hw_wm_level, sw_wm_level)) { 3096 + drm_err(&i915->drm, 3097 + "[PLANE:%d:%s] mismatch in SAGV trans WM (expected e=%d b=%u l=%u, got e=%d b=%u l=%u)\n", 3098 + plane->base.base.id, plane->base.name, 3099 + sw_wm_level->enable, 3100 + sw_wm_level->blocks, 3101 + sw_wm_level->lines, 3102 + hw_wm_level->enable, 3103 + hw_wm_level->blocks, 3104 + hw_wm_level->lines); 3105 + } 3106 + 3107 + /* DDB */ 3108 + hw_ddb_entry = &hw->ddb[PLANE_CURSOR]; 3109 + sw_ddb_entry = &new_crtc_state->wm.skl.plane_ddb[PLANE_CURSOR]; 3110 + 3111 + if (!skl_ddb_entry_equal(hw_ddb_entry, sw_ddb_entry)) { 3112 + drm_err(&i915->drm, 3113 + "[PLANE:%d:%s] mismatch in DDB (expected (%u,%u), found (%u,%u))\n", 3114 + plane->base.base.id, plane->base.name, 3115 + sw_ddb_entry->start, sw_ddb_entry->end, 3116 + hw_ddb_entry->start, hw_ddb_entry->end); 3117 + } 3118 + } 3119 + 3120 + kfree(hw); 3121 + } 3122 + 3123 + bool skl_watermark_ipc_enabled(struct drm_i915_private *i915) 3124 + { 3125 + return i915->display.wm.ipc_enabled; 3126 + } 3127 + 3128 + void skl_watermark_ipc_update(struct drm_i915_private *i915) 3129 + { 3130 + if (!HAS_IPC(i915)) 3131 + return; 3132 + 3133 + intel_uncore_rmw(&i915->uncore, DISP_ARB_CTL2, DISP_IPC_ENABLE, 3134 + skl_watermark_ipc_enabled(i915) ? DISP_IPC_ENABLE : 0); 3135 + } 3136 + 3137 + static bool skl_watermark_ipc_can_enable(struct drm_i915_private *i915) 3138 + { 3139 + /* Display WA #0477 WaDisableIPC: skl */ 3140 + if (IS_SKYLAKE(i915)) 3141 + return false; 3142 + 3143 + /* Display WA #1141: SKL:all KBL:all CFL */ 3144 + if (IS_KABYLAKE(i915) || 3145 + IS_COFFEELAKE(i915) || 3146 + IS_COMETLAKE(i915)) 3147 + return i915->dram_info.symmetric_memory; 3148 + 3149 + return true; 3150 + } 3151 + 3152 + void skl_watermark_ipc_init(struct drm_i915_private *i915) 3153 + { 3154 + if (!HAS_IPC(i915)) 3155 + return; 3156 + 3157 + i915->display.wm.ipc_enabled = skl_watermark_ipc_can_enable(i915); 3158 + 3159 + skl_watermark_ipc_update(i915); 3160 + } 3161 + 3162 + static void 3163 + adjust_wm_latency(struct drm_i915_private *i915, 3164 + u16 wm[], int max_level, int read_latency) 3165 + { 3166 + bool wm_lv_0_adjust_needed = i915->dram_info.wm_lv_0_adjust_needed; 3167 + int i, level; 3168 + 3169 + /* 3170 + * If a level n (n > 1) has a 0us latency, all levels m (m >= n) 3171 + * need to be disabled. We make sure to sanitize the values out 3172 + * of the punit to satisfy this requirement. 3173 + */ 3174 + for (level = 1; level <= max_level; level++) { 3175 + if (wm[level] == 0) { 3176 + for (i = level + 1; i <= max_level; i++) 3177 + wm[i] = 0; 3178 + 3179 + max_level = level - 1; 3180 + break; 3181 + } 3182 + } 3183 + 3184 + /* 3185 + * WaWmMemoryReadLatency 3186 + * 3187 + * punit doesn't take into account the read latency so we need 3188 + * to add proper adjustement to each valid level we retrieve 3189 + * from the punit when level 0 response data is 0us. 3190 + */ 3191 + if (wm[0] == 0) { 3192 + for (level = 0; level <= max_level; level++) 3193 + wm[level] += read_latency; 3194 + } 3195 + 3196 + /* 3197 + * WA Level-0 adjustment for 16GB DIMMs: SKL+ 3198 + * If we could not get dimm info enable this WA to prevent from 3199 + * any underrun. If not able to get Dimm info assume 16GB dimm 3200 + * to avoid any underrun. 3201 + */ 3202 + if (wm_lv_0_adjust_needed) 3203 + wm[0] += 1; 3204 + } 3205 + 3206 + static void mtl_read_wm_latency(struct drm_i915_private *i915, u16 wm[]) 3207 + { 3208 + struct intel_uncore *uncore = &i915->uncore; 3209 + int max_level = ilk_wm_max_level(i915); 3210 + u32 val; 3211 + 3212 + val = intel_uncore_read(uncore, MTL_LATENCY_LP0_LP1); 3213 + wm[0] = REG_FIELD_GET(MTL_LATENCY_LEVEL_EVEN_MASK, val); 3214 + wm[1] = REG_FIELD_GET(MTL_LATENCY_LEVEL_ODD_MASK, val); 3215 + 3216 + val = intel_uncore_read(uncore, MTL_LATENCY_LP2_LP3); 3217 + wm[2] = REG_FIELD_GET(MTL_LATENCY_LEVEL_EVEN_MASK, val); 3218 + wm[3] = REG_FIELD_GET(MTL_LATENCY_LEVEL_ODD_MASK, val); 3219 + 3220 + val = intel_uncore_read(uncore, MTL_LATENCY_LP4_LP5); 3221 + wm[4] = REG_FIELD_GET(MTL_LATENCY_LEVEL_EVEN_MASK, val); 3222 + wm[5] = REG_FIELD_GET(MTL_LATENCY_LEVEL_ODD_MASK, val); 3223 + 3224 + adjust_wm_latency(i915, wm, max_level, 6); 3225 + } 3226 + 3227 + static void skl_read_wm_latency(struct drm_i915_private *i915, u16 wm[]) 3228 + { 3229 + int max_level = ilk_wm_max_level(i915); 3230 + int read_latency = DISPLAY_VER(i915) >= 12 ? 3 : 2; 3231 + int mult = IS_DG2(i915) ? 2 : 1; 3232 + u32 val; 3233 + int ret; 3234 + 3235 + /* read the first set of memory latencies[0:3] */ 3236 + val = 0; /* data0 to be programmed to 0 for first set */ 3237 + ret = snb_pcode_read(&i915->uncore, GEN9_PCODE_READ_MEM_LATENCY, &val, NULL); 3238 + if (ret) { 3239 + drm_err(&i915->drm, "SKL Mailbox read error = %d\n", ret); 3240 + return; 3241 + } 3242 + 3243 + wm[0] = REG_FIELD_GET(GEN9_MEM_LATENCY_LEVEL_0_4_MASK, val) * mult; 3244 + wm[1] = REG_FIELD_GET(GEN9_MEM_LATENCY_LEVEL_1_5_MASK, val) * mult; 3245 + wm[2] = REG_FIELD_GET(GEN9_MEM_LATENCY_LEVEL_2_6_MASK, val) * mult; 3246 + wm[3] = REG_FIELD_GET(GEN9_MEM_LATENCY_LEVEL_3_7_MASK, val) * mult; 3247 + 3248 + /* read the second set of memory latencies[4:7] */ 3249 + val = 1; /* data0 to be programmed to 1 for second set */ 3250 + ret = snb_pcode_read(&i915->uncore, GEN9_PCODE_READ_MEM_LATENCY, &val, NULL); 3251 + if (ret) { 3252 + drm_err(&i915->drm, "SKL Mailbox read error = %d\n", ret); 3253 + return; 3254 + } 3255 + 3256 + wm[4] = REG_FIELD_GET(GEN9_MEM_LATENCY_LEVEL_0_4_MASK, val) * mult; 3257 + wm[5] = REG_FIELD_GET(GEN9_MEM_LATENCY_LEVEL_1_5_MASK, val) * mult; 3258 + wm[6] = REG_FIELD_GET(GEN9_MEM_LATENCY_LEVEL_2_6_MASK, val) * mult; 3259 + wm[7] = REG_FIELD_GET(GEN9_MEM_LATENCY_LEVEL_3_7_MASK, val) * mult; 3260 + 3261 + adjust_wm_latency(i915, wm, max_level, read_latency); 3262 + } 3263 + 3264 + static void skl_setup_wm_latency(struct drm_i915_private *i915) 3265 + { 3266 + if (DISPLAY_VER(i915) >= 14) 3267 + mtl_read_wm_latency(i915, i915->display.wm.skl_latency); 3268 + else 3269 + skl_read_wm_latency(i915, i915->display.wm.skl_latency); 3270 + 3271 + intel_print_wm_latency(i915, "Gen9 Plane", i915->display.wm.skl_latency); 3272 + } 3273 + 3274 + static const struct intel_wm_funcs skl_wm_funcs = { 3275 + .compute_global_watermarks = skl_compute_wm, 3276 + }; 3277 + 3278 + void skl_wm_init(struct drm_i915_private *i915) 3279 + { 3280 + intel_sagv_init(i915); 3281 + 3282 + skl_setup_wm_latency(i915); 3283 + 3284 + i915->display.funcs.wm = &skl_wm_funcs; 3285 + } 3286 + 3287 + static struct intel_global_state *intel_dbuf_duplicate_state(struct intel_global_obj *obj) 3288 + { 3289 + struct intel_dbuf_state *dbuf_state; 3290 + 3291 + dbuf_state = kmemdup(obj->state, sizeof(*dbuf_state), GFP_KERNEL); 3292 + if (!dbuf_state) 3293 + return NULL; 3294 + 3295 + return &dbuf_state->base; 3296 + } 3297 + 3298 + static void intel_dbuf_destroy_state(struct intel_global_obj *obj, 3299 + struct intel_global_state *state) 3300 + { 3301 + kfree(state); 3302 + } 3303 + 3304 + static const struct intel_global_state_funcs intel_dbuf_funcs = { 3305 + .atomic_duplicate_state = intel_dbuf_duplicate_state, 3306 + .atomic_destroy_state = intel_dbuf_destroy_state, 3307 + }; 3308 + 3309 + struct intel_dbuf_state * 3310 + intel_atomic_get_dbuf_state(struct intel_atomic_state *state) 3311 + { 3312 + struct drm_i915_private *i915 = to_i915(state->base.dev); 3313 + struct intel_global_state *dbuf_state; 3314 + 3315 + dbuf_state = intel_atomic_get_global_obj_state(state, &i915->display.dbuf.obj); 3316 + if (IS_ERR(dbuf_state)) 3317 + return ERR_CAST(dbuf_state); 3318 + 3319 + return to_intel_dbuf_state(dbuf_state); 3320 + } 3321 + 3322 + int intel_dbuf_init(struct drm_i915_private *i915) 3323 + { 3324 + struct intel_dbuf_state *dbuf_state; 3325 + 3326 + dbuf_state = kzalloc(sizeof(*dbuf_state), GFP_KERNEL); 3327 + if (!dbuf_state) 3328 + return -ENOMEM; 3329 + 3330 + intel_atomic_global_obj_init(i915, &i915->display.dbuf.obj, 3331 + &dbuf_state->base, &intel_dbuf_funcs); 3332 + 3333 + return 0; 3334 + } 3335 + 3336 + /* 3337 + * Configure MBUS_CTL and all DBUF_CTL_S of each slice to join_mbus state before 3338 + * update the request state of all DBUS slices. 3339 + */ 3340 + static void update_mbus_pre_enable(struct intel_atomic_state *state) 3341 + { 3342 + struct drm_i915_private *i915 = to_i915(state->base.dev); 3343 + u32 mbus_ctl, dbuf_min_tracker_val; 3344 + enum dbuf_slice slice; 3345 + const struct intel_dbuf_state *dbuf_state = 3346 + intel_atomic_get_new_dbuf_state(state); 3347 + 3348 + if (!HAS_MBUS_JOINING(i915)) 3349 + return; 3350 + 3351 + /* 3352 + * TODO: Implement vblank synchronized MBUS joining changes. 3353 + * Must be properly coordinated with dbuf reprogramming. 3354 + */ 3355 + if (dbuf_state->joined_mbus) { 3356 + mbus_ctl = MBUS_HASHING_MODE_1x4 | MBUS_JOIN | 3357 + MBUS_JOIN_PIPE_SELECT_NONE; 3358 + dbuf_min_tracker_val = DBUF_MIN_TRACKER_STATE_SERVICE(3); 3359 + } else { 3360 + mbus_ctl = MBUS_HASHING_MODE_2x2 | 3361 + MBUS_JOIN_PIPE_SELECT_NONE; 3362 + dbuf_min_tracker_val = DBUF_MIN_TRACKER_STATE_SERVICE(1); 3363 + } 3364 + 3365 + intel_de_rmw(i915, MBUS_CTL, 3366 + MBUS_HASHING_MODE_MASK | MBUS_JOIN | 3367 + MBUS_JOIN_PIPE_SELECT_MASK, mbus_ctl); 3368 + 3369 + for_each_dbuf_slice(i915, slice) 3370 + intel_de_rmw(i915, DBUF_CTL_S(slice), 3371 + DBUF_MIN_TRACKER_STATE_SERVICE_MASK, 3372 + dbuf_min_tracker_val); 3373 + } 3374 + 3375 + void intel_dbuf_pre_plane_update(struct intel_atomic_state *state) 3376 + { 3377 + struct drm_i915_private *i915 = to_i915(state->base.dev); 3378 + const struct intel_dbuf_state *new_dbuf_state = 3379 + intel_atomic_get_new_dbuf_state(state); 3380 + const struct intel_dbuf_state *old_dbuf_state = 3381 + intel_atomic_get_old_dbuf_state(state); 3382 + 3383 + if (!new_dbuf_state || 3384 + (new_dbuf_state->enabled_slices == old_dbuf_state->enabled_slices && 3385 + new_dbuf_state->joined_mbus == old_dbuf_state->joined_mbus)) 3386 + return; 3387 + 3388 + WARN_ON(!new_dbuf_state->base.changed); 3389 + 3390 + update_mbus_pre_enable(state); 3391 + gen9_dbuf_slices_update(i915, 3392 + old_dbuf_state->enabled_slices | 3393 + new_dbuf_state->enabled_slices); 3394 + } 3395 + 3396 + void intel_dbuf_post_plane_update(struct intel_atomic_state *state) 3397 + { 3398 + struct drm_i915_private *i915 = to_i915(state->base.dev); 3399 + const struct intel_dbuf_state *new_dbuf_state = 3400 + intel_atomic_get_new_dbuf_state(state); 3401 + const struct intel_dbuf_state *old_dbuf_state = 3402 + intel_atomic_get_old_dbuf_state(state); 3403 + 3404 + if (!new_dbuf_state || 3405 + (new_dbuf_state->enabled_slices == old_dbuf_state->enabled_slices && 3406 + new_dbuf_state->joined_mbus == old_dbuf_state->joined_mbus)) 3407 + return; 3408 + 3409 + WARN_ON(!new_dbuf_state->base.changed); 3410 + 3411 + gen9_dbuf_slices_update(i915, 3412 + new_dbuf_state->enabled_slices); 3413 + } 3414 + 3415 + static bool xelpdp_is_only_pipe_per_dbuf_bank(enum pipe pipe, u8 active_pipes) 3416 + { 3417 + switch (pipe) { 3418 + case PIPE_A: 3419 + return !(active_pipes & BIT(PIPE_D)); 3420 + case PIPE_D: 3421 + return !(active_pipes & BIT(PIPE_A)); 3422 + case PIPE_B: 3423 + return !(active_pipes & BIT(PIPE_C)); 3424 + case PIPE_C: 3425 + return !(active_pipes & BIT(PIPE_B)); 3426 + default: /* to suppress compiler warning */ 3427 + MISSING_CASE(pipe); 3428 + break; 3429 + } 3430 + 3431 + return false; 3432 + } 3433 + 3434 + void intel_mbus_dbox_update(struct intel_atomic_state *state) 3435 + { 3436 + struct drm_i915_private *i915 = to_i915(state->base.dev); 3437 + const struct intel_dbuf_state *new_dbuf_state, *old_dbuf_state; 3438 + const struct intel_crtc_state *new_crtc_state; 3439 + const struct intel_crtc *crtc; 3440 + u32 val = 0; 3441 + int i; 3442 + 3443 + if (DISPLAY_VER(i915) < 11) 3444 + return; 3445 + 3446 + new_dbuf_state = intel_atomic_get_new_dbuf_state(state); 3447 + old_dbuf_state = intel_atomic_get_old_dbuf_state(state); 3448 + if (!new_dbuf_state || 3449 + (new_dbuf_state->joined_mbus == old_dbuf_state->joined_mbus && 3450 + new_dbuf_state->active_pipes == old_dbuf_state->active_pipes)) 3451 + return; 3452 + 3453 + if (DISPLAY_VER(i915) >= 14) 3454 + val |= MBUS_DBOX_I_CREDIT(2); 3455 + 3456 + if (DISPLAY_VER(i915) >= 12) { 3457 + val |= MBUS_DBOX_B2B_TRANSACTIONS_MAX(16); 3458 + val |= MBUS_DBOX_B2B_TRANSACTIONS_DELAY(1); 3459 + val |= MBUS_DBOX_REGULATE_B2B_TRANSACTIONS_EN; 3460 + } 3461 + 3462 + if (DISPLAY_VER(i915) >= 14) 3463 + val |= new_dbuf_state->joined_mbus ? MBUS_DBOX_A_CREDIT(12) : 3464 + MBUS_DBOX_A_CREDIT(8); 3465 + else if (IS_ALDERLAKE_P(i915)) 3466 + /* Wa_22010947358:adl-p */ 3467 + val |= new_dbuf_state->joined_mbus ? MBUS_DBOX_A_CREDIT(6) : 3468 + MBUS_DBOX_A_CREDIT(4); 3469 + else 3470 + val |= MBUS_DBOX_A_CREDIT(2); 3471 + 3472 + if (DISPLAY_VER(i915) >= 14) { 3473 + val |= MBUS_DBOX_B_CREDIT(0xA); 3474 + } else if (IS_ALDERLAKE_P(i915)) { 3475 + val |= MBUS_DBOX_BW_CREDIT(2); 3476 + val |= MBUS_DBOX_B_CREDIT(8); 3477 + } else if (DISPLAY_VER(i915) >= 12) { 3478 + val |= MBUS_DBOX_BW_CREDIT(2); 3479 + val |= MBUS_DBOX_B_CREDIT(12); 3480 + } else { 3481 + val |= MBUS_DBOX_BW_CREDIT(1); 3482 + val |= MBUS_DBOX_B_CREDIT(8); 3483 + } 3484 + 3485 + for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 3486 + u32 pipe_val = val; 3487 + 3488 + if (!new_crtc_state->hw.active) 3489 + continue; 3490 + 3491 + if (DISPLAY_VER(i915) >= 14) { 3492 + if (xelpdp_is_only_pipe_per_dbuf_bank(crtc->pipe, 3493 + new_dbuf_state->active_pipes)) 3494 + pipe_val |= MBUS_DBOX_BW_8CREDITS_MTL; 3495 + else 3496 + pipe_val |= MBUS_DBOX_BW_4CREDITS_MTL; 3497 + } 3498 + 3499 + intel_de_write(i915, PIPE_MBUS_DBOX_CTL(crtc->pipe), pipe_val); 3500 + } 3501 + } 3502 + 3503 + static int skl_watermark_ipc_status_show(struct seq_file *m, void *data) 3504 + { 3505 + struct drm_i915_private *i915 = m->private; 3506 + 3507 + seq_printf(m, "Isochronous Priority Control: %s\n", 3508 + str_yes_no(skl_watermark_ipc_enabled(i915))); 3509 + return 0; 3510 + } 3511 + 3512 + static int skl_watermark_ipc_status_open(struct inode *inode, struct file *file) 3513 + { 3514 + struct drm_i915_private *i915 = inode->i_private; 3515 + 3516 + return single_open(file, skl_watermark_ipc_status_show, i915); 3517 + } 3518 + 3519 + static ssize_t skl_watermark_ipc_status_write(struct file *file, 3520 + const char __user *ubuf, 3521 + size_t len, loff_t *offp) 3522 + { 3523 + struct seq_file *m = file->private_data; 3524 + struct drm_i915_private *i915 = m->private; 3525 + intel_wakeref_t wakeref; 3526 + bool enable; 3527 + int ret; 3528 + 3529 + ret = kstrtobool_from_user(ubuf, len, &enable); 3530 + if (ret < 0) 3531 + return ret; 3532 + 3533 + with_intel_runtime_pm(&i915->runtime_pm, wakeref) { 3534 + if (!skl_watermark_ipc_enabled(i915) && enable) 3535 + drm_info(&i915->drm, 3536 + "Enabling IPC: WM will be proper only after next commit\n"); 3537 + i915->display.wm.ipc_enabled = enable; 3538 + skl_watermark_ipc_update(i915); 3539 + } 3540 + 3541 + return len; 3542 + } 3543 + 3544 + static const struct file_operations skl_watermark_ipc_status_fops = { 3545 + .owner = THIS_MODULE, 3546 + .open = skl_watermark_ipc_status_open, 3547 + .read = seq_read, 3548 + .llseek = seq_lseek, 3549 + .release = single_release, 3550 + .write = skl_watermark_ipc_status_write 3551 + }; 3552 + 3553 + void skl_watermark_ipc_debugfs_register(struct drm_i915_private *i915) 3554 + { 3555 + struct drm_minor *minor = i915->drm.primary; 3556 + 3557 + if (!HAS_IPC(i915)) 3558 + return; 3559 + 3560 + debugfs_create_file("i915_ipc_status", 0644, minor->debugfs_root, i915, 3561 + &skl_watermark_ipc_status_fops); 3562 + }
+80
drivers/gpu/drm/i915/display/skl_watermark.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2022 Intel Corporation 4 + */ 5 + 6 + #ifndef __SKL_WATERMARK_H__ 7 + #define __SKL_WATERMARK_H__ 8 + 9 + #include <linux/types.h> 10 + 11 + #include "intel_display.h" 12 + #include "intel_global_state.h" 13 + #include "intel_pm_types.h" 14 + 15 + struct drm_i915_private; 16 + struct intel_atomic_state; 17 + struct intel_bw_state; 18 + struct intel_crtc; 19 + struct intel_crtc_state; 20 + struct intel_plane; 21 + 22 + u8 intel_enabled_dbuf_slices_mask(struct drm_i915_private *i915); 23 + 24 + void intel_sagv_pre_plane_update(struct intel_atomic_state *state); 25 + void intel_sagv_post_plane_update(struct intel_atomic_state *state); 26 + bool intel_can_enable_sagv(struct drm_i915_private *i915, 27 + const struct intel_bw_state *bw_state); 28 + 29 + u32 skl_ddb_dbuf_slice_mask(struct drm_i915_private *i915, 30 + const struct skl_ddb_entry *entry); 31 + 32 + void skl_write_plane_wm(struct intel_plane *plane, 33 + const struct intel_crtc_state *crtc_state); 34 + void skl_write_cursor_wm(struct intel_plane *plane, 35 + const struct intel_crtc_state *crtc_state); 36 + 37 + bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry *ddb, 38 + const struct skl_ddb_entry *entries, 39 + int num_entries, int ignore_idx); 40 + 41 + void skl_wm_get_hw_state(struct drm_i915_private *i915); 42 + void skl_wm_sanitize(struct drm_i915_private *i915); 43 + 44 + void intel_wm_state_verify(struct intel_crtc *crtc, 45 + struct intel_crtc_state *new_crtc_state); 46 + 47 + void skl_watermark_ipc_init(struct drm_i915_private *i915); 48 + void skl_watermark_ipc_update(struct drm_i915_private *i915); 49 + bool skl_watermark_ipc_enabled(struct drm_i915_private *i915); 50 + void skl_watermark_ipc_debugfs_register(struct drm_i915_private *i915); 51 + 52 + void skl_wm_init(struct drm_i915_private *i915); 53 + 54 + struct intel_dbuf_state { 55 + struct intel_global_state base; 56 + 57 + struct skl_ddb_entry ddb[I915_MAX_PIPES]; 58 + unsigned int weight[I915_MAX_PIPES]; 59 + u8 slices[I915_MAX_PIPES]; 60 + u8 enabled_slices; 61 + u8 active_pipes; 62 + bool joined_mbus; 63 + }; 64 + 65 + struct intel_dbuf_state * 66 + intel_atomic_get_dbuf_state(struct intel_atomic_state *state); 67 + 68 + #define to_intel_dbuf_state(x) container_of((x), struct intel_dbuf_state, base) 69 + #define intel_atomic_get_old_dbuf_state(state) \ 70 + to_intel_dbuf_state(intel_atomic_get_old_global_obj_state(state, &to_i915(state->base.dev)->display.dbuf.obj)) 71 + #define intel_atomic_get_new_dbuf_state(state) \ 72 + to_intel_dbuf_state(intel_atomic_get_new_global_obj_state(state, &to_i915(state->base.dev)->display.dbuf.obj)) 73 + 74 + int intel_dbuf_init(struct drm_i915_private *i915); 75 + void intel_dbuf_pre_plane_update(struct intel_atomic_state *state); 76 + void intel_dbuf_post_plane_update(struct intel_atomic_state *state); 77 + void intel_mbus_dbox_update(struct intel_atomic_state *state); 78 + 79 + #endif /* __SKL_WATERMARK_H__ */ 80 +
+11 -12
drivers/gpu/drm/i915/display/vlv_dsi.c
··· 822 822 u32 val; 823 823 824 824 /* Disable DPOunit clock gating, can stall pipe */ 825 - val = intel_de_read(dev_priv, DSPCLK_GATE_D); 825 + val = intel_de_read(dev_priv, DSPCLK_GATE_D(dev_priv)); 826 826 val |= DPOUNIT_CLOCK_GATE_DISABLE; 827 - intel_de_write(dev_priv, DSPCLK_GATE_D, val); 827 + intel_de_write(dev_priv, DSPCLK_GATE_D(dev_priv), val); 828 828 } 829 829 830 830 if (!IS_GEMINILAKE(dev_priv)) ··· 998 998 999 999 vlv_dsi_pll_disable(encoder); 1000 1000 1001 - val = intel_de_read(dev_priv, DSPCLK_GATE_D); 1001 + val = intel_de_read(dev_priv, DSPCLK_GATE_D(dev_priv)); 1002 1002 val &= ~DPOUNIT_CLOCK_GATE_DISABLE; 1003 - intel_de_write(dev_priv, DSPCLK_GATE_D, val); 1003 + intel_de_write(dev_priv, DSPCLK_GATE_D(dev_priv), val); 1004 1004 } 1005 1005 1006 1006 /* Assert reset */ ··· 1277 1277 pclk = vlv_dsi_get_pclk(encoder, pipe_config); 1278 1278 } 1279 1279 1280 - if (intel_dsi->dual_link) 1281 - pclk *= 2; 1280 + pipe_config->port_clock = pclk; 1282 1281 1283 - if (pclk) { 1284 - pipe_config->hw.adjusted_mode.crtc_clock = pclk; 1285 - pipe_config->port_clock = pclk; 1286 - } 1282 + /* FIXME definitely not right for burst/cmd mode/pixel overlap */ 1283 + pipe_config->hw.adjusted_mode.crtc_clock = pclk; 1284 + if (intel_dsi->dual_link) 1285 + pipe_config->hw.adjusted_mode.crtc_clock *= 2; 1287 1286 } 1288 1287 1289 1288 /* return txclkesc cycles in terms of divider and duration in us */ ··· 1871 1872 return; 1872 1873 1873 1874 if (IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) 1874 - dev_priv->mipi_mmio_base = BXT_MIPI_BASE; 1875 + dev_priv->display.dsi.mmio_base = BXT_MIPI_BASE; 1875 1876 else 1876 - dev_priv->mipi_mmio_base = VLV_MIPI_BASE; 1877 + dev_priv->display.dsi.mmio_base = VLV_MIPI_BASE; 1877 1878 1878 1879 intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL); 1879 1880 if (!intel_dsi)
+86 -55
drivers/gpu/drm/i915/display/vlv_dsi_pll.c
··· 113 113 return 0; 114 114 } 115 115 116 + static int vlv_dsi_pclk(struct intel_encoder *encoder, 117 + struct intel_crtc_state *config) 118 + { 119 + struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 120 + struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); 121 + int bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format); 122 + u32 dsi_clock; 123 + u32 pll_ctl, pll_div; 124 + u32 m = 0, p = 0, n; 125 + int refclk = IS_CHERRYVIEW(dev_priv) ? 100000 : 25000; 126 + int i; 127 + 128 + pll_ctl = config->dsi_pll.ctrl; 129 + pll_div = config->dsi_pll.div; 130 + 131 + /* mask out other bits and extract the P1 divisor */ 132 + pll_ctl &= DSI_PLL_P1_POST_DIV_MASK; 133 + pll_ctl = pll_ctl >> (DSI_PLL_P1_POST_DIV_SHIFT - 2); 134 + 135 + /* N1 divisor */ 136 + n = (pll_div & DSI_PLL_N1_DIV_MASK) >> DSI_PLL_N1_DIV_SHIFT; 137 + n = 1 << n; /* register has log2(N1) */ 138 + 139 + /* mask out the other bits and extract the M1 divisor */ 140 + pll_div &= DSI_PLL_M1_DIV_MASK; 141 + pll_div = pll_div >> DSI_PLL_M1_DIV_SHIFT; 142 + 143 + while (pll_ctl) { 144 + pll_ctl = pll_ctl >> 1; 145 + p++; 146 + } 147 + p--; 148 + 149 + if (!p) { 150 + drm_err(&dev_priv->drm, "wrong P1 divisor\n"); 151 + return 0; 152 + } 153 + 154 + for (i = 0; i < ARRAY_SIZE(lfsr_converts); i++) { 155 + if (lfsr_converts[i] == pll_div) 156 + break; 157 + } 158 + 159 + if (i == ARRAY_SIZE(lfsr_converts)) { 160 + drm_err(&dev_priv->drm, "wrong m_seed programmed\n"); 161 + return 0; 162 + } 163 + 164 + m = i + 62; 165 + 166 + dsi_clock = (m * refclk) / (p * n); 167 + 168 + return DIV_ROUND_CLOSEST(dsi_clock * intel_dsi->lane_count, bpp); 169 + } 170 + 116 171 /* 117 172 * XXX: The muxing and gating is hard coded for now. Need to add support for 118 173 * sharing PLLs with two DSI outputs. ··· 177 122 { 178 123 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 179 124 struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); 180 - int ret; 181 - u32 dsi_clk; 125 + int pclk, dsi_clk, ret; 182 126 183 127 dsi_clk = dsi_clk_from_pclk(intel_dsi->pclk, intel_dsi->pixel_format, 184 128 intel_dsi->lane_count); ··· 198 144 199 145 drm_dbg_kms(&dev_priv->drm, "dsi pll div %08x, ctrl %08x\n", 200 146 config->dsi_pll.div, config->dsi_pll.ctrl); 147 + 148 + pclk = vlv_dsi_pclk(encoder, config); 149 + config->port_clock = pclk; 150 + 151 + /* FIXME definitely not right for burst/cmd mode/pixel overlap */ 152 + config->hw.adjusted_mode.crtc_clock = pclk; 153 + if (intel_dsi->dual_link) 154 + config->hw.adjusted_mode.crtc_clock *= 2; 201 155 202 156 return 0; 203 157 } ··· 324 262 struct intel_crtc_state *config) 325 263 { 326 264 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 327 - struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); 328 - int bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format); 329 - u32 dsi_clock, pclk; 330 265 u32 pll_ctl, pll_div; 331 - u32 m = 0, p = 0, n; 332 - int refclk = IS_CHERRYVIEW(dev_priv) ? 100000 : 25000; 333 - int i; 334 266 335 267 drm_dbg_kms(&dev_priv->drm, "\n"); 336 268 ··· 336 280 config->dsi_pll.ctrl = pll_ctl & ~DSI_PLL_LOCK; 337 281 config->dsi_pll.div = pll_div; 338 282 339 - /* mask out other bits and extract the P1 divisor */ 340 - pll_ctl &= DSI_PLL_P1_POST_DIV_MASK; 341 - pll_ctl = pll_ctl >> (DSI_PLL_P1_POST_DIV_SHIFT - 2); 283 + return vlv_dsi_pclk(encoder, config); 284 + } 342 285 343 - /* N1 divisor */ 344 - n = (pll_div & DSI_PLL_N1_DIV_MASK) >> DSI_PLL_N1_DIV_SHIFT; 345 - n = 1 << n; /* register has log2(N1) */ 286 + static int bxt_dsi_pclk(struct intel_encoder *encoder, 287 + const struct intel_crtc_state *config) 288 + { 289 + struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); 290 + int bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format); 291 + u32 dsi_ratio, dsi_clk; 346 292 347 - /* mask out the other bits and extract the M1 divisor */ 348 - pll_div &= DSI_PLL_M1_DIV_MASK; 349 - pll_div = pll_div >> DSI_PLL_M1_DIV_SHIFT; 293 + dsi_ratio = config->dsi_pll.ctrl & BXT_DSI_PLL_RATIO_MASK; 294 + dsi_clk = (dsi_ratio * BXT_REF_CLOCK_KHZ) / 2; 350 295 351 - while (pll_ctl) { 352 - pll_ctl = pll_ctl >> 1; 353 - p++; 354 - } 355 - p--; 356 - 357 - if (!p) { 358 - drm_err(&dev_priv->drm, "wrong P1 divisor\n"); 359 - return 0; 360 - } 361 - 362 - for (i = 0; i < ARRAY_SIZE(lfsr_converts); i++) { 363 - if (lfsr_converts[i] == pll_div) 364 - break; 365 - } 366 - 367 - if (i == ARRAY_SIZE(lfsr_converts)) { 368 - drm_err(&dev_priv->drm, "wrong m_seed programmed\n"); 369 - return 0; 370 - } 371 - 372 - m = i + 62; 373 - 374 - dsi_clock = (m * refclk) / (p * n); 375 - 376 - pclk = DIV_ROUND_CLOSEST(dsi_clock * intel_dsi->lane_count, bpp); 377 - 378 - return pclk; 296 + return DIV_ROUND_CLOSEST(dsi_clk * intel_dsi->lane_count, bpp); 379 297 } 380 298 381 299 u32 bxt_dsi_get_pclk(struct intel_encoder *encoder, 382 300 struct intel_crtc_state *config) 383 301 { 384 - u32 pclk; 385 - u32 dsi_clk; 386 - u32 dsi_ratio; 387 - struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); 388 302 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 389 - int bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format); 303 + u32 pclk; 390 304 391 305 config->dsi_pll.ctrl = intel_de_read(dev_priv, BXT_DSI_PLL_CTL); 392 306 393 - dsi_ratio = config->dsi_pll.ctrl & BXT_DSI_PLL_RATIO_MASK; 394 - 395 - dsi_clk = (dsi_ratio * BXT_REF_CLOCK_KHZ) / 2; 396 - 397 - pclk = DIV_ROUND_CLOSEST(dsi_clk * intel_dsi->lane_count, bpp); 307 + pclk = bxt_dsi_pclk(encoder, config); 398 308 399 309 drm_dbg(&dev_priv->drm, "Calculated pclk=%u\n", pclk); 400 310 return pclk; ··· 485 463 struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); 486 464 u8 dsi_ratio, dsi_ratio_min, dsi_ratio_max; 487 465 u32 dsi_clk; 466 + int pclk; 488 467 489 468 dsi_clk = dsi_clk_from_pclk(intel_dsi->pclk, intel_dsi->pixel_format, 490 469 intel_dsi->lane_count); ··· 524 501 */ 525 502 if (IS_BROXTON(dev_priv) && dsi_ratio <= 50) 526 503 config->dsi_pll.ctrl |= BXT_DSI_PLL_PVD_RATIO_1; 504 + 505 + pclk = bxt_dsi_pclk(encoder, config); 506 + config->port_clock = pclk; 507 + 508 + /* FIXME definitely not right for burst/cmd mode/pixel overlap */ 509 + config->hw.adjusted_mode.crtc_clock = pclk; 510 + if (intel_dsi->dual_link) 511 + config->hw.adjusted_mode.crtc_clock *= 2; 527 512 528 513 return 0; 529 514 }
+95 -93
drivers/gpu/drm/i915/display/vlv_dsi_regs.h
··· 11 11 #define VLV_MIPI_BASE VLV_DISPLAY_BASE 12 12 #define BXT_MIPI_BASE 0x60000 13 13 14 + #define _MIPI_MMIO_BASE(__i915) ((__i915)->display.dsi.mmio_base) 15 + 14 16 #define _MIPI_PORT(port, a, c) (((port) == PORT_A) ? a : c) /* ports A and C only */ 15 17 #define _MMIO_MIPI(port, a, c) _MMIO(_MIPI_PORT(port, a, c)) 16 18 ··· 98 96 99 97 /* MIPI DSI Controller and D-PHY registers */ 100 98 101 - #define _MIPIA_DEVICE_READY (dev_priv->mipi_mmio_base + 0xb000) 102 - #define _MIPIC_DEVICE_READY (dev_priv->mipi_mmio_base + 0xb800) 99 + #define _MIPIA_DEVICE_READY (_MIPI_MMIO_BASE(dev_priv) + 0xb000) 100 + #define _MIPIC_DEVICE_READY (_MIPI_MMIO_BASE(dev_priv) + 0xb800) 103 101 #define MIPI_DEVICE_READY(port) _MMIO_MIPI(port, _MIPIA_DEVICE_READY, _MIPIC_DEVICE_READY) 104 102 #define BUS_POSSESSION (1 << 3) /* set to give bus to receiver */ 105 103 #define ULPS_STATE_MASK (3 << 1) ··· 108 106 #define ULPS_STATE_NORMAL_OPERATION (0 << 1) 109 107 #define DEVICE_READY (1 << 0) 110 108 111 - #define _MIPIA_INTR_STAT (dev_priv->mipi_mmio_base + 0xb004) 112 - #define _MIPIC_INTR_STAT (dev_priv->mipi_mmio_base + 0xb804) 109 + #define _MIPIA_INTR_STAT (_MIPI_MMIO_BASE(dev_priv) + 0xb004) 110 + #define _MIPIC_INTR_STAT (_MIPI_MMIO_BASE(dev_priv) + 0xb804) 113 111 #define MIPI_INTR_STAT(port) _MMIO_MIPI(port, _MIPIA_INTR_STAT, _MIPIC_INTR_STAT) 114 - #define _MIPIA_INTR_EN (dev_priv->mipi_mmio_base + 0xb008) 115 - #define _MIPIC_INTR_EN (dev_priv->mipi_mmio_base + 0xb808) 112 + #define _MIPIA_INTR_EN (_MIPI_MMIO_BASE(dev_priv) + 0xb008) 113 + #define _MIPIC_INTR_EN (_MIPI_MMIO_BASE(dev_priv) + 0xb808) 116 114 #define MIPI_INTR_EN(port) _MMIO_MIPI(port, _MIPIA_INTR_EN, _MIPIC_INTR_EN) 117 115 #define TEARING_EFFECT (1 << 31) 118 116 #define SPL_PKT_SENT_INTERRUPT (1 << 30) ··· 147 145 #define RXSOT_SYNC_ERROR (1 << 1) 148 146 #define RXSOT_ERROR (1 << 0) 149 147 150 - #define _MIPIA_DSI_FUNC_PRG (dev_priv->mipi_mmio_base + 0xb00c) 151 - #define _MIPIC_DSI_FUNC_PRG (dev_priv->mipi_mmio_base + 0xb80c) 148 + #define _MIPIA_DSI_FUNC_PRG (_MIPI_MMIO_BASE(dev_priv) + 0xb00c) 149 + #define _MIPIC_DSI_FUNC_PRG (_MIPI_MMIO_BASE(dev_priv) + 0xb80c) 152 150 #define MIPI_DSI_FUNC_PRG(port) _MMIO_MIPI(port, _MIPIA_DSI_FUNC_PRG, _MIPIC_DSI_FUNC_PRG) 153 151 #define CMD_MODE_DATA_WIDTH_MASK (7 << 13) 154 152 #define CMD_MODE_NOT_SUPPORTED (0 << 13) ··· 170 168 #define DATA_LANES_PRG_REG_SHIFT 0 171 169 #define DATA_LANES_PRG_REG_MASK (7 << 0) 172 170 173 - #define _MIPIA_HS_TX_TIMEOUT (dev_priv->mipi_mmio_base + 0xb010) 174 - #define _MIPIC_HS_TX_TIMEOUT (dev_priv->mipi_mmio_base + 0xb810) 171 + #define _MIPIA_HS_TX_TIMEOUT (_MIPI_MMIO_BASE(dev_priv) + 0xb010) 172 + #define _MIPIC_HS_TX_TIMEOUT (_MIPI_MMIO_BASE(dev_priv) + 0xb810) 175 173 #define MIPI_HS_TX_TIMEOUT(port) _MMIO_MIPI(port, _MIPIA_HS_TX_TIMEOUT, _MIPIC_HS_TX_TIMEOUT) 176 174 #define HIGH_SPEED_TX_TIMEOUT_COUNTER_MASK 0xffffff 177 175 178 - #define _MIPIA_LP_RX_TIMEOUT (dev_priv->mipi_mmio_base + 0xb014) 179 - #define _MIPIC_LP_RX_TIMEOUT (dev_priv->mipi_mmio_base + 0xb814) 176 + #define _MIPIA_LP_RX_TIMEOUT (_MIPI_MMIO_BASE(dev_priv) + 0xb014) 177 + #define _MIPIC_LP_RX_TIMEOUT (_MIPI_MMIO_BASE(dev_priv) + 0xb814) 180 178 #define MIPI_LP_RX_TIMEOUT(port) _MMIO_MIPI(port, _MIPIA_LP_RX_TIMEOUT, _MIPIC_LP_RX_TIMEOUT) 181 179 #define LOW_POWER_RX_TIMEOUT_COUNTER_MASK 0xffffff 182 180 183 - #define _MIPIA_TURN_AROUND_TIMEOUT (dev_priv->mipi_mmio_base + 0xb018) 184 - #define _MIPIC_TURN_AROUND_TIMEOUT (dev_priv->mipi_mmio_base + 0xb818) 181 + #define _MIPIA_TURN_AROUND_TIMEOUT (_MIPI_MMIO_BASE(dev_priv) + 0xb018) 182 + #define _MIPIC_TURN_AROUND_TIMEOUT (_MIPI_MMIO_BASE(dev_priv) + 0xb818) 185 183 #define MIPI_TURN_AROUND_TIMEOUT(port) _MMIO_MIPI(port, _MIPIA_TURN_AROUND_TIMEOUT, _MIPIC_TURN_AROUND_TIMEOUT) 186 184 #define TURN_AROUND_TIMEOUT_MASK 0x3f 187 185 188 - #define _MIPIA_DEVICE_RESET_TIMER (dev_priv->mipi_mmio_base + 0xb01c) 189 - #define _MIPIC_DEVICE_RESET_TIMER (dev_priv->mipi_mmio_base + 0xb81c) 186 + #define _MIPIA_DEVICE_RESET_TIMER (_MIPI_MMIO_BASE(dev_priv) + 0xb01c) 187 + #define _MIPIC_DEVICE_RESET_TIMER (_MIPI_MMIO_BASE(dev_priv) + 0xb81c) 190 188 #define MIPI_DEVICE_RESET_TIMER(port) _MMIO_MIPI(port, _MIPIA_DEVICE_RESET_TIMER, _MIPIC_DEVICE_RESET_TIMER) 191 189 #define DEVICE_RESET_TIMER_MASK 0xffff 192 190 193 - #define _MIPIA_DPI_RESOLUTION (dev_priv->mipi_mmio_base + 0xb020) 194 - #define _MIPIC_DPI_RESOLUTION (dev_priv->mipi_mmio_base + 0xb820) 191 + #define _MIPIA_DPI_RESOLUTION (_MIPI_MMIO_BASE(dev_priv) + 0xb020) 192 + #define _MIPIC_DPI_RESOLUTION (_MIPI_MMIO_BASE(dev_priv) + 0xb820) 195 193 #define MIPI_DPI_RESOLUTION(port) _MMIO_MIPI(port, _MIPIA_DPI_RESOLUTION, _MIPIC_DPI_RESOLUTION) 196 194 #define VERTICAL_ADDRESS_SHIFT 16 197 195 #define VERTICAL_ADDRESS_MASK (0xffff << 16) 198 196 #define HORIZONTAL_ADDRESS_SHIFT 0 199 197 #define HORIZONTAL_ADDRESS_MASK 0xffff 200 198 201 - #define _MIPIA_DBI_FIFO_THROTTLE (dev_priv->mipi_mmio_base + 0xb024) 202 - #define _MIPIC_DBI_FIFO_THROTTLE (dev_priv->mipi_mmio_base + 0xb824) 199 + #define _MIPIA_DBI_FIFO_THROTTLE (_MIPI_MMIO_BASE(dev_priv) + 0xb024) 200 + #define _MIPIC_DBI_FIFO_THROTTLE (_MIPI_MMIO_BASE(dev_priv) + 0xb824) 203 201 #define MIPI_DBI_FIFO_THROTTLE(port) _MMIO_MIPI(port, _MIPIA_DBI_FIFO_THROTTLE, _MIPIC_DBI_FIFO_THROTTLE) 204 202 #define DBI_FIFO_EMPTY_HALF (0 << 0) 205 203 #define DBI_FIFO_EMPTY_QUARTER (1 << 0) 206 204 #define DBI_FIFO_EMPTY_7_LOCATIONS (2 << 0) 207 205 208 206 /* regs below are bits 15:0 */ 209 - #define _MIPIA_HSYNC_PADDING_COUNT (dev_priv->mipi_mmio_base + 0xb028) 210 - #define _MIPIC_HSYNC_PADDING_COUNT (dev_priv->mipi_mmio_base + 0xb828) 207 + #define _MIPIA_HSYNC_PADDING_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb028) 208 + #define _MIPIC_HSYNC_PADDING_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb828) 211 209 #define MIPI_HSYNC_PADDING_COUNT(port) _MMIO_MIPI(port, _MIPIA_HSYNC_PADDING_COUNT, _MIPIC_HSYNC_PADDING_COUNT) 212 210 213 - #define _MIPIA_HBP_COUNT (dev_priv->mipi_mmio_base + 0xb02c) 214 - #define _MIPIC_HBP_COUNT (dev_priv->mipi_mmio_base + 0xb82c) 211 + #define _MIPIA_HBP_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb02c) 212 + #define _MIPIC_HBP_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb82c) 215 213 #define MIPI_HBP_COUNT(port) _MMIO_MIPI(port, _MIPIA_HBP_COUNT, _MIPIC_HBP_COUNT) 216 214 217 - #define _MIPIA_HFP_COUNT (dev_priv->mipi_mmio_base + 0xb030) 218 - #define _MIPIC_HFP_COUNT (dev_priv->mipi_mmio_base + 0xb830) 215 + #define _MIPIA_HFP_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb030) 216 + #define _MIPIC_HFP_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb830) 219 217 #define MIPI_HFP_COUNT(port) _MMIO_MIPI(port, _MIPIA_HFP_COUNT, _MIPIC_HFP_COUNT) 220 218 221 - #define _MIPIA_HACTIVE_AREA_COUNT (dev_priv->mipi_mmio_base + 0xb034) 222 - #define _MIPIC_HACTIVE_AREA_COUNT (dev_priv->mipi_mmio_base + 0xb834) 219 + #define _MIPIA_HACTIVE_AREA_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb034) 220 + #define _MIPIC_HACTIVE_AREA_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb834) 223 221 #define MIPI_HACTIVE_AREA_COUNT(port) _MMIO_MIPI(port, _MIPIA_HACTIVE_AREA_COUNT, _MIPIC_HACTIVE_AREA_COUNT) 224 222 225 - #define _MIPIA_VSYNC_PADDING_COUNT (dev_priv->mipi_mmio_base + 0xb038) 226 - #define _MIPIC_VSYNC_PADDING_COUNT (dev_priv->mipi_mmio_base + 0xb838) 223 + #define _MIPIA_VSYNC_PADDING_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb038) 224 + #define _MIPIC_VSYNC_PADDING_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb838) 227 225 #define MIPI_VSYNC_PADDING_COUNT(port) _MMIO_MIPI(port, _MIPIA_VSYNC_PADDING_COUNT, _MIPIC_VSYNC_PADDING_COUNT) 228 226 229 - #define _MIPIA_VBP_COUNT (dev_priv->mipi_mmio_base + 0xb03c) 230 - #define _MIPIC_VBP_COUNT (dev_priv->mipi_mmio_base + 0xb83c) 227 + #define _MIPIA_VBP_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb03c) 228 + #define _MIPIC_VBP_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb83c) 231 229 #define MIPI_VBP_COUNT(port) _MMIO_MIPI(port, _MIPIA_VBP_COUNT, _MIPIC_VBP_COUNT) 232 230 233 - #define _MIPIA_VFP_COUNT (dev_priv->mipi_mmio_base + 0xb040) 234 - #define _MIPIC_VFP_COUNT (dev_priv->mipi_mmio_base + 0xb840) 231 + #define _MIPIA_VFP_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb040) 232 + #define _MIPIC_VFP_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb840) 235 233 #define MIPI_VFP_COUNT(port) _MMIO_MIPI(port, _MIPIA_VFP_COUNT, _MIPIC_VFP_COUNT) 236 234 237 - #define _MIPIA_HIGH_LOW_SWITCH_COUNT (dev_priv->mipi_mmio_base + 0xb044) 238 - #define _MIPIC_HIGH_LOW_SWITCH_COUNT (dev_priv->mipi_mmio_base + 0xb844) 235 + #define _MIPIA_HIGH_LOW_SWITCH_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb044) 236 + #define _MIPIC_HIGH_LOW_SWITCH_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb844) 239 237 #define MIPI_HIGH_LOW_SWITCH_COUNT(port) _MMIO_MIPI(port, _MIPIA_HIGH_LOW_SWITCH_COUNT, _MIPIC_HIGH_LOW_SWITCH_COUNT) 240 238 241 - #define _MIPIA_DPI_CONTROL (dev_priv->mipi_mmio_base + 0xb048) 242 - #define _MIPIC_DPI_CONTROL (dev_priv->mipi_mmio_base + 0xb848) 239 + #define _MIPIA_DPI_CONTROL (_MIPI_MMIO_BASE(dev_priv) + 0xb048) 240 + #define _MIPIC_DPI_CONTROL (_MIPI_MMIO_BASE(dev_priv) + 0xb848) 243 241 #define MIPI_DPI_CONTROL(port) _MMIO_MIPI(port, _MIPIA_DPI_CONTROL, _MIPIC_DPI_CONTROL) 244 242 #define DPI_LP_MODE (1 << 6) 245 243 #define BACKLIGHT_OFF (1 << 5) ··· 249 247 #define TURN_ON (1 << 1) 250 248 #define SHUTDOWN (1 << 0) 251 249 252 - #define _MIPIA_DPI_DATA (dev_priv->mipi_mmio_base + 0xb04c) 253 - #define _MIPIC_DPI_DATA (dev_priv->mipi_mmio_base + 0xb84c) 250 + #define _MIPIA_DPI_DATA (_MIPI_MMIO_BASE(dev_priv) + 0xb04c) 251 + #define _MIPIC_DPI_DATA (_MIPI_MMIO_BASE(dev_priv) + 0xb84c) 254 252 #define MIPI_DPI_DATA(port) _MMIO_MIPI(port, _MIPIA_DPI_DATA, _MIPIC_DPI_DATA) 255 253 #define COMMAND_BYTE_SHIFT 0 256 254 #define COMMAND_BYTE_MASK (0x3f << 0) 257 255 258 - #define _MIPIA_INIT_COUNT (dev_priv->mipi_mmio_base + 0xb050) 259 - #define _MIPIC_INIT_COUNT (dev_priv->mipi_mmio_base + 0xb850) 256 + #define _MIPIA_INIT_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb050) 257 + #define _MIPIC_INIT_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb850) 260 258 #define MIPI_INIT_COUNT(port) _MMIO_MIPI(port, _MIPIA_INIT_COUNT, _MIPIC_INIT_COUNT) 261 259 #define MASTER_INIT_TIMER_SHIFT 0 262 260 #define MASTER_INIT_TIMER_MASK (0xffff << 0) 263 261 264 - #define _MIPIA_MAX_RETURN_PKT_SIZE (dev_priv->mipi_mmio_base + 0xb054) 265 - #define _MIPIC_MAX_RETURN_PKT_SIZE (dev_priv->mipi_mmio_base + 0xb854) 262 + #define _MIPIA_MAX_RETURN_PKT_SIZE (_MIPI_MMIO_BASE(dev_priv) + 0xb054) 263 + #define _MIPIC_MAX_RETURN_PKT_SIZE (_MIPI_MMIO_BASE(dev_priv) + 0xb854) 266 264 #define MIPI_MAX_RETURN_PKT_SIZE(port) _MMIO_MIPI(port, \ 267 265 _MIPIA_MAX_RETURN_PKT_SIZE, _MIPIC_MAX_RETURN_PKT_SIZE) 268 266 #define MAX_RETURN_PKT_SIZE_SHIFT 0 269 267 #define MAX_RETURN_PKT_SIZE_MASK (0x3ff << 0) 270 268 271 - #define _MIPIA_VIDEO_MODE_FORMAT (dev_priv->mipi_mmio_base + 0xb058) 272 - #define _MIPIC_VIDEO_MODE_FORMAT (dev_priv->mipi_mmio_base + 0xb858) 269 + #define _MIPIA_VIDEO_MODE_FORMAT (_MIPI_MMIO_BASE(dev_priv) + 0xb058) 270 + #define _MIPIC_VIDEO_MODE_FORMAT (_MIPI_MMIO_BASE(dev_priv) + 0xb858) 273 271 #define MIPI_VIDEO_MODE_FORMAT(port) _MMIO_MIPI(port, _MIPIA_VIDEO_MODE_FORMAT, _MIPIC_VIDEO_MODE_FORMAT) 274 272 #define RANDOM_DPI_DISPLAY_RESOLUTION (1 << 4) 275 273 #define DISABLE_VIDEO_BTA (1 << 3) ··· 278 276 #define VIDEO_MODE_NON_BURST_WITH_SYNC_EVENTS (2 << 0) 279 277 #define VIDEO_MODE_BURST (3 << 0) 280 278 281 - #define _MIPIA_EOT_DISABLE (dev_priv->mipi_mmio_base + 0xb05c) 282 - #define _MIPIC_EOT_DISABLE (dev_priv->mipi_mmio_base + 0xb85c) 279 + #define _MIPIA_EOT_DISABLE (_MIPI_MMIO_BASE(dev_priv) + 0xb05c) 280 + #define _MIPIC_EOT_DISABLE (_MIPI_MMIO_BASE(dev_priv) + 0xb85c) 283 281 #define MIPI_EOT_DISABLE(port) _MMIO_MIPI(port, _MIPIA_EOT_DISABLE, _MIPIC_EOT_DISABLE) 284 282 #define BXT_DEFEATURE_DPI_FIFO_CTR (1 << 9) 285 283 #define BXT_DPHY_DEFEATURE_EN (1 << 8) ··· 292 290 #define CLOCKSTOP (1 << 1) 293 291 #define EOT_DISABLE (1 << 0) 294 292 295 - #define _MIPIA_LP_BYTECLK (dev_priv->mipi_mmio_base + 0xb060) 296 - #define _MIPIC_LP_BYTECLK (dev_priv->mipi_mmio_base + 0xb860) 293 + #define _MIPIA_LP_BYTECLK (_MIPI_MMIO_BASE(dev_priv) + 0xb060) 294 + #define _MIPIC_LP_BYTECLK (_MIPI_MMIO_BASE(dev_priv) + 0xb860) 297 295 #define MIPI_LP_BYTECLK(port) _MMIO_MIPI(port, _MIPIA_LP_BYTECLK, _MIPIC_LP_BYTECLK) 298 296 #define LP_BYTECLK_SHIFT 0 299 297 #define LP_BYTECLK_MASK (0xffff << 0) 300 298 301 - #define _MIPIA_TLPX_TIME_COUNT (dev_priv->mipi_mmio_base + 0xb0a4) 302 - #define _MIPIC_TLPX_TIME_COUNT (dev_priv->mipi_mmio_base + 0xb8a4) 299 + #define _MIPIA_TLPX_TIME_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb0a4) 300 + #define _MIPIC_TLPX_TIME_COUNT (_MIPI_MMIO_BASE(dev_priv) + 0xb8a4) 303 301 #define MIPI_TLPX_TIME_COUNT(port) _MMIO_MIPI(port, _MIPIA_TLPX_TIME_COUNT, _MIPIC_TLPX_TIME_COUNT) 304 302 305 - #define _MIPIA_CLK_LANE_TIMING (dev_priv->mipi_mmio_base + 0xb098) 306 - #define _MIPIC_CLK_LANE_TIMING (dev_priv->mipi_mmio_base + 0xb898) 303 + #define _MIPIA_CLK_LANE_TIMING (_MIPI_MMIO_BASE(dev_priv) + 0xb098) 304 + #define _MIPIC_CLK_LANE_TIMING (_MIPI_MMIO_BASE(dev_priv) + 0xb898) 307 305 #define MIPI_CLK_LANE_TIMING(port) _MMIO_MIPI(port, _MIPIA_CLK_LANE_TIMING, _MIPIC_CLK_LANE_TIMING) 308 306 309 307 /* bits 31:0 */ 310 - #define _MIPIA_LP_GEN_DATA (dev_priv->mipi_mmio_base + 0xb064) 311 - #define _MIPIC_LP_GEN_DATA (dev_priv->mipi_mmio_base + 0xb864) 308 + #define _MIPIA_LP_GEN_DATA (_MIPI_MMIO_BASE(dev_priv) + 0xb064) 309 + #define _MIPIC_LP_GEN_DATA (_MIPI_MMIO_BASE(dev_priv) + 0xb864) 312 310 #define MIPI_LP_GEN_DATA(port) _MMIO_MIPI(port, _MIPIA_LP_GEN_DATA, _MIPIC_LP_GEN_DATA) 313 311 314 312 /* bits 31:0 */ 315 - #define _MIPIA_HS_GEN_DATA (dev_priv->mipi_mmio_base + 0xb068) 316 - #define _MIPIC_HS_GEN_DATA (dev_priv->mipi_mmio_base + 0xb868) 313 + #define _MIPIA_HS_GEN_DATA (_MIPI_MMIO_BASE(dev_priv) + 0xb068) 314 + #define _MIPIC_HS_GEN_DATA (_MIPI_MMIO_BASE(dev_priv) + 0xb868) 317 315 #define MIPI_HS_GEN_DATA(port) _MMIO_MIPI(port, _MIPIA_HS_GEN_DATA, _MIPIC_HS_GEN_DATA) 318 316 319 - #define _MIPIA_LP_GEN_CTRL (dev_priv->mipi_mmio_base + 0xb06c) 320 - #define _MIPIC_LP_GEN_CTRL (dev_priv->mipi_mmio_base + 0xb86c) 317 + #define _MIPIA_LP_GEN_CTRL (_MIPI_MMIO_BASE(dev_priv) + 0xb06c) 318 + #define _MIPIC_LP_GEN_CTRL (_MIPI_MMIO_BASE(dev_priv) + 0xb86c) 321 319 #define MIPI_LP_GEN_CTRL(port) _MMIO_MIPI(port, _MIPIA_LP_GEN_CTRL, _MIPIC_LP_GEN_CTRL) 322 - #define _MIPIA_HS_GEN_CTRL (dev_priv->mipi_mmio_base + 0xb070) 323 - #define _MIPIC_HS_GEN_CTRL (dev_priv->mipi_mmio_base + 0xb870) 320 + #define _MIPIA_HS_GEN_CTRL (_MIPI_MMIO_BASE(dev_priv) + 0xb070) 321 + #define _MIPIC_HS_GEN_CTRL (_MIPI_MMIO_BASE(dev_priv) + 0xb870) 324 322 #define MIPI_HS_GEN_CTRL(port) _MMIO_MIPI(port, _MIPIA_HS_GEN_CTRL, _MIPIC_HS_GEN_CTRL) 325 323 #define LONG_PACKET_WORD_COUNT_SHIFT 8 326 324 #define LONG_PACKET_WORD_COUNT_MASK (0xffff << 8) ··· 332 330 #define DATA_TYPE_MASK (0x3f << 0) 333 331 /* data type values, see include/video/mipi_display.h */ 334 332 335 - #define _MIPIA_GEN_FIFO_STAT (dev_priv->mipi_mmio_base + 0xb074) 336 - #define _MIPIC_GEN_FIFO_STAT (dev_priv->mipi_mmio_base + 0xb874) 333 + #define _MIPIA_GEN_FIFO_STAT (_MIPI_MMIO_BASE(dev_priv) + 0xb074) 334 + #define _MIPIC_GEN_FIFO_STAT (_MIPI_MMIO_BASE(dev_priv) + 0xb874) 337 335 #define MIPI_GEN_FIFO_STAT(port) _MMIO_MIPI(port, _MIPIA_GEN_FIFO_STAT, _MIPIC_GEN_FIFO_STAT) 338 336 #define DPI_FIFO_EMPTY (1 << 28) 339 337 #define DBI_FIFO_EMPTY (1 << 27) ··· 350 348 #define HS_DATA_FIFO_HALF_EMPTY (1 << 1) 351 349 #define HS_DATA_FIFO_FULL (1 << 0) 352 350 353 - #define _MIPIA_HS_LS_DBI_ENABLE (dev_priv->mipi_mmio_base + 0xb078) 354 - #define _MIPIC_HS_LS_DBI_ENABLE (dev_priv->mipi_mmio_base + 0xb878) 351 + #define _MIPIA_HS_LS_DBI_ENABLE (_MIPI_MMIO_BASE(dev_priv) + 0xb078) 352 + #define _MIPIC_HS_LS_DBI_ENABLE (_MIPI_MMIO_BASE(dev_priv) + 0xb878) 355 353 #define MIPI_HS_LP_DBI_ENABLE(port) _MMIO_MIPI(port, _MIPIA_HS_LS_DBI_ENABLE, _MIPIC_HS_LS_DBI_ENABLE) 356 354 #define DBI_HS_LP_MODE_MASK (1 << 0) 357 355 #define DBI_LP_MODE (1 << 0) 358 356 #define DBI_HS_MODE (0 << 0) 359 357 360 - #define _MIPIA_DPHY_PARAM (dev_priv->mipi_mmio_base + 0xb080) 361 - #define _MIPIC_DPHY_PARAM (dev_priv->mipi_mmio_base + 0xb880) 358 + #define _MIPIA_DPHY_PARAM (_MIPI_MMIO_BASE(dev_priv) + 0xb080) 359 + #define _MIPIC_DPHY_PARAM (_MIPI_MMIO_BASE(dev_priv) + 0xb880) 362 360 #define MIPI_DPHY_PARAM(port) _MMIO_MIPI(port, _MIPIA_DPHY_PARAM, _MIPIC_DPHY_PARAM) 363 361 #define EXIT_ZERO_COUNT_SHIFT 24 364 362 #define EXIT_ZERO_COUNT_MASK (0x3f << 24) ··· 369 367 #define PREPARE_COUNT_SHIFT 0 370 368 #define PREPARE_COUNT_MASK (0x3f << 0) 371 369 372 - #define _MIPIA_DBI_BW_CTRL (dev_priv->mipi_mmio_base + 0xb084) 373 - #define _MIPIC_DBI_BW_CTRL (dev_priv->mipi_mmio_base + 0xb884) 370 + #define _MIPIA_DBI_BW_CTRL (_MIPI_MMIO_BASE(dev_priv) + 0xb084) 371 + #define _MIPIC_DBI_BW_CTRL (_MIPI_MMIO_BASE(dev_priv) + 0xb884) 374 372 #define MIPI_DBI_BW_CTRL(port) _MMIO_MIPI(port, _MIPIA_DBI_BW_CTRL, _MIPIC_DBI_BW_CTRL) 375 373 376 - #define _MIPIA_CLK_LANE_SWITCH_TIME_CNT (dev_priv->mipi_mmio_base + 0xb088) 377 - #define _MIPIC_CLK_LANE_SWITCH_TIME_CNT (dev_priv->mipi_mmio_base + 0xb888) 374 + #define _MIPIA_CLK_LANE_SWITCH_TIME_CNT (_MIPI_MMIO_BASE(dev_priv) + 0xb088) 375 + #define _MIPIC_CLK_LANE_SWITCH_TIME_CNT (_MIPI_MMIO_BASE(dev_priv) + 0xb888) 378 376 #define MIPI_CLK_LANE_SWITCH_TIME_CNT(port) _MMIO_MIPI(port, _MIPIA_CLK_LANE_SWITCH_TIME_CNT, _MIPIC_CLK_LANE_SWITCH_TIME_CNT) 379 377 #define LP_HS_SSW_CNT_SHIFT 16 380 378 #define LP_HS_SSW_CNT_MASK (0xffff << 16) 381 379 #define HS_LP_PWR_SW_CNT_SHIFT 0 382 380 #define HS_LP_PWR_SW_CNT_MASK (0xffff << 0) 383 381 384 - #define _MIPIA_STOP_STATE_STALL (dev_priv->mipi_mmio_base + 0xb08c) 385 - #define _MIPIC_STOP_STATE_STALL (dev_priv->mipi_mmio_base + 0xb88c) 382 + #define _MIPIA_STOP_STATE_STALL (_MIPI_MMIO_BASE(dev_priv) + 0xb08c) 383 + #define _MIPIC_STOP_STATE_STALL (_MIPI_MMIO_BASE(dev_priv) + 0xb88c) 386 384 #define MIPI_STOP_STATE_STALL(port) _MMIO_MIPI(port, _MIPIA_STOP_STATE_STALL, _MIPIC_STOP_STATE_STALL) 387 385 #define STOP_STATE_STALL_COUNTER_SHIFT 0 388 386 #define STOP_STATE_STALL_COUNTER_MASK (0xff << 0) 389 387 390 - #define _MIPIA_INTR_STAT_REG_1 (dev_priv->mipi_mmio_base + 0xb090) 391 - #define _MIPIC_INTR_STAT_REG_1 (dev_priv->mipi_mmio_base + 0xb890) 388 + #define _MIPIA_INTR_STAT_REG_1 (_MIPI_MMIO_BASE(dev_priv) + 0xb090) 389 + #define _MIPIC_INTR_STAT_REG_1 (_MIPI_MMIO_BASE(dev_priv) + 0xb890) 392 390 #define MIPI_INTR_STAT_REG_1(port) _MMIO_MIPI(port, _MIPIA_INTR_STAT_REG_1, _MIPIC_INTR_STAT_REG_1) 393 - #define _MIPIA_INTR_EN_REG_1 (dev_priv->mipi_mmio_base + 0xb094) 394 - #define _MIPIC_INTR_EN_REG_1 (dev_priv->mipi_mmio_base + 0xb894) 391 + #define _MIPIA_INTR_EN_REG_1 (_MIPI_MMIO_BASE(dev_priv) + 0xb094) 392 + #define _MIPIC_INTR_EN_REG_1 (_MIPI_MMIO_BASE(dev_priv) + 0xb894) 395 393 #define MIPI_INTR_EN_REG_1(port) _MMIO_MIPI(port, _MIPIA_INTR_EN_REG_1, _MIPIC_INTR_EN_REG_1) 396 394 #define RX_CONTENTION_DETECTED (1 << 0) 397 395 398 396 /* XXX: only pipe A ?!? */ 399 - #define MIPIA_DBI_TYPEC_CTRL (dev_priv->mipi_mmio_base + 0xb100) 397 + #define MIPIA_DBI_TYPEC_CTRL (_MIPI_MMIO_BASE(dev_priv) + 0xb100) 400 398 #define DBI_TYPEC_ENABLE (1 << 31) 401 399 #define DBI_TYPEC_WIP (1 << 30) 402 400 #define DBI_TYPEC_OPTION_SHIFT 28 ··· 409 407 410 408 /* MIPI adapter registers */ 411 409 412 - #define _MIPIA_CTRL (dev_priv->mipi_mmio_base + 0xb104) 413 - #define _MIPIC_CTRL (dev_priv->mipi_mmio_base + 0xb904) 410 + #define _MIPIA_CTRL (_MIPI_MMIO_BASE(dev_priv) + 0xb104) 411 + #define _MIPIC_CTRL (_MIPI_MMIO_BASE(dev_priv) + 0xb904) 414 412 #define MIPI_CTRL(port) _MMIO_MIPI(port, _MIPIA_CTRL, _MIPIC_CTRL) 415 413 #define ESCAPE_CLOCK_DIVIDER_SHIFT 5 /* A only */ 416 414 #define ESCAPE_CLOCK_DIVIDER_MASK (3 << 5) ··· 442 440 #define GLK_MIPIIO_PORT_POWERED (1 << 1) /* RO */ 443 441 #define GLK_MIPIIO_ENABLE (1 << 0) 444 442 445 - #define _MIPIA_DATA_ADDRESS (dev_priv->mipi_mmio_base + 0xb108) 446 - #define _MIPIC_DATA_ADDRESS (dev_priv->mipi_mmio_base + 0xb908) 443 + #define _MIPIA_DATA_ADDRESS (_MIPI_MMIO_BASE(dev_priv) + 0xb108) 444 + #define _MIPIC_DATA_ADDRESS (_MIPI_MMIO_BASE(dev_priv) + 0xb908) 447 445 #define MIPI_DATA_ADDRESS(port) _MMIO_MIPI(port, _MIPIA_DATA_ADDRESS, _MIPIC_DATA_ADDRESS) 448 446 #define DATA_MEM_ADDRESS_SHIFT 5 449 447 #define DATA_MEM_ADDRESS_MASK (0x7ffffff << 5) 450 448 #define DATA_VALID (1 << 0) 451 449 452 - #define _MIPIA_DATA_LENGTH (dev_priv->mipi_mmio_base + 0xb10c) 453 - #define _MIPIC_DATA_LENGTH (dev_priv->mipi_mmio_base + 0xb90c) 450 + #define _MIPIA_DATA_LENGTH (_MIPI_MMIO_BASE(dev_priv) + 0xb10c) 451 + #define _MIPIC_DATA_LENGTH (_MIPI_MMIO_BASE(dev_priv) + 0xb90c) 454 452 #define MIPI_DATA_LENGTH(port) _MMIO_MIPI(port, _MIPIA_DATA_LENGTH, _MIPIC_DATA_LENGTH) 455 453 #define DATA_LENGTH_SHIFT 0 456 454 #define DATA_LENGTH_MASK (0xfffff << 0) 457 455 458 - #define _MIPIA_COMMAND_ADDRESS (dev_priv->mipi_mmio_base + 0xb110) 459 - #define _MIPIC_COMMAND_ADDRESS (dev_priv->mipi_mmio_base + 0xb910) 456 + #define _MIPIA_COMMAND_ADDRESS (_MIPI_MMIO_BASE(dev_priv) + 0xb110) 457 + #define _MIPIC_COMMAND_ADDRESS (_MIPI_MMIO_BASE(dev_priv) + 0xb910) 460 458 #define MIPI_COMMAND_ADDRESS(port) _MMIO_MIPI(port, _MIPIA_COMMAND_ADDRESS, _MIPIC_COMMAND_ADDRESS) 461 459 #define COMMAND_MEM_ADDRESS_SHIFT 5 462 460 #define COMMAND_MEM_ADDRESS_MASK (0x7ffffff << 5) ··· 464 462 #define MEMORY_WRITE_DATA_FROM_PIPE_RENDERING (1 << 1) 465 463 #define COMMAND_VALID (1 << 0) 466 464 467 - #define _MIPIA_COMMAND_LENGTH (dev_priv->mipi_mmio_base + 0xb114) 468 - #define _MIPIC_COMMAND_LENGTH (dev_priv->mipi_mmio_base + 0xb914) 465 + #define _MIPIA_COMMAND_LENGTH (_MIPI_MMIO_BASE(dev_priv) + 0xb114) 466 + #define _MIPIC_COMMAND_LENGTH (_MIPI_MMIO_BASE(dev_priv) + 0xb914) 469 467 #define MIPI_COMMAND_LENGTH(port) _MMIO_MIPI(port, _MIPIA_COMMAND_LENGTH, _MIPIC_COMMAND_LENGTH) 470 468 #define COMMAND_LENGTH_SHIFT(n) (8 * (n)) /* n: 0...3 */ 471 469 #define COMMAND_LENGTH_MASK(n) (0xff << (8 * (n))) 472 470 473 - #define _MIPIA_READ_DATA_RETURN0 (dev_priv->mipi_mmio_base + 0xb118) 474 - #define _MIPIC_READ_DATA_RETURN0 (dev_priv->mipi_mmio_base + 0xb918) 471 + #define _MIPIA_READ_DATA_RETURN0 (_MIPI_MMIO_BASE(dev_priv) + 0xb118) 472 + #define _MIPIC_READ_DATA_RETURN0 (_MIPI_MMIO_BASE(dev_priv) + 0xb918) 475 473 #define MIPI_READ_DATA_RETURN(port, n) _MMIO(_MIPI(port, _MIPIA_READ_DATA_RETURN0, _MIPIC_READ_DATA_RETURN0) + 4 * (n)) /* n: 0...7 */ 476 474 477 - #define _MIPIA_READ_DATA_VALID (dev_priv->mipi_mmio_base + 0xb138) 478 - #define _MIPIC_READ_DATA_VALID (dev_priv->mipi_mmio_base + 0xb938) 475 + #define _MIPIA_READ_DATA_VALID (_MIPI_MMIO_BASE(dev_priv) + 0xb138) 476 + #define _MIPIC_READ_DATA_VALID (_MIPI_MMIO_BASE(dev_priv) + 0xb938) 479 477 #define MIPI_READ_DATA_VALID(port) _MMIO_MIPI(port, _MIPIA_READ_DATA_VALID, _MIPIC_READ_DATA_VALID) 480 478 #define READ_DATA_VALID(n) (1 << (n)) 481 479
+2 -2
drivers/gpu/drm/i915/gt/intel_gt_pm_debugfs.c
··· 504 504 drm_puts(p, "no P-state info available\n"); 505 505 } 506 506 507 - drm_printf(p, "Current CD clock frequency: %d kHz\n", i915->cdclk.hw.cdclk); 508 - drm_printf(p, "Max CD clock frequency: %d kHz\n", i915->max_cdclk_freq); 507 + drm_printf(p, "Current CD clock frequency: %d kHz\n", i915->display.cdclk.hw.cdclk); 508 + drm_printf(p, "Max CD clock frequency: %d kHz\n", i915->display.cdclk.max_cdclk_freq); 509 509 drm_printf(p, "Max pixel clock frequency: %d kHz\n", i915->max_dotclk_freq); 510 510 511 511 intel_runtime_pm_put(uncore->rpm, wakeref);
+2 -1
drivers/gpu/drm/i915/gvt/edid.c
··· 32 32 * 33 33 */ 34 34 35 + #include "display/intel_gmbus_regs.h" 36 + #include "gvt.h" 35 37 #include "i915_drv.h" 36 38 #include "i915_reg.h" 37 - #include "gvt.h" 38 39 39 40 #define GMBUS1_TOTAL_BYTES_SHIFT 16 40 41 #define GMBUS1_TOTAL_BYTES_MASK 0x1ff
+1 -1
drivers/gpu/drm/i915/i915_debugfs.c
··· 492 492 seq_puts(m, "Runtime power management not supported\n"); 493 493 494 494 seq_printf(m, "Runtime power status: %s\n", 495 - str_enabled_disabled(!dev_priv->power_domains.init_wakeref)); 495 + str_enabled_disabled(!dev_priv->display.power.domains.init_wakeref)); 496 496 497 497 seq_printf(m, "GPU idle: %s\n", str_yes_no(!to_gt(dev_priv)->awake)); 498 498 seq_printf(m, "IRQs disabled: %s\n",
+12 -7
drivers/gpu/drm/i915/i915_driver.c
··· 61 61 #include "display/intel_pps.h" 62 62 #include "display/intel_sprite.h" 63 63 #include "display/intel_vga.h" 64 + #include "display/skl_watermark.h" 64 65 65 66 #include "gem/i915_gem_context.h" 66 67 #include "gem/i915_gem_create.h" ··· 344 343 345 344 spin_lock_init(&dev_priv->irq_lock); 346 345 spin_lock_init(&dev_priv->gpu_error.lock); 347 - mutex_init(&dev_priv->backlight_lock); 346 + mutex_init(&dev_priv->display.backlight.lock); 348 347 349 348 mutex_init(&dev_priv->sb_lock); 350 349 cpu_latency_qos_add_request(&dev_priv->sb_qos, PM_QOS_DEFAULT_VALUE); ··· 352 351 mutex_init(&dev_priv->display.audio.mutex); 353 352 mutex_init(&dev_priv->display.wm.wm_mutex); 354 353 mutex_init(&dev_priv->display.pps.mutex); 355 - mutex_init(&dev_priv->hdcp_comp_mutex); 354 + mutex_init(&dev_priv->display.hdcp.comp_mutex); 356 355 357 356 i915_memcpy_init_early(dev_priv); 358 357 intel_runtime_pm_init_early(&dev_priv->runtime_pm); ··· 987 986 988 987 void i915_driver_remove(struct drm_i915_private *i915) 989 988 { 990 - disable_rpm_wakeref_asserts(&i915->runtime_pm); 989 + intel_wakeref_t wakeref; 990 + 991 + wakeref = intel_runtime_pm_get(&i915->runtime_pm); 991 992 992 993 i915_driver_unregister(i915); 993 994 ··· 1013 1010 1014 1011 i915_driver_hw_remove(i915); 1015 1012 1016 - enable_rpm_wakeref_asserts(&i915->runtime_pm); 1013 + intel_runtime_pm_put(&i915->runtime_pm, wakeref); 1017 1014 } 1018 1015 1019 1016 static void i915_driver_release(struct drm_device *dev) 1020 1017 { 1021 1018 struct drm_i915_private *dev_priv = to_i915(dev); 1022 1019 struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; 1020 + intel_wakeref_t wakeref; 1023 1021 1024 1022 if (!dev_priv->do_release) 1025 1023 return; 1026 1024 1027 - disable_rpm_wakeref_asserts(rpm); 1025 + wakeref = intel_runtime_pm_get(rpm); 1028 1026 1029 1027 i915_gem_driver_release(dev_priv); 1030 1028 ··· 1036 1032 1037 1033 i915_driver_mmio_release(dev_priv); 1038 1034 1039 - enable_rpm_wakeref_asserts(rpm); 1035 + intel_runtime_pm_put(rpm, wakeref); 1036 + 1040 1037 intel_runtime_pm_driver_release(rpm); 1041 1038 1042 1039 i915_driver_late_release(dev_priv); ··· 1756 1751 intel_hpd_poll_disable(dev_priv); 1757 1752 } 1758 1753 1759 - intel_enable_ipc(dev_priv); 1754 + skl_watermark_ipc_update(dev_priv); 1760 1755 1761 1756 enable_rpm_wakeref_asserts(rpm); 1762 1757
+14 -231
drivers/gpu/drm/i915/i915_drv.h
··· 34 34 35 35 #include <linux/pm_qos.h> 36 36 37 - #include <drm/drm_connector.h> 38 37 #include <drm/ttm/ttm_device.h> 39 38 40 - #include "display/intel_cdclk.h" 41 39 #include "display/intel_display.h" 42 40 #include "display/intel_display_core.h" 43 - #include "display/intel_display_power.h" 44 - #include "display/intel_dsb.h" 45 - #include "display/intel_fbc.h" 46 - #include "display/intel_frontbuffer.h" 47 - #include "display/intel_global_state.h" 48 - #include "display/intel_opregion.h" 49 41 50 42 #include "gem/i915_gem_context_types.h" 51 43 #include "gem/i915_gem_lmem.h" ··· 68 76 struct drm_i915_clock_gating_funcs; 69 77 struct drm_i915_gem_object; 70 78 struct drm_i915_private; 71 - struct intel_cdclk_config; 72 - struct intel_cdclk_state; 73 - struct intel_cdclk_vals; 74 79 struct intel_connector; 75 80 struct intel_dp; 76 81 struct intel_encoder; ··· 85 96 I915_GEM_DOMAIN_INSTRUCTION | \ 86 97 I915_GEM_DOMAIN_VERTEX) 87 98 88 - struct sdvo_device_mapping { 89 - u8 initialized; 90 - u8 dvo_port; 91 - u8 slave_addr; 92 - u8 dvo_wiring; 93 - u8 i2c_pin; 94 - u8 ddc_pin; 95 - }; 96 - 97 99 #define I915_COLOR_UNEVICTABLE (-1) /* a non-vma sharing the address space */ 98 100 99 101 #define GEM_QUIRK_PIN_SWIZZLED_PAGES BIT(0) 100 - 101 - #define QUIRK_LVDS_SSC_DISABLE (1<<1) 102 - #define QUIRK_INVERT_BRIGHTNESS (1<<2) 103 - #define QUIRK_BACKLIGHT_PRESENT (1<<3) 104 - #define QUIRK_INCREASE_T12_DELAY (1<<6) 105 - #define QUIRK_INCREASE_DDI_DISABLED_TIME (1<<7) 106 - #define QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK (1<<8) 107 102 108 103 struct i915_suspend_saved_registers { 109 104 u32 saveDSPARB; ··· 177 204 return i915_fence_context_timeout(i915, U64_MAX); 178 205 } 179 206 180 - /* Amount of SAGV/QGV points, BSpec precisely defines this */ 181 - #define I915_NUM_QGV_POINTS 8 182 - 183 207 #define HAS_HW_SAGV_WM(i915) (DISPLAY_VER(i915) >= 13 && !IS_DGFX(i915)) 184 - 185 - /* Amount of PSF GV points, BSpec precisely defines this */ 186 - #define I915_NUM_PSF_GV_POINTS 3 187 - 188 - struct intel_vbt_data { 189 - /* bdb version */ 190 - u16 version; 191 - 192 - /* Feature bits */ 193 - unsigned int int_tv_support:1; 194 - unsigned int int_crt_support:1; 195 - unsigned int lvds_use_ssc:1; 196 - unsigned int int_lvds_support:1; 197 - unsigned int display_clock_mode:1; 198 - unsigned int fdi_rx_polarity_inverted:1; 199 - int lvds_ssc_freq; 200 - enum drm_panel_orientation orientation; 201 - 202 - bool override_afc_startup; 203 - u8 override_afc_startup_val; 204 - 205 - int crt_ddc_pin; 206 - 207 - struct list_head display_devices; 208 - struct list_head bdb_blocks; 209 - 210 - struct intel_bios_encoder_data *ports[I915_MAX_PORTS]; /* Non-NULL if port present. */ 211 - struct sdvo_device_mapping sdvo_mappings[2]; 212 - }; 213 - 214 - struct i915_frontbuffer_tracking { 215 - spinlock_t lock; 216 - 217 - /* 218 - * Tracking bits for delayed frontbuffer flushing du to gpu activity or 219 - * scheduled flips. 220 - */ 221 - unsigned busy_bits; 222 - unsigned flip_bits; 223 - }; 224 208 225 209 struct i915_virtual_gpu { 226 210 struct mutex lock; /* serialises sending of g2v_notify command pkts */ ··· 241 311 242 312 struct intel_wopcm wopcm; 243 313 244 - /* MMIO base address for MIPI regs */ 245 - u32 mipi_mmio_base; 246 - 247 314 struct pci_dev *bridge_dev; 248 315 249 316 struct rb_root uabi_engines; ··· 264 337 }; 265 338 u32 pipestat_irq_mask[I915_MAX_PIPES]; 266 339 267 - struct intel_fbc *fbc[I915_MAX_FBCS]; 268 - struct intel_opregion opregion; 269 - struct intel_vbt_data vbt; 270 - 271 340 bool preserve_bios_swizzle; 272 - 273 - /* backlight registers and fields in struct intel_panel */ 274 - struct mutex backlight_lock; 275 341 276 342 unsigned int fsb_freq, mem_freq, is_ddr3; 277 343 unsigned int skl_preferred_vco_freq; 278 - unsigned int max_cdclk_freq; 279 344 280 345 unsigned int max_dotclk_freq; 281 346 unsigned int hpll_freq; 282 - unsigned int fdi_pll_freq; 283 347 unsigned int czclk_freq; 284 - 285 - struct { 286 - /* The current hardware cdclk configuration */ 287 - struct intel_cdclk_config hw; 288 - 289 - /* cdclk, divider, and ratio table from bspec */ 290 - const struct intel_cdclk_vals *table; 291 - 292 - struct intel_global_obj obj; 293 - } cdclk; 294 - 295 - struct { 296 - /* The current hardware dbuf configuration */ 297 - u8 enabled_slices; 298 - 299 - struct intel_global_obj obj; 300 - } dbuf; 301 348 302 349 /** 303 350 * wq - Driver workqueue for GEM. ··· 282 381 */ 283 382 struct workqueue_struct *wq; 284 383 285 - /* ordered wq for modesets */ 286 - struct workqueue_struct *modeset_wq; 287 - /* unbound hipri wq for page flips/plane updates */ 288 - struct workqueue_struct *flip_wq; 289 - 290 384 /* pm private clock gating functions */ 291 385 const struct drm_i915_clock_gating_funcs *clock_gating_funcs; 292 386 ··· 290 394 unsigned short pch_id; 291 395 292 396 unsigned long gem_quirks; 293 - unsigned long quirks; 294 397 295 398 struct drm_atomic_state *modeset_restore_state; 296 399 struct drm_modeset_acquire_ctx reset_ctx; ··· 299 404 /* Kernel Modesetting */ 300 405 301 406 struct list_head global_obj_list; 302 - 303 - struct i915_frontbuffer_tracking fb_tracking; 304 - 305 - struct intel_atomic_helper { 306 - struct llist_head free_list; 307 - struct work_struct free_work; 308 - } atomic_helper; 309 407 310 408 bool mchbar_need_disable; 311 409 ··· 318 430 */ 319 431 u32 edram_size_mb; 320 432 321 - struct i915_power_domains power_domains; 322 - 323 433 struct i915_gpu_error gpu_error; 324 434 325 - struct drm_property *broadcast_rgb_property; 326 - struct drm_property *force_audio_property; 327 - 328 - u32 fdi_rx_config; 329 - 330 - /* Shadow for DISPLAY_PHY_CONTROL which can't be safely read */ 331 - u32 chv_phy_control; 332 435 /* 333 436 * Shadows for CHV DPLL_MD regs to keep the state 334 437 * checker somewhat working in the presence hardware ··· 348 469 u8 num_qgv_points; 349 470 u8 num_psf_gv_points; 350 471 } dram_info; 351 - 352 - struct intel_bw_info { 353 - /* for each QGV point */ 354 - unsigned int deratedbw[I915_NUM_QGV_POINTS]; 355 - /* for each PSF GV point */ 356 - unsigned int psf_bw[I915_NUM_PSF_GV_POINTS]; 357 - u8 num_qgv_points; 358 - u8 num_psf_gv_points; 359 - u8 num_planes; 360 - } max_bw[6]; 361 - 362 - struct intel_global_obj bw_obj; 363 472 364 473 struct intel_runtime_pm runtime_pm; 365 474 ··· 391 524 392 525 bool irq_enabled; 393 526 394 - union { 395 - /* perform PHY state sanity checks? */ 396 - bool chv_phy_assert[2]; 397 - 398 - /* 399 - * DG2: Mask of PHYs that were not calibrated by the firmware 400 - * and should not be used. 401 - */ 402 - u8 snps_phy_failed_calibration; 403 - }; 527 + /* 528 + * DG2: Mask of PHYs that were not calibrated by the firmware 529 + * and should not be used. 530 + */ 531 + u8 snps_phy_failed_calibration; 404 532 405 533 bool ipc_enabled; 406 534 407 535 struct i915_pmu pmu; 408 536 409 537 struct i915_drm_clients clients; 410 - 411 - struct i915_hdcp_comp_master *hdcp_master; 412 - bool hdcp_comp_added; 413 - 414 - /* Mutex to protect the above hdcp component related values. */ 415 - struct mutex hdcp_comp_mutex; 416 538 417 539 /* The TTM device structure. */ 418 540 struct ttm_device bdev; ··· 461 605 (engine__) && (engine__)->uabi_class == (class__); \ 462 606 (engine__) = rb_to_uabi_engine(rb_next(&(engine__)->uabi_node))) 463 607 464 - #define I915_GTT_OFFSET_NONE ((u32)-1) 465 - 466 608 #define INTEL_INFO(dev_priv) (&(dev_priv)->__info) 467 609 #define RUNTIME_INFO(dev_priv) (&(dev_priv)->__runtime) 468 610 #define DRIVER_CAPS(dev_priv) (&(dev_priv)->caps) ··· 469 615 470 616 #define IP_VER(ver, rel) ((ver) << 8 | (rel)) 471 617 472 - #define GRAPHICS_VER(i915) (RUNTIME_INFO(i915)->graphics.ver) 473 - #define GRAPHICS_VER_FULL(i915) IP_VER(RUNTIME_INFO(i915)->graphics.ver, \ 474 - RUNTIME_INFO(i915)->graphics.rel) 618 + #define GRAPHICS_VER(i915) (RUNTIME_INFO(i915)->graphics.ip.ver) 619 + #define GRAPHICS_VER_FULL(i915) IP_VER(RUNTIME_INFO(i915)->graphics.ip.ver, \ 620 + RUNTIME_INFO(i915)->graphics.ip.rel) 475 621 #define IS_GRAPHICS_VER(i915, from, until) \ 476 622 (GRAPHICS_VER(i915) >= (from) && GRAPHICS_VER(i915) <= (until)) 477 623 478 - #define MEDIA_VER(i915) (INTEL_INFO(i915)->media.ver) 479 - #define MEDIA_VER_FULL(i915) IP_VER(INTEL_INFO(i915)->media.ver, \ 480 - INTEL_INFO(i915)->media.rel) 624 + #define MEDIA_VER(i915) (RUNTIME_INFO(i915)->media.ip.ver) 625 + #define MEDIA_VER_FULL(i915) IP_VER(RUNTIME_INFO(i915)->media.ip.ver, \ 626 + RUNTIME_INFO(i915)->media.ip.rel) 481 627 #define IS_MEDIA_VER(i915, from, until) \ 482 628 (MEDIA_VER(i915) >= (from) && MEDIA_VER(i915) <= (until)) 483 629 484 - #define DISPLAY_VER(i915) (INTEL_INFO(i915)->display.ver) 630 + #define DISPLAY_VER(i915) (RUNTIME_INFO(i915)->display.ip.ver) 485 631 #define IS_DISPLAY_VER(i915, from, until) \ 486 632 (DISPLAY_VER(i915) >= (from) && DISPLAY_VER(i915) <= (until)) 487 633 ··· 870 1016 #define HAS_DP_MST(dev_priv) (INTEL_INFO(dev_priv)->display.has_dp_mst) 871 1017 #define HAS_DP20(dev_priv) (IS_DG2(dev_priv) || DISPLAY_VER(dev_priv) >= 14) 872 1018 1019 + #define HAS_DOUBLE_BUFFERED_M_N(dev_priv) (DISPLAY_VER(dev_priv) >= 9 || IS_BROADWELL(dev_priv)) 1020 + 873 1021 #define HAS_CDCLK_CRAWL(dev_priv) (INTEL_INFO(dev_priv)->display.has_cdclk_crawl) 874 1022 #define HAS_DDI(dev_priv) (INTEL_INFO(dev_priv)->display.has_ddi) 875 1023 #define HAS_FPGA_DBG_UNCLAIMED(dev_priv) (INTEL_INFO(dev_priv)->display.has_fpga_dbg) ··· 977 1121 #define HAS_3D_PIPELINE(i915) (INTEL_INFO(i915)->has_3d_pipeline) 978 1122 979 1123 #define HAS_ONE_EU_PER_FUSE_BIT(i915) (INTEL_INFO(i915)->has_one_eu_per_fuse_bit) 980 - 981 - /* i915_gem.c */ 982 - void i915_gem_init_early(struct drm_i915_private *dev_priv); 983 - void i915_gem_cleanup_early(struct drm_i915_private *dev_priv); 984 - 985 - static inline void i915_gem_drain_freed_objects(struct drm_i915_private *i915) 986 - { 987 - /* 988 - * A single pass should suffice to release all the freed objects (along 989 - * most call paths) , but be a little more paranoid in that freeing 990 - * the objects does take a little amount of time, during which the rcu 991 - * callbacks could have added new objects into the freed list, and 992 - * armed the work again. 993 - */ 994 - while (atomic_read(&i915->mm.free_count)) { 995 - flush_work(&i915->mm.free_work); 996 - flush_delayed_work(&i915->bdev.wq); 997 - rcu_barrier(); 998 - } 999 - } 1000 - 1001 - static inline void i915_gem_drain_workqueue(struct drm_i915_private *i915) 1002 - { 1003 - /* 1004 - * Similar to objects above (see i915_gem_drain_freed-objects), in 1005 - * general we have workers that are armed by RCU and then rearm 1006 - * themselves in their callbacks. To be paranoid, we need to 1007 - * drain the workqueue a second time after waiting for the RCU 1008 - * grace period so that we catch work queued via RCU from the first 1009 - * pass. As neither drain_workqueue() nor flush_workqueue() report 1010 - * a result, we make an assumption that we only don't require more 1011 - * than 3 passes to catch all _recursive_ RCU delayed work. 1012 - * 1013 - */ 1014 - int pass = 3; 1015 - do { 1016 - flush_workqueue(i915->wq); 1017 - rcu_barrier(); 1018 - i915_gem_drain_freed_objects(i915); 1019 - } while (--pass); 1020 - drain_workqueue(i915->wq); 1021 - } 1022 - 1023 - struct i915_vma * __must_check 1024 - i915_gem_object_ggtt_pin_ww(struct drm_i915_gem_object *obj, 1025 - struct i915_gem_ww_ctx *ww, 1026 - const struct i915_gtt_view *view, 1027 - u64 size, u64 alignment, u64 flags); 1028 - 1029 - struct i915_vma * __must_check 1030 - i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, 1031 - const struct i915_gtt_view *view, 1032 - u64 size, u64 alignment, u64 flags); 1033 - 1034 - int i915_gem_object_unbind(struct drm_i915_gem_object *obj, 1035 - unsigned long flags); 1036 - #define I915_GEM_OBJECT_UNBIND_ACTIVE BIT(0) 1037 - #define I915_GEM_OBJECT_UNBIND_BARRIER BIT(1) 1038 - #define I915_GEM_OBJECT_UNBIND_TEST BIT(2) 1039 - #define I915_GEM_OBJECT_UNBIND_VM_TRYLOCK BIT(3) 1040 - #define I915_GEM_OBJECT_UNBIND_ASYNC BIT(4) 1041 - 1042 - void i915_gem_runtime_suspend(struct drm_i915_private *dev_priv); 1043 - 1044 - int __must_check i915_gem_set_global_seqno(struct drm_device *dev, u32 seqno); 1045 - 1046 - int __must_check i915_gem_init(struct drm_i915_private *dev_priv); 1047 - void i915_gem_driver_register(struct drm_i915_private *i915); 1048 - void i915_gem_driver_unregister(struct drm_i915_private *i915); 1049 - void i915_gem_driver_remove(struct drm_i915_private *dev_priv); 1050 - void i915_gem_driver_release(struct drm_i915_private *dev_priv); 1051 - 1052 - int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file); 1053 1124 1054 1125 /* intel_device_info.c */ 1055 1126 static inline struct intel_device_info *
+38 -1
drivers/gpu/drm/i915/i915_gem.c
··· 1089 1089 return err; 1090 1090 } 1091 1091 1092 + /* 1093 + * A single pass should suffice to release all the freed objects (along most 1094 + * call paths), but be a little more paranoid in that freeing the objects does 1095 + * take a little amount of time, during which the rcu callbacks could have added 1096 + * new objects into the freed list, and armed the work again. 1097 + */ 1098 + void i915_gem_drain_freed_objects(struct drm_i915_private *i915) 1099 + { 1100 + while (atomic_read(&i915->mm.free_count)) { 1101 + flush_work(&i915->mm.free_work); 1102 + flush_delayed_work(&i915->bdev.wq); 1103 + rcu_barrier(); 1104 + } 1105 + } 1106 + 1107 + /* 1108 + * Similar to objects above (see i915_gem_drain_freed-objects), in general we 1109 + * have workers that are armed by RCU and then rearm themselves in their 1110 + * callbacks. To be paranoid, we need to drain the workqueue a second time after 1111 + * waiting for the RCU grace period so that we catch work queued via RCU from 1112 + * the first pass. As neither drain_workqueue() nor flush_workqueue() report a 1113 + * result, we make an assumption that we only don't require more than 3 passes 1114 + * to catch all _recursive_ RCU delayed work. 1115 + */ 1116 + void i915_gem_drain_workqueue(struct drm_i915_private *i915) 1117 + { 1118 + int i; 1119 + 1120 + for (i = 0; i < 3; i++) { 1121 + flush_workqueue(i915->wq); 1122 + rcu_barrier(); 1123 + i915_gem_drain_freed_objects(i915); 1124 + } 1125 + 1126 + drain_workqueue(i915->wq); 1127 + } 1128 + 1092 1129 int i915_gem_init(struct drm_i915_private *dev_priv) 1093 1130 { 1094 1131 int ret; ··· 1253 1216 i915_gem_init__mm(dev_priv); 1254 1217 i915_gem_init__contexts(dev_priv); 1255 1218 1256 - spin_lock_init(&dev_priv->fb_tracking.lock); 1219 + spin_lock_init(&dev_priv->display.fb_tracking.lock); 1257 1220 } 1258 1221 1259 1222 void i915_gem_cleanup_early(struct drm_i915_private *dev_priv)
+43
drivers/gpu/drm/i915/i915_gem.h
··· 26 26 #define __I915_GEM_H__ 27 27 28 28 #include <linux/bug.h> 29 + #include <linux/types.h> 29 30 30 31 #include <drm/drm_drv.h> 31 32 32 33 #include "i915_utils.h" 33 34 35 + struct drm_file; 36 + struct drm_i915_gem_object; 34 37 struct drm_i915_private; 38 + struct i915_gem_ww_ctx; 39 + struct i915_gtt_view; 40 + struct i915_vma; 41 + 42 + void i915_gem_init_early(struct drm_i915_private *i915); 43 + void i915_gem_cleanup_early(struct drm_i915_private *i915); 44 + 45 + void i915_gem_drain_freed_objects(struct drm_i915_private *i915); 46 + void i915_gem_drain_workqueue(struct drm_i915_private *i915); 47 + 48 + struct i915_vma * __must_check 49 + i915_gem_object_ggtt_pin_ww(struct drm_i915_gem_object *obj, 50 + struct i915_gem_ww_ctx *ww, 51 + const struct i915_gtt_view *view, 52 + u64 size, u64 alignment, u64 flags); 53 + 54 + struct i915_vma * __must_check 55 + i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, 56 + const struct i915_gtt_view *view, 57 + u64 size, u64 alignment, u64 flags); 58 + 59 + int i915_gem_object_unbind(struct drm_i915_gem_object *obj, 60 + unsigned long flags); 61 + #define I915_GEM_OBJECT_UNBIND_ACTIVE BIT(0) 62 + #define I915_GEM_OBJECT_UNBIND_BARRIER BIT(1) 63 + #define I915_GEM_OBJECT_UNBIND_TEST BIT(2) 64 + #define I915_GEM_OBJECT_UNBIND_VM_TRYLOCK BIT(3) 65 + #define I915_GEM_OBJECT_UNBIND_ASYNC BIT(4) 66 + 67 + void i915_gem_runtime_suspend(struct drm_i915_private *i915); 68 + 69 + int __must_check i915_gem_init(struct drm_i915_private *i915); 70 + void i915_gem_driver_register(struct drm_i915_private *i915); 71 + void i915_gem_driver_unregister(struct drm_i915_private *i915); 72 + void i915_gem_driver_remove(struct drm_i915_private *i915); 73 + void i915_gem_driver_release(struct drm_i915_private *i915); 74 + 75 + int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file); 76 + 77 + /* FIXME: All of the below belong somewhere else. */ 35 78 36 79 #ifdef CONFIG_DRM_I915_DEBUG_GEM 37 80
+1 -1
drivers/gpu/drm/i915/i915_irq.c
··· 595 595 596 596 static bool i915_has_asle(struct drm_i915_private *dev_priv) 597 597 { 598 - if (!dev_priv->opregion.asle) 598 + if (!dev_priv->display.opregion.asle) 599 599 return false; 600 600 601 601 return IS_PINEVIEW(dev_priv) || IS_MOBILE(dev_priv);
+19 -19
drivers/gpu/drm/i915/i915_pci.c
··· 37 37 38 38 #define PLATFORM(x) .platform = (x) 39 39 #define GEN(x) \ 40 - .__runtime.graphics.ver = (x), \ 41 - .media.ver = (x), \ 42 - .display.ver = (x) 40 + .__runtime.graphics.ip.ver = (x), \ 41 + .__runtime.media.ip.ver = (x), \ 42 + .__runtime.display.ip.ver = (x) 43 43 44 44 #define I845_PIPE_OFFSETS \ 45 45 .display.pipe_offsets = { \ ··· 743 743 static const struct intel_device_info glk_info = { 744 744 GEN9_LP_FEATURES, 745 745 PLATFORM(INTEL_GEMINILAKE), 746 - .display.ver = 10, 746 + .__runtime.display.ip.ver = 10, 747 747 .display.dbuf.size = 1024 - 4, /* 4 blocks for bypass path allocation */ 748 748 GLK_COLORS, 749 749 }; ··· 922 922 static const struct intel_device_info dg1_info = { 923 923 GEN12_FEATURES, 924 924 DGFX_FEATURES, 925 - .__runtime.graphics.rel = 10, 925 + .__runtime.graphics.ip.rel = 10, 926 926 PLATFORM(INTEL_DG1), 927 927 .__runtime.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 928 928 .require_force_probe = 1, ··· 965 965 .display.has_hotplug = 1, \ 966 966 .display.has_ipc = 1, \ 967 967 .display.has_psr = 1, \ 968 - .display.ver = 13, \ 968 + .__runtime.display.ip.ver = 13, \ 969 969 .__runtime.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), \ 970 970 .display.pipe_offsets = { \ 971 971 [TRANSCODER_A] = PIPE_A_OFFSET, \ ··· 1009 1009 I915_GTT_PAGE_SIZE_2M 1010 1010 1011 1011 #define XE_HP_FEATURES \ 1012 - .__runtime.graphics.ver = 12, \ 1013 - .__runtime.graphics.rel = 50, \ 1012 + .__runtime.graphics.ip.ver = 12, \ 1013 + .__runtime.graphics.ip.rel = 50, \ 1014 1014 XE_HP_PAGE_SIZES, \ 1015 1015 .dma_mask_size = 46, \ 1016 1016 .has_3d_pipeline = 1, \ ··· 1030 1030 .__runtime.ppgtt_type = INTEL_PPGTT_FULL 1031 1031 1032 1032 #define XE_HPM_FEATURES \ 1033 - .media.ver = 12, \ 1034 - .media.rel = 50 1033 + .__runtime.media.ip.ver = 12, \ 1034 + .__runtime.media.ip.rel = 50 1035 1035 1036 1036 __maybe_unused 1037 1037 static const struct intel_device_info xehpsdv_info = { ··· 1056 1056 XE_HP_FEATURES, \ 1057 1057 XE_HPM_FEATURES, \ 1058 1058 DGFX_FEATURES, \ 1059 - .__runtime.graphics.rel = 55, \ 1060 - .media.rel = 55, \ 1059 + .__runtime.graphics.ip.rel = 55, \ 1060 + .__runtime.media.ip.rel = 55, \ 1061 1061 PLATFORM(INTEL_DG2), \ 1062 1062 .has_4tile = 1, \ 1063 1063 .has_64k_pages = 1, \ ··· 1100 1100 XE_HPC_FEATURES, 1101 1101 XE_HPM_FEATURES, 1102 1102 DGFX_FEATURES, 1103 - .__runtime.graphics.rel = 60, 1104 - .media.rel = 60, 1103 + .__runtime.graphics.ip.rel = 60, 1104 + .__runtime.media.ip.rel = 60, 1105 1105 PLATFORM(INTEL_PONTEVECCHIO), 1106 1106 .display = { 0 }, 1107 1107 .has_flat_ccs = 0, ··· 1114 1114 1115 1115 #define XE_LPDP_FEATURES \ 1116 1116 XE_LPD_FEATURES, \ 1117 - .display.ver = 14, \ 1117 + .__runtime.display.ip.ver = 14, \ 1118 1118 .display.has_cdclk_crawl = 1, \ 1119 1119 .__runtime.fbc_mask = BIT(INTEL_FBC_A) | BIT(INTEL_FBC_B) 1120 1120 ··· 1136 1136 * Real graphics IP version will be obtained from hardware GMD_ID 1137 1137 * register. Value provided here is just for sanity checking. 1138 1138 */ 1139 - .__runtime.graphics.ver = 12, 1140 - .__runtime.graphics.rel = 70, 1141 - .media.ver = 13, 1139 + .__runtime.graphics.ip.ver = 12, 1140 + .__runtime.graphics.ip.rel = 70, 1141 + .__runtime.media.ip.ver = 13, 1142 1142 PLATFORM(INTEL_METEORLAKE), 1143 1143 .display.has_modular_fia = 1, 1144 1144 .extra_gt_list = xelpmp_extra_gt, ··· 1295 1295 1296 1296 static bool intel_mmio_bar_valid(struct pci_dev *pdev, struct intel_device_info *intel_info) 1297 1297 { 1298 - int gttmmaddr_bar = intel_info->__runtime.graphics.ver == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR; 1298 + int gttmmaddr_bar = intel_info->__runtime.graphics.ip.ver == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR; 1299 1299 1300 1300 return i915_pci_resource_valid(pdev, gttmmaddr_bar); 1301 1301 }
+2 -1
drivers/gpu/drm/i915/i915_perf.c
··· 1376 1376 { 1377 1377 struct i915_perf *perf = stream->perf; 1378 1378 1379 - BUG_ON(stream != perf->exclusive_stream); 1379 + if (WARN_ON(stream != perf->exclusive_stream)) 1380 + return; 1380 1381 1381 1382 /* 1382 1383 * Unset exclusive_stream first, it will be checked while disabling
+73 -78
drivers/gpu/drm/i915/i915_reg.h
··· 1125 1125 #define MBUS_DBOX_REGULATE_B2B_TRANSACTIONS_EN REG_BIT(16) /* tgl+ */ 1126 1126 #define MBUS_DBOX_BW_CREDIT_MASK REG_GENMASK(15, 14) 1127 1127 #define MBUS_DBOX_BW_CREDIT(x) REG_FIELD_PREP(MBUS_DBOX_BW_CREDIT_MASK, x) 1128 + #define MBUS_DBOX_BW_4CREDITS_MTL REG_FIELD_PREP(MBUS_DBOX_BW_CREDIT_MASK, 0x2) 1129 + #define MBUS_DBOX_BW_8CREDITS_MTL REG_FIELD_PREP(MBUS_DBOX_BW_CREDIT_MASK, 0x3) 1128 1130 #define MBUS_DBOX_B_CREDIT_MASK REG_GENMASK(12, 8) 1129 1131 #define MBUS_DBOX_B_CREDIT(x) REG_FIELD_PREP(MBUS_DBOX_B_CREDIT_MASK, x) 1132 + #define MBUS_DBOX_I_CREDIT_MASK REG_GENMASK(7, 5) 1133 + #define MBUS_DBOX_I_CREDIT(x) REG_FIELD_PREP(MBUS_DBOX_I_CREDIT_MASK, x) 1130 1134 #define MBUS_DBOX_A_CREDIT_MASK REG_GENMASK(3, 0) 1131 1135 #define MBUS_DBOX_A_CREDIT(x) REG_FIELD_PREP(MBUS_DBOX_A_CREDIT_MASK, x) 1132 1136 ··· 1466 1462 #define FBC_REND_CACHE_CLEAN REG_BIT(1) 1467 1463 1468 1464 /* 1469 - * GPIO regs 1470 - */ 1471 - #define GPIO(gpio) _MMIO(dev_priv->display.gmbus.mmio_base + 0x5010 + \ 1472 - 4 * (gpio)) 1473 - 1474 - # define GPIO_CLOCK_DIR_MASK (1 << 0) 1475 - # define GPIO_CLOCK_DIR_IN (0 << 1) 1476 - # define GPIO_CLOCK_DIR_OUT (1 << 1) 1477 - # define GPIO_CLOCK_VAL_MASK (1 << 2) 1478 - # define GPIO_CLOCK_VAL_OUT (1 << 3) 1479 - # define GPIO_CLOCK_VAL_IN (1 << 4) 1480 - # define GPIO_CLOCK_PULLUP_DISABLE (1 << 5) 1481 - # define GPIO_DATA_DIR_MASK (1 << 8) 1482 - # define GPIO_DATA_DIR_IN (0 << 9) 1483 - # define GPIO_DATA_DIR_OUT (1 << 9) 1484 - # define GPIO_DATA_VAL_MASK (1 << 10) 1485 - # define GPIO_DATA_VAL_OUT (1 << 11) 1486 - # define GPIO_DATA_VAL_IN (1 << 12) 1487 - # define GPIO_DATA_PULLUP_DISABLE (1 << 13) 1488 - 1489 - #define GMBUS0 _MMIO(dev_priv->display.gmbus.mmio_base + 0x5100) /* clock/port select */ 1490 - #define GMBUS_AKSV_SELECT (1 << 11) 1491 - #define GMBUS_RATE_100KHZ (0 << 8) 1492 - #define GMBUS_RATE_50KHZ (1 << 8) 1493 - #define GMBUS_RATE_400KHZ (2 << 8) /* reserved on Pineview */ 1494 - #define GMBUS_RATE_1MHZ (3 << 8) /* reserved on Pineview */ 1495 - #define GMBUS_HOLD_EXT (1 << 7) /* 300ns hold time, rsvd on Pineview */ 1496 - #define GMBUS_BYTE_CNT_OVERRIDE (1 << 6) 1497 - 1498 - #define GMBUS1 _MMIO(dev_priv->display.gmbus.mmio_base + 0x5104) /* command/status */ 1499 - #define GMBUS_SW_CLR_INT (1 << 31) 1500 - #define GMBUS_SW_RDY (1 << 30) 1501 - #define GMBUS_ENT (1 << 29) /* enable timeout */ 1502 - #define GMBUS_CYCLE_NONE (0 << 25) 1503 - #define GMBUS_CYCLE_WAIT (1 << 25) 1504 - #define GMBUS_CYCLE_INDEX (2 << 25) 1505 - #define GMBUS_CYCLE_STOP (4 << 25) 1506 - #define GMBUS_BYTE_COUNT_SHIFT 16 1507 - #define GMBUS_BYTE_COUNT_MAX 256U 1508 - #define GEN9_GMBUS_BYTE_COUNT_MAX 511U 1509 - #define GMBUS_SLAVE_INDEX_SHIFT 8 1510 - #define GMBUS_SLAVE_ADDR_SHIFT 1 1511 - #define GMBUS_SLAVE_READ (1 << 0) 1512 - #define GMBUS_SLAVE_WRITE (0 << 0) 1513 - #define GMBUS2 _MMIO(dev_priv->display.gmbus.mmio_base + 0x5108) /* status */ 1514 - #define GMBUS_INUSE (1 << 15) 1515 - #define GMBUS_HW_WAIT_PHASE (1 << 14) 1516 - #define GMBUS_STALL_TIMEOUT (1 << 13) 1517 - #define GMBUS_INT (1 << 12) 1518 - #define GMBUS_HW_RDY (1 << 11) 1519 - #define GMBUS_SATOER (1 << 10) 1520 - #define GMBUS_ACTIVE (1 << 9) 1521 - #define GMBUS3 _MMIO(dev_priv->display.gmbus.mmio_base + 0x510c) /* data buffer bytes 3-0 */ 1522 - #define GMBUS4 _MMIO(dev_priv->display.gmbus.mmio_base + 0x5110) /* interrupt mask (Pineview+) */ 1523 - #define GMBUS_SLAVE_TIMEOUT_EN (1 << 4) 1524 - #define GMBUS_NAK_EN (1 << 3) 1525 - #define GMBUS_IDLE_EN (1 << 2) 1526 - #define GMBUS_HW_WAIT_EN (1 << 1) 1527 - #define GMBUS_HW_RDY_EN (1 << 0) 1528 - #define GMBUS5 _MMIO(dev_priv->display.gmbus.mmio_base + 0x5120) /* byte index */ 1529 - #define GMBUS_2BYTE_INDEX_EN (1 << 31) 1530 - 1531 - /* 1532 1465 * Clock control & power management 1533 1466 */ 1534 1467 #define _DPLL_A (DISPLAY_MMIO_BASE(dev_priv) + 0x6014) ··· 1641 1700 #define DSTATE_PLL_D3_OFF (1 << 3) 1642 1701 #define DSTATE_GFX_CLOCK_GATING (1 << 1) 1643 1702 #define DSTATE_DOT_CLOCK_GATING (1 << 0) 1644 - #define DSPCLK_GATE_D _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x6200) 1703 + #define DSPCLK_GATE_D(__i915) _MMIO(DISPLAY_MMIO_BASE(__i915) + 0x6200) 1645 1704 # define DPUNIT_B_CLOCK_GATE_DISABLE (1 << 30) /* 965 */ 1646 1705 # define VSUNIT_CLOCK_GATE_DISABLE (1 << 29) /* 965 */ 1647 1706 # define VRHUNIT_CLOCK_GATE_DISABLE (1 << 28) /* 965 */ ··· 3455 3514 #define DP_AUX_CH_CTL(aux_ch) _MMIO_PORT(aux_ch, _DPA_AUX_CH_CTL, _DPB_AUX_CH_CTL) 3456 3515 #define DP_AUX_CH_DATA(aux_ch, i) _MMIO(_PORT(aux_ch, _DPA_AUX_CH_DATA1, _DPB_AUX_CH_DATA1) + (i) * 4) /* 5 registers */ 3457 3516 3517 + #define _XELPDP_USBC1_AUX_CH_CTL 0x16F210 3518 + #define _XELPDP_USBC2_AUX_CH_CTL 0x16F410 3519 + #define _XELPDP_USBC3_AUX_CH_CTL 0x16F610 3520 + #define _XELPDP_USBC4_AUX_CH_CTL 0x16F810 3521 + 3522 + #define XELPDP_DP_AUX_CH_CTL(aux_ch) _MMIO(_PICK(aux_ch, \ 3523 + _DPA_AUX_CH_CTL, \ 3524 + _DPB_AUX_CH_CTL, \ 3525 + 0, /* port/aux_ch C is non-existent */ \ 3526 + _XELPDP_USBC1_AUX_CH_CTL, \ 3527 + _XELPDP_USBC2_AUX_CH_CTL, \ 3528 + _XELPDP_USBC3_AUX_CH_CTL, \ 3529 + _XELPDP_USBC4_AUX_CH_CTL)) 3530 + 3531 + #define _XELPDP_USBC1_AUX_CH_DATA1 0x16F214 3532 + #define _XELPDP_USBC2_AUX_CH_DATA1 0x16F414 3533 + #define _XELPDP_USBC3_AUX_CH_DATA1 0x16F614 3534 + #define _XELPDP_USBC4_AUX_CH_DATA1 0x16F814 3535 + 3536 + #define XELPDP_DP_AUX_CH_DATA(aux_ch, i) _MMIO(_PICK(aux_ch, \ 3537 + _DPA_AUX_CH_DATA1, \ 3538 + _DPB_AUX_CH_DATA1, \ 3539 + 0, /* port/aux_ch C is non-existent */ \ 3540 + _XELPDP_USBC1_AUX_CH_DATA1, \ 3541 + _XELPDP_USBC2_AUX_CH_DATA1, \ 3542 + _XELPDP_USBC3_AUX_CH_DATA1, \ 3543 + _XELPDP_USBC4_AUX_CH_DATA1) + (i) * 4) 3544 + 3458 3545 #define DP_AUX_CH_CTL_SEND_BUSY (1 << 31) 3459 3546 #define DP_AUX_CH_CTL_DONE (1 << 30) 3460 3547 #define DP_AUX_CH_CTL_INTERRUPT (1 << 29) ··· 3495 3526 #define DP_AUX_CH_CTL_RECEIVE_ERROR (1 << 25) 3496 3527 #define DP_AUX_CH_CTL_MESSAGE_SIZE_MASK (0x1f << 20) 3497 3528 #define DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT 20 3529 + #define XELPDP_DP_AUX_CH_CTL_POWER_REQUEST REG_BIT(19) 3530 + #define XELPDP_DP_AUX_CH_CTL_POWER_STATUS REG_BIT(18) 3498 3531 #define DP_AUX_CH_CTL_PRECHARGE_2US_MASK (0xf << 16) 3499 3532 #define DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT 16 3500 3533 #define DP_AUX_CH_CTL_AUX_AKSV_SELECT (1 << 15) ··· 5728 5757 [TRANSCODER_B] = _CHICKEN_TRANS_B, \ 5729 5758 [TRANSCODER_C] = _CHICKEN_TRANS_C, \ 5730 5759 [TRANSCODER_D] = _CHICKEN_TRANS_D)) 5760 + 5761 + #define _MTL_CHICKEN_TRANS_A 0x604e0 5762 + #define _MTL_CHICKEN_TRANS_B 0x614e0 5763 + #define MTL_CHICKEN_TRANS(trans) _MMIO_TRANS((trans), \ 5764 + _MTL_CHICKEN_TRANS_A, \ 5765 + _MTL_CHICKEN_TRANS_B) 5766 + 5731 5767 #define HSW_FRAME_START_DELAY_MASK REG_GENMASK(28, 27) 5732 5768 #define HSW_FRAME_START_DELAY(x) REG_FIELD_PREP(HSW_FRAME_START_DELAY_MASK, x) 5733 5769 #define VSC_DATA_SEL_SOFTWARE_CONTROL REG_BIT(25) /* GLK */ ··· 6592 6614 #define GEN6_DECODE_RC6_VID(vids) (((vids) * 5) + 245) 6593 6615 #define BDW_PCODE_DISPLAY_FREQ_CHANGE_REQ 0x18 6594 6616 #define GEN9_PCODE_READ_MEM_LATENCY 0x6 6595 - #define GEN9_MEM_LATENCY_LEVEL_MASK 0xFF 6596 - #define GEN9_MEM_LATENCY_LEVEL_1_5_SHIFT 8 6597 - #define GEN9_MEM_LATENCY_LEVEL_2_6_SHIFT 16 6598 - #define GEN9_MEM_LATENCY_LEVEL_3_7_SHIFT 24 6617 + #define GEN9_MEM_LATENCY_LEVEL_3_7_MASK REG_GENMASK(31, 24) 6618 + #define GEN9_MEM_LATENCY_LEVEL_2_6_MASK REG_GENMASK(23, 16) 6619 + #define GEN9_MEM_LATENCY_LEVEL_1_5_MASK REG_GENMASK(15, 8) 6620 + #define GEN9_MEM_LATENCY_LEVEL_0_4_MASK REG_GENMASK(7, 0) 6599 6621 #define SKL_PCODE_LOAD_HDCP_KEYS 0x5 6600 6622 #define SKL_PCODE_CDCLK_CONTROL 0x7 6601 6623 #define SKL_CDCLK_PREPARE_FOR_CHANGE 0x3 ··· 7118 7140 7119 7141 /* CDCLK_CTL */ 7120 7142 #define CDCLK_CTL _MMIO(0x46000) 7121 - #define CDCLK_FREQ_SEL_MASK (3 << 26) 7122 - #define CDCLK_FREQ_450_432 (0 << 26) 7123 - #define CDCLK_FREQ_540 (1 << 26) 7124 - #define CDCLK_FREQ_337_308 (2 << 26) 7125 - #define CDCLK_FREQ_675_617 (3 << 26) 7126 - #define BXT_CDCLK_CD2X_DIV_SEL_MASK (3 << 22) 7127 - #define BXT_CDCLK_CD2X_DIV_SEL_1 (0 << 22) 7128 - #define BXT_CDCLK_CD2X_DIV_SEL_1_5 (1 << 22) 7129 - #define BXT_CDCLK_CD2X_DIV_SEL_2 (2 << 22) 7130 - #define BXT_CDCLK_CD2X_DIV_SEL_4 (3 << 22) 7143 + #define CDCLK_FREQ_SEL_MASK REG_GENMASK(27, 26) 7144 + #define CDCLK_FREQ_450_432 REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 0) 7145 + #define CDCLK_FREQ_540 REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 1) 7146 + #define CDCLK_FREQ_337_308 REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 2) 7147 + #define CDCLK_FREQ_675_617 REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 3) 7148 + #define BXT_CDCLK_CD2X_DIV_SEL_MASK REG_GENMASK(23, 22) 7149 + #define BXT_CDCLK_CD2X_DIV_SEL_1 REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 0) 7150 + #define BXT_CDCLK_CD2X_DIV_SEL_1_5 REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 1) 7151 + #define BXT_CDCLK_CD2X_DIV_SEL_2 REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 2) 7152 + #define BXT_CDCLK_CD2X_DIV_SEL_4 REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 3) 7131 7153 #define BXT_CDCLK_CD2X_PIPE(pipe) ((pipe) << 20) 7132 7154 #define CDCLK_DIVMUX_CD_OVERRIDE (1 << 19) 7133 7155 #define BXT_CDCLK_CD2X_PIPE_NONE BXT_CDCLK_CD2X_PIPE(3) ··· 8338 8360 #define MTL_LATENCY_LP4_LP5 _MMIO(0x45788) 8339 8361 #define MTL_LATENCY_LEVEL_EVEN_MASK REG_GENMASK(12, 0) 8340 8362 #define MTL_LATENCY_LEVEL_ODD_MASK REG_GENMASK(28, 16) 8363 + 8364 + #define MTL_LATENCY_SAGV _MMIO(0x4578b) 8365 + #define MTL_LATENCY_QCLK_SAGV REG_GENMASK(12, 0) 8366 + 8367 + #define MTL_MEM_SS_INFO_GLOBAL _MMIO(0x45700) 8368 + #define MTL_N_OF_ENABLED_QGV_POINTS_MASK REG_GENMASK(11, 8) 8369 + #define MTL_N_OF_POPULATED_CH_MASK REG_GENMASK(7, 4) 8370 + #define MTL_DDR_TYPE_MASK REG_GENMASK(3, 0) 8371 + 8372 + #define MTL_MEM_SS_INFO_QGV_POINT_LOW(point) _MMIO(0x45710 + (point) * 2) 8373 + #define MTL_TRCD_MASK REG_GENMASK(31, 24) 8374 + #define MTL_TRP_MASK REG_GENMASK(23, 16) 8375 + #define MTL_DCLK_MASK REG_GENMASK(15, 0) 8376 + 8377 + #define MTL_MEM_SS_INFO_QGV_POINT_HIGH(point) _MMIO(0x45714 + (point) * 2) 8378 + #define MTL_TRAS_MASK REG_GENMASK(16, 8) 8379 + #define MTL_TRDPRE_MASK REG_GENMASK(7, 0) 8341 8380 8342 8381 #endif /* _I915_REG_H_ */
-2
drivers/gpu/drm/i915/i915_sw_fence.c
··· 241 241 const char *name, 242 242 struct lock_class_key *key) 243 243 { 244 - BUG_ON(!fn); 245 - 246 244 __init_waitqueue_head(&fence->wait, name, key); 247 245 fence->fn = fn; 248 246 #ifdef CONFIG_DRM_I915_SW_FENCE_CHECK_DAG
+5 -1
drivers/gpu/drm/i915/i915_sw_fence.h
··· 48 48 do { \ 49 49 static struct lock_class_key __key; \ 50 50 \ 51 + BUILD_BUG_ON((fn) == NULL); \ 51 52 __i915_sw_fence_init((fence), (fn), #fence, &__key); \ 52 53 } while (0) 53 54 #else 54 55 #define i915_sw_fence_init(fence, fn) \ 55 - __i915_sw_fence_init((fence), (fn), NULL, NULL) 56 + do { \ 57 + BUILD_BUG_ON((fn) == NULL); \ 58 + __i915_sw_fence_init((fence), (fn), NULL, NULL); \ 59 + } while (0) 56 60 #endif 57 61 58 62 void i915_sw_fence_reinit(struct i915_sw_fence *fence);
+18 -10
drivers/gpu/drm/i915/intel_device_info.c
··· 92 92 const struct intel_runtime_info *runtime, 93 93 struct drm_printer *p) 94 94 { 95 - if (runtime->graphics.rel) 96 - drm_printf(p, "graphics version: %u.%02u\n", runtime->graphics.ver, 97 - runtime->graphics.rel); 95 + if (runtime->graphics.ip.rel) 96 + drm_printf(p, "graphics version: %u.%02u\n", 97 + runtime->graphics.ip.ver, 98 + runtime->graphics.ip.rel); 98 99 else 99 - drm_printf(p, "graphics version: %u\n", runtime->graphics.ver); 100 + drm_printf(p, "graphics version: %u\n", 101 + runtime->graphics.ip.ver); 100 102 101 - if (info->media.rel) 102 - drm_printf(p, "media version: %u.%02u\n", info->media.ver, info->media.rel); 103 + if (runtime->media.ip.rel) 104 + drm_printf(p, "media version: %u.%02u\n", 105 + runtime->media.ip.ver, 106 + runtime->media.ip.rel); 103 107 else 104 - drm_printf(p, "media version: %u\n", info->media.ver); 108 + drm_printf(p, "media version: %u\n", 109 + runtime->media.ip.ver); 105 110 106 - if (info->display.rel) 107 - drm_printf(p, "display version: %u.%02u\n", info->display.ver, info->display.rel); 111 + if (runtime->display.ip.rel) 112 + drm_printf(p, "display version: %u.%02u\n", 113 + runtime->display.ip.ver, 114 + runtime->display.ip.rel); 108 115 else 109 - drm_printf(p, "display version: %u\n", info->display.ver); 116 + drm_printf(p, "display version: %u\n", 117 + runtime->display.ip.ver); 110 118 111 119 drm_printf(p, "gt: %d\n", info->gt); 112 120 drm_printf(p, "memory-regions: %x\n", runtime->memory_regions);
+9 -6
drivers/gpu/drm/i915/intel_device_info.h
··· 201 201 }; 202 202 203 203 struct intel_runtime_info { 204 - struct ip_version graphics; 204 + struct { 205 + struct ip_version ip; 206 + } graphics; 207 + struct { 208 + struct ip_version ip; 209 + } media; 210 + struct { 211 + struct ip_version ip; 212 + } display; 205 213 206 214 /* 207 215 * Platform mask is used for optimizing or-ed IS_PLATFORM calls into ··· 255 247 }; 256 248 257 249 struct intel_device_info { 258 - struct ip_version media; 259 - 260 250 enum intel_platform platform; 261 251 262 252 unsigned int dma_mask_size; /* available DMA address bits */ ··· 268 262 #undef DEFINE_FLAG 269 263 270 264 struct { 271 - u8 ver; 272 - u8 rel; 273 - 274 265 u8 abox_mask; 275 266 276 267 struct {
+40 -1
drivers/gpu/drm/i915/intel_dram.c
··· 466 466 return icl_pcode_read_mem_global_info(i915); 467 467 } 468 468 469 + static int xelpdp_get_dram_info(struct drm_i915_private *i915) 470 + { 471 + u32 val = intel_uncore_read(&i915->uncore, MTL_MEM_SS_INFO_GLOBAL); 472 + struct dram_info *dram_info = &i915->dram_info; 473 + 474 + val = REG_FIELD_GET(MTL_DDR_TYPE_MASK, val); 475 + switch (val) { 476 + case 0: 477 + dram_info->type = INTEL_DRAM_DDR4; 478 + break; 479 + case 1: 480 + dram_info->type = INTEL_DRAM_DDR5; 481 + break; 482 + case 2: 483 + dram_info->type = INTEL_DRAM_LPDDR5; 484 + break; 485 + case 3: 486 + dram_info->type = INTEL_DRAM_LPDDR4; 487 + break; 488 + case 4: 489 + dram_info->type = INTEL_DRAM_DDR3; 490 + break; 491 + case 5: 492 + dram_info->type = INTEL_DRAM_LPDDR3; 493 + break; 494 + default: 495 + MISSING_CASE(val); 496 + return -EINVAL; 497 + } 498 + 499 + dram_info->num_channels = REG_FIELD_GET(MTL_N_OF_POPULATED_CH_MASK, val); 500 + dram_info->num_qgv_points = REG_FIELD_GET(MTL_N_OF_ENABLED_QGV_POINTS_MASK, val); 501 + /* PSF GV points not supported in D14+ */ 502 + 503 + return 0; 504 + } 505 + 469 506 void intel_dram_detect(struct drm_i915_private *i915) 470 507 { 471 508 struct dram_info *dram_info = &i915->dram_info; ··· 517 480 */ 518 481 dram_info->wm_lv_0_adjust_needed = !IS_GEN9_LP(i915); 519 482 520 - if (GRAPHICS_VER(i915) >= 12) 483 + if (DISPLAY_VER(i915) >= 14) 484 + ret = xelpdp_get_dram_info(i915); 485 + else if (GRAPHICS_VER(i915) >= 12) 521 486 ret = gen12_get_dram_info(i915); 522 487 else if (GRAPHICS_VER(i915) >= 11) 523 488 ret = gen11_get_dram_info(i915);
+46 -3488
drivers/gpu/drm/i915/intel_pm.c
··· 25 25 * 26 26 */ 27 27 28 - #include <linux/module.h> 29 - #include <linux/string_helpers.h> 30 - #include <linux/pm_runtime.h> 31 - 32 - #include <drm/drm_atomic_helper.h> 33 - #include <drm/drm_blend.h> 34 - #include <drm/drm_fourcc.h> 35 - 36 - #include "display/intel_atomic.h" 37 - #include "display/intel_atomic_plane.h" 38 - #include "display/intel_bw.h" 39 28 #include "display/intel_de.h" 40 29 #include "display/intel_display_trace.h" 41 - #include "display/intel_display_types.h" 42 - #include "display/intel_fb.h" 43 - #include "display/intel_fbc.h" 44 - #include "display/intel_sprite.h" 45 - #include "display/skl_universal_plane.h" 30 + #include "display/skl_watermark.h" 46 31 47 32 #include "gt/intel_engine_regs.h" 48 33 #include "gt/intel_gt_regs.h" 49 - #include "gt/intel_llc.h" 50 34 51 35 #include "i915_drv.h" 52 - #include "i915_fixed.h" 53 - #include "i915_irq.h" 54 36 #include "intel_mchbar_regs.h" 55 - #include "intel_pcode.h" 56 37 #include "intel_pm.h" 57 38 #include "vlv_sideband.h" 58 - #include "../../../platform/x86/intel_ips.h" 59 - 60 - static void skl_sagv_disable(struct drm_i915_private *dev_priv); 61 39 62 40 struct drm_i915_clock_gating_funcs { 63 41 void (*init_clock_gating)(struct drm_i915_private *i915); 64 - }; 65 - 66 - /* Stores plane specific WM parameters */ 67 - struct skl_wm_params { 68 - bool x_tiled, y_tiled; 69 - bool rc_surface; 70 - bool is_planar; 71 - u32 width; 72 - u8 cpp; 73 - u32 plane_pixel_rate; 74 - u32 y_min_scanlines; 75 - u32 plane_bytes_per_line; 76 - uint_fixed_16_16_t plane_blocks_per_line; 77 - uint_fixed_16_16_t y_tile_minimum; 78 - u32 linetime_us; 79 - u32 dbuf_block_size; 80 42 }; 81 43 82 44 /* used in computing the new watermarks state */ ··· 799 837 return dev_priv->display.wm.max_level + 1; 800 838 } 801 839 802 - static bool intel_wm_plane_visible(const struct intel_crtc_state *crtc_state, 803 - const struct intel_plane_state *plane_state) 840 + bool intel_wm_plane_visible(const struct intel_crtc_state *crtc_state, 841 + const struct intel_plane_state *plane_state) 804 842 { 805 843 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 806 844 ··· 2823 2861 result->enable = true; 2824 2862 } 2825 2863 2826 - static void 2827 - adjust_wm_latency(struct drm_i915_private *i915, 2828 - u16 wm[], int max_level, int read_latency) 2864 + static void hsw_read_wm_latency(struct drm_i915_private *i915, u16 wm[]) 2829 2865 { 2830 - bool wm_lv_0_adjust_needed = i915->dram_info.wm_lv_0_adjust_needed; 2831 - int i, level; 2866 + u64 sskpd; 2832 2867 2833 - /* 2834 - * If a level n (n > 1) has a 0us latency, all levels m (m >= n) 2835 - * need to be disabled. We make sure to sanitize the values out 2836 - * of the punit to satisfy this requirement. 2837 - */ 2838 - for (level = 1; level <= max_level; level++) { 2839 - if (wm[level] == 0) { 2840 - for (i = level + 1; i <= max_level; i++) 2841 - wm[i] = 0; 2868 + sskpd = intel_uncore_read64(&i915->uncore, MCH_SSKPD); 2842 2869 2843 - max_level = level - 1; 2844 - break; 2845 - } 2846 - } 2847 - 2848 - /* 2849 - * WaWmMemoryReadLatency 2850 - * 2851 - * punit doesn't take into account the read latency so we need 2852 - * to add proper adjustement to each valid level we retrieve 2853 - * from the punit when level 0 response data is 0us. 2854 - */ 2855 - if (wm[0] == 0) { 2856 - for (level = 0; level <= max_level; level++) 2857 - wm[level] += read_latency; 2858 - } 2859 - 2860 - /* 2861 - * WA Level-0 adjustment for 16GB DIMMs: SKL+ 2862 - * If we could not get dimm info enable this WA to prevent from 2863 - * any underrun. If not able to get Dimm info assume 16GB dimm 2864 - * to avoid any underrun. 2865 - */ 2866 - if (wm_lv_0_adjust_needed) 2867 - wm[0] += 1; 2870 + wm[0] = REG_FIELD_GET64(SSKPD_NEW_WM0_MASK_HSW, sskpd); 2871 + if (wm[0] == 0) 2872 + wm[0] = REG_FIELD_GET64(SSKPD_OLD_WM0_MASK_HSW, sskpd); 2873 + wm[1] = REG_FIELD_GET64(SSKPD_WM1_MASK_HSW, sskpd); 2874 + wm[2] = REG_FIELD_GET64(SSKPD_WM2_MASK_HSW, sskpd); 2875 + wm[3] = REG_FIELD_GET64(SSKPD_WM3_MASK_HSW, sskpd); 2876 + wm[4] = REG_FIELD_GET64(SSKPD_WM4_MASK_HSW, sskpd); 2868 2877 } 2869 2878 2870 - static void intel_read_wm_latency(struct drm_i915_private *dev_priv, 2871 - u16 wm[]) 2879 + static void snb_read_wm_latency(struct drm_i915_private *i915, u16 wm[]) 2872 2880 { 2873 - struct intel_uncore *uncore = &dev_priv->uncore; 2874 - int max_level = ilk_wm_max_level(dev_priv); 2881 + u32 sskpd; 2875 2882 2876 - if (DISPLAY_VER(dev_priv) >= 14) { 2877 - u32 val; 2883 + sskpd = intel_uncore_read(&i915->uncore, MCH_SSKPD); 2878 2884 2879 - val = intel_uncore_read(uncore, MTL_LATENCY_LP0_LP1); 2880 - wm[0] = REG_FIELD_GET(MTL_LATENCY_LEVEL_EVEN_MASK, val); 2881 - wm[1] = REG_FIELD_GET(MTL_LATENCY_LEVEL_ODD_MASK, val); 2882 - val = intel_uncore_read(uncore, MTL_LATENCY_LP2_LP3); 2883 - wm[2] = REG_FIELD_GET(MTL_LATENCY_LEVEL_EVEN_MASK, val); 2884 - wm[3] = REG_FIELD_GET(MTL_LATENCY_LEVEL_ODD_MASK, val); 2885 - val = intel_uncore_read(uncore, MTL_LATENCY_LP4_LP5); 2886 - wm[4] = REG_FIELD_GET(MTL_LATENCY_LEVEL_EVEN_MASK, val); 2887 - wm[5] = REG_FIELD_GET(MTL_LATENCY_LEVEL_ODD_MASK, val); 2885 + wm[0] = REG_FIELD_GET(SSKPD_WM0_MASK_SNB, sskpd); 2886 + wm[1] = REG_FIELD_GET(SSKPD_WM1_MASK_SNB, sskpd); 2887 + wm[2] = REG_FIELD_GET(SSKPD_WM2_MASK_SNB, sskpd); 2888 + wm[3] = REG_FIELD_GET(SSKPD_WM3_MASK_SNB, sskpd); 2889 + } 2888 2890 2889 - adjust_wm_latency(dev_priv, wm, max_level, 6); 2890 - } else if (DISPLAY_VER(dev_priv) >= 9) { 2891 - int read_latency = DISPLAY_VER(dev_priv) >= 12 ? 3 : 2; 2892 - int mult = IS_DG2(dev_priv) ? 2 : 1; 2893 - u32 val; 2894 - int ret; 2891 + static void ilk_read_wm_latency(struct drm_i915_private *i915, u16 wm[]) 2892 + { 2893 + u32 mltr; 2895 2894 2896 - /* read the first set of memory latencies[0:3] */ 2897 - val = 0; /* data0 to be programmed to 0 for first set */ 2898 - ret = snb_pcode_read(&dev_priv->uncore, GEN9_PCODE_READ_MEM_LATENCY, 2899 - &val, NULL); 2895 + mltr = intel_uncore_read(&i915->uncore, MLTR_ILK); 2900 2896 2901 - if (ret) { 2902 - drm_err(&dev_priv->drm, 2903 - "SKL Mailbox read error = %d\n", ret); 2904 - return; 2905 - } 2906 - 2907 - wm[0] = (val & GEN9_MEM_LATENCY_LEVEL_MASK) * mult; 2908 - wm[1] = ((val >> GEN9_MEM_LATENCY_LEVEL_1_5_SHIFT) & 2909 - GEN9_MEM_LATENCY_LEVEL_MASK) * mult; 2910 - wm[2] = ((val >> GEN9_MEM_LATENCY_LEVEL_2_6_SHIFT) & 2911 - GEN9_MEM_LATENCY_LEVEL_MASK) * mult; 2912 - wm[3] = ((val >> GEN9_MEM_LATENCY_LEVEL_3_7_SHIFT) & 2913 - GEN9_MEM_LATENCY_LEVEL_MASK) * mult; 2914 - 2915 - /* read the second set of memory latencies[4:7] */ 2916 - val = 1; /* data0 to be programmed to 1 for second set */ 2917 - ret = snb_pcode_read(&dev_priv->uncore, GEN9_PCODE_READ_MEM_LATENCY, 2918 - &val, NULL); 2919 - if (ret) { 2920 - drm_err(&dev_priv->drm, 2921 - "SKL Mailbox read error = %d\n", ret); 2922 - return; 2923 - } 2924 - 2925 - wm[4] = (val & GEN9_MEM_LATENCY_LEVEL_MASK) * mult; 2926 - wm[5] = ((val >> GEN9_MEM_LATENCY_LEVEL_1_5_SHIFT) & 2927 - GEN9_MEM_LATENCY_LEVEL_MASK) * mult; 2928 - wm[6] = ((val >> GEN9_MEM_LATENCY_LEVEL_2_6_SHIFT) & 2929 - GEN9_MEM_LATENCY_LEVEL_MASK) * mult; 2930 - wm[7] = ((val >> GEN9_MEM_LATENCY_LEVEL_3_7_SHIFT) & 2931 - GEN9_MEM_LATENCY_LEVEL_MASK) * mult; 2932 - 2933 - adjust_wm_latency(dev_priv, wm, max_level, read_latency); 2934 - } else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { 2935 - u64 sskpd = intel_uncore_read64(uncore, MCH_SSKPD); 2936 - 2937 - wm[0] = REG_FIELD_GET64(SSKPD_NEW_WM0_MASK_HSW, sskpd); 2938 - if (wm[0] == 0) 2939 - wm[0] = REG_FIELD_GET64(SSKPD_OLD_WM0_MASK_HSW, sskpd); 2940 - wm[1] = REG_FIELD_GET64(SSKPD_WM1_MASK_HSW, sskpd); 2941 - wm[2] = REG_FIELD_GET64(SSKPD_WM2_MASK_HSW, sskpd); 2942 - wm[3] = REG_FIELD_GET64(SSKPD_WM3_MASK_HSW, sskpd); 2943 - wm[4] = REG_FIELD_GET64(SSKPD_WM4_MASK_HSW, sskpd); 2944 - } else if (DISPLAY_VER(dev_priv) >= 6) { 2945 - u32 sskpd = intel_uncore_read(uncore, MCH_SSKPD); 2946 - 2947 - wm[0] = REG_FIELD_GET(SSKPD_WM0_MASK_SNB, sskpd); 2948 - wm[1] = REG_FIELD_GET(SSKPD_WM1_MASK_SNB, sskpd); 2949 - wm[2] = REG_FIELD_GET(SSKPD_WM2_MASK_SNB, sskpd); 2950 - wm[3] = REG_FIELD_GET(SSKPD_WM3_MASK_SNB, sskpd); 2951 - } else if (DISPLAY_VER(dev_priv) >= 5) { 2952 - u32 mltr = intel_uncore_read(uncore, MLTR_ILK); 2953 - 2954 - /* ILK primary LP0 latency is 700 ns */ 2955 - wm[0] = 7; 2956 - wm[1] = REG_FIELD_GET(MLTR_WM1_MASK, mltr); 2957 - wm[2] = REG_FIELD_GET(MLTR_WM2_MASK, mltr); 2958 - } else { 2959 - MISSING_CASE(INTEL_DEVID(dev_priv)); 2960 - } 2897 + /* ILK primary LP0 latency is 700 ns */ 2898 + wm[0] = 7; 2899 + wm[1] = REG_FIELD_GET(MLTR_WM1_MASK, mltr); 2900 + wm[2] = REG_FIELD_GET(MLTR_WM2_MASK, mltr); 2961 2901 } 2962 2902 2963 2903 static void intel_fixup_spr_wm_latency(struct drm_i915_private *dev_priv, ··· 2893 3029 return 2; 2894 3030 } 2895 3031 2896 - static void intel_print_wm_latency(struct drm_i915_private *dev_priv, 2897 - const char *name, 2898 - const u16 wm[]) 3032 + void intel_print_wm_latency(struct drm_i915_private *dev_priv, 3033 + const char *name, const u16 wm[]) 2899 3034 { 2900 3035 int level, max_level = ilk_wm_max_level(dev_priv); 2901 3036 ··· 2991 3128 2992 3129 static void ilk_setup_wm_latency(struct drm_i915_private *dev_priv) 2993 3130 { 2994 - intel_read_wm_latency(dev_priv, dev_priv->display.wm.pri_latency); 3131 + if (IS_BROADWELL(dev_priv) || IS_HASWELL(dev_priv)) 3132 + hsw_read_wm_latency(dev_priv, dev_priv->display.wm.pri_latency); 3133 + else if (DISPLAY_VER(dev_priv) >= 6) 3134 + snb_read_wm_latency(dev_priv, dev_priv->display.wm.pri_latency); 3135 + else 3136 + ilk_read_wm_latency(dev_priv, dev_priv->display.wm.pri_latency); 2995 3137 2996 3138 memcpy(dev_priv->display.wm.spr_latency, dev_priv->display.wm.pri_latency, 2997 3139 sizeof(dev_priv->display.wm.pri_latency)); ··· 3014 3146 snb_wm_latency_quirk(dev_priv); 3015 3147 snb_wm_lp3_irq_quirk(dev_priv); 3016 3148 } 3017 - } 3018 - 3019 - static void skl_setup_wm_latency(struct drm_i915_private *dev_priv) 3020 - { 3021 - intel_read_wm_latency(dev_priv, dev_priv->display.wm.skl_latency); 3022 - intel_print_wm_latency(dev_priv, "Gen9 Plane", dev_priv->display.wm.skl_latency); 3023 3149 } 3024 3150 3025 3151 static bool ilk_validate_pipe_wm(const struct drm_i915_private *dev_priv, ··· 3526 3664 return _ilk_disable_lp_wm(dev_priv, WM_DIRTY_LP_ALL); 3527 3665 } 3528 3666 3529 - u8 intel_enabled_dbuf_slices_mask(struct drm_i915_private *dev_priv) 3530 - { 3531 - u8 enabled_slices = 0; 3532 - enum dbuf_slice slice; 3533 - 3534 - for_each_dbuf_slice(dev_priv, slice) { 3535 - if (intel_uncore_read(&dev_priv->uncore, 3536 - DBUF_CTL_S(slice)) & DBUF_POWER_STATE) 3537 - enabled_slices |= BIT(slice); 3538 - } 3539 - 3540 - return enabled_slices; 3541 - } 3542 - 3543 - /* 3544 - * FIXME: We still don't have the proper code detect if we need to apply the WA, 3545 - * so assume we'll always need it in order to avoid underruns. 3546 - */ 3547 - static bool skl_needs_memory_bw_wa(struct drm_i915_private *dev_priv) 3548 - { 3549 - return DISPLAY_VER(dev_priv) == 9; 3550 - } 3551 - 3552 - static bool 3553 - intel_has_sagv(struct drm_i915_private *dev_priv) 3554 - { 3555 - return DISPLAY_VER(dev_priv) >= 9 && !IS_LP(dev_priv) && 3556 - dev_priv->display.sagv.status != I915_SAGV_NOT_CONTROLLED; 3557 - } 3558 - 3559 - static u32 3560 - intel_sagv_block_time(struct drm_i915_private *dev_priv) 3561 - { 3562 - if (DISPLAY_VER(dev_priv) >= 12) { 3563 - u32 val = 0; 3564 - int ret; 3565 - 3566 - ret = snb_pcode_read(&dev_priv->uncore, 3567 - GEN12_PCODE_READ_SAGV_BLOCK_TIME_US, 3568 - &val, NULL); 3569 - if (ret) { 3570 - drm_dbg_kms(&dev_priv->drm, "Couldn't read SAGV block time!\n"); 3571 - return 0; 3572 - } 3573 - 3574 - return val; 3575 - } else if (DISPLAY_VER(dev_priv) == 11) { 3576 - return 10; 3577 - } else if (DISPLAY_VER(dev_priv) == 9 && !IS_LP(dev_priv)) { 3578 - return 30; 3579 - } else { 3580 - return 0; 3581 - } 3582 - } 3583 - 3584 - static void intel_sagv_init(struct drm_i915_private *i915) 3585 - { 3586 - if (!intel_has_sagv(i915)) 3587 - i915->display.sagv.status = I915_SAGV_NOT_CONTROLLED; 3588 - 3589 - /* 3590 - * Probe to see if we have working SAGV control. 3591 - * For icl+ this was already determined by intel_bw_init_hw(). 3592 - */ 3593 - if (DISPLAY_VER(i915) < 11) 3594 - skl_sagv_disable(i915); 3595 - 3596 - drm_WARN_ON(&i915->drm, i915->display.sagv.status == I915_SAGV_UNKNOWN); 3597 - 3598 - i915->display.sagv.block_time_us = intel_sagv_block_time(i915); 3599 - 3600 - drm_dbg_kms(&i915->drm, "SAGV supported: %s, original SAGV block time: %u us\n", 3601 - str_yes_no(intel_has_sagv(i915)), i915->display.sagv.block_time_us); 3602 - 3603 - /* avoid overflow when adding with wm0 latency/etc. */ 3604 - if (drm_WARN(&i915->drm, i915->display.sagv.block_time_us > U16_MAX, 3605 - "Excessive SAGV block time %u, ignoring\n", 3606 - i915->display.sagv.block_time_us)) 3607 - i915->display.sagv.block_time_us = 0; 3608 - 3609 - if (!intel_has_sagv(i915)) 3610 - i915->display.sagv.block_time_us = 0; 3611 - } 3612 - 3613 - /* 3614 - * SAGV dynamically adjusts the system agent voltage and clock frequencies 3615 - * depending on power and performance requirements. The display engine access 3616 - * to system memory is blocked during the adjustment time. Because of the 3617 - * blocking time, having this enabled can cause full system hangs and/or pipe 3618 - * underruns if we don't meet all of the following requirements: 3619 - * 3620 - * - <= 1 pipe enabled 3621 - * - All planes can enable watermarks for latencies >= SAGV engine block time 3622 - * - We're not using an interlaced display configuration 3623 - */ 3624 - static void skl_sagv_enable(struct drm_i915_private *dev_priv) 3625 - { 3626 - int ret; 3627 - 3628 - if (!intel_has_sagv(dev_priv)) 3629 - return; 3630 - 3631 - if (dev_priv->display.sagv.status == I915_SAGV_ENABLED) 3632 - return; 3633 - 3634 - drm_dbg_kms(&dev_priv->drm, "Enabling SAGV\n"); 3635 - ret = snb_pcode_write(&dev_priv->uncore, GEN9_PCODE_SAGV_CONTROL, 3636 - GEN9_SAGV_ENABLE); 3637 - 3638 - /* We don't need to wait for SAGV when enabling */ 3639 - 3640 - /* 3641 - * Some skl systems, pre-release machines in particular, 3642 - * don't actually have SAGV. 3643 - */ 3644 - if (IS_SKYLAKE(dev_priv) && ret == -ENXIO) { 3645 - drm_dbg(&dev_priv->drm, "No SAGV found on system, ignoring\n"); 3646 - dev_priv->display.sagv.status = I915_SAGV_NOT_CONTROLLED; 3647 - return; 3648 - } else if (ret < 0) { 3649 - drm_err(&dev_priv->drm, "Failed to enable SAGV\n"); 3650 - return; 3651 - } 3652 - 3653 - dev_priv->display.sagv.status = I915_SAGV_ENABLED; 3654 - } 3655 - 3656 - static void skl_sagv_disable(struct drm_i915_private *dev_priv) 3657 - { 3658 - int ret; 3659 - 3660 - if (!intel_has_sagv(dev_priv)) 3661 - return; 3662 - 3663 - if (dev_priv->display.sagv.status == I915_SAGV_DISABLED) 3664 - return; 3665 - 3666 - drm_dbg_kms(&dev_priv->drm, "Disabling SAGV\n"); 3667 - /* bspec says to keep retrying for at least 1 ms */ 3668 - ret = skl_pcode_request(&dev_priv->uncore, GEN9_PCODE_SAGV_CONTROL, 3669 - GEN9_SAGV_DISABLE, 3670 - GEN9_SAGV_IS_DISABLED, GEN9_SAGV_IS_DISABLED, 3671 - 1); 3672 - /* 3673 - * Some skl systems, pre-release machines in particular, 3674 - * don't actually have SAGV. 3675 - */ 3676 - if (IS_SKYLAKE(dev_priv) && ret == -ENXIO) { 3677 - drm_dbg(&dev_priv->drm, "No SAGV found on system, ignoring\n"); 3678 - dev_priv->display.sagv.status = I915_SAGV_NOT_CONTROLLED; 3679 - return; 3680 - } else if (ret < 0) { 3681 - drm_err(&dev_priv->drm, "Failed to disable SAGV (%d)\n", ret); 3682 - return; 3683 - } 3684 - 3685 - dev_priv->display.sagv.status = I915_SAGV_DISABLED; 3686 - } 3687 - 3688 - static void skl_sagv_pre_plane_update(struct intel_atomic_state *state) 3689 - { 3690 - struct drm_i915_private *i915 = to_i915(state->base.dev); 3691 - const struct intel_bw_state *new_bw_state = 3692 - intel_atomic_get_new_bw_state(state); 3693 - 3694 - if (!new_bw_state) 3695 - return; 3696 - 3697 - if (!intel_can_enable_sagv(i915, new_bw_state)) 3698 - skl_sagv_disable(i915); 3699 - } 3700 - 3701 - static void skl_sagv_post_plane_update(struct intel_atomic_state *state) 3702 - { 3703 - struct drm_i915_private *i915 = to_i915(state->base.dev); 3704 - const struct intel_bw_state *new_bw_state = 3705 - intel_atomic_get_new_bw_state(state); 3706 - 3707 - if (!new_bw_state) 3708 - return; 3709 - 3710 - if (intel_can_enable_sagv(i915, new_bw_state)) 3711 - skl_sagv_enable(i915); 3712 - } 3713 - 3714 - static void icl_sagv_pre_plane_update(struct intel_atomic_state *state) 3715 - { 3716 - struct drm_i915_private *dev_priv = to_i915(state->base.dev); 3717 - const struct intel_bw_state *old_bw_state = 3718 - intel_atomic_get_old_bw_state(state); 3719 - const struct intel_bw_state *new_bw_state = 3720 - intel_atomic_get_new_bw_state(state); 3721 - u16 old_mask, new_mask; 3722 - 3723 - if (!new_bw_state) 3724 - return; 3725 - 3726 - old_mask = old_bw_state->qgv_points_mask; 3727 - new_mask = old_bw_state->qgv_points_mask | new_bw_state->qgv_points_mask; 3728 - 3729 - if (old_mask == new_mask) 3730 - return; 3731 - 3732 - WARN_ON(!new_bw_state->base.changed); 3733 - 3734 - drm_dbg_kms(&dev_priv->drm, "Restricting QGV points: 0x%x -> 0x%x\n", 3735 - old_mask, new_mask); 3736 - 3737 - /* 3738 - * Restrict required qgv points before updating the configuration. 3739 - * According to BSpec we can't mask and unmask qgv points at the same 3740 - * time. Also masking should be done before updating the configuration 3741 - * and unmasking afterwards. 3742 - */ 3743 - icl_pcode_restrict_qgv_points(dev_priv, new_mask); 3744 - } 3745 - 3746 - static void icl_sagv_post_plane_update(struct intel_atomic_state *state) 3747 - { 3748 - struct drm_i915_private *dev_priv = to_i915(state->base.dev); 3749 - const struct intel_bw_state *old_bw_state = 3750 - intel_atomic_get_old_bw_state(state); 3751 - const struct intel_bw_state *new_bw_state = 3752 - intel_atomic_get_new_bw_state(state); 3753 - u16 old_mask, new_mask; 3754 - 3755 - if (!new_bw_state) 3756 - return; 3757 - 3758 - old_mask = old_bw_state->qgv_points_mask | new_bw_state->qgv_points_mask; 3759 - new_mask = new_bw_state->qgv_points_mask; 3760 - 3761 - if (old_mask == new_mask) 3762 - return; 3763 - 3764 - WARN_ON(!new_bw_state->base.changed); 3765 - 3766 - drm_dbg_kms(&dev_priv->drm, "Relaxing QGV points: 0x%x -> 0x%x\n", 3767 - old_mask, new_mask); 3768 - 3769 - /* 3770 - * Allow required qgv points after updating the configuration. 3771 - * According to BSpec we can't mask and unmask qgv points at the same 3772 - * time. Also masking should be done before updating the configuration 3773 - * and unmasking afterwards. 3774 - */ 3775 - icl_pcode_restrict_qgv_points(dev_priv, new_mask); 3776 - } 3777 - 3778 - void intel_sagv_pre_plane_update(struct intel_atomic_state *state) 3779 - { 3780 - struct drm_i915_private *i915 = to_i915(state->base.dev); 3781 - 3782 - /* 3783 - * Just return if we can't control SAGV or don't have it. 3784 - * This is different from situation when we have SAGV but just can't 3785 - * afford it due to DBuf limitation - in case if SAGV is completely 3786 - * disabled in a BIOS, we are not even allowed to send a PCode request, 3787 - * as it will throw an error. So have to check it here. 3788 - */ 3789 - if (!intel_has_sagv(i915)) 3790 - return; 3791 - 3792 - if (DISPLAY_VER(i915) >= 11) 3793 - icl_sagv_pre_plane_update(state); 3794 - else 3795 - skl_sagv_pre_plane_update(state); 3796 - } 3797 - 3798 - void intel_sagv_post_plane_update(struct intel_atomic_state *state) 3799 - { 3800 - struct drm_i915_private *i915 = to_i915(state->base.dev); 3801 - 3802 - /* 3803 - * Just return if we can't control SAGV or don't have it. 3804 - * This is different from situation when we have SAGV but just can't 3805 - * afford it due to DBuf limitation - in case if SAGV is completely 3806 - * disabled in a BIOS, we are not even allowed to send a PCode request, 3807 - * as it will throw an error. So have to check it here. 3808 - */ 3809 - if (!intel_has_sagv(i915)) 3810 - return; 3811 - 3812 - if (DISPLAY_VER(i915) >= 11) 3813 - icl_sagv_post_plane_update(state); 3814 - else 3815 - skl_sagv_post_plane_update(state); 3816 - } 3817 - 3818 - static bool skl_crtc_can_enable_sagv(const struct intel_crtc_state *crtc_state) 3819 - { 3820 - struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 3821 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 3822 - enum plane_id plane_id; 3823 - int max_level = INT_MAX; 3824 - 3825 - if (!intel_has_sagv(dev_priv)) 3826 - return false; 3827 - 3828 - if (!crtc_state->hw.active) 3829 - return true; 3830 - 3831 - if (crtc_state->hw.pipe_mode.flags & DRM_MODE_FLAG_INTERLACE) 3832 - return false; 3833 - 3834 - for_each_plane_id_on_crtc(crtc, plane_id) { 3835 - const struct skl_plane_wm *wm = 3836 - &crtc_state->wm.skl.optimal.planes[plane_id]; 3837 - int level; 3838 - 3839 - /* Skip this plane if it's not enabled */ 3840 - if (!wm->wm[0].enable) 3841 - continue; 3842 - 3843 - /* Find the highest enabled wm level for this plane */ 3844 - for (level = ilk_wm_max_level(dev_priv); 3845 - !wm->wm[level].enable; --level) 3846 - { } 3847 - 3848 - /* Highest common enabled wm level for all planes */ 3849 - max_level = min(level, max_level); 3850 - } 3851 - 3852 - /* No enabled planes? */ 3853 - if (max_level == INT_MAX) 3854 - return true; 3855 - 3856 - for_each_plane_id_on_crtc(crtc, plane_id) { 3857 - const struct skl_plane_wm *wm = 3858 - &crtc_state->wm.skl.optimal.planes[plane_id]; 3859 - 3860 - /* 3861 - * All enabled planes must have enabled a common wm level that 3862 - * can tolerate memory latencies higher than sagv_block_time_us 3863 - */ 3864 - if (wm->wm[0].enable && !wm->wm[max_level].can_sagv) 3865 - return false; 3866 - } 3867 - 3868 - return true; 3869 - } 3870 - 3871 - static bool tgl_crtc_can_enable_sagv(const struct intel_crtc_state *crtc_state) 3872 - { 3873 - struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 3874 - enum plane_id plane_id; 3875 - 3876 - if (!crtc_state->hw.active) 3877 - return true; 3878 - 3879 - for_each_plane_id_on_crtc(crtc, plane_id) { 3880 - const struct skl_plane_wm *wm = 3881 - &crtc_state->wm.skl.optimal.planes[plane_id]; 3882 - 3883 - if (wm->wm[0].enable && !wm->sagv.wm0.enable) 3884 - return false; 3885 - } 3886 - 3887 - return true; 3888 - } 3889 - 3890 - static bool intel_crtc_can_enable_sagv(const struct intel_crtc_state *crtc_state) 3891 - { 3892 - struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 3893 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 3894 - 3895 - if (DISPLAY_VER(dev_priv) >= 12) 3896 - return tgl_crtc_can_enable_sagv(crtc_state); 3897 - else 3898 - return skl_crtc_can_enable_sagv(crtc_state); 3899 - } 3900 - 3901 - bool intel_can_enable_sagv(struct drm_i915_private *dev_priv, 3902 - const struct intel_bw_state *bw_state) 3903 - { 3904 - if (DISPLAY_VER(dev_priv) < 11 && 3905 - bw_state->active_pipes && !is_power_of_2(bw_state->active_pipes)) 3906 - return false; 3907 - 3908 - return bw_state->pipe_sagv_reject == 0; 3909 - } 3910 - 3911 - static int intel_compute_sagv_mask(struct intel_atomic_state *state) 3912 - { 3913 - struct drm_i915_private *dev_priv = to_i915(state->base.dev); 3914 - int ret; 3915 - struct intel_crtc *crtc; 3916 - struct intel_crtc_state *new_crtc_state; 3917 - struct intel_bw_state *new_bw_state = NULL; 3918 - const struct intel_bw_state *old_bw_state = NULL; 3919 - int i; 3920 - 3921 - for_each_new_intel_crtc_in_state(state, crtc, 3922 - new_crtc_state, i) { 3923 - new_bw_state = intel_atomic_get_bw_state(state); 3924 - if (IS_ERR(new_bw_state)) 3925 - return PTR_ERR(new_bw_state); 3926 - 3927 - old_bw_state = intel_atomic_get_old_bw_state(state); 3928 - 3929 - if (intel_crtc_can_enable_sagv(new_crtc_state)) 3930 - new_bw_state->pipe_sagv_reject &= ~BIT(crtc->pipe); 3931 - else 3932 - new_bw_state->pipe_sagv_reject |= BIT(crtc->pipe); 3933 - } 3934 - 3935 - if (!new_bw_state) 3936 - return 0; 3937 - 3938 - new_bw_state->active_pipes = 3939 - intel_calc_active_pipes(state, old_bw_state->active_pipes); 3940 - 3941 - if (new_bw_state->active_pipes != old_bw_state->active_pipes) { 3942 - ret = intel_atomic_lock_global_state(&new_bw_state->base); 3943 - if (ret) 3944 - return ret; 3945 - } 3946 - 3947 - if (intel_can_enable_sagv(dev_priv, new_bw_state) != 3948 - intel_can_enable_sagv(dev_priv, old_bw_state)) { 3949 - ret = intel_atomic_serialize_global_state(&new_bw_state->base); 3950 - if (ret) 3951 - return ret; 3952 - } else if (new_bw_state->pipe_sagv_reject != old_bw_state->pipe_sagv_reject) { 3953 - ret = intel_atomic_lock_global_state(&new_bw_state->base); 3954 - if (ret) 3955 - return ret; 3956 - } 3957 - 3958 - for_each_new_intel_crtc_in_state(state, crtc, 3959 - new_crtc_state, i) { 3960 - struct skl_pipe_wm *pipe_wm = &new_crtc_state->wm.skl.optimal; 3961 - 3962 - /* 3963 - * We store use_sagv_wm in the crtc state rather than relying on 3964 - * that bw state since we have no convenient way to get at the 3965 - * latter from the plane commit hooks (especially in the legacy 3966 - * cursor case) 3967 - */ 3968 - pipe_wm->use_sagv_wm = !HAS_HW_SAGV_WM(dev_priv) && 3969 - DISPLAY_VER(dev_priv) >= 12 && 3970 - intel_can_enable_sagv(dev_priv, new_bw_state); 3971 - } 3972 - 3973 - return 0; 3974 - } 3975 - 3976 - static u16 skl_ddb_entry_init(struct skl_ddb_entry *entry, 3977 - u16 start, u16 end) 3978 - { 3979 - entry->start = start; 3980 - entry->end = end; 3981 - 3982 - return end; 3983 - } 3984 - 3985 - static int intel_dbuf_slice_size(struct drm_i915_private *dev_priv) 3986 - { 3987 - return INTEL_INFO(dev_priv)->display.dbuf.size / 3988 - hweight8(INTEL_INFO(dev_priv)->display.dbuf.slice_mask); 3989 - } 3990 - 3991 - static void 3992 - skl_ddb_entry_for_slices(struct drm_i915_private *dev_priv, u8 slice_mask, 3993 - struct skl_ddb_entry *ddb) 3994 - { 3995 - int slice_size = intel_dbuf_slice_size(dev_priv); 3996 - 3997 - if (!slice_mask) { 3998 - ddb->start = 0; 3999 - ddb->end = 0; 4000 - return; 4001 - } 4002 - 4003 - ddb->start = (ffs(slice_mask) - 1) * slice_size; 4004 - ddb->end = fls(slice_mask) * slice_size; 4005 - 4006 - WARN_ON(ddb->start >= ddb->end); 4007 - WARN_ON(ddb->end > INTEL_INFO(dev_priv)->display.dbuf.size); 4008 - } 4009 - 4010 - static unsigned int mbus_ddb_offset(struct drm_i915_private *i915, u8 slice_mask) 4011 - { 4012 - struct skl_ddb_entry ddb; 4013 - 4014 - if (slice_mask & (BIT(DBUF_S1) | BIT(DBUF_S2))) 4015 - slice_mask = BIT(DBUF_S1); 4016 - else if (slice_mask & (BIT(DBUF_S3) | BIT(DBUF_S4))) 4017 - slice_mask = BIT(DBUF_S3); 4018 - 4019 - skl_ddb_entry_for_slices(i915, slice_mask, &ddb); 4020 - 4021 - return ddb.start; 4022 - } 4023 - 4024 - u32 skl_ddb_dbuf_slice_mask(struct drm_i915_private *dev_priv, 4025 - const struct skl_ddb_entry *entry) 4026 - { 4027 - int slice_size = intel_dbuf_slice_size(dev_priv); 4028 - enum dbuf_slice start_slice, end_slice; 4029 - u8 slice_mask = 0; 4030 - 4031 - if (!skl_ddb_entry_size(entry)) 4032 - return 0; 4033 - 4034 - start_slice = entry->start / slice_size; 4035 - end_slice = (entry->end - 1) / slice_size; 4036 - 4037 - /* 4038 - * Per plane DDB entry can in a really worst case be on multiple slices 4039 - * but single entry is anyway contigious. 4040 - */ 4041 - while (start_slice <= end_slice) { 4042 - slice_mask |= BIT(start_slice); 4043 - start_slice++; 4044 - } 4045 - 4046 - return slice_mask; 4047 - } 4048 - 4049 - static unsigned int intel_crtc_ddb_weight(const struct intel_crtc_state *crtc_state) 4050 - { 4051 - const struct drm_display_mode *pipe_mode = &crtc_state->hw.pipe_mode; 4052 - int hdisplay, vdisplay; 4053 - 4054 - if (!crtc_state->hw.active) 4055 - return 0; 4056 - 4057 - /* 4058 - * Watermark/ddb requirement highly depends upon width of the 4059 - * framebuffer, So instead of allocating DDB equally among pipes 4060 - * distribute DDB based on resolution/width of the display. 4061 - */ 4062 - drm_mode_get_hv_timing(pipe_mode, &hdisplay, &vdisplay); 4063 - 4064 - return hdisplay; 4065 - } 4066 - 4067 - static void intel_crtc_dbuf_weights(const struct intel_dbuf_state *dbuf_state, 4068 - enum pipe for_pipe, 4069 - unsigned int *weight_start, 4070 - unsigned int *weight_end, 4071 - unsigned int *weight_total) 4072 - { 4073 - struct drm_i915_private *dev_priv = 4074 - to_i915(dbuf_state->base.state->base.dev); 4075 - enum pipe pipe; 4076 - 4077 - *weight_start = 0; 4078 - *weight_end = 0; 4079 - *weight_total = 0; 4080 - 4081 - for_each_pipe(dev_priv, pipe) { 4082 - int weight = dbuf_state->weight[pipe]; 4083 - 4084 - /* 4085 - * Do not account pipes using other slice sets 4086 - * luckily as of current BSpec slice sets do not partially 4087 - * intersect(pipes share either same one slice or same slice set 4088 - * i.e no partial intersection), so it is enough to check for 4089 - * equality for now. 4090 - */ 4091 - if (dbuf_state->slices[pipe] != dbuf_state->slices[for_pipe]) 4092 - continue; 4093 - 4094 - *weight_total += weight; 4095 - if (pipe < for_pipe) { 4096 - *weight_start += weight; 4097 - *weight_end += weight; 4098 - } else if (pipe == for_pipe) { 4099 - *weight_end += weight; 4100 - } 4101 - } 4102 - } 4103 - 4104 - static int 4105 - skl_crtc_allocate_ddb(struct intel_atomic_state *state, struct intel_crtc *crtc) 4106 - { 4107 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 4108 - unsigned int weight_total, weight_start, weight_end; 4109 - const struct intel_dbuf_state *old_dbuf_state = 4110 - intel_atomic_get_old_dbuf_state(state); 4111 - struct intel_dbuf_state *new_dbuf_state = 4112 - intel_atomic_get_new_dbuf_state(state); 4113 - struct intel_crtc_state *crtc_state; 4114 - struct skl_ddb_entry ddb_slices; 4115 - enum pipe pipe = crtc->pipe; 4116 - unsigned int mbus_offset = 0; 4117 - u32 ddb_range_size; 4118 - u32 dbuf_slice_mask; 4119 - u32 start, end; 4120 - int ret; 4121 - 4122 - if (new_dbuf_state->weight[pipe] == 0) { 4123 - skl_ddb_entry_init(&new_dbuf_state->ddb[pipe], 0, 0); 4124 - goto out; 4125 - } 4126 - 4127 - dbuf_slice_mask = new_dbuf_state->slices[pipe]; 4128 - 4129 - skl_ddb_entry_for_slices(dev_priv, dbuf_slice_mask, &ddb_slices); 4130 - mbus_offset = mbus_ddb_offset(dev_priv, dbuf_slice_mask); 4131 - ddb_range_size = skl_ddb_entry_size(&ddb_slices); 4132 - 4133 - intel_crtc_dbuf_weights(new_dbuf_state, pipe, 4134 - &weight_start, &weight_end, &weight_total); 4135 - 4136 - start = ddb_range_size * weight_start / weight_total; 4137 - end = ddb_range_size * weight_end / weight_total; 4138 - 4139 - skl_ddb_entry_init(&new_dbuf_state->ddb[pipe], 4140 - ddb_slices.start - mbus_offset + start, 4141 - ddb_slices.start - mbus_offset + end); 4142 - 4143 - out: 4144 - if (old_dbuf_state->slices[pipe] == new_dbuf_state->slices[pipe] && 4145 - skl_ddb_entry_equal(&old_dbuf_state->ddb[pipe], 4146 - &new_dbuf_state->ddb[pipe])) 4147 - return 0; 4148 - 4149 - ret = intel_atomic_lock_global_state(&new_dbuf_state->base); 4150 - if (ret) 4151 - return ret; 4152 - 4153 - crtc_state = intel_atomic_get_crtc_state(&state->base, crtc); 4154 - if (IS_ERR(crtc_state)) 4155 - return PTR_ERR(crtc_state); 4156 - 4157 - /* 4158 - * Used for checking overlaps, so we need absolute 4159 - * offsets instead of MBUS relative offsets. 4160 - */ 4161 - crtc_state->wm.skl.ddb.start = mbus_offset + new_dbuf_state->ddb[pipe].start; 4162 - crtc_state->wm.skl.ddb.end = mbus_offset + new_dbuf_state->ddb[pipe].end; 4163 - 4164 - drm_dbg_kms(&dev_priv->drm, 4165 - "[CRTC:%d:%s] dbuf slices 0x%x -> 0x%x, ddb (%d - %d) -> (%d - %d), active pipes 0x%x -> 0x%x\n", 4166 - crtc->base.base.id, crtc->base.name, 4167 - old_dbuf_state->slices[pipe], new_dbuf_state->slices[pipe], 4168 - old_dbuf_state->ddb[pipe].start, old_dbuf_state->ddb[pipe].end, 4169 - new_dbuf_state->ddb[pipe].start, new_dbuf_state->ddb[pipe].end, 4170 - old_dbuf_state->active_pipes, new_dbuf_state->active_pipes); 4171 - 4172 - return 0; 4173 - } 4174 - 4175 - static int skl_compute_wm_params(const struct intel_crtc_state *crtc_state, 4176 - int width, const struct drm_format_info *format, 4177 - u64 modifier, unsigned int rotation, 4178 - u32 plane_pixel_rate, struct skl_wm_params *wp, 4179 - int color_plane); 4180 - 4181 - static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state, 4182 - struct intel_plane *plane, 4183 - int level, 4184 - unsigned int latency, 4185 - const struct skl_wm_params *wp, 4186 - const struct skl_wm_level *result_prev, 4187 - struct skl_wm_level *result /* out */); 4188 - 4189 - static unsigned int 4190 - skl_cursor_allocation(const struct intel_crtc_state *crtc_state, 4191 - int num_active) 4192 - { 4193 - struct intel_plane *plane = to_intel_plane(crtc_state->uapi.crtc->cursor); 4194 - struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev); 4195 - int level, max_level = ilk_wm_max_level(dev_priv); 4196 - struct skl_wm_level wm = {}; 4197 - int ret, min_ddb_alloc = 0; 4198 - struct skl_wm_params wp; 4199 - 4200 - ret = skl_compute_wm_params(crtc_state, 256, 4201 - drm_format_info(DRM_FORMAT_ARGB8888), 4202 - DRM_FORMAT_MOD_LINEAR, 4203 - DRM_MODE_ROTATE_0, 4204 - crtc_state->pixel_rate, &wp, 0); 4205 - drm_WARN_ON(&dev_priv->drm, ret); 4206 - 4207 - for (level = 0; level <= max_level; level++) { 4208 - unsigned int latency = dev_priv->display.wm.skl_latency[level]; 4209 - 4210 - skl_compute_plane_wm(crtc_state, plane, level, latency, &wp, &wm, &wm); 4211 - if (wm.min_ddb_alloc == U16_MAX) 4212 - break; 4213 - 4214 - min_ddb_alloc = wm.min_ddb_alloc; 4215 - } 4216 - 4217 - return max(num_active == 1 ? 32 : 8, min_ddb_alloc); 4218 - } 4219 - 4220 - static void skl_ddb_entry_init_from_hw(struct skl_ddb_entry *entry, u32 reg) 4221 - { 4222 - skl_ddb_entry_init(entry, 4223 - REG_FIELD_GET(PLANE_BUF_START_MASK, reg), 4224 - REG_FIELD_GET(PLANE_BUF_END_MASK, reg)); 4225 - if (entry->end) 4226 - entry->end++; 4227 - } 4228 - 4229 - static void 4230 - skl_ddb_get_hw_plane_state(struct drm_i915_private *dev_priv, 4231 - const enum pipe pipe, 4232 - const enum plane_id plane_id, 4233 - struct skl_ddb_entry *ddb, 4234 - struct skl_ddb_entry *ddb_y) 4235 - { 4236 - u32 val; 4237 - 4238 - /* Cursor doesn't support NV12/planar, so no extra calculation needed */ 4239 - if (plane_id == PLANE_CURSOR) { 4240 - val = intel_uncore_read(&dev_priv->uncore, CUR_BUF_CFG(pipe)); 4241 - skl_ddb_entry_init_from_hw(ddb, val); 4242 - return; 4243 - } 4244 - 4245 - val = intel_uncore_read(&dev_priv->uncore, PLANE_BUF_CFG(pipe, plane_id)); 4246 - skl_ddb_entry_init_from_hw(ddb, val); 4247 - 4248 - if (DISPLAY_VER(dev_priv) >= 11) 4249 - return; 4250 - 4251 - val = intel_uncore_read(&dev_priv->uncore, PLANE_NV12_BUF_CFG(pipe, plane_id)); 4252 - skl_ddb_entry_init_from_hw(ddb_y, val); 4253 - } 4254 - 4255 - static void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc, 4256 - struct skl_ddb_entry *ddb, 4257 - struct skl_ddb_entry *ddb_y) 4258 - { 4259 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 4260 - enum intel_display_power_domain power_domain; 4261 - enum pipe pipe = crtc->pipe; 4262 - intel_wakeref_t wakeref; 4263 - enum plane_id plane_id; 4264 - 4265 - power_domain = POWER_DOMAIN_PIPE(pipe); 4266 - wakeref = intel_display_power_get_if_enabled(dev_priv, power_domain); 4267 - if (!wakeref) 4268 - return; 4269 - 4270 - for_each_plane_id_on_crtc(crtc, plane_id) 4271 - skl_ddb_get_hw_plane_state(dev_priv, pipe, 4272 - plane_id, 4273 - &ddb[plane_id], 4274 - &ddb_y[plane_id]); 4275 - 4276 - intel_display_power_put(dev_priv, power_domain, wakeref); 4277 - } 4278 - 4279 - struct dbuf_slice_conf_entry { 4280 - u8 active_pipes; 4281 - u8 dbuf_mask[I915_MAX_PIPES]; 4282 - bool join_mbus; 4283 - }; 4284 - 4285 - /* 4286 - * Table taken from Bspec 12716 4287 - * Pipes do have some preferred DBuf slice affinity, 4288 - * plus there are some hardcoded requirements on how 4289 - * those should be distributed for multipipe scenarios. 4290 - * For more DBuf slices algorithm can get even more messy 4291 - * and less readable, so decided to use a table almost 4292 - * as is from BSpec itself - that way it is at least easier 4293 - * to compare, change and check. 4294 - */ 4295 - static const struct dbuf_slice_conf_entry icl_allowed_dbufs[] = 4296 - /* Autogenerated with igt/tools/intel_dbuf_map tool: */ 4297 - { 4298 - { 4299 - .active_pipes = BIT(PIPE_A), 4300 - .dbuf_mask = { 4301 - [PIPE_A] = BIT(DBUF_S1), 4302 - }, 4303 - }, 4304 - { 4305 - .active_pipes = BIT(PIPE_B), 4306 - .dbuf_mask = { 4307 - [PIPE_B] = BIT(DBUF_S1), 4308 - }, 4309 - }, 4310 - { 4311 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B), 4312 - .dbuf_mask = { 4313 - [PIPE_A] = BIT(DBUF_S1), 4314 - [PIPE_B] = BIT(DBUF_S2), 4315 - }, 4316 - }, 4317 - { 4318 - .active_pipes = BIT(PIPE_C), 4319 - .dbuf_mask = { 4320 - [PIPE_C] = BIT(DBUF_S2), 4321 - }, 4322 - }, 4323 - { 4324 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_C), 4325 - .dbuf_mask = { 4326 - [PIPE_A] = BIT(DBUF_S1), 4327 - [PIPE_C] = BIT(DBUF_S2), 4328 - }, 4329 - }, 4330 - { 4331 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_C), 4332 - .dbuf_mask = { 4333 - [PIPE_B] = BIT(DBUF_S1), 4334 - [PIPE_C] = BIT(DBUF_S2), 4335 - }, 4336 - }, 4337 - { 4338 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), 4339 - .dbuf_mask = { 4340 - [PIPE_A] = BIT(DBUF_S1), 4341 - [PIPE_B] = BIT(DBUF_S1), 4342 - [PIPE_C] = BIT(DBUF_S2), 4343 - }, 4344 - }, 4345 - {} 4346 - }; 4347 - 4348 - /* 4349 - * Table taken from Bspec 49255 4350 - * Pipes do have some preferred DBuf slice affinity, 4351 - * plus there are some hardcoded requirements on how 4352 - * those should be distributed for multipipe scenarios. 4353 - * For more DBuf slices algorithm can get even more messy 4354 - * and less readable, so decided to use a table almost 4355 - * as is from BSpec itself - that way it is at least easier 4356 - * to compare, change and check. 4357 - */ 4358 - static const struct dbuf_slice_conf_entry tgl_allowed_dbufs[] = 4359 - /* Autogenerated with igt/tools/intel_dbuf_map tool: */ 4360 - { 4361 - { 4362 - .active_pipes = BIT(PIPE_A), 4363 - .dbuf_mask = { 4364 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4365 - }, 4366 - }, 4367 - { 4368 - .active_pipes = BIT(PIPE_B), 4369 - .dbuf_mask = { 4370 - [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 4371 - }, 4372 - }, 4373 - { 4374 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B), 4375 - .dbuf_mask = { 4376 - [PIPE_A] = BIT(DBUF_S2), 4377 - [PIPE_B] = BIT(DBUF_S1), 4378 - }, 4379 - }, 4380 - { 4381 - .active_pipes = BIT(PIPE_C), 4382 - .dbuf_mask = { 4383 - [PIPE_C] = BIT(DBUF_S2) | BIT(DBUF_S1), 4384 - }, 4385 - }, 4386 - { 4387 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_C), 4388 - .dbuf_mask = { 4389 - [PIPE_A] = BIT(DBUF_S1), 4390 - [PIPE_C] = BIT(DBUF_S2), 4391 - }, 4392 - }, 4393 - { 4394 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_C), 4395 - .dbuf_mask = { 4396 - [PIPE_B] = BIT(DBUF_S1), 4397 - [PIPE_C] = BIT(DBUF_S2), 4398 - }, 4399 - }, 4400 - { 4401 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), 4402 - .dbuf_mask = { 4403 - [PIPE_A] = BIT(DBUF_S1), 4404 - [PIPE_B] = BIT(DBUF_S1), 4405 - [PIPE_C] = BIT(DBUF_S2), 4406 - }, 4407 - }, 4408 - { 4409 - .active_pipes = BIT(PIPE_D), 4410 - .dbuf_mask = { 4411 - [PIPE_D] = BIT(DBUF_S2) | BIT(DBUF_S1), 4412 - }, 4413 - }, 4414 - { 4415 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_D), 4416 - .dbuf_mask = { 4417 - [PIPE_A] = BIT(DBUF_S1), 4418 - [PIPE_D] = BIT(DBUF_S2), 4419 - }, 4420 - }, 4421 - { 4422 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_D), 4423 - .dbuf_mask = { 4424 - [PIPE_B] = BIT(DBUF_S1), 4425 - [PIPE_D] = BIT(DBUF_S2), 4426 - }, 4427 - }, 4428 - { 4429 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_D), 4430 - .dbuf_mask = { 4431 - [PIPE_A] = BIT(DBUF_S1), 4432 - [PIPE_B] = BIT(DBUF_S1), 4433 - [PIPE_D] = BIT(DBUF_S2), 4434 - }, 4435 - }, 4436 - { 4437 - .active_pipes = BIT(PIPE_C) | BIT(PIPE_D), 4438 - .dbuf_mask = { 4439 - [PIPE_C] = BIT(DBUF_S1), 4440 - [PIPE_D] = BIT(DBUF_S2), 4441 - }, 4442 - }, 4443 - { 4444 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_C) | BIT(PIPE_D), 4445 - .dbuf_mask = { 4446 - [PIPE_A] = BIT(DBUF_S1), 4447 - [PIPE_C] = BIT(DBUF_S2), 4448 - [PIPE_D] = BIT(DBUF_S2), 4449 - }, 4450 - }, 4451 - { 4452 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 4453 - .dbuf_mask = { 4454 - [PIPE_B] = BIT(DBUF_S1), 4455 - [PIPE_C] = BIT(DBUF_S2), 4456 - [PIPE_D] = BIT(DBUF_S2), 4457 - }, 4458 - }, 4459 - { 4460 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 4461 - .dbuf_mask = { 4462 - [PIPE_A] = BIT(DBUF_S1), 4463 - [PIPE_B] = BIT(DBUF_S1), 4464 - [PIPE_C] = BIT(DBUF_S2), 4465 - [PIPE_D] = BIT(DBUF_S2), 4466 - }, 4467 - }, 4468 - {} 4469 - }; 4470 - 4471 - static const struct dbuf_slice_conf_entry dg2_allowed_dbufs[] = { 4472 - { 4473 - .active_pipes = BIT(PIPE_A), 4474 - .dbuf_mask = { 4475 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4476 - }, 4477 - }, 4478 - { 4479 - .active_pipes = BIT(PIPE_B), 4480 - .dbuf_mask = { 4481 - [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 4482 - }, 4483 - }, 4484 - { 4485 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B), 4486 - .dbuf_mask = { 4487 - [PIPE_A] = BIT(DBUF_S1), 4488 - [PIPE_B] = BIT(DBUF_S2), 4489 - }, 4490 - }, 4491 - { 4492 - .active_pipes = BIT(PIPE_C), 4493 - .dbuf_mask = { 4494 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4495 - }, 4496 - }, 4497 - { 4498 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_C), 4499 - .dbuf_mask = { 4500 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4501 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4502 - }, 4503 - }, 4504 - { 4505 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_C), 4506 - .dbuf_mask = { 4507 - [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 4508 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4509 - }, 4510 - }, 4511 - { 4512 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), 4513 - .dbuf_mask = { 4514 - [PIPE_A] = BIT(DBUF_S1), 4515 - [PIPE_B] = BIT(DBUF_S2), 4516 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4517 - }, 4518 - }, 4519 - { 4520 - .active_pipes = BIT(PIPE_D), 4521 - .dbuf_mask = { 4522 - [PIPE_D] = BIT(DBUF_S3) | BIT(DBUF_S4), 4523 - }, 4524 - }, 4525 - { 4526 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_D), 4527 - .dbuf_mask = { 4528 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4529 - [PIPE_D] = BIT(DBUF_S3) | BIT(DBUF_S4), 4530 - }, 4531 - }, 4532 - { 4533 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_D), 4534 - .dbuf_mask = { 4535 - [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 4536 - [PIPE_D] = BIT(DBUF_S3) | BIT(DBUF_S4), 4537 - }, 4538 - }, 4539 - { 4540 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_D), 4541 - .dbuf_mask = { 4542 - [PIPE_A] = BIT(DBUF_S1), 4543 - [PIPE_B] = BIT(DBUF_S2), 4544 - [PIPE_D] = BIT(DBUF_S3) | BIT(DBUF_S4), 4545 - }, 4546 - }, 4547 - { 4548 - .active_pipes = BIT(PIPE_C) | BIT(PIPE_D), 4549 - .dbuf_mask = { 4550 - [PIPE_C] = BIT(DBUF_S3), 4551 - [PIPE_D] = BIT(DBUF_S4), 4552 - }, 4553 - }, 4554 - { 4555 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_C) | BIT(PIPE_D), 4556 - .dbuf_mask = { 4557 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4558 - [PIPE_C] = BIT(DBUF_S3), 4559 - [PIPE_D] = BIT(DBUF_S4), 4560 - }, 4561 - }, 4562 - { 4563 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 4564 - .dbuf_mask = { 4565 - [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2), 4566 - [PIPE_C] = BIT(DBUF_S3), 4567 - [PIPE_D] = BIT(DBUF_S4), 4568 - }, 4569 - }, 4570 - { 4571 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 4572 - .dbuf_mask = { 4573 - [PIPE_A] = BIT(DBUF_S1), 4574 - [PIPE_B] = BIT(DBUF_S2), 4575 - [PIPE_C] = BIT(DBUF_S3), 4576 - [PIPE_D] = BIT(DBUF_S4), 4577 - }, 4578 - }, 4579 - {} 4580 - }; 4581 - 4582 - static const struct dbuf_slice_conf_entry adlp_allowed_dbufs[] = { 4583 - /* 4584 - * Keep the join_mbus cases first so check_mbus_joined() 4585 - * will prefer them over the !join_mbus cases. 4586 - */ 4587 - { 4588 - .active_pipes = BIT(PIPE_A), 4589 - .dbuf_mask = { 4590 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2) | BIT(DBUF_S3) | BIT(DBUF_S4), 4591 - }, 4592 - .join_mbus = true, 4593 - }, 4594 - { 4595 - .active_pipes = BIT(PIPE_B), 4596 - .dbuf_mask = { 4597 - [PIPE_B] = BIT(DBUF_S1) | BIT(DBUF_S2) | BIT(DBUF_S3) | BIT(DBUF_S4), 4598 - }, 4599 - .join_mbus = true, 4600 - }, 4601 - { 4602 - .active_pipes = BIT(PIPE_A), 4603 - .dbuf_mask = { 4604 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4605 - }, 4606 - .join_mbus = false, 4607 - }, 4608 - { 4609 - .active_pipes = BIT(PIPE_B), 4610 - .dbuf_mask = { 4611 - [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 4612 - }, 4613 - .join_mbus = false, 4614 - }, 4615 - { 4616 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B), 4617 - .dbuf_mask = { 4618 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4619 - [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 4620 - }, 4621 - }, 4622 - { 4623 - .active_pipes = BIT(PIPE_C), 4624 - .dbuf_mask = { 4625 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4626 - }, 4627 - }, 4628 - { 4629 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_C), 4630 - .dbuf_mask = { 4631 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4632 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4633 - }, 4634 - }, 4635 - { 4636 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_C), 4637 - .dbuf_mask = { 4638 - [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 4639 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4640 - }, 4641 - }, 4642 - { 4643 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), 4644 - .dbuf_mask = { 4645 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4646 - [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 4647 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4648 - }, 4649 - }, 4650 - { 4651 - .active_pipes = BIT(PIPE_D), 4652 - .dbuf_mask = { 4653 - [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 4654 - }, 4655 - }, 4656 - { 4657 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_D), 4658 - .dbuf_mask = { 4659 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4660 - [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 4661 - }, 4662 - }, 4663 - { 4664 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_D), 4665 - .dbuf_mask = { 4666 - [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 4667 - [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 4668 - }, 4669 - }, 4670 - { 4671 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_D), 4672 - .dbuf_mask = { 4673 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4674 - [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 4675 - [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 4676 - }, 4677 - }, 4678 - { 4679 - .active_pipes = BIT(PIPE_C) | BIT(PIPE_D), 4680 - .dbuf_mask = { 4681 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4682 - [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 4683 - }, 4684 - }, 4685 - { 4686 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_C) | BIT(PIPE_D), 4687 - .dbuf_mask = { 4688 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4689 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4690 - [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 4691 - }, 4692 - }, 4693 - { 4694 - .active_pipes = BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 4695 - .dbuf_mask = { 4696 - [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 4697 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4698 - [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 4699 - }, 4700 - }, 4701 - { 4702 - .active_pipes = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), 4703 - .dbuf_mask = { 4704 - [PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2), 4705 - [PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4), 4706 - [PIPE_C] = BIT(DBUF_S3) | BIT(DBUF_S4), 4707 - [PIPE_D] = BIT(DBUF_S1) | BIT(DBUF_S2), 4708 - }, 4709 - }, 4710 - {} 4711 - 4712 - }; 4713 - 4714 - static bool check_mbus_joined(u8 active_pipes, 4715 - const struct dbuf_slice_conf_entry *dbuf_slices) 4716 - { 4717 - int i; 4718 - 4719 - for (i = 0; dbuf_slices[i].active_pipes != 0; i++) { 4720 - if (dbuf_slices[i].active_pipes == active_pipes) 4721 - return dbuf_slices[i].join_mbus; 4722 - } 4723 - return false; 4724 - } 4725 - 4726 - static bool adlp_check_mbus_joined(u8 active_pipes) 4727 - { 4728 - return check_mbus_joined(active_pipes, adlp_allowed_dbufs); 4729 - } 4730 - 4731 - static u8 compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus, 4732 - const struct dbuf_slice_conf_entry *dbuf_slices) 4733 - { 4734 - int i; 4735 - 4736 - for (i = 0; dbuf_slices[i].active_pipes != 0; i++) { 4737 - if (dbuf_slices[i].active_pipes == active_pipes && 4738 - dbuf_slices[i].join_mbus == join_mbus) 4739 - return dbuf_slices[i].dbuf_mask[pipe]; 4740 - } 4741 - return 0; 4742 - } 4743 - 4744 - /* 4745 - * This function finds an entry with same enabled pipe configuration and 4746 - * returns correspondent DBuf slice mask as stated in BSpec for particular 4747 - * platform. 4748 - */ 4749 - static u8 icl_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus) 4750 - { 4751 - /* 4752 - * FIXME: For ICL this is still a bit unclear as prev BSpec revision 4753 - * required calculating "pipe ratio" in order to determine 4754 - * if one or two slices can be used for single pipe configurations 4755 - * as additional constraint to the existing table. 4756 - * However based on recent info, it should be not "pipe ratio" 4757 - * but rather ratio between pixel_rate and cdclk with additional 4758 - * constants, so for now we are using only table until this is 4759 - * clarified. Also this is the reason why crtc_state param is 4760 - * still here - we will need it once those additional constraints 4761 - * pop up. 4762 - */ 4763 - return compute_dbuf_slices(pipe, active_pipes, join_mbus, 4764 - icl_allowed_dbufs); 4765 - } 4766 - 4767 - static u8 tgl_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus) 4768 - { 4769 - return compute_dbuf_slices(pipe, active_pipes, join_mbus, 4770 - tgl_allowed_dbufs); 4771 - } 4772 - 4773 - static u8 adlp_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus) 4774 - { 4775 - return compute_dbuf_slices(pipe, active_pipes, join_mbus, 4776 - adlp_allowed_dbufs); 4777 - } 4778 - 4779 - static u8 dg2_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus) 4780 - { 4781 - return compute_dbuf_slices(pipe, active_pipes, join_mbus, 4782 - dg2_allowed_dbufs); 4783 - } 4784 - 4785 - static u8 skl_compute_dbuf_slices(struct intel_crtc *crtc, u8 active_pipes, bool join_mbus) 4786 - { 4787 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 4788 - enum pipe pipe = crtc->pipe; 4789 - 4790 - if (IS_DG2(dev_priv)) 4791 - return dg2_compute_dbuf_slices(pipe, active_pipes, join_mbus); 4792 - else if (DISPLAY_VER(dev_priv) >= 13) 4793 - return adlp_compute_dbuf_slices(pipe, active_pipes, join_mbus); 4794 - else if (DISPLAY_VER(dev_priv) == 12) 4795 - return tgl_compute_dbuf_slices(pipe, active_pipes, join_mbus); 4796 - else if (DISPLAY_VER(dev_priv) == 11) 4797 - return icl_compute_dbuf_slices(pipe, active_pipes, join_mbus); 4798 - /* 4799 - * For anything else just return one slice yet. 4800 - * Should be extended for other platforms. 4801 - */ 4802 - return active_pipes & BIT(pipe) ? BIT(DBUF_S1) : 0; 4803 - } 4804 - 4805 - static bool 4806 - use_minimal_wm0_only(const struct intel_crtc_state *crtc_state, 4807 - struct intel_plane *plane) 4808 - { 4809 - struct drm_i915_private *i915 = to_i915(plane->base.dev); 4810 - 4811 - return DISPLAY_VER(i915) >= 13 && 4812 - crtc_state->uapi.async_flip && 4813 - plane->async_flip; 4814 - } 4815 - 4816 - static u64 4817 - skl_total_relative_data_rate(const struct intel_crtc_state *crtc_state) 4818 - { 4819 - struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 4820 - struct drm_i915_private *i915 = to_i915(crtc->base.dev); 4821 - enum plane_id plane_id; 4822 - u64 data_rate = 0; 4823 - 4824 - for_each_plane_id_on_crtc(crtc, plane_id) { 4825 - if (plane_id == PLANE_CURSOR) 4826 - continue; 4827 - 4828 - data_rate += crtc_state->rel_data_rate[plane_id]; 4829 - 4830 - if (DISPLAY_VER(i915) < 11) 4831 - data_rate += crtc_state->rel_data_rate_y[plane_id]; 4832 - } 4833 - 4834 - return data_rate; 4835 - } 4836 - 4837 - static const struct skl_wm_level * 4838 - skl_plane_wm_level(const struct skl_pipe_wm *pipe_wm, 4839 - enum plane_id plane_id, 4840 - int level) 4841 - { 4842 - const struct skl_plane_wm *wm = &pipe_wm->planes[plane_id]; 4843 - 4844 - if (level == 0 && pipe_wm->use_sagv_wm) 4845 - return &wm->sagv.wm0; 4846 - 4847 - return &wm->wm[level]; 4848 - } 4849 - 4850 - static const struct skl_wm_level * 4851 - skl_plane_trans_wm(const struct skl_pipe_wm *pipe_wm, 4852 - enum plane_id plane_id) 4853 - { 4854 - const struct skl_plane_wm *wm = &pipe_wm->planes[plane_id]; 4855 - 4856 - if (pipe_wm->use_sagv_wm) 4857 - return &wm->sagv.trans_wm; 4858 - 4859 - return &wm->trans_wm; 4860 - } 4861 - 4862 - /* 4863 - * We only disable the watermarks for each plane if 4864 - * they exceed the ddb allocation of said plane. This 4865 - * is done so that we don't end up touching cursor 4866 - * watermarks needlessly when some other plane reduces 4867 - * our max possible watermark level. 4868 - * 4869 - * Bspec has this to say about the PLANE_WM enable bit: 4870 - * "All the watermarks at this level for all enabled 4871 - * planes must be enabled before the level will be used." 4872 - * So this is actually safe to do. 4873 - */ 4874 - static void 4875 - skl_check_wm_level(struct skl_wm_level *wm, const struct skl_ddb_entry *ddb) 4876 - { 4877 - if (wm->min_ddb_alloc > skl_ddb_entry_size(ddb)) 4878 - memset(wm, 0, sizeof(*wm)); 4879 - } 4880 - 4881 - static void 4882 - skl_check_nv12_wm_level(struct skl_wm_level *wm, struct skl_wm_level *uv_wm, 4883 - const struct skl_ddb_entry *ddb_y, const struct skl_ddb_entry *ddb) 4884 - { 4885 - if (wm->min_ddb_alloc > skl_ddb_entry_size(ddb_y) || 4886 - uv_wm->min_ddb_alloc > skl_ddb_entry_size(ddb)) { 4887 - memset(wm, 0, sizeof(*wm)); 4888 - memset(uv_wm, 0, sizeof(*uv_wm)); 4889 - } 4890 - } 4891 - 4892 - static bool icl_need_wm1_wa(struct drm_i915_private *i915, 4893 - enum plane_id plane_id) 4894 - { 4895 - /* 4896 - * Wa_1408961008:icl, ehl 4897 - * Wa_14012656716:tgl, adl 4898 - * Underruns with WM1+ disabled 4899 - */ 4900 - return DISPLAY_VER(i915) == 11 || 4901 - (IS_DISPLAY_VER(i915, 12, 13) && plane_id == PLANE_CURSOR); 4902 - } 4903 - 4904 - struct skl_plane_ddb_iter { 4905 - u64 data_rate; 4906 - u16 start, size; 4907 - }; 4908 - 4909 - static void 4910 - skl_allocate_plane_ddb(struct skl_plane_ddb_iter *iter, 4911 - struct skl_ddb_entry *ddb, 4912 - const struct skl_wm_level *wm, 4913 - u64 data_rate) 4914 - { 4915 - u16 size, extra = 0; 4916 - 4917 - if (data_rate) { 4918 - extra = min_t(u16, iter->size, 4919 - DIV64_U64_ROUND_UP(iter->size * data_rate, 4920 - iter->data_rate)); 4921 - iter->size -= extra; 4922 - iter->data_rate -= data_rate; 4923 - } 4924 - 4925 - /* 4926 - * Keep ddb entry of all disabled planes explicitly zeroed 4927 - * to avoid skl_ddb_add_affected_planes() adding them to 4928 - * the state when other planes change their allocations. 4929 - */ 4930 - size = wm->min_ddb_alloc + extra; 4931 - if (size) 4932 - iter->start = skl_ddb_entry_init(ddb, iter->start, 4933 - iter->start + size); 4934 - } 4935 - 4936 - static int 4937 - skl_crtc_allocate_plane_ddb(struct intel_atomic_state *state, 4938 - struct intel_crtc *crtc) 4939 - { 4940 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 4941 - struct intel_crtc_state *crtc_state = 4942 - intel_atomic_get_new_crtc_state(state, crtc); 4943 - const struct intel_dbuf_state *dbuf_state = 4944 - intel_atomic_get_new_dbuf_state(state); 4945 - const struct skl_ddb_entry *alloc = &dbuf_state->ddb[crtc->pipe]; 4946 - int num_active = hweight8(dbuf_state->active_pipes); 4947 - struct skl_plane_ddb_iter iter; 4948 - enum plane_id plane_id; 4949 - u16 cursor_size; 4950 - u32 blocks; 4951 - int level; 4952 - 4953 - /* Clear the partitioning for disabled planes. */ 4954 - memset(crtc_state->wm.skl.plane_ddb, 0, sizeof(crtc_state->wm.skl.plane_ddb)); 4955 - memset(crtc_state->wm.skl.plane_ddb_y, 0, sizeof(crtc_state->wm.skl.plane_ddb_y)); 4956 - 4957 - if (!crtc_state->hw.active) 4958 - return 0; 4959 - 4960 - iter.start = alloc->start; 4961 - iter.size = skl_ddb_entry_size(alloc); 4962 - if (iter.size == 0) 4963 - return 0; 4964 - 4965 - /* Allocate fixed number of blocks for cursor. */ 4966 - cursor_size = skl_cursor_allocation(crtc_state, num_active); 4967 - iter.size -= cursor_size; 4968 - skl_ddb_entry_init(&crtc_state->wm.skl.plane_ddb[PLANE_CURSOR], 4969 - alloc->end - cursor_size, alloc->end); 4970 - 4971 - iter.data_rate = skl_total_relative_data_rate(crtc_state); 4972 - 4973 - /* 4974 - * Find the highest watermark level for which we can satisfy the block 4975 - * requirement of active planes. 4976 - */ 4977 - for (level = ilk_wm_max_level(dev_priv); level >= 0; level--) { 4978 - blocks = 0; 4979 - for_each_plane_id_on_crtc(crtc, plane_id) { 4980 - const struct skl_plane_wm *wm = 4981 - &crtc_state->wm.skl.optimal.planes[plane_id]; 4982 - 4983 - if (plane_id == PLANE_CURSOR) { 4984 - const struct skl_ddb_entry *ddb = 4985 - &crtc_state->wm.skl.plane_ddb[plane_id]; 4986 - 4987 - if (wm->wm[level].min_ddb_alloc > skl_ddb_entry_size(ddb)) { 4988 - drm_WARN_ON(&dev_priv->drm, 4989 - wm->wm[level].min_ddb_alloc != U16_MAX); 4990 - blocks = U32_MAX; 4991 - break; 4992 - } 4993 - continue; 4994 - } 4995 - 4996 - blocks += wm->wm[level].min_ddb_alloc; 4997 - blocks += wm->uv_wm[level].min_ddb_alloc; 4998 - } 4999 - 5000 - if (blocks <= iter.size) { 5001 - iter.size -= blocks; 5002 - break; 5003 - } 5004 - } 5005 - 5006 - if (level < 0) { 5007 - drm_dbg_kms(&dev_priv->drm, 5008 - "Requested display configuration exceeds system DDB limitations"); 5009 - drm_dbg_kms(&dev_priv->drm, "minimum required %d/%d\n", 5010 - blocks, iter.size); 5011 - return -EINVAL; 5012 - } 5013 - 5014 - /* avoid the WARN later when we don't allocate any extra DDB */ 5015 - if (iter.data_rate == 0) 5016 - iter.size = 0; 5017 - 5018 - /* 5019 - * Grant each plane the blocks it requires at the highest achievable 5020 - * watermark level, plus an extra share of the leftover blocks 5021 - * proportional to its relative data rate. 5022 - */ 5023 - for_each_plane_id_on_crtc(crtc, plane_id) { 5024 - struct skl_ddb_entry *ddb = 5025 - &crtc_state->wm.skl.plane_ddb[plane_id]; 5026 - struct skl_ddb_entry *ddb_y = 5027 - &crtc_state->wm.skl.plane_ddb_y[plane_id]; 5028 - const struct skl_plane_wm *wm = 5029 - &crtc_state->wm.skl.optimal.planes[plane_id]; 5030 - 5031 - if (plane_id == PLANE_CURSOR) 5032 - continue; 5033 - 5034 - if (DISPLAY_VER(dev_priv) < 11 && 5035 - crtc_state->nv12_planes & BIT(plane_id)) { 5036 - skl_allocate_plane_ddb(&iter, ddb_y, &wm->wm[level], 5037 - crtc_state->rel_data_rate_y[plane_id]); 5038 - skl_allocate_plane_ddb(&iter, ddb, &wm->uv_wm[level], 5039 - crtc_state->rel_data_rate[plane_id]); 5040 - } else { 5041 - skl_allocate_plane_ddb(&iter, ddb, &wm->wm[level], 5042 - crtc_state->rel_data_rate[plane_id]); 5043 - } 5044 - } 5045 - drm_WARN_ON(&dev_priv->drm, iter.size != 0 || iter.data_rate != 0); 5046 - 5047 - /* 5048 - * When we calculated watermark values we didn't know how high 5049 - * of a level we'd actually be able to hit, so we just marked 5050 - * all levels as "enabled." Go back now and disable the ones 5051 - * that aren't actually possible. 5052 - */ 5053 - for (level++; level <= ilk_wm_max_level(dev_priv); level++) { 5054 - for_each_plane_id_on_crtc(crtc, plane_id) { 5055 - const struct skl_ddb_entry *ddb = 5056 - &crtc_state->wm.skl.plane_ddb[plane_id]; 5057 - const struct skl_ddb_entry *ddb_y = 5058 - &crtc_state->wm.skl.plane_ddb_y[plane_id]; 5059 - struct skl_plane_wm *wm = 5060 - &crtc_state->wm.skl.optimal.planes[plane_id]; 5061 - 5062 - if (DISPLAY_VER(dev_priv) < 11 && 5063 - crtc_state->nv12_planes & BIT(plane_id)) 5064 - skl_check_nv12_wm_level(&wm->wm[level], 5065 - &wm->uv_wm[level], 5066 - ddb_y, ddb); 5067 - else 5068 - skl_check_wm_level(&wm->wm[level], ddb); 5069 - 5070 - if (icl_need_wm1_wa(dev_priv, plane_id) && 5071 - level == 1 && wm->wm[0].enable) { 5072 - wm->wm[level].blocks = wm->wm[0].blocks; 5073 - wm->wm[level].lines = wm->wm[0].lines; 5074 - wm->wm[level].ignore_lines = wm->wm[0].ignore_lines; 5075 - } 5076 - } 5077 - } 5078 - 5079 - /* 5080 - * Go back and disable the transition and SAGV watermarks 5081 - * if it turns out we don't have enough DDB blocks for them. 5082 - */ 5083 - for_each_plane_id_on_crtc(crtc, plane_id) { 5084 - const struct skl_ddb_entry *ddb = 5085 - &crtc_state->wm.skl.plane_ddb[plane_id]; 5086 - const struct skl_ddb_entry *ddb_y = 5087 - &crtc_state->wm.skl.plane_ddb_y[plane_id]; 5088 - struct skl_plane_wm *wm = 5089 - &crtc_state->wm.skl.optimal.planes[plane_id]; 5090 - 5091 - if (DISPLAY_VER(dev_priv) < 11 && 5092 - crtc_state->nv12_planes & BIT(plane_id)) { 5093 - skl_check_wm_level(&wm->trans_wm, ddb_y); 5094 - } else { 5095 - WARN_ON(skl_ddb_entry_size(ddb_y)); 5096 - 5097 - skl_check_wm_level(&wm->trans_wm, ddb); 5098 - } 5099 - 5100 - skl_check_wm_level(&wm->sagv.wm0, ddb); 5101 - skl_check_wm_level(&wm->sagv.trans_wm, ddb); 5102 - } 5103 - 5104 - return 0; 5105 - } 5106 - 5107 - /* 5108 - * The max latency should be 257 (max the punit can code is 255 and we add 2us 5109 - * for the read latency) and cpp should always be <= 8, so that 5110 - * should allow pixel_rate up to ~2 GHz which seems sufficient since max 5111 - * 2xcdclk is 1350 MHz and the pixel rate should never exceed that. 5112 - */ 5113 - static uint_fixed_16_16_t 5114 - skl_wm_method1(const struct drm_i915_private *dev_priv, u32 pixel_rate, 5115 - u8 cpp, u32 latency, u32 dbuf_block_size) 5116 - { 5117 - u32 wm_intermediate_val; 5118 - uint_fixed_16_16_t ret; 5119 - 5120 - if (latency == 0) 5121 - return FP_16_16_MAX; 5122 - 5123 - wm_intermediate_val = latency * pixel_rate * cpp; 5124 - ret = div_fixed16(wm_intermediate_val, 1000 * dbuf_block_size); 5125 - 5126 - if (DISPLAY_VER(dev_priv) >= 10) 5127 - ret = add_fixed16_u32(ret, 1); 5128 - 5129 - return ret; 5130 - } 5131 - 5132 - static uint_fixed_16_16_t 5133 - skl_wm_method2(u32 pixel_rate, u32 pipe_htotal, u32 latency, 5134 - uint_fixed_16_16_t plane_blocks_per_line) 5135 - { 5136 - u32 wm_intermediate_val; 5137 - uint_fixed_16_16_t ret; 5138 - 5139 - if (latency == 0) 5140 - return FP_16_16_MAX; 5141 - 5142 - wm_intermediate_val = latency * pixel_rate; 5143 - wm_intermediate_val = DIV_ROUND_UP(wm_intermediate_val, 5144 - pipe_htotal * 1000); 5145 - ret = mul_u32_fixed16(wm_intermediate_val, plane_blocks_per_line); 5146 - return ret; 5147 - } 5148 - 5149 - static uint_fixed_16_16_t 5150 - intel_get_linetime_us(const struct intel_crtc_state *crtc_state) 5151 - { 5152 - struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev); 5153 - u32 pixel_rate; 5154 - u32 crtc_htotal; 5155 - uint_fixed_16_16_t linetime_us; 5156 - 5157 - if (!crtc_state->hw.active) 5158 - return u32_to_fixed16(0); 5159 - 5160 - pixel_rate = crtc_state->pixel_rate; 5161 - 5162 - if (drm_WARN_ON(&dev_priv->drm, pixel_rate == 0)) 5163 - return u32_to_fixed16(0); 5164 - 5165 - crtc_htotal = crtc_state->hw.pipe_mode.crtc_htotal; 5166 - linetime_us = div_fixed16(crtc_htotal * 1000, pixel_rate); 5167 - 5168 - return linetime_us; 5169 - } 5170 - 5171 - static int 5172 - skl_compute_wm_params(const struct intel_crtc_state *crtc_state, 5173 - int width, const struct drm_format_info *format, 5174 - u64 modifier, unsigned int rotation, 5175 - u32 plane_pixel_rate, struct skl_wm_params *wp, 5176 - int color_plane) 5177 - { 5178 - struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 5179 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 5180 - u32 interm_pbpl; 5181 - 5182 - /* only planar format has two planes */ 5183 - if (color_plane == 1 && 5184 - !intel_format_info_is_yuv_semiplanar(format, modifier)) { 5185 - drm_dbg_kms(&dev_priv->drm, 5186 - "Non planar format have single plane\n"); 5187 - return -EINVAL; 5188 - } 5189 - 5190 - wp->y_tiled = modifier == I915_FORMAT_MOD_Y_TILED || 5191 - modifier == I915_FORMAT_MOD_4_TILED || 5192 - modifier == I915_FORMAT_MOD_Yf_TILED || 5193 - modifier == I915_FORMAT_MOD_Y_TILED_CCS || 5194 - modifier == I915_FORMAT_MOD_Yf_TILED_CCS; 5195 - wp->x_tiled = modifier == I915_FORMAT_MOD_X_TILED; 5196 - wp->rc_surface = modifier == I915_FORMAT_MOD_Y_TILED_CCS || 5197 - modifier == I915_FORMAT_MOD_Yf_TILED_CCS; 5198 - wp->is_planar = intel_format_info_is_yuv_semiplanar(format, modifier); 5199 - 5200 - wp->width = width; 5201 - if (color_plane == 1 && wp->is_planar) 5202 - wp->width /= 2; 5203 - 5204 - wp->cpp = format->cpp[color_plane]; 5205 - wp->plane_pixel_rate = plane_pixel_rate; 5206 - 5207 - if (DISPLAY_VER(dev_priv) >= 11 && 5208 - modifier == I915_FORMAT_MOD_Yf_TILED && wp->cpp == 1) 5209 - wp->dbuf_block_size = 256; 5210 - else 5211 - wp->dbuf_block_size = 512; 5212 - 5213 - if (drm_rotation_90_or_270(rotation)) { 5214 - switch (wp->cpp) { 5215 - case 1: 5216 - wp->y_min_scanlines = 16; 5217 - break; 5218 - case 2: 5219 - wp->y_min_scanlines = 8; 5220 - break; 5221 - case 4: 5222 - wp->y_min_scanlines = 4; 5223 - break; 5224 - default: 5225 - MISSING_CASE(wp->cpp); 5226 - return -EINVAL; 5227 - } 5228 - } else { 5229 - wp->y_min_scanlines = 4; 5230 - } 5231 - 5232 - if (skl_needs_memory_bw_wa(dev_priv)) 5233 - wp->y_min_scanlines *= 2; 5234 - 5235 - wp->plane_bytes_per_line = wp->width * wp->cpp; 5236 - if (wp->y_tiled) { 5237 - interm_pbpl = DIV_ROUND_UP(wp->plane_bytes_per_line * 5238 - wp->y_min_scanlines, 5239 - wp->dbuf_block_size); 5240 - 5241 - if (DISPLAY_VER(dev_priv) >= 10) 5242 - interm_pbpl++; 5243 - 5244 - wp->plane_blocks_per_line = div_fixed16(interm_pbpl, 5245 - wp->y_min_scanlines); 5246 - } else { 5247 - interm_pbpl = DIV_ROUND_UP(wp->plane_bytes_per_line, 5248 - wp->dbuf_block_size); 5249 - 5250 - if (!wp->x_tiled || DISPLAY_VER(dev_priv) >= 10) 5251 - interm_pbpl++; 5252 - 5253 - wp->plane_blocks_per_line = u32_to_fixed16(interm_pbpl); 5254 - } 5255 - 5256 - wp->y_tile_minimum = mul_u32_fixed16(wp->y_min_scanlines, 5257 - wp->plane_blocks_per_line); 5258 - 5259 - wp->linetime_us = fixed16_to_u32_round_up( 5260 - intel_get_linetime_us(crtc_state)); 5261 - 5262 - return 0; 5263 - } 5264 - 5265 - static int 5266 - skl_compute_plane_wm_params(const struct intel_crtc_state *crtc_state, 5267 - const struct intel_plane_state *plane_state, 5268 - struct skl_wm_params *wp, int color_plane) 5269 - { 5270 - const struct drm_framebuffer *fb = plane_state->hw.fb; 5271 - int width; 5272 - 5273 - /* 5274 - * Src coordinates are already rotated by 270 degrees for 5275 - * the 90/270 degree plane rotation cases (to match the 5276 - * GTT mapping), hence no need to account for rotation here. 5277 - */ 5278 - width = drm_rect_width(&plane_state->uapi.src) >> 16; 5279 - 5280 - return skl_compute_wm_params(crtc_state, width, 5281 - fb->format, fb->modifier, 5282 - plane_state->hw.rotation, 5283 - intel_plane_pixel_rate(crtc_state, plane_state), 5284 - wp, color_plane); 5285 - } 5286 - 5287 - static bool skl_wm_has_lines(struct drm_i915_private *dev_priv, int level) 5288 - { 5289 - if (DISPLAY_VER(dev_priv) >= 10) 5290 - return true; 5291 - 5292 - /* The number of lines are ignored for the level 0 watermark. */ 5293 - return level > 0; 5294 - } 5295 - 5296 - static int skl_wm_max_lines(struct drm_i915_private *dev_priv) 5297 - { 5298 - if (DISPLAY_VER(dev_priv) >= 13) 5299 - return 255; 5300 - else 5301 - return 31; 5302 - } 5303 - 5304 - static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state, 5305 - struct intel_plane *plane, 5306 - int level, 5307 - unsigned int latency, 5308 - const struct skl_wm_params *wp, 5309 - const struct skl_wm_level *result_prev, 5310 - struct skl_wm_level *result /* out */) 5311 - { 5312 - struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev); 5313 - uint_fixed_16_16_t method1, method2; 5314 - uint_fixed_16_16_t selected_result; 5315 - u32 blocks, lines, min_ddb_alloc = 0; 5316 - 5317 - if (latency == 0 || 5318 - (use_minimal_wm0_only(crtc_state, plane) && level > 0)) { 5319 - /* reject it */ 5320 - result->min_ddb_alloc = U16_MAX; 5321 - return; 5322 - } 5323 - 5324 - /* 5325 - * WaIncreaseLatencyIPCEnabled: kbl,cfl 5326 - * Display WA #1141: kbl,cfl 5327 - */ 5328 - if ((IS_KABYLAKE(dev_priv) || 5329 - IS_COFFEELAKE(dev_priv) || 5330 - IS_COMETLAKE(dev_priv)) && 5331 - dev_priv->ipc_enabled) 5332 - latency += 4; 5333 - 5334 - if (skl_needs_memory_bw_wa(dev_priv) && wp->x_tiled) 5335 - latency += 15; 5336 - 5337 - method1 = skl_wm_method1(dev_priv, wp->plane_pixel_rate, 5338 - wp->cpp, latency, wp->dbuf_block_size); 5339 - method2 = skl_wm_method2(wp->plane_pixel_rate, 5340 - crtc_state->hw.pipe_mode.crtc_htotal, 5341 - latency, 5342 - wp->plane_blocks_per_line); 5343 - 5344 - if (wp->y_tiled) { 5345 - selected_result = max_fixed16(method2, wp->y_tile_minimum); 5346 - } else { 5347 - if ((wp->cpp * crtc_state->hw.pipe_mode.crtc_htotal / 5348 - wp->dbuf_block_size < 1) && 5349 - (wp->plane_bytes_per_line / wp->dbuf_block_size < 1)) { 5350 - selected_result = method2; 5351 - } else if (latency >= wp->linetime_us) { 5352 - if (DISPLAY_VER(dev_priv) == 9) 5353 - selected_result = min_fixed16(method1, method2); 5354 - else 5355 - selected_result = method2; 5356 - } else { 5357 - selected_result = method1; 5358 - } 5359 - } 5360 - 5361 - blocks = fixed16_to_u32_round_up(selected_result) + 1; 5362 - /* 5363 - * Lets have blocks at minimum equivalent to plane_blocks_per_line 5364 - * as there will be at minimum one line for lines configuration. This 5365 - * is a work around for FIFO underruns observed with resolutions like 5366 - * 4k 60 Hz in single channel DRAM configurations. 5367 - * 5368 - * As per the Bspec 49325, if the ddb allocation can hold at least 5369 - * one plane_blocks_per_line, we should have selected method2 in 5370 - * the above logic. Assuming that modern versions have enough dbuf 5371 - * and method2 guarantees blocks equivalent to at least 1 line, 5372 - * select the blocks as plane_blocks_per_line. 5373 - * 5374 - * TODO: Revisit the logic when we have better understanding on DRAM 5375 - * channels' impact on the level 0 memory latency and the relevant 5376 - * wm calculations. 5377 - */ 5378 - if (skl_wm_has_lines(dev_priv, level)) 5379 - blocks = max(blocks, 5380 - fixed16_to_u32_round_up(wp->plane_blocks_per_line)); 5381 - lines = div_round_up_fixed16(selected_result, 5382 - wp->plane_blocks_per_line); 5383 - 5384 - if (DISPLAY_VER(dev_priv) == 9) { 5385 - /* Display WA #1125: skl,bxt,kbl */ 5386 - if (level == 0 && wp->rc_surface) 5387 - blocks += fixed16_to_u32_round_up(wp->y_tile_minimum); 5388 - 5389 - /* Display WA #1126: skl,bxt,kbl */ 5390 - if (level >= 1 && level <= 7) { 5391 - if (wp->y_tiled) { 5392 - blocks += fixed16_to_u32_round_up(wp->y_tile_minimum); 5393 - lines += wp->y_min_scanlines; 5394 - } else { 5395 - blocks++; 5396 - } 5397 - 5398 - /* 5399 - * Make sure result blocks for higher latency levels are 5400 - * atleast as high as level below the current level. 5401 - * Assumption in DDB algorithm optimization for special 5402 - * cases. Also covers Display WA #1125 for RC. 5403 - */ 5404 - if (result_prev->blocks > blocks) 5405 - blocks = result_prev->blocks; 5406 - } 5407 - } 5408 - 5409 - if (DISPLAY_VER(dev_priv) >= 11) { 5410 - if (wp->y_tiled) { 5411 - int extra_lines; 5412 - 5413 - if (lines % wp->y_min_scanlines == 0) 5414 - extra_lines = wp->y_min_scanlines; 5415 - else 5416 - extra_lines = wp->y_min_scanlines * 2 - 5417 - lines % wp->y_min_scanlines; 5418 - 5419 - min_ddb_alloc = mul_round_up_u32_fixed16(lines + extra_lines, 5420 - wp->plane_blocks_per_line); 5421 - } else { 5422 - min_ddb_alloc = blocks + DIV_ROUND_UP(blocks, 10); 5423 - } 5424 - } 5425 - 5426 - if (!skl_wm_has_lines(dev_priv, level)) 5427 - lines = 0; 5428 - 5429 - if (lines > skl_wm_max_lines(dev_priv)) { 5430 - /* reject it */ 5431 - result->min_ddb_alloc = U16_MAX; 5432 - return; 5433 - } 5434 - 5435 - /* 5436 - * If lines is valid, assume we can use this watermark level 5437 - * for now. We'll come back and disable it after we calculate the 5438 - * DDB allocation if it turns out we don't actually have enough 5439 - * blocks to satisfy it. 5440 - */ 5441 - result->blocks = blocks; 5442 - result->lines = lines; 5443 - /* Bspec says: value >= plane ddb allocation -> invalid, hence the +1 here */ 5444 - result->min_ddb_alloc = max(min_ddb_alloc, blocks) + 1; 5445 - result->enable = true; 5446 - 5447 - if (DISPLAY_VER(dev_priv) < 12 && dev_priv->display.sagv.block_time_us) 5448 - result->can_sagv = latency >= dev_priv->display.sagv.block_time_us; 5449 - } 5450 - 5451 - static void 5452 - skl_compute_wm_levels(const struct intel_crtc_state *crtc_state, 5453 - struct intel_plane *plane, 5454 - const struct skl_wm_params *wm_params, 5455 - struct skl_wm_level *levels) 5456 - { 5457 - struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev); 5458 - int level, max_level = ilk_wm_max_level(dev_priv); 5459 - struct skl_wm_level *result_prev = &levels[0]; 5460 - 5461 - for (level = 0; level <= max_level; level++) { 5462 - struct skl_wm_level *result = &levels[level]; 5463 - unsigned int latency = dev_priv->display.wm.skl_latency[level]; 5464 - 5465 - skl_compute_plane_wm(crtc_state, plane, level, latency, 5466 - wm_params, result_prev, result); 5467 - 5468 - result_prev = result; 5469 - } 5470 - } 5471 - 5472 - static void tgl_compute_sagv_wm(const struct intel_crtc_state *crtc_state, 5473 - struct intel_plane *plane, 5474 - const struct skl_wm_params *wm_params, 5475 - struct skl_plane_wm *plane_wm) 5476 - { 5477 - struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev); 5478 - struct skl_wm_level *sagv_wm = &plane_wm->sagv.wm0; 5479 - struct skl_wm_level *levels = plane_wm->wm; 5480 - unsigned int latency = 0; 5481 - 5482 - if (dev_priv->display.sagv.block_time_us) 5483 - latency = dev_priv->display.sagv.block_time_us + dev_priv->display.wm.skl_latency[0]; 5484 - 5485 - skl_compute_plane_wm(crtc_state, plane, 0, latency, 5486 - wm_params, &levels[0], 5487 - sagv_wm); 5488 - } 5489 - 5490 - static void skl_compute_transition_wm(struct drm_i915_private *dev_priv, 5491 - struct skl_wm_level *trans_wm, 5492 - const struct skl_wm_level *wm0, 5493 - const struct skl_wm_params *wp) 5494 - { 5495 - u16 trans_min, trans_amount, trans_y_tile_min; 5496 - u16 wm0_blocks, trans_offset, blocks; 5497 - 5498 - /* Transition WM don't make any sense if ipc is disabled */ 5499 - if (!dev_priv->ipc_enabled) 5500 - return; 5501 - 5502 - /* 5503 - * WaDisableTWM:skl,kbl,cfl,bxt 5504 - * Transition WM are not recommended by HW team for GEN9 5505 - */ 5506 - if (DISPLAY_VER(dev_priv) == 9) 5507 - return; 5508 - 5509 - if (DISPLAY_VER(dev_priv) >= 11) 5510 - trans_min = 4; 5511 - else 5512 - trans_min = 14; 5513 - 5514 - /* Display WA #1140: glk,cnl */ 5515 - if (DISPLAY_VER(dev_priv) == 10) 5516 - trans_amount = 0; 5517 - else 5518 - trans_amount = 10; /* This is configurable amount */ 5519 - 5520 - trans_offset = trans_min + trans_amount; 5521 - 5522 - /* 5523 - * The spec asks for Selected Result Blocks for wm0 (the real value), 5524 - * not Result Blocks (the integer value). Pay attention to the capital 5525 - * letters. The value wm_l0->blocks is actually Result Blocks, but 5526 - * since Result Blocks is the ceiling of Selected Result Blocks plus 1, 5527 - * and since we later will have to get the ceiling of the sum in the 5528 - * transition watermarks calculation, we can just pretend Selected 5529 - * Result Blocks is Result Blocks minus 1 and it should work for the 5530 - * current platforms. 5531 - */ 5532 - wm0_blocks = wm0->blocks - 1; 5533 - 5534 - if (wp->y_tiled) { 5535 - trans_y_tile_min = 5536 - (u16)mul_round_up_u32_fixed16(2, wp->y_tile_minimum); 5537 - blocks = max(wm0_blocks, trans_y_tile_min) + trans_offset; 5538 - } else { 5539 - blocks = wm0_blocks + trans_offset; 5540 - } 5541 - blocks++; 5542 - 5543 - /* 5544 - * Just assume we can enable the transition watermark. After 5545 - * computing the DDB we'll come back and disable it if that 5546 - * assumption turns out to be false. 5547 - */ 5548 - trans_wm->blocks = blocks; 5549 - trans_wm->min_ddb_alloc = max_t(u16, wm0->min_ddb_alloc, blocks + 1); 5550 - trans_wm->enable = true; 5551 - } 5552 - 5553 - static int skl_build_plane_wm_single(struct intel_crtc_state *crtc_state, 5554 - const struct intel_plane_state *plane_state, 5555 - struct intel_plane *plane, int color_plane) 5556 - { 5557 - struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 5558 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 5559 - struct skl_plane_wm *wm = &crtc_state->wm.skl.raw.planes[plane->id]; 5560 - struct skl_wm_params wm_params; 5561 - int ret; 5562 - 5563 - ret = skl_compute_plane_wm_params(crtc_state, plane_state, 5564 - &wm_params, color_plane); 5565 - if (ret) 5566 - return ret; 5567 - 5568 - skl_compute_wm_levels(crtc_state, plane, &wm_params, wm->wm); 5569 - 5570 - skl_compute_transition_wm(dev_priv, &wm->trans_wm, 5571 - &wm->wm[0], &wm_params); 5572 - 5573 - if (DISPLAY_VER(dev_priv) >= 12) { 5574 - tgl_compute_sagv_wm(crtc_state, plane, &wm_params, wm); 5575 - 5576 - skl_compute_transition_wm(dev_priv, &wm->sagv.trans_wm, 5577 - &wm->sagv.wm0, &wm_params); 5578 - } 5579 - 5580 - return 0; 5581 - } 5582 - 5583 - static int skl_build_plane_wm_uv(struct intel_crtc_state *crtc_state, 5584 - const struct intel_plane_state *plane_state, 5585 - struct intel_plane *plane) 5586 - { 5587 - struct skl_plane_wm *wm = &crtc_state->wm.skl.raw.planes[plane->id]; 5588 - struct skl_wm_params wm_params; 5589 - int ret; 5590 - 5591 - wm->is_planar = true; 5592 - 5593 - /* uv plane watermarks must also be validated for NV12/Planar */ 5594 - ret = skl_compute_plane_wm_params(crtc_state, plane_state, 5595 - &wm_params, 1); 5596 - if (ret) 5597 - return ret; 5598 - 5599 - skl_compute_wm_levels(crtc_state, plane, &wm_params, wm->uv_wm); 5600 - 5601 - return 0; 5602 - } 5603 - 5604 - static int skl_build_plane_wm(struct intel_crtc_state *crtc_state, 5605 - const struct intel_plane_state *plane_state) 5606 - { 5607 - struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 5608 - enum plane_id plane_id = plane->id; 5609 - struct skl_plane_wm *wm = &crtc_state->wm.skl.raw.planes[plane_id]; 5610 - const struct drm_framebuffer *fb = plane_state->hw.fb; 5611 - int ret; 5612 - 5613 - memset(wm, 0, sizeof(*wm)); 5614 - 5615 - if (!intel_wm_plane_visible(crtc_state, plane_state)) 5616 - return 0; 5617 - 5618 - ret = skl_build_plane_wm_single(crtc_state, plane_state, 5619 - plane, 0); 5620 - if (ret) 5621 - return ret; 5622 - 5623 - if (fb->format->is_yuv && fb->format->num_planes > 1) { 5624 - ret = skl_build_plane_wm_uv(crtc_state, plane_state, 5625 - plane); 5626 - if (ret) 5627 - return ret; 5628 - } 5629 - 5630 - return 0; 5631 - } 5632 - 5633 - static int icl_build_plane_wm(struct intel_crtc_state *crtc_state, 5634 - const struct intel_plane_state *plane_state) 5635 - { 5636 - struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 5637 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 5638 - enum plane_id plane_id = plane->id; 5639 - struct skl_plane_wm *wm = &crtc_state->wm.skl.raw.planes[plane_id]; 5640 - int ret; 5641 - 5642 - /* Watermarks calculated in master */ 5643 - if (plane_state->planar_slave) 5644 - return 0; 5645 - 5646 - memset(wm, 0, sizeof(*wm)); 5647 - 5648 - if (plane_state->planar_linked_plane) { 5649 - const struct drm_framebuffer *fb = plane_state->hw.fb; 5650 - 5651 - drm_WARN_ON(&dev_priv->drm, 5652 - !intel_wm_plane_visible(crtc_state, plane_state)); 5653 - drm_WARN_ON(&dev_priv->drm, !fb->format->is_yuv || 5654 - fb->format->num_planes == 1); 5655 - 5656 - ret = skl_build_plane_wm_single(crtc_state, plane_state, 5657 - plane_state->planar_linked_plane, 0); 5658 - if (ret) 5659 - return ret; 5660 - 5661 - ret = skl_build_plane_wm_single(crtc_state, plane_state, 5662 - plane, 1); 5663 - if (ret) 5664 - return ret; 5665 - } else if (intel_wm_plane_visible(crtc_state, plane_state)) { 5666 - ret = skl_build_plane_wm_single(crtc_state, plane_state, 5667 - plane, 0); 5668 - if (ret) 5669 - return ret; 5670 - } 5671 - 5672 - return 0; 5673 - } 5674 - 5675 - static int skl_build_pipe_wm(struct intel_atomic_state *state, 5676 - struct intel_crtc *crtc) 5677 - { 5678 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 5679 - struct intel_crtc_state *crtc_state = 5680 - intel_atomic_get_new_crtc_state(state, crtc); 5681 - const struct intel_plane_state *plane_state; 5682 - struct intel_plane *plane; 5683 - int ret, i; 5684 - 5685 - for_each_new_intel_plane_in_state(state, plane, plane_state, i) { 5686 - /* 5687 - * FIXME should perhaps check {old,new}_plane_crtc->hw.crtc 5688 - * instead but we don't populate that correctly for NV12 Y 5689 - * planes so for now hack this. 5690 - */ 5691 - if (plane->pipe != crtc->pipe) 5692 - continue; 5693 - 5694 - if (DISPLAY_VER(dev_priv) >= 11) 5695 - ret = icl_build_plane_wm(crtc_state, plane_state); 5696 - else 5697 - ret = skl_build_plane_wm(crtc_state, plane_state); 5698 - if (ret) 5699 - return ret; 5700 - } 5701 - 5702 - crtc_state->wm.skl.optimal = crtc_state->wm.skl.raw; 5703 - 5704 - return 0; 5705 - } 5706 - 5707 - static void skl_ddb_entry_write(struct drm_i915_private *dev_priv, 5708 - i915_reg_t reg, 5709 - const struct skl_ddb_entry *entry) 5710 - { 5711 - if (entry->end) 5712 - intel_de_write_fw(dev_priv, reg, 5713 - PLANE_BUF_END(entry->end - 1) | 5714 - PLANE_BUF_START(entry->start)); 5715 - else 5716 - intel_de_write_fw(dev_priv, reg, 0); 5717 - } 5718 - 5719 - static void skl_write_wm_level(struct drm_i915_private *dev_priv, 5720 - i915_reg_t reg, 5721 - const struct skl_wm_level *level) 5722 - { 5723 - u32 val = 0; 5724 - 5725 - if (level->enable) 5726 - val |= PLANE_WM_EN; 5727 - if (level->ignore_lines) 5728 - val |= PLANE_WM_IGNORE_LINES; 5729 - val |= REG_FIELD_PREP(PLANE_WM_BLOCKS_MASK, level->blocks); 5730 - val |= REG_FIELD_PREP(PLANE_WM_LINES_MASK, level->lines); 5731 - 5732 - intel_de_write_fw(dev_priv, reg, val); 5733 - } 5734 - 5735 - void skl_write_plane_wm(struct intel_plane *plane, 5736 - const struct intel_crtc_state *crtc_state) 5737 - { 5738 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 5739 - int level, max_level = ilk_wm_max_level(dev_priv); 5740 - enum plane_id plane_id = plane->id; 5741 - enum pipe pipe = plane->pipe; 5742 - const struct skl_pipe_wm *pipe_wm = &crtc_state->wm.skl.optimal; 5743 - const struct skl_ddb_entry *ddb = 5744 - &crtc_state->wm.skl.plane_ddb[plane_id]; 5745 - const struct skl_ddb_entry *ddb_y = 5746 - &crtc_state->wm.skl.plane_ddb_y[plane_id]; 5747 - 5748 - for (level = 0; level <= max_level; level++) 5749 - skl_write_wm_level(dev_priv, PLANE_WM(pipe, plane_id, level), 5750 - skl_plane_wm_level(pipe_wm, plane_id, level)); 5751 - 5752 - skl_write_wm_level(dev_priv, PLANE_WM_TRANS(pipe, plane_id), 5753 - skl_plane_trans_wm(pipe_wm, plane_id)); 5754 - 5755 - if (HAS_HW_SAGV_WM(dev_priv)) { 5756 - const struct skl_plane_wm *wm = &pipe_wm->planes[plane_id]; 5757 - 5758 - skl_write_wm_level(dev_priv, PLANE_WM_SAGV(pipe, plane_id), 5759 - &wm->sagv.wm0); 5760 - skl_write_wm_level(dev_priv, PLANE_WM_SAGV_TRANS(pipe, plane_id), 5761 - &wm->sagv.trans_wm); 5762 - } 5763 - 5764 - skl_ddb_entry_write(dev_priv, 5765 - PLANE_BUF_CFG(pipe, plane_id), ddb); 5766 - 5767 - if (DISPLAY_VER(dev_priv) < 11) 5768 - skl_ddb_entry_write(dev_priv, 5769 - PLANE_NV12_BUF_CFG(pipe, plane_id), ddb_y); 5770 - } 5771 - 5772 - void skl_write_cursor_wm(struct intel_plane *plane, 5773 - const struct intel_crtc_state *crtc_state) 5774 - { 5775 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 5776 - int level, max_level = ilk_wm_max_level(dev_priv); 5777 - enum plane_id plane_id = plane->id; 5778 - enum pipe pipe = plane->pipe; 5779 - const struct skl_pipe_wm *pipe_wm = &crtc_state->wm.skl.optimal; 5780 - const struct skl_ddb_entry *ddb = 5781 - &crtc_state->wm.skl.plane_ddb[plane_id]; 5782 - 5783 - for (level = 0; level <= max_level; level++) 5784 - skl_write_wm_level(dev_priv, CUR_WM(pipe, level), 5785 - skl_plane_wm_level(pipe_wm, plane_id, level)); 5786 - 5787 - skl_write_wm_level(dev_priv, CUR_WM_TRANS(pipe), 5788 - skl_plane_trans_wm(pipe_wm, plane_id)); 5789 - 5790 - if (HAS_HW_SAGV_WM(dev_priv)) { 5791 - const struct skl_plane_wm *wm = &pipe_wm->planes[plane_id]; 5792 - 5793 - skl_write_wm_level(dev_priv, CUR_WM_SAGV(pipe), 5794 - &wm->sagv.wm0); 5795 - skl_write_wm_level(dev_priv, CUR_WM_SAGV_TRANS(pipe), 5796 - &wm->sagv.trans_wm); 5797 - } 5798 - 5799 - skl_ddb_entry_write(dev_priv, CUR_BUF_CFG(pipe), ddb); 5800 - } 5801 - 5802 - static bool skl_wm_level_equals(const struct skl_wm_level *l1, 5803 - const struct skl_wm_level *l2) 5804 - { 5805 - return l1->enable == l2->enable && 5806 - l1->ignore_lines == l2->ignore_lines && 5807 - l1->lines == l2->lines && 5808 - l1->blocks == l2->blocks; 5809 - } 5810 - 5811 - static bool skl_plane_wm_equals(struct drm_i915_private *dev_priv, 5812 - const struct skl_plane_wm *wm1, 5813 - const struct skl_plane_wm *wm2) 5814 - { 5815 - int level, max_level = ilk_wm_max_level(dev_priv); 5816 - 5817 - for (level = 0; level <= max_level; level++) { 5818 - /* 5819 - * We don't check uv_wm as the hardware doesn't actually 5820 - * use it. It only gets used for calculating the required 5821 - * ddb allocation. 5822 - */ 5823 - if (!skl_wm_level_equals(&wm1->wm[level], &wm2->wm[level])) 5824 - return false; 5825 - } 5826 - 5827 - return skl_wm_level_equals(&wm1->trans_wm, &wm2->trans_wm) && 5828 - skl_wm_level_equals(&wm1->sagv.wm0, &wm2->sagv.wm0) && 5829 - skl_wm_level_equals(&wm1->sagv.trans_wm, &wm2->sagv.trans_wm); 5830 - } 5831 - 5832 - static bool skl_ddb_entries_overlap(const struct skl_ddb_entry *a, 5833 - const struct skl_ddb_entry *b) 5834 - { 5835 - return a->start < b->end && b->start < a->end; 5836 - } 5837 - 5838 - static void skl_ddb_entry_union(struct skl_ddb_entry *a, 5839 - const struct skl_ddb_entry *b) 5840 - { 5841 - if (a->end && b->end) { 5842 - a->start = min(a->start, b->start); 5843 - a->end = max(a->end, b->end); 5844 - } else if (b->end) { 5845 - a->start = b->start; 5846 - a->end = b->end; 5847 - } 5848 - } 5849 - 5850 - bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry *ddb, 5851 - const struct skl_ddb_entry *entries, 5852 - int num_entries, int ignore_idx) 5853 - { 5854 - int i; 5855 - 5856 - for (i = 0; i < num_entries; i++) { 5857 - if (i != ignore_idx && 5858 - skl_ddb_entries_overlap(ddb, &entries[i])) 5859 - return true; 5860 - } 5861 - 5862 - return false; 5863 - } 5864 - 5865 - static int 5866 - skl_ddb_add_affected_planes(const struct intel_crtc_state *old_crtc_state, 5867 - struct intel_crtc_state *new_crtc_state) 5868 - { 5869 - struct intel_atomic_state *state = to_intel_atomic_state(new_crtc_state->uapi.state); 5870 - struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->uapi.crtc); 5871 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 5872 - struct intel_plane *plane; 5873 - 5874 - for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) { 5875 - struct intel_plane_state *plane_state; 5876 - enum plane_id plane_id = plane->id; 5877 - 5878 - if (skl_ddb_entry_equal(&old_crtc_state->wm.skl.plane_ddb[plane_id], 5879 - &new_crtc_state->wm.skl.plane_ddb[plane_id]) && 5880 - skl_ddb_entry_equal(&old_crtc_state->wm.skl.plane_ddb_y[plane_id], 5881 - &new_crtc_state->wm.skl.plane_ddb_y[plane_id])) 5882 - continue; 5883 - 5884 - plane_state = intel_atomic_get_plane_state(state, plane); 5885 - if (IS_ERR(plane_state)) 5886 - return PTR_ERR(plane_state); 5887 - 5888 - new_crtc_state->update_planes |= BIT(plane_id); 5889 - } 5890 - 5891 - return 0; 5892 - } 5893 - 5894 - static u8 intel_dbuf_enabled_slices(const struct intel_dbuf_state *dbuf_state) 5895 - { 5896 - struct drm_i915_private *dev_priv = to_i915(dbuf_state->base.state->base.dev); 5897 - u8 enabled_slices; 5898 - enum pipe pipe; 5899 - 5900 - /* 5901 - * FIXME: For now we always enable slice S1 as per 5902 - * the Bspec display initialization sequence. 5903 - */ 5904 - enabled_slices = BIT(DBUF_S1); 5905 - 5906 - for_each_pipe(dev_priv, pipe) 5907 - enabled_slices |= dbuf_state->slices[pipe]; 5908 - 5909 - return enabled_slices; 5910 - } 5911 - 5912 - static int 5913 - skl_compute_ddb(struct intel_atomic_state *state) 5914 - { 5915 - struct drm_i915_private *dev_priv = to_i915(state->base.dev); 5916 - const struct intel_dbuf_state *old_dbuf_state; 5917 - struct intel_dbuf_state *new_dbuf_state = NULL; 5918 - const struct intel_crtc_state *old_crtc_state; 5919 - struct intel_crtc_state *new_crtc_state; 5920 - struct intel_crtc *crtc; 5921 - int ret, i; 5922 - 5923 - for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 5924 - new_dbuf_state = intel_atomic_get_dbuf_state(state); 5925 - if (IS_ERR(new_dbuf_state)) 5926 - return PTR_ERR(new_dbuf_state); 5927 - 5928 - old_dbuf_state = intel_atomic_get_old_dbuf_state(state); 5929 - break; 5930 - } 5931 - 5932 - if (!new_dbuf_state) 5933 - return 0; 5934 - 5935 - new_dbuf_state->active_pipes = 5936 - intel_calc_active_pipes(state, old_dbuf_state->active_pipes); 5937 - 5938 - if (old_dbuf_state->active_pipes != new_dbuf_state->active_pipes) { 5939 - ret = intel_atomic_lock_global_state(&new_dbuf_state->base); 5940 - if (ret) 5941 - return ret; 5942 - } 5943 - 5944 - if (HAS_MBUS_JOINING(dev_priv)) 5945 - new_dbuf_state->joined_mbus = 5946 - adlp_check_mbus_joined(new_dbuf_state->active_pipes); 5947 - 5948 - for_each_intel_crtc(&dev_priv->drm, crtc) { 5949 - enum pipe pipe = crtc->pipe; 5950 - 5951 - new_dbuf_state->slices[pipe] = 5952 - skl_compute_dbuf_slices(crtc, new_dbuf_state->active_pipes, 5953 - new_dbuf_state->joined_mbus); 5954 - 5955 - if (old_dbuf_state->slices[pipe] == new_dbuf_state->slices[pipe]) 5956 - continue; 5957 - 5958 - ret = intel_atomic_lock_global_state(&new_dbuf_state->base); 5959 - if (ret) 5960 - return ret; 5961 - } 5962 - 5963 - new_dbuf_state->enabled_slices = intel_dbuf_enabled_slices(new_dbuf_state); 5964 - 5965 - if (old_dbuf_state->enabled_slices != new_dbuf_state->enabled_slices || 5966 - old_dbuf_state->joined_mbus != new_dbuf_state->joined_mbus) { 5967 - ret = intel_atomic_serialize_global_state(&new_dbuf_state->base); 5968 - if (ret) 5969 - return ret; 5970 - 5971 - if (old_dbuf_state->joined_mbus != new_dbuf_state->joined_mbus) { 5972 - /* TODO: Implement vblank synchronized MBUS joining changes */ 5973 - ret = intel_modeset_all_pipes(state); 5974 - if (ret) 5975 - return ret; 5976 - } 5977 - 5978 - drm_dbg_kms(&dev_priv->drm, 5979 - "Enabled dbuf slices 0x%x -> 0x%x (total dbuf slices 0x%x), mbus joined? %s->%s\n", 5980 - old_dbuf_state->enabled_slices, 5981 - new_dbuf_state->enabled_slices, 5982 - INTEL_INFO(dev_priv)->display.dbuf.slice_mask, 5983 - str_yes_no(old_dbuf_state->joined_mbus), 5984 - str_yes_no(new_dbuf_state->joined_mbus)); 5985 - } 5986 - 5987 - for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 5988 - enum pipe pipe = crtc->pipe; 5989 - 5990 - new_dbuf_state->weight[pipe] = intel_crtc_ddb_weight(new_crtc_state); 5991 - 5992 - if (old_dbuf_state->weight[pipe] == new_dbuf_state->weight[pipe]) 5993 - continue; 5994 - 5995 - ret = intel_atomic_lock_global_state(&new_dbuf_state->base); 5996 - if (ret) 5997 - return ret; 5998 - } 5999 - 6000 - for_each_intel_crtc(&dev_priv->drm, crtc) { 6001 - ret = skl_crtc_allocate_ddb(state, crtc); 6002 - if (ret) 6003 - return ret; 6004 - } 6005 - 6006 - for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, 6007 - new_crtc_state, i) { 6008 - ret = skl_crtc_allocate_plane_ddb(state, crtc); 6009 - if (ret) 6010 - return ret; 6011 - 6012 - ret = skl_ddb_add_affected_planes(old_crtc_state, 6013 - new_crtc_state); 6014 - if (ret) 6015 - return ret; 6016 - } 6017 - 6018 - return 0; 6019 - } 6020 - 6021 - static char enast(bool enable) 6022 - { 6023 - return enable ? '*' : ' '; 6024 - } 6025 - 6026 - static void 6027 - skl_print_wm_changes(struct intel_atomic_state *state) 6028 - { 6029 - struct drm_i915_private *dev_priv = to_i915(state->base.dev); 6030 - const struct intel_crtc_state *old_crtc_state; 6031 - const struct intel_crtc_state *new_crtc_state; 6032 - struct intel_plane *plane; 6033 - struct intel_crtc *crtc; 6034 - int i; 6035 - 6036 - if (!drm_debug_enabled(DRM_UT_KMS)) 6037 - return; 6038 - 6039 - for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, 6040 - new_crtc_state, i) { 6041 - const struct skl_pipe_wm *old_pipe_wm, *new_pipe_wm; 6042 - 6043 - old_pipe_wm = &old_crtc_state->wm.skl.optimal; 6044 - new_pipe_wm = &new_crtc_state->wm.skl.optimal; 6045 - 6046 - for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) { 6047 - enum plane_id plane_id = plane->id; 6048 - const struct skl_ddb_entry *old, *new; 6049 - 6050 - old = &old_crtc_state->wm.skl.plane_ddb[plane_id]; 6051 - new = &new_crtc_state->wm.skl.plane_ddb[plane_id]; 6052 - 6053 - if (skl_ddb_entry_equal(old, new)) 6054 - continue; 6055 - 6056 - drm_dbg_kms(&dev_priv->drm, 6057 - "[PLANE:%d:%s] ddb (%4d - %4d) -> (%4d - %4d), size %4d -> %4d\n", 6058 - plane->base.base.id, plane->base.name, 6059 - old->start, old->end, new->start, new->end, 6060 - skl_ddb_entry_size(old), skl_ddb_entry_size(new)); 6061 - } 6062 - 6063 - for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) { 6064 - enum plane_id plane_id = plane->id; 6065 - const struct skl_plane_wm *old_wm, *new_wm; 6066 - 6067 - old_wm = &old_pipe_wm->planes[plane_id]; 6068 - new_wm = &new_pipe_wm->planes[plane_id]; 6069 - 6070 - if (skl_plane_wm_equals(dev_priv, old_wm, new_wm)) 6071 - continue; 6072 - 6073 - drm_dbg_kms(&dev_priv->drm, 6074 - "[PLANE:%d:%s] level %cwm0,%cwm1,%cwm2,%cwm3,%cwm4,%cwm5,%cwm6,%cwm7,%ctwm,%cswm,%cstwm" 6075 - " -> %cwm0,%cwm1,%cwm2,%cwm3,%cwm4,%cwm5,%cwm6,%cwm7,%ctwm,%cswm,%cstwm\n", 6076 - plane->base.base.id, plane->base.name, 6077 - enast(old_wm->wm[0].enable), enast(old_wm->wm[1].enable), 6078 - enast(old_wm->wm[2].enable), enast(old_wm->wm[3].enable), 6079 - enast(old_wm->wm[4].enable), enast(old_wm->wm[5].enable), 6080 - enast(old_wm->wm[6].enable), enast(old_wm->wm[7].enable), 6081 - enast(old_wm->trans_wm.enable), 6082 - enast(old_wm->sagv.wm0.enable), 6083 - enast(old_wm->sagv.trans_wm.enable), 6084 - enast(new_wm->wm[0].enable), enast(new_wm->wm[1].enable), 6085 - enast(new_wm->wm[2].enable), enast(new_wm->wm[3].enable), 6086 - enast(new_wm->wm[4].enable), enast(new_wm->wm[5].enable), 6087 - enast(new_wm->wm[6].enable), enast(new_wm->wm[7].enable), 6088 - enast(new_wm->trans_wm.enable), 6089 - enast(new_wm->sagv.wm0.enable), 6090 - enast(new_wm->sagv.trans_wm.enable)); 6091 - 6092 - drm_dbg_kms(&dev_priv->drm, 6093 - "[PLANE:%d:%s] lines %c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%4d" 6094 - " -> %c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%4d\n", 6095 - plane->base.base.id, plane->base.name, 6096 - enast(old_wm->wm[0].ignore_lines), old_wm->wm[0].lines, 6097 - enast(old_wm->wm[1].ignore_lines), old_wm->wm[1].lines, 6098 - enast(old_wm->wm[2].ignore_lines), old_wm->wm[2].lines, 6099 - enast(old_wm->wm[3].ignore_lines), old_wm->wm[3].lines, 6100 - enast(old_wm->wm[4].ignore_lines), old_wm->wm[4].lines, 6101 - enast(old_wm->wm[5].ignore_lines), old_wm->wm[5].lines, 6102 - enast(old_wm->wm[6].ignore_lines), old_wm->wm[6].lines, 6103 - enast(old_wm->wm[7].ignore_lines), old_wm->wm[7].lines, 6104 - enast(old_wm->trans_wm.ignore_lines), old_wm->trans_wm.lines, 6105 - enast(old_wm->sagv.wm0.ignore_lines), old_wm->sagv.wm0.lines, 6106 - enast(old_wm->sagv.trans_wm.ignore_lines), old_wm->sagv.trans_wm.lines, 6107 - enast(new_wm->wm[0].ignore_lines), new_wm->wm[0].lines, 6108 - enast(new_wm->wm[1].ignore_lines), new_wm->wm[1].lines, 6109 - enast(new_wm->wm[2].ignore_lines), new_wm->wm[2].lines, 6110 - enast(new_wm->wm[3].ignore_lines), new_wm->wm[3].lines, 6111 - enast(new_wm->wm[4].ignore_lines), new_wm->wm[4].lines, 6112 - enast(new_wm->wm[5].ignore_lines), new_wm->wm[5].lines, 6113 - enast(new_wm->wm[6].ignore_lines), new_wm->wm[6].lines, 6114 - enast(new_wm->wm[7].ignore_lines), new_wm->wm[7].lines, 6115 - enast(new_wm->trans_wm.ignore_lines), new_wm->trans_wm.lines, 6116 - enast(new_wm->sagv.wm0.ignore_lines), new_wm->sagv.wm0.lines, 6117 - enast(new_wm->sagv.trans_wm.ignore_lines), new_wm->sagv.trans_wm.lines); 6118 - 6119 - drm_dbg_kms(&dev_priv->drm, 6120 - "[PLANE:%d:%s] blocks %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%5d" 6121 - " -> %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%5d\n", 6122 - plane->base.base.id, plane->base.name, 6123 - old_wm->wm[0].blocks, old_wm->wm[1].blocks, 6124 - old_wm->wm[2].blocks, old_wm->wm[3].blocks, 6125 - old_wm->wm[4].blocks, old_wm->wm[5].blocks, 6126 - old_wm->wm[6].blocks, old_wm->wm[7].blocks, 6127 - old_wm->trans_wm.blocks, 6128 - old_wm->sagv.wm0.blocks, 6129 - old_wm->sagv.trans_wm.blocks, 6130 - new_wm->wm[0].blocks, new_wm->wm[1].blocks, 6131 - new_wm->wm[2].blocks, new_wm->wm[3].blocks, 6132 - new_wm->wm[4].blocks, new_wm->wm[5].blocks, 6133 - new_wm->wm[6].blocks, new_wm->wm[7].blocks, 6134 - new_wm->trans_wm.blocks, 6135 - new_wm->sagv.wm0.blocks, 6136 - new_wm->sagv.trans_wm.blocks); 6137 - 6138 - drm_dbg_kms(&dev_priv->drm, 6139 - "[PLANE:%d:%s] min_ddb %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%5d" 6140 - " -> %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%5d\n", 6141 - plane->base.base.id, plane->base.name, 6142 - old_wm->wm[0].min_ddb_alloc, old_wm->wm[1].min_ddb_alloc, 6143 - old_wm->wm[2].min_ddb_alloc, old_wm->wm[3].min_ddb_alloc, 6144 - old_wm->wm[4].min_ddb_alloc, old_wm->wm[5].min_ddb_alloc, 6145 - old_wm->wm[6].min_ddb_alloc, old_wm->wm[7].min_ddb_alloc, 6146 - old_wm->trans_wm.min_ddb_alloc, 6147 - old_wm->sagv.wm0.min_ddb_alloc, 6148 - old_wm->sagv.trans_wm.min_ddb_alloc, 6149 - new_wm->wm[0].min_ddb_alloc, new_wm->wm[1].min_ddb_alloc, 6150 - new_wm->wm[2].min_ddb_alloc, new_wm->wm[3].min_ddb_alloc, 6151 - new_wm->wm[4].min_ddb_alloc, new_wm->wm[5].min_ddb_alloc, 6152 - new_wm->wm[6].min_ddb_alloc, new_wm->wm[7].min_ddb_alloc, 6153 - new_wm->trans_wm.min_ddb_alloc, 6154 - new_wm->sagv.wm0.min_ddb_alloc, 6155 - new_wm->sagv.trans_wm.min_ddb_alloc); 6156 - } 6157 - } 6158 - } 6159 - 6160 - static bool skl_plane_selected_wm_equals(struct intel_plane *plane, 6161 - const struct skl_pipe_wm *old_pipe_wm, 6162 - const struct skl_pipe_wm *new_pipe_wm) 6163 - { 6164 - struct drm_i915_private *i915 = to_i915(plane->base.dev); 6165 - int level, max_level = ilk_wm_max_level(i915); 6166 - 6167 - for (level = 0; level <= max_level; level++) { 6168 - /* 6169 - * We don't check uv_wm as the hardware doesn't actually 6170 - * use it. It only gets used for calculating the required 6171 - * ddb allocation. 6172 - */ 6173 - if (!skl_wm_level_equals(skl_plane_wm_level(old_pipe_wm, plane->id, level), 6174 - skl_plane_wm_level(new_pipe_wm, plane->id, level))) 6175 - return false; 6176 - } 6177 - 6178 - if (HAS_HW_SAGV_WM(i915)) { 6179 - const struct skl_plane_wm *old_wm = &old_pipe_wm->planes[plane->id]; 6180 - const struct skl_plane_wm *new_wm = &new_pipe_wm->planes[plane->id]; 6181 - 6182 - if (!skl_wm_level_equals(&old_wm->sagv.wm0, &new_wm->sagv.wm0) || 6183 - !skl_wm_level_equals(&old_wm->sagv.trans_wm, &new_wm->sagv.trans_wm)) 6184 - return false; 6185 - } 6186 - 6187 - return skl_wm_level_equals(skl_plane_trans_wm(old_pipe_wm, plane->id), 6188 - skl_plane_trans_wm(new_pipe_wm, plane->id)); 6189 - } 6190 - 6191 - /* 6192 - * To make sure the cursor watermark registers are always consistent 6193 - * with our computed state the following scenario needs special 6194 - * treatment: 6195 - * 6196 - * 1. enable cursor 6197 - * 2. move cursor entirely offscreen 6198 - * 3. disable cursor 6199 - * 6200 - * Step 2. does call .disable_plane() but does not zero the watermarks 6201 - * (since we consider an offscreen cursor still active for the purposes 6202 - * of watermarks). Step 3. would not normally call .disable_plane() 6203 - * because the actual plane visibility isn't changing, and we don't 6204 - * deallocate the cursor ddb until the pipe gets disabled. So we must 6205 - * force step 3. to call .disable_plane() to update the watermark 6206 - * registers properly. 6207 - * 6208 - * Other planes do not suffer from this issues as their watermarks are 6209 - * calculated based on the actual plane visibility. The only time this 6210 - * can trigger for the other planes is during the initial readout as the 6211 - * default value of the watermarks registers is not zero. 6212 - */ 6213 - static int skl_wm_add_affected_planes(struct intel_atomic_state *state, 6214 - struct intel_crtc *crtc) 6215 - { 6216 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 6217 - const struct intel_crtc_state *old_crtc_state = 6218 - intel_atomic_get_old_crtc_state(state, crtc); 6219 - struct intel_crtc_state *new_crtc_state = 6220 - intel_atomic_get_new_crtc_state(state, crtc); 6221 - struct intel_plane *plane; 6222 - 6223 - for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) { 6224 - struct intel_plane_state *plane_state; 6225 - enum plane_id plane_id = plane->id; 6226 - 6227 - /* 6228 - * Force a full wm update for every plane on modeset. 6229 - * Required because the reset value of the wm registers 6230 - * is non-zero, whereas we want all disabled planes to 6231 - * have zero watermarks. So if we turn off the relevant 6232 - * power well the hardware state will go out of sync 6233 - * with the software state. 6234 - */ 6235 - if (!drm_atomic_crtc_needs_modeset(&new_crtc_state->uapi) && 6236 - skl_plane_selected_wm_equals(plane, 6237 - &old_crtc_state->wm.skl.optimal, 6238 - &new_crtc_state->wm.skl.optimal)) 6239 - continue; 6240 - 6241 - plane_state = intel_atomic_get_plane_state(state, plane); 6242 - if (IS_ERR(plane_state)) 6243 - return PTR_ERR(plane_state); 6244 - 6245 - new_crtc_state->update_planes |= BIT(plane_id); 6246 - } 6247 - 6248 - return 0; 6249 - } 6250 - 6251 - static int 6252 - skl_compute_wm(struct intel_atomic_state *state) 6253 - { 6254 - struct intel_crtc *crtc; 6255 - struct intel_crtc_state *new_crtc_state; 6256 - int ret, i; 6257 - 6258 - for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 6259 - ret = skl_build_pipe_wm(state, crtc); 6260 - if (ret) 6261 - return ret; 6262 - } 6263 - 6264 - ret = skl_compute_ddb(state); 6265 - if (ret) 6266 - return ret; 6267 - 6268 - ret = intel_compute_sagv_mask(state); 6269 - if (ret) 6270 - return ret; 6271 - 6272 - /* 6273 - * skl_compute_ddb() will have adjusted the final watermarks 6274 - * based on how much ddb is available. Now we can actually 6275 - * check if the final watermarks changed. 6276 - */ 6277 - for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 6278 - ret = skl_wm_add_affected_planes(state, crtc); 6279 - if (ret) 6280 - return ret; 6281 - } 6282 - 6283 - skl_print_wm_changes(state); 6284 - 6285 - return 0; 6286 - } 6287 - 6288 3667 static void ilk_compute_wm_config(struct drm_i915_private *dev_priv, 6289 3668 struct intel_wm_config *config) 6290 3669 { ··· 3603 6500 crtc->wm.active.ilk = crtc_state->wm.ilk.optimal; 3604 6501 ilk_program_watermarks(dev_priv); 3605 6502 mutex_unlock(&dev_priv->display.wm.wm_mutex); 3606 - } 3607 - 3608 - static void skl_wm_level_from_reg_val(u32 val, struct skl_wm_level *level) 3609 - { 3610 - level->enable = val & PLANE_WM_EN; 3611 - level->ignore_lines = val & PLANE_WM_IGNORE_LINES; 3612 - level->blocks = REG_FIELD_GET(PLANE_WM_BLOCKS_MASK, val); 3613 - level->lines = REG_FIELD_GET(PLANE_WM_LINES_MASK, val); 3614 - } 3615 - 3616 - static void skl_pipe_wm_get_hw_state(struct intel_crtc *crtc, 3617 - struct skl_pipe_wm *out) 3618 - { 3619 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 3620 - enum pipe pipe = crtc->pipe; 3621 - int level, max_level; 3622 - enum plane_id plane_id; 3623 - u32 val; 3624 - 3625 - max_level = ilk_wm_max_level(dev_priv); 3626 - 3627 - for_each_plane_id_on_crtc(crtc, plane_id) { 3628 - struct skl_plane_wm *wm = &out->planes[plane_id]; 3629 - 3630 - for (level = 0; level <= max_level; level++) { 3631 - if (plane_id != PLANE_CURSOR) 3632 - val = intel_uncore_read(&dev_priv->uncore, PLANE_WM(pipe, plane_id, level)); 3633 - else 3634 - val = intel_uncore_read(&dev_priv->uncore, CUR_WM(pipe, level)); 3635 - 3636 - skl_wm_level_from_reg_val(val, &wm->wm[level]); 3637 - } 3638 - 3639 - if (plane_id != PLANE_CURSOR) 3640 - val = intel_uncore_read(&dev_priv->uncore, PLANE_WM_TRANS(pipe, plane_id)); 3641 - else 3642 - val = intel_uncore_read(&dev_priv->uncore, CUR_WM_TRANS(pipe)); 3643 - 3644 - skl_wm_level_from_reg_val(val, &wm->trans_wm); 3645 - 3646 - if (HAS_HW_SAGV_WM(dev_priv)) { 3647 - if (plane_id != PLANE_CURSOR) 3648 - val = intel_uncore_read(&dev_priv->uncore, 3649 - PLANE_WM_SAGV(pipe, plane_id)); 3650 - else 3651 - val = intel_uncore_read(&dev_priv->uncore, 3652 - CUR_WM_SAGV(pipe)); 3653 - 3654 - skl_wm_level_from_reg_val(val, &wm->sagv.wm0); 3655 - 3656 - if (plane_id != PLANE_CURSOR) 3657 - val = intel_uncore_read(&dev_priv->uncore, 3658 - PLANE_WM_SAGV_TRANS(pipe, plane_id)); 3659 - else 3660 - val = intel_uncore_read(&dev_priv->uncore, 3661 - CUR_WM_SAGV_TRANS(pipe)); 3662 - 3663 - skl_wm_level_from_reg_val(val, &wm->sagv.trans_wm); 3664 - } else if (DISPLAY_VER(dev_priv) >= 12) { 3665 - wm->sagv.wm0 = wm->wm[0]; 3666 - wm->sagv.trans_wm = wm->trans_wm; 3667 - } 3668 - } 3669 - } 3670 - 3671 - void skl_wm_get_hw_state(struct drm_i915_private *dev_priv) 3672 - { 3673 - struct intel_dbuf_state *dbuf_state = 3674 - to_intel_dbuf_state(dev_priv->dbuf.obj.state); 3675 - struct intel_crtc *crtc; 3676 - 3677 - if (HAS_MBUS_JOINING(dev_priv)) 3678 - dbuf_state->joined_mbus = intel_de_read(dev_priv, MBUS_CTL) & MBUS_JOIN; 3679 - 3680 - for_each_intel_crtc(&dev_priv->drm, crtc) { 3681 - struct intel_crtc_state *crtc_state = 3682 - to_intel_crtc_state(crtc->base.state); 3683 - enum pipe pipe = crtc->pipe; 3684 - unsigned int mbus_offset; 3685 - enum plane_id plane_id; 3686 - u8 slices; 3687 - 3688 - memset(&crtc_state->wm.skl.optimal, 0, 3689 - sizeof(crtc_state->wm.skl.optimal)); 3690 - if (crtc_state->hw.active) 3691 - skl_pipe_wm_get_hw_state(crtc, &crtc_state->wm.skl.optimal); 3692 - crtc_state->wm.skl.raw = crtc_state->wm.skl.optimal; 3693 - 3694 - memset(&dbuf_state->ddb[pipe], 0, sizeof(dbuf_state->ddb[pipe])); 3695 - 3696 - for_each_plane_id_on_crtc(crtc, plane_id) { 3697 - struct skl_ddb_entry *ddb = 3698 - &crtc_state->wm.skl.plane_ddb[plane_id]; 3699 - struct skl_ddb_entry *ddb_y = 3700 - &crtc_state->wm.skl.plane_ddb_y[plane_id]; 3701 - 3702 - if (!crtc_state->hw.active) 3703 - continue; 3704 - 3705 - skl_ddb_get_hw_plane_state(dev_priv, crtc->pipe, 3706 - plane_id, ddb, ddb_y); 3707 - 3708 - skl_ddb_entry_union(&dbuf_state->ddb[pipe], ddb); 3709 - skl_ddb_entry_union(&dbuf_state->ddb[pipe], ddb_y); 3710 - } 3711 - 3712 - dbuf_state->weight[pipe] = intel_crtc_ddb_weight(crtc_state); 3713 - 3714 - /* 3715 - * Used for checking overlaps, so we need absolute 3716 - * offsets instead of MBUS relative offsets. 3717 - */ 3718 - slices = skl_compute_dbuf_slices(crtc, dbuf_state->active_pipes, 3719 - dbuf_state->joined_mbus); 3720 - mbus_offset = mbus_ddb_offset(dev_priv, slices); 3721 - crtc_state->wm.skl.ddb.start = mbus_offset + dbuf_state->ddb[pipe].start; 3722 - crtc_state->wm.skl.ddb.end = mbus_offset + dbuf_state->ddb[pipe].end; 3723 - 3724 - /* The slices actually used by the planes on the pipe */ 3725 - dbuf_state->slices[pipe] = 3726 - skl_ddb_dbuf_slice_mask(dev_priv, &crtc_state->wm.skl.ddb); 3727 - 3728 - drm_dbg_kms(&dev_priv->drm, 3729 - "[CRTC:%d:%s] dbuf slices 0x%x, ddb (%d - %d), active pipes 0x%x, mbus joined: %s\n", 3730 - crtc->base.base.id, crtc->base.name, 3731 - dbuf_state->slices[pipe], dbuf_state->ddb[pipe].start, 3732 - dbuf_state->ddb[pipe].end, dbuf_state->active_pipes, 3733 - str_yes_no(dbuf_state->joined_mbus)); 3734 - } 3735 - 3736 - dbuf_state->enabled_slices = dev_priv->dbuf.enabled_slices; 3737 - } 3738 - 3739 - static bool skl_dbuf_is_misconfigured(struct drm_i915_private *i915) 3740 - { 3741 - const struct intel_dbuf_state *dbuf_state = 3742 - to_intel_dbuf_state(i915->dbuf.obj.state); 3743 - struct skl_ddb_entry entries[I915_MAX_PIPES] = {}; 3744 - struct intel_crtc *crtc; 3745 - 3746 - for_each_intel_crtc(&i915->drm, crtc) { 3747 - const struct intel_crtc_state *crtc_state = 3748 - to_intel_crtc_state(crtc->base.state); 3749 - 3750 - entries[crtc->pipe] = crtc_state->wm.skl.ddb; 3751 - } 3752 - 3753 - for_each_intel_crtc(&i915->drm, crtc) { 3754 - const struct intel_crtc_state *crtc_state = 3755 - to_intel_crtc_state(crtc->base.state); 3756 - u8 slices; 3757 - 3758 - slices = skl_compute_dbuf_slices(crtc, dbuf_state->active_pipes, 3759 - dbuf_state->joined_mbus); 3760 - if (dbuf_state->slices[crtc->pipe] & ~slices) 3761 - return true; 3762 - 3763 - if (skl_ddb_allocation_overlaps(&crtc_state->wm.skl.ddb, entries, 3764 - I915_MAX_PIPES, crtc->pipe)) 3765 - return true; 3766 - } 3767 - 3768 - return false; 3769 - } 3770 - 3771 - void skl_wm_sanitize(struct drm_i915_private *i915) 3772 - { 3773 - struct intel_crtc *crtc; 3774 - 3775 - /* 3776 - * On TGL/RKL (at least) the BIOS likes to assign the planes 3777 - * to the wrong DBUF slices. This will cause an infinite loop 3778 - * in skl_commit_modeset_enables() as it can't find a way to 3779 - * transition between the old bogus DBUF layout to the new 3780 - * proper DBUF layout without DBUF allocation overlaps between 3781 - * the planes (which cannot be allowed or else the hardware 3782 - * may hang). If we detect a bogus DBUF layout just turn off 3783 - * all the planes so that skl_commit_modeset_enables() can 3784 - * simply ignore them. 3785 - */ 3786 - if (!skl_dbuf_is_misconfigured(i915)) 3787 - return; 3788 - 3789 - drm_dbg_kms(&i915->drm, "BIOS has misprogrammed the DBUF, disabling all planes\n"); 3790 - 3791 - for_each_intel_crtc(&i915->drm, crtc) { 3792 - struct intel_plane *plane = to_intel_plane(crtc->base.primary); 3793 - const struct intel_plane_state *plane_state = 3794 - to_intel_plane_state(plane->base.state); 3795 - struct intel_crtc_state *crtc_state = 3796 - to_intel_crtc_state(crtc->base.state); 3797 - 3798 - if (plane_state->uapi.visible) 3799 - intel_plane_disable_noatomic(crtc, plane); 3800 - 3801 - drm_WARN_ON(&i915->drm, crtc_state->active_planes != 0); 3802 - 3803 - memset(&crtc_state->wm.skl.ddb, 0, sizeof(crtc_state->wm.skl.ddb)); 3804 - } 3805 6503 } 3806 6504 3807 6505 static void ilk_pipe_wm_get_hw_state(struct intel_crtc *crtc) ··· 4098 7194 !(intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL) & DISP_FBC_WM_DIS); 4099 7195 } 4100 7196 4101 - void intel_wm_state_verify(struct intel_crtc *crtc, 4102 - struct intel_crtc_state *new_crtc_state) 4103 - { 4104 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 4105 - struct skl_hw_state { 4106 - struct skl_ddb_entry ddb[I915_MAX_PLANES]; 4107 - struct skl_ddb_entry ddb_y[I915_MAX_PLANES]; 4108 - struct skl_pipe_wm wm; 4109 - } *hw; 4110 - const struct skl_pipe_wm *sw_wm = &new_crtc_state->wm.skl.optimal; 4111 - int level, max_level = ilk_wm_max_level(dev_priv); 4112 - struct intel_plane *plane; 4113 - u8 hw_enabled_slices; 4114 - 4115 - if (DISPLAY_VER(dev_priv) < 9 || !new_crtc_state->hw.active) 4116 - return; 4117 - 4118 - hw = kzalloc(sizeof(*hw), GFP_KERNEL); 4119 - if (!hw) 4120 - return; 4121 - 4122 - skl_pipe_wm_get_hw_state(crtc, &hw->wm); 4123 - 4124 - skl_pipe_ddb_get_hw_state(crtc, hw->ddb, hw->ddb_y); 4125 - 4126 - hw_enabled_slices = intel_enabled_dbuf_slices_mask(dev_priv); 4127 - 4128 - if (DISPLAY_VER(dev_priv) >= 11 && 4129 - hw_enabled_slices != dev_priv->dbuf.enabled_slices) 4130 - drm_err(&dev_priv->drm, 4131 - "mismatch in DBUF Slices (expected 0x%x, got 0x%x)\n", 4132 - dev_priv->dbuf.enabled_slices, 4133 - hw_enabled_slices); 4134 - 4135 - for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) { 4136 - const struct skl_ddb_entry *hw_ddb_entry, *sw_ddb_entry; 4137 - const struct skl_wm_level *hw_wm_level, *sw_wm_level; 4138 - 4139 - /* Watermarks */ 4140 - for (level = 0; level <= max_level; level++) { 4141 - hw_wm_level = &hw->wm.planes[plane->id].wm[level]; 4142 - sw_wm_level = skl_plane_wm_level(sw_wm, plane->id, level); 4143 - 4144 - if (skl_wm_level_equals(hw_wm_level, sw_wm_level)) 4145 - continue; 4146 - 4147 - drm_err(&dev_priv->drm, 4148 - "[PLANE:%d:%s] mismatch in WM%d (expected e=%d b=%u l=%u, got e=%d b=%u l=%u)\n", 4149 - plane->base.base.id, plane->base.name, level, 4150 - sw_wm_level->enable, 4151 - sw_wm_level->blocks, 4152 - sw_wm_level->lines, 4153 - hw_wm_level->enable, 4154 - hw_wm_level->blocks, 4155 - hw_wm_level->lines); 4156 - } 4157 - 4158 - hw_wm_level = &hw->wm.planes[plane->id].trans_wm; 4159 - sw_wm_level = skl_plane_trans_wm(sw_wm, plane->id); 4160 - 4161 - if (!skl_wm_level_equals(hw_wm_level, sw_wm_level)) { 4162 - drm_err(&dev_priv->drm, 4163 - "[PLANE:%d:%s] mismatch in trans WM (expected e=%d b=%u l=%u, got e=%d b=%u l=%u)\n", 4164 - plane->base.base.id, plane->base.name, 4165 - sw_wm_level->enable, 4166 - sw_wm_level->blocks, 4167 - sw_wm_level->lines, 4168 - hw_wm_level->enable, 4169 - hw_wm_level->blocks, 4170 - hw_wm_level->lines); 4171 - } 4172 - 4173 - hw_wm_level = &hw->wm.planes[plane->id].sagv.wm0; 4174 - sw_wm_level = &sw_wm->planes[plane->id].sagv.wm0; 4175 - 4176 - if (HAS_HW_SAGV_WM(dev_priv) && 4177 - !skl_wm_level_equals(hw_wm_level, sw_wm_level)) { 4178 - drm_err(&dev_priv->drm, 4179 - "[PLANE:%d:%s] mismatch in SAGV WM (expected e=%d b=%u l=%u, got e=%d b=%u l=%u)\n", 4180 - plane->base.base.id, plane->base.name, 4181 - sw_wm_level->enable, 4182 - sw_wm_level->blocks, 4183 - sw_wm_level->lines, 4184 - hw_wm_level->enable, 4185 - hw_wm_level->blocks, 4186 - hw_wm_level->lines); 4187 - } 4188 - 4189 - hw_wm_level = &hw->wm.planes[plane->id].sagv.trans_wm; 4190 - sw_wm_level = &sw_wm->planes[plane->id].sagv.trans_wm; 4191 - 4192 - if (HAS_HW_SAGV_WM(dev_priv) && 4193 - !skl_wm_level_equals(hw_wm_level, sw_wm_level)) { 4194 - drm_err(&dev_priv->drm, 4195 - "[PLANE:%d:%s] mismatch in SAGV trans WM (expected e=%d b=%u l=%u, got e=%d b=%u l=%u)\n", 4196 - plane->base.base.id, plane->base.name, 4197 - sw_wm_level->enable, 4198 - sw_wm_level->blocks, 4199 - sw_wm_level->lines, 4200 - hw_wm_level->enable, 4201 - hw_wm_level->blocks, 4202 - hw_wm_level->lines); 4203 - } 4204 - 4205 - /* DDB */ 4206 - hw_ddb_entry = &hw->ddb[PLANE_CURSOR]; 4207 - sw_ddb_entry = &new_crtc_state->wm.skl.plane_ddb[PLANE_CURSOR]; 4208 - 4209 - if (!skl_ddb_entry_equal(hw_ddb_entry, sw_ddb_entry)) { 4210 - drm_err(&dev_priv->drm, 4211 - "[PLANE:%d:%s] mismatch in DDB (expected (%u,%u), found (%u,%u))\n", 4212 - plane->base.base.id, plane->base.name, 4213 - sw_ddb_entry->start, sw_ddb_entry->end, 4214 - hw_ddb_entry->start, hw_ddb_entry->end); 4215 - } 4216 - } 4217 - 4218 - kfree(hw); 4219 - } 4220 - 4221 - void intel_enable_ipc(struct drm_i915_private *dev_priv) 4222 - { 4223 - u32 val; 4224 - 4225 - if (!HAS_IPC(dev_priv)) 4226 - return; 4227 - 4228 - val = intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL2); 4229 - 4230 - if (dev_priv->ipc_enabled) 4231 - val |= DISP_IPC_ENABLE; 4232 - else 4233 - val &= ~DISP_IPC_ENABLE; 4234 - 4235 - intel_uncore_write(&dev_priv->uncore, DISP_ARB_CTL2, val); 4236 - } 4237 - 4238 - static bool intel_can_enable_ipc(struct drm_i915_private *dev_priv) 4239 - { 4240 - /* Display WA #0477 WaDisableIPC: skl */ 4241 - if (IS_SKYLAKE(dev_priv)) 4242 - return false; 4243 - 4244 - /* Display WA #1141: SKL:all KBL:all CFL */ 4245 - if (IS_KABYLAKE(dev_priv) || 4246 - IS_COFFEELAKE(dev_priv) || 4247 - IS_COMETLAKE(dev_priv)) 4248 - return dev_priv->dram_info.symmetric_memory; 4249 - 4250 - return true; 4251 - } 4252 - 4253 - void intel_init_ipc(struct drm_i915_private *dev_priv) 4254 - { 4255 - if (!HAS_IPC(dev_priv)) 4256 - return; 4257 - 4258 - dev_priv->ipc_enabled = intel_can_enable_ipc(dev_priv); 4259 - 4260 - intel_enable_ipc(dev_priv); 4261 - } 4262 - 4263 7197 static void ibx_init_clock_gating(struct drm_i915_private *dev_priv) 4264 7198 { 4265 7199 /* ··· 4205 7463 val = intel_uncore_read(&dev_priv->uncore, TRANS_CHICKEN2(pipe)); 4206 7464 val |= TRANS_CHICKEN2_TIMING_OVERRIDE; 4207 7465 val &= ~TRANS_CHICKEN2_FDI_POLARITY_REVERSED; 4208 - if (dev_priv->vbt.fdi_rx_polarity_inverted) 7466 + if (dev_priv->display.vbt.fdi_rx_polarity_inverted) 4209 7467 val |= TRANS_CHICKEN2_FDI_POLARITY_REVERSED; 4210 7468 val &= ~TRANS_CHICKEN2_DISABLE_DEEP_COLOR_COUNTER; 4211 7469 val &= ~TRANS_CHICKEN2_DISABLE_DEEP_COLOR_MODESWITCH; ··· 4734 7992 OVCUNIT_CLOCK_GATE_DISABLE; 4735 7993 if (IS_GM45(dev_priv)) 4736 7994 dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE; 4737 - intel_uncore_write(&dev_priv->uncore, DSPCLK_GATE_D, dspclk_gate); 7995 + intel_uncore_write(&dev_priv->uncore, DSPCLK_GATE_D(dev_priv), dspclk_gate); 4738 7996 4739 7997 g4x_disable_trickle_feed(dev_priv); 4740 7998 } ··· 4745 8003 4746 8004 intel_uncore_write(uncore, RENCLK_GATE_D1, I965_RCC_CLOCK_GATE_DISABLE); 4747 8005 intel_uncore_write(uncore, RENCLK_GATE_D2, 0); 4748 - intel_uncore_write(uncore, DSPCLK_GATE_D, 0); 8006 + intel_uncore_write(uncore, DSPCLK_GATE_D(dev_priv), 0); 4749 8007 intel_uncore_write(uncore, RAMCLK_GATE_D, 0); 4750 8008 intel_uncore_write16(uncore, DEUC, 0); 4751 8009 intel_uncore_write(uncore, ··· 4937 8195 } 4938 8196 } 4939 8197 4940 - static const struct intel_wm_funcs skl_wm_funcs = { 4941 - .compute_global_watermarks = skl_compute_wm, 4942 - }; 4943 - 4944 8198 static const struct intel_wm_funcs ilk_wm_funcs = { 4945 8199 .compute_pipe_wm = ilk_compute_pipe_wm, 4946 8200 .compute_intermediate_wm = ilk_compute_intermediate_wm, ··· 4981 8243 /* Set up chip specific power management-related functions */ 4982 8244 void intel_init_pm(struct drm_i915_private *dev_priv) 4983 8245 { 8246 + if (DISPLAY_VER(dev_priv) >= 9) { 8247 + skl_wm_init(dev_priv); 8248 + return; 8249 + } 8250 + 4984 8251 /* For cxsr */ 4985 8252 if (IS_PINEVIEW(dev_priv)) 4986 8253 pnv_get_mem_freq(dev_priv); 4987 8254 else if (GRAPHICS_VER(dev_priv) == 5) 4988 8255 ilk_get_mem_freq(dev_priv); 4989 8256 4990 - intel_sagv_init(dev_priv); 4991 - 4992 8257 /* For FIFO watermark updates */ 4993 - if (DISPLAY_VER(dev_priv) >= 9) { 4994 - skl_setup_wm_latency(dev_priv); 4995 - dev_priv->display.funcs.wm = &skl_wm_funcs; 4996 - } else if (HAS_PCH_SPLIT(dev_priv)) { 8258 + if (HAS_PCH_SPLIT(dev_priv)) { 4997 8259 ilk_setup_wm_latency(dev_priv); 4998 8260 4999 8261 if ((DISPLAY_VER(dev_priv) == 5 && dev_priv->display.wm.pri_latency[1] && ··· 5049 8311 { 5050 8312 dev_priv->runtime_pm.suspended = false; 5051 8313 atomic_set(&dev_priv->runtime_pm.wakeref_count, 0); 5052 - } 5053 - 5054 - static struct intel_global_state *intel_dbuf_duplicate_state(struct intel_global_obj *obj) 5055 - { 5056 - struct intel_dbuf_state *dbuf_state; 5057 - 5058 - dbuf_state = kmemdup(obj->state, sizeof(*dbuf_state), GFP_KERNEL); 5059 - if (!dbuf_state) 5060 - return NULL; 5061 - 5062 - return &dbuf_state->base; 5063 - } 5064 - 5065 - static void intel_dbuf_destroy_state(struct intel_global_obj *obj, 5066 - struct intel_global_state *state) 5067 - { 5068 - kfree(state); 5069 - } 5070 - 5071 - static const struct intel_global_state_funcs intel_dbuf_funcs = { 5072 - .atomic_duplicate_state = intel_dbuf_duplicate_state, 5073 - .atomic_destroy_state = intel_dbuf_destroy_state, 5074 - }; 5075 - 5076 - struct intel_dbuf_state * 5077 - intel_atomic_get_dbuf_state(struct intel_atomic_state *state) 5078 - { 5079 - struct drm_i915_private *dev_priv = to_i915(state->base.dev); 5080 - struct intel_global_state *dbuf_state; 5081 - 5082 - dbuf_state = intel_atomic_get_global_obj_state(state, &dev_priv->dbuf.obj); 5083 - if (IS_ERR(dbuf_state)) 5084 - return ERR_CAST(dbuf_state); 5085 - 5086 - return to_intel_dbuf_state(dbuf_state); 5087 - } 5088 - 5089 - int intel_dbuf_init(struct drm_i915_private *dev_priv) 5090 - { 5091 - struct intel_dbuf_state *dbuf_state; 5092 - 5093 - dbuf_state = kzalloc(sizeof(*dbuf_state), GFP_KERNEL); 5094 - if (!dbuf_state) 5095 - return -ENOMEM; 5096 - 5097 - intel_atomic_global_obj_init(dev_priv, &dev_priv->dbuf.obj, 5098 - &dbuf_state->base, &intel_dbuf_funcs); 5099 - 5100 - return 0; 5101 - } 5102 - 5103 - /* 5104 - * Configure MBUS_CTL and all DBUF_CTL_S of each slice to join_mbus state before 5105 - * update the request state of all DBUS slices. 5106 - */ 5107 - static void update_mbus_pre_enable(struct intel_atomic_state *state) 5108 - { 5109 - struct drm_i915_private *dev_priv = to_i915(state->base.dev); 5110 - u32 mbus_ctl, dbuf_min_tracker_val; 5111 - enum dbuf_slice slice; 5112 - const struct intel_dbuf_state *dbuf_state = 5113 - intel_atomic_get_new_dbuf_state(state); 5114 - 5115 - if (!HAS_MBUS_JOINING(dev_priv)) 5116 - return; 5117 - 5118 - /* 5119 - * TODO: Implement vblank synchronized MBUS joining changes. 5120 - * Must be properly coordinated with dbuf reprogramming. 5121 - */ 5122 - if (dbuf_state->joined_mbus) { 5123 - mbus_ctl = MBUS_HASHING_MODE_1x4 | MBUS_JOIN | 5124 - MBUS_JOIN_PIPE_SELECT_NONE; 5125 - dbuf_min_tracker_val = DBUF_MIN_TRACKER_STATE_SERVICE(3); 5126 - } else { 5127 - mbus_ctl = MBUS_HASHING_MODE_2x2 | 5128 - MBUS_JOIN_PIPE_SELECT_NONE; 5129 - dbuf_min_tracker_val = DBUF_MIN_TRACKER_STATE_SERVICE(1); 5130 - } 5131 - 5132 - intel_de_rmw(dev_priv, MBUS_CTL, 5133 - MBUS_HASHING_MODE_MASK | MBUS_JOIN | 5134 - MBUS_JOIN_PIPE_SELECT_MASK, mbus_ctl); 5135 - 5136 - for_each_dbuf_slice(dev_priv, slice) 5137 - intel_de_rmw(dev_priv, DBUF_CTL_S(slice), 5138 - DBUF_MIN_TRACKER_STATE_SERVICE_MASK, 5139 - dbuf_min_tracker_val); 5140 - } 5141 - 5142 - void intel_dbuf_pre_plane_update(struct intel_atomic_state *state) 5143 - { 5144 - struct drm_i915_private *dev_priv = to_i915(state->base.dev); 5145 - const struct intel_dbuf_state *new_dbuf_state = 5146 - intel_atomic_get_new_dbuf_state(state); 5147 - const struct intel_dbuf_state *old_dbuf_state = 5148 - intel_atomic_get_old_dbuf_state(state); 5149 - 5150 - if (!new_dbuf_state || 5151 - ((new_dbuf_state->enabled_slices == old_dbuf_state->enabled_slices) 5152 - && (new_dbuf_state->joined_mbus == old_dbuf_state->joined_mbus))) 5153 - return; 5154 - 5155 - WARN_ON(!new_dbuf_state->base.changed); 5156 - 5157 - update_mbus_pre_enable(state); 5158 - gen9_dbuf_slices_update(dev_priv, 5159 - old_dbuf_state->enabled_slices | 5160 - new_dbuf_state->enabled_slices); 5161 - } 5162 - 5163 - void intel_dbuf_post_plane_update(struct intel_atomic_state *state) 5164 - { 5165 - struct drm_i915_private *dev_priv = to_i915(state->base.dev); 5166 - const struct intel_dbuf_state *new_dbuf_state = 5167 - intel_atomic_get_new_dbuf_state(state); 5168 - const struct intel_dbuf_state *old_dbuf_state = 5169 - intel_atomic_get_old_dbuf_state(state); 5170 - 5171 - if (!new_dbuf_state || 5172 - ((new_dbuf_state->enabled_slices == old_dbuf_state->enabled_slices) 5173 - && (new_dbuf_state->joined_mbus == old_dbuf_state->joined_mbus))) 5174 - return; 5175 - 5176 - WARN_ON(!new_dbuf_state->base.changed); 5177 - 5178 - gen9_dbuf_slices_update(dev_priv, 5179 - new_dbuf_state->enabled_slices); 5180 - } 5181 - 5182 - void intel_mbus_dbox_update(struct intel_atomic_state *state) 5183 - { 5184 - struct drm_i915_private *i915 = to_i915(state->base.dev); 5185 - const struct intel_dbuf_state *new_dbuf_state, *old_dbuf_state; 5186 - const struct intel_crtc_state *new_crtc_state; 5187 - const struct intel_crtc *crtc; 5188 - u32 val = 0; 5189 - int i; 5190 - 5191 - if (DISPLAY_VER(i915) < 11) 5192 - return; 5193 - 5194 - new_dbuf_state = intel_atomic_get_new_dbuf_state(state); 5195 - old_dbuf_state = intel_atomic_get_old_dbuf_state(state); 5196 - if (!new_dbuf_state || 5197 - (new_dbuf_state->joined_mbus == old_dbuf_state->joined_mbus && 5198 - new_dbuf_state->active_pipes == old_dbuf_state->active_pipes)) 5199 - return; 5200 - 5201 - if (DISPLAY_VER(i915) >= 12) { 5202 - val |= MBUS_DBOX_B2B_TRANSACTIONS_MAX(16); 5203 - val |= MBUS_DBOX_B2B_TRANSACTIONS_DELAY(1); 5204 - val |= MBUS_DBOX_REGULATE_B2B_TRANSACTIONS_EN; 5205 - } 5206 - 5207 - /* Wa_22010947358:adl-p */ 5208 - if (IS_ALDERLAKE_P(i915)) 5209 - val |= new_dbuf_state->joined_mbus ? MBUS_DBOX_A_CREDIT(6) : 5210 - MBUS_DBOX_A_CREDIT(4); 5211 - else 5212 - val |= MBUS_DBOX_A_CREDIT(2); 5213 - 5214 - if (IS_ALDERLAKE_P(i915)) { 5215 - val |= MBUS_DBOX_BW_CREDIT(2); 5216 - val |= MBUS_DBOX_B_CREDIT(8); 5217 - } else if (DISPLAY_VER(i915) >= 12) { 5218 - val |= MBUS_DBOX_BW_CREDIT(2); 5219 - val |= MBUS_DBOX_B_CREDIT(12); 5220 - } else { 5221 - val |= MBUS_DBOX_BW_CREDIT(1); 5222 - val |= MBUS_DBOX_B_CREDIT(8); 5223 - } 5224 - 5225 - for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 5226 - if (!new_crtc_state->hw.active || 5227 - !intel_crtc_needs_modeset(new_crtc_state)) 5228 - continue; 5229 - 5230 - intel_de_write(i915, PIPE_MBUS_DBOX_CTL(crtc->pipe), val); 5231 - } 5232 8314 }
+5 -60
drivers/gpu/drm/i915/intel_pm.h
··· 8 8 9 9 #include <linux/types.h> 10 10 11 - #include "display/intel_display.h" 12 - #include "display/intel_global_state.h" 13 - 14 - #include "i915_drv.h" 15 - 16 - struct drm_device; 17 11 struct drm_i915_private; 18 - struct i915_request; 19 - struct intel_atomic_state; 20 - struct intel_bw_state; 21 - struct intel_crtc; 22 12 struct intel_crtc_state; 23 - struct intel_plane; 24 - struct skl_ddb_entry; 25 - struct skl_pipe_wm; 26 - struct skl_wm_level; 13 + struct intel_plane_state; 27 14 28 15 void intel_init_clock_gating(struct drm_i915_private *dev_priv); 29 16 void intel_suspend_hw(struct drm_i915_private *dev_priv); ··· 21 34 void g4x_wm_get_hw_state(struct drm_i915_private *dev_priv); 22 35 void vlv_wm_get_hw_state(struct drm_i915_private *dev_priv); 23 36 void ilk_wm_get_hw_state(struct drm_i915_private *dev_priv); 24 - void skl_wm_get_hw_state(struct drm_i915_private *dev_priv); 25 - void intel_wm_state_verify(struct intel_crtc *crtc, 26 - struct intel_crtc_state *new_crtc_state); 27 - u8 intel_enabled_dbuf_slices_mask(struct drm_i915_private *dev_priv); 28 - void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv); 29 - u32 skl_ddb_dbuf_slice_mask(struct drm_i915_private *dev_priv, 30 - const struct skl_ddb_entry *entry); 31 37 void g4x_wm_sanitize(struct drm_i915_private *dev_priv); 32 38 void vlv_wm_sanitize(struct drm_i915_private *dev_priv); 33 - void skl_wm_sanitize(struct drm_i915_private *dev_priv); 34 - bool intel_can_enable_sagv(struct drm_i915_private *dev_priv, 35 - const struct intel_bw_state *bw_state); 36 - void intel_sagv_pre_plane_update(struct intel_atomic_state *state); 37 - void intel_sagv_post_plane_update(struct intel_atomic_state *state); 38 - bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry *ddb, 39 - const struct skl_ddb_entry *entries, 40 - int num_entries, int ignore_idx); 41 - void skl_write_plane_wm(struct intel_plane *plane, 42 - const struct intel_crtc_state *crtc_state); 43 - void skl_write_cursor_wm(struct intel_plane *plane, 44 - const struct intel_crtc_state *crtc_state); 45 39 bool ilk_disable_lp_wm(struct drm_i915_private *dev_priv); 46 - void intel_init_ipc(struct drm_i915_private *dev_priv); 47 - void intel_enable_ipc(struct drm_i915_private *dev_priv); 40 + bool intel_wm_plane_visible(const struct intel_crtc_state *crtc_state, 41 + const struct intel_plane_state *plane_state); 42 + void intel_print_wm_latency(struct drm_i915_private *dev_priv, 43 + const char *name, const u16 wm[]); 48 44 49 45 bool intel_set_memory_cxsr(struct drm_i915_private *dev_priv, bool enable); 50 - 51 - struct intel_dbuf_state { 52 - struct intel_global_state base; 53 - 54 - struct skl_ddb_entry ddb[I915_MAX_PIPES]; 55 - unsigned int weight[I915_MAX_PIPES]; 56 - u8 slices[I915_MAX_PIPES]; 57 - u8 enabled_slices; 58 - u8 active_pipes; 59 - bool joined_mbus; 60 - }; 61 - 62 - struct intel_dbuf_state * 63 - intel_atomic_get_dbuf_state(struct intel_atomic_state *state); 64 - 65 - #define to_intel_dbuf_state(x) container_of((x), struct intel_dbuf_state, base) 66 - #define intel_atomic_get_old_dbuf_state(state) \ 67 - to_intel_dbuf_state(intel_atomic_get_old_global_obj_state(state, &to_i915(state->base.dev)->dbuf.obj)) 68 - #define intel_atomic_get_new_dbuf_state(state) \ 69 - to_intel_dbuf_state(intel_atomic_get_new_global_obj_state(state, &to_i915(state->base.dev)->dbuf.obj)) 70 - 71 - int intel_dbuf_init(struct drm_i915_private *dev_priv); 72 - void intel_dbuf_pre_plane_update(struct intel_atomic_state *state); 73 - void intel_dbuf_post_plane_update(struct intel_atomic_state *state); 74 - void intel_mbus_dbox_update(struct intel_atomic_state *state); 75 46 76 47 #endif /* __INTEL_PM_H__ */
+1 -1
drivers/gpu/drm/i915/selftests/mock_gem_device.c
··· 173 173 /* Using the global GTT may ask questions about KMS users, so prepare */ 174 174 drm_mode_config_init(&i915->drm); 175 175 176 - RUNTIME_INFO(i915)->graphics.ver = -1; 176 + RUNTIME_INFO(i915)->graphics.ip.ver = -1; 177 177 178 178 RUNTIME_INFO(i915)->page_sizes = 179 179 I915_GTT_PAGE_SIZE_4K |