2 * Copyright © 2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eugeni Dodonov <eugeni.dodonov@intel.com>
28 #include "display/intel_de.h"
29 #include "display/intel_display.h"
30 #include "display/intel_display_trace.h"
31 #include "display/skl_watermark.h"
33 #include "gt/intel_engine_regs.h"
34 #include "gt/intel_gt.h"
35 #include "gt/intel_gt_mcr.h"
36 #include "gt/intel_gt_regs.h"
39 #include "intel_clock_gating.h"
40 #include "intel_mchbar_regs.h"
41 #include "vlv_sideband.h"
43 struct drm_i915_clock_gating_funcs {
44 void (*init_clock_gating)(struct drm_i915_private *i915);
47 static void gen9_init_clock_gating(struct drm_i915_private *i915)
51 * WaCompressedResourceDisplayNewHashMode:skl,kbl
52 * Display WA #0390: skl,kbl
54 * Must match Sampler, Pixel Back End, and Media. See
55 * WaCompressedResourceSamplerPbeMediaNewHashMode.
57 intel_uncore_rmw(&i915->uncore, CHICKEN_PAR1_1, 0, SKL_DE_COMPRESSED_HASH_MODE);
60 /* See Bspec note for PSR2_CTL bit 31, Wa#828:skl,bxt,kbl,cfl */
61 intel_uncore_rmw(&i915->uncore, CHICKEN_PAR1_1, 0, SKL_EDP_PSR_FIX_RDWRAP);
63 /* WaEnableChickenDCPR:skl,bxt,kbl,glk,cfl */
64 intel_uncore_rmw(&i915->uncore, GEN8_CHICKEN_DCPR_1, 0, MASK_WAKEMEM);
67 * WaFbcWakeMemOn:skl,bxt,kbl,glk,cfl
68 * Display WA #0859: skl,bxt,kbl,glk,cfl
70 intel_uncore_rmw(&i915->uncore, DISP_ARB_CTL, 0, DISP_FBC_MEMORY_WAKE);
73 static void bxt_init_clock_gating(struct drm_i915_private *i915)
75 gen9_init_clock_gating(i915);
77 /* WaDisableSDEUnitClockGating:bxt */
78 intel_uncore_rmw(&i915->uncore, GEN8_UCGCTL6, 0, GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
82 * GEN8_HDCUNIT_CLOCK_GATE_DISABLE_HDCREQ applies on 3x6 GT SKUs only.
84 intel_uncore_rmw(&i915->uncore, GEN8_UCGCTL6, 0, GEN8_HDCUNIT_CLOCK_GATE_DISABLE_HDCREQ);
87 * Wa: Backlight PWM may stop in the asserted state, causing backlight
90 intel_uncore_write(&i915->uncore, GEN9_CLKGATE_DIS_0,
91 intel_uncore_read(&i915->uncore, GEN9_CLKGATE_DIS_0) |
92 PWM1_GATING_DIS | PWM2_GATING_DIS);
95 * Lower the display internal timeout.
96 * This is needed to avoid any hard hangs when DSI port PLL
97 * is off and a MMIO access is attempted by any privilege
98 * application, using batch buffers or any other means.
100 intel_uncore_write(&i915->uncore, RM_TIMEOUT, MMIO_TIMEOUT_US(950));
103 * WaFbcTurnOffFbcWatermark:bxt
104 * Display WA #0562: bxt
106 intel_uncore_rmw(&i915->uncore, DISP_ARB_CTL, 0, DISP_FBC_WM_DIS);
109 * WaFbcHighMemBwCorruptionAvoidance:bxt
110 * Display WA #0883: bxt
112 intel_uncore_rmw(&i915->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A), 0, DPFC_DISABLE_DUMMY0);
115 static void glk_init_clock_gating(struct drm_i915_private *i915)
117 gen9_init_clock_gating(i915);
120 * WaDisablePWMClockGating:glk
121 * Backlight PWM may stop in the asserted state, causing backlight
124 intel_uncore_write(&i915->uncore, GEN9_CLKGATE_DIS_0,
125 intel_uncore_read(&i915->uncore, GEN9_CLKGATE_DIS_0) |
126 PWM1_GATING_DIS | PWM2_GATING_DIS);
129 static void ibx_init_clock_gating(struct drm_i915_private *i915)
132 * On Ibex Peak and Cougar Point, we need to disable clock
133 * gating for the panel power sequencer or it will fail to
134 * start up when no ports are active.
136 intel_uncore_write(&i915->uncore, SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE);
139 static void g4x_disable_trickle_feed(struct drm_i915_private *dev_priv)
143 for_each_pipe(dev_priv, pipe) {
144 intel_uncore_rmw(&dev_priv->uncore, DSPCNTR(pipe), 0, DISP_TRICKLE_FEED_DISABLE);
146 intel_uncore_rmw(&dev_priv->uncore, DSPSURF(pipe), 0, 0);
147 intel_uncore_posting_read(&dev_priv->uncore, DSPSURF(pipe));
151 static void ilk_init_clock_gating(struct drm_i915_private *i915)
153 u32 dspclk_gate = ILK_VRHUNIT_CLOCK_GATE_DISABLE;
157 * WaFbcDisableDpfcClockGating:ilk
159 dspclk_gate |= ILK_DPFCRUNIT_CLOCK_GATE_DISABLE |
160 ILK_DPFCUNIT_CLOCK_GATE_DISABLE |
161 ILK_DPFDUNIT_CLOCK_GATE_ENABLE;
163 intel_uncore_write(&i915->uncore, PCH_3DCGDIS0,
164 MARIUNIT_CLOCK_GATE_DISABLE |
165 SVSMUNIT_CLOCK_GATE_DISABLE);
166 intel_uncore_write(&i915->uncore, PCH_3DCGDIS1,
167 VFMUNIT_CLOCK_GATE_DISABLE);
170 * According to the spec the following bits should be set in
171 * order to enable memory self-refresh
172 * The bit 22/21 of 0x42004
173 * The bit 5 of 0x42020
174 * The bit 15 of 0x45000
176 intel_uncore_write(&i915->uncore, ILK_DISPLAY_CHICKEN2,
177 (intel_uncore_read(&i915->uncore, ILK_DISPLAY_CHICKEN2) |
178 ILK_DPARB_GATE | ILK_VSDPFD_FULL));
179 dspclk_gate |= ILK_DPARBUNIT_CLOCK_GATE_ENABLE;
180 intel_uncore_write(&i915->uncore, DISP_ARB_CTL,
181 (intel_uncore_read(&i915->uncore, DISP_ARB_CTL) |
185 * Based on the document from hardware guys the following bits
186 * should be set unconditionally in order to enable FBC.
187 * The bit 22 of 0x42000
188 * The bit 22 of 0x42004
189 * The bit 7,8,9 of 0x42020.
191 if (IS_IRONLAKE_M(i915)) {
192 /* WaFbcAsynchFlipDisableFbcQueue:ilk */
193 intel_uncore_rmw(&i915->uncore, ILK_DISPLAY_CHICKEN1, 0, ILK_FBCQ_DIS);
194 intel_uncore_rmw(&i915->uncore, ILK_DISPLAY_CHICKEN2, 0, ILK_DPARB_GATE);
197 intel_uncore_write(&i915->uncore, ILK_DSPCLK_GATE_D, dspclk_gate);
199 intel_uncore_rmw(&i915->uncore, ILK_DISPLAY_CHICKEN2, 0, ILK_ELPIN_409_SELECT);
201 g4x_disable_trickle_feed(i915);
203 ibx_init_clock_gating(i915);
206 static void cpt_init_clock_gating(struct drm_i915_private *i915)
212 * On Ibex Peak and Cougar Point, we need to disable clock
213 * gating for the panel power sequencer or it will fail to
214 * start up when no ports are active.
216 intel_uncore_write(&i915->uncore, SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE |
217 PCH_DPLUNIT_CLOCK_GATE_DISABLE |
218 PCH_CPUNIT_CLOCK_GATE_DISABLE);
219 intel_uncore_rmw(&i915->uncore, SOUTH_CHICKEN2, 0, DPLS_EDP_PPS_FIX_DIS);
220 /* The below fixes the weird display corruption, a few pixels shifted
221 * downward, on (only) LVDS of some HP laptops with IVY.
223 for_each_pipe(i915, pipe) {
224 val = intel_uncore_read(&i915->uncore, TRANS_CHICKEN2(pipe));
225 val |= TRANS_CHICKEN2_TIMING_OVERRIDE;
226 val &= ~TRANS_CHICKEN2_FDI_POLARITY_REVERSED;
227 if (i915->display.vbt.fdi_rx_polarity_inverted)
228 val |= TRANS_CHICKEN2_FDI_POLARITY_REVERSED;
229 val &= ~TRANS_CHICKEN2_DISABLE_DEEP_COLOR_COUNTER;
230 val &= ~TRANS_CHICKEN2_DISABLE_DEEP_COLOR_MODESWITCH;
231 intel_uncore_write(&i915->uncore, TRANS_CHICKEN2(pipe), val);
233 /* WADP0ClockGatingDisable */
234 for_each_pipe(i915, pipe) {
235 intel_uncore_write(&i915->uncore, TRANS_CHICKEN1(pipe),
236 TRANS_CHICKEN1_DP0UNIT_GC_DISABLE);
240 static void gen6_check_mch_setup(struct drm_i915_private *i915)
244 tmp = intel_uncore_read(&i915->uncore, MCH_SSKPD);
245 if (REG_FIELD_GET(SSKPD_WM0_MASK_SNB, tmp) != 12)
246 drm_dbg_kms(&i915->drm,
247 "Wrong MCH_SSKPD value: 0x%08x This can cause underruns.\n",
251 static void gen6_init_clock_gating(struct drm_i915_private *i915)
253 u32 dspclk_gate = ILK_VRHUNIT_CLOCK_GATE_DISABLE;
255 intel_uncore_write(&i915->uncore, ILK_DSPCLK_GATE_D, dspclk_gate);
257 intel_uncore_rmw(&i915->uncore, ILK_DISPLAY_CHICKEN2, 0, ILK_ELPIN_409_SELECT);
259 intel_uncore_write(&i915->uncore, GEN6_UCGCTL1,
260 intel_uncore_read(&i915->uncore, GEN6_UCGCTL1) |
261 GEN6_BLBUNIT_CLOCK_GATE_DISABLE |
262 GEN6_CSUNIT_CLOCK_GATE_DISABLE);
264 /* According to the BSpec vol1g, bit 12 (RCPBUNIT) clock
265 * gating disable must be set. Failure to set it results in
266 * flickering pixels due to Z write ordering failures after
267 * some amount of runtime in the Mesa "fire" demo, and Unigine
268 * Sanctuary and Tropics, and apparently anything else with
269 * alpha test or pixel discard.
271 * According to the spec, bit 11 (RCCUNIT) must also be set,
272 * but we didn't debug actual testcases to find it out.
274 * WaDisableRCCUnitClockGating:snb
275 * WaDisableRCPBUnitClockGating:snb
277 intel_uncore_write(&i915->uncore, GEN6_UCGCTL2,
278 GEN6_RCPBUNIT_CLOCK_GATE_DISABLE |
279 GEN6_RCCUNIT_CLOCK_GATE_DISABLE);
282 * According to the spec the following bits should be
283 * set in order to enable memory self-refresh and fbc:
284 * The bit21 and bit22 of 0x42000
285 * The bit21 and bit22 of 0x42004
286 * The bit5 and bit7 of 0x42020
287 * The bit14 of 0x70180
288 * The bit14 of 0x71180
290 * WaFbcAsynchFlipDisableFbcQueue:snb
292 intel_uncore_write(&i915->uncore, ILK_DISPLAY_CHICKEN1,
293 intel_uncore_read(&i915->uncore, ILK_DISPLAY_CHICKEN1) |
294 ILK_FBCQ_DIS | ILK_PABSTRETCH_DIS);
295 intel_uncore_write(&i915->uncore, ILK_DISPLAY_CHICKEN2,
296 intel_uncore_read(&i915->uncore, ILK_DISPLAY_CHICKEN2) |
297 ILK_DPARB_GATE | ILK_VSDPFD_FULL);
298 intel_uncore_write(&i915->uncore, ILK_DSPCLK_GATE_D,
299 intel_uncore_read(&i915->uncore, ILK_DSPCLK_GATE_D) |
300 ILK_DPARBUNIT_CLOCK_GATE_ENABLE |
301 ILK_DPFDUNIT_CLOCK_GATE_ENABLE);
303 g4x_disable_trickle_feed(i915);
305 cpt_init_clock_gating(i915);
307 gen6_check_mch_setup(i915);
310 static void lpt_init_clock_gating(struct drm_i915_private *i915)
313 * TODO: this bit should only be enabled when really needed, then
314 * disabled when not needed anymore in order to save power.
316 if (HAS_PCH_LPT_LP(i915))
317 intel_uncore_rmw(&i915->uncore, SOUTH_DSPCLK_GATE_D,
318 0, PCH_LP_PARTITION_LEVEL_DISABLE);
320 /* WADPOClockGatingDisable:hsw */
321 intel_uncore_rmw(&i915->uncore, TRANS_CHICKEN1(PIPE_A),
322 0, TRANS_CHICKEN1_DP0UNIT_GC_DISABLE);
325 static void gen8_set_l3sqc_credits(struct drm_i915_private *i915,
326 int general_prio_credits,
327 int high_prio_credits)
332 /* WaTempDisableDOPClkGating:bdw */
333 misccpctl = intel_uncore_rmw(&i915->uncore, GEN7_MISCCPCTL,
334 GEN7_DOP_CLOCK_GATE_ENABLE, 0);
336 val = intel_gt_mcr_read_any(to_gt(i915), GEN8_L3SQCREG1);
337 val &= ~L3_PRIO_CREDITS_MASK;
338 val |= L3_GENERAL_PRIO_CREDITS(general_prio_credits);
339 val |= L3_HIGH_PRIO_CREDITS(high_prio_credits);
340 intel_gt_mcr_multicast_write(to_gt(i915), GEN8_L3SQCREG1, val);
343 * Wait at least 100 clocks before re-enabling clock gating.
344 * See the definition of L3SQCREG1 in BSpec.
346 intel_gt_mcr_read_any(to_gt(i915), GEN8_L3SQCREG1);
348 intel_uncore_write(&i915->uncore, GEN7_MISCCPCTL, misccpctl);
351 static void icl_init_clock_gating(struct drm_i915_private *i915)
353 /* Wa_1409120013:icl,ehl */
354 intel_uncore_write(&i915->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
355 DPFC_CHICKEN_COMP_DUMMY_PIXEL);
357 /*Wa_14010594013:icl, ehl */
358 intel_uncore_rmw(&i915->uncore, GEN8_CHICKEN_DCPR_1,
362 static void gen12lp_init_clock_gating(struct drm_i915_private *i915)
365 if (DISPLAY_VER(i915) == 12)
366 intel_uncore_write(&i915->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
367 DPFC_CHICKEN_COMP_DUMMY_PIXEL);
369 /* Wa_14013723622:tgl,rkl,dg1,adl-s */
370 if (DISPLAY_VER(i915) == 12)
371 intel_uncore_rmw(&i915->uncore, CLKREQ_POLICY,
372 CLKREQ_POLICY_MEM_UP_OVRD, 0);
375 static void adlp_init_clock_gating(struct drm_i915_private *i915)
377 gen12lp_init_clock_gating(i915);
379 /* Wa_22011091694:adlp */
380 intel_de_rmw(i915, GEN9_CLKGATE_DIS_5, 0, DPCE_GATING_DIS);
382 /* Bspec/49189 Initialize Sequence */
383 intel_de_rmw(i915, GEN8_CHICKEN_DCPR_1, DDI_CLOCK_REG_ACCESS, 0);
386 static void xehpsdv_init_clock_gating(struct drm_i915_private *i915)
388 /* Wa_22010146351:xehpsdv */
389 if (IS_XEHPSDV_GRAPHICS_STEP(i915, STEP_A0, STEP_B0))
390 intel_uncore_rmw(&i915->uncore, XEHP_CLOCK_GATE_DIS, 0, SGR_DIS);
393 static void dg2_init_clock_gating(struct drm_i915_private *i915)
395 /* Wa_22010954014:dg2 */
396 intel_uncore_rmw(&i915->uncore, XEHP_CLOCK_GATE_DIS, 0,
400 * Wa_14010733611:dg2_g10
401 * Wa_22010146351:dg2_g10
403 if (IS_DG2_GRAPHICS_STEP(i915, G10, STEP_A0, STEP_B0))
404 intel_uncore_rmw(&i915->uncore, XEHP_CLOCK_GATE_DIS, 0,
408 static void pvc_init_clock_gating(struct drm_i915_private *i915)
410 /* Wa_14012385139:pvc */
411 if (IS_PVC_BD_STEP(i915, STEP_A0, STEP_B0))
412 intel_uncore_rmw(&i915->uncore, XEHP_CLOCK_GATE_DIS, 0, SGR_DIS);
414 /* Wa_22010954014:pvc */
415 if (IS_PVC_BD_STEP(i915, STEP_A0, STEP_B0))
416 intel_uncore_rmw(&i915->uncore, XEHP_CLOCK_GATE_DIS, 0, SGSI_SIDECLK_DIS);
419 static void cnp_init_clock_gating(struct drm_i915_private *i915)
421 if (!HAS_PCH_CNP(i915))
424 /* Display WA #1181 WaSouthDisplayDisablePWMCGEGating: cnp */
425 intel_uncore_rmw(&i915->uncore, SOUTH_DSPCLK_GATE_D, 0, CNP_PWM_CGE_GATING_DISABLE);
428 static void cfl_init_clock_gating(struct drm_i915_private *i915)
430 cnp_init_clock_gating(i915);
431 gen9_init_clock_gating(i915);
433 /* WAC6entrylatency:cfl */
434 intel_uncore_rmw(&i915->uncore, FBC_LLC_READ_CTRL, 0, FBC_LLC_FULLY_OPEN);
437 * WaFbcTurnOffFbcWatermark:cfl
438 * Display WA #0562: cfl
440 intel_uncore_rmw(&i915->uncore, DISP_ARB_CTL, 0, DISP_FBC_WM_DIS);
443 * WaFbcNukeOnHostModify:cfl
444 * Display WA #0873: cfl
446 intel_uncore_rmw(&i915->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
447 0, DPFC_NUKE_ON_ANY_MODIFICATION);
450 static void kbl_init_clock_gating(struct drm_i915_private *i915)
452 gen9_init_clock_gating(i915);
454 /* WAC6entrylatency:kbl */
455 intel_uncore_rmw(&i915->uncore, FBC_LLC_READ_CTRL, 0, FBC_LLC_FULLY_OPEN);
457 /* WaDisableSDEUnitClockGating:kbl */
458 if (IS_KBL_GRAPHICS_STEP(i915, 0, STEP_C0))
459 intel_uncore_rmw(&i915->uncore, GEN8_UCGCTL6,
460 0, GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
462 /* WaDisableGamClockGating:kbl */
463 if (IS_KBL_GRAPHICS_STEP(i915, 0, STEP_C0))
464 intel_uncore_rmw(&i915->uncore, GEN6_UCGCTL1,
465 0, GEN6_GAMUNIT_CLOCK_GATE_DISABLE);
468 * WaFbcTurnOffFbcWatermark:kbl
469 * Display WA #0562: kbl
471 intel_uncore_rmw(&i915->uncore, DISP_ARB_CTL, 0, DISP_FBC_WM_DIS);
474 * WaFbcNukeOnHostModify:kbl
475 * Display WA #0873: kbl
477 intel_uncore_rmw(&i915->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
478 0, DPFC_NUKE_ON_ANY_MODIFICATION);
481 static void skl_init_clock_gating(struct drm_i915_private *i915)
483 gen9_init_clock_gating(i915);
485 /* WaDisableDopClockGating:skl */
486 intel_uncore_rmw(&i915->uncore, GEN7_MISCCPCTL,
487 GEN7_DOP_CLOCK_GATE_ENABLE, 0);
489 /* WAC6entrylatency:skl */
490 intel_uncore_rmw(&i915->uncore, FBC_LLC_READ_CTRL, 0, FBC_LLC_FULLY_OPEN);
493 * WaFbcTurnOffFbcWatermark:skl
494 * Display WA #0562: skl
496 intel_uncore_rmw(&i915->uncore, DISP_ARB_CTL, 0, DISP_FBC_WM_DIS);
499 * WaFbcNukeOnHostModify:skl
500 * Display WA #0873: skl
502 intel_uncore_rmw(&i915->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
503 0, DPFC_NUKE_ON_ANY_MODIFICATION);
506 * WaFbcHighMemBwCorruptionAvoidance:skl
507 * Display WA #0883: skl
509 intel_uncore_rmw(&i915->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A), 0, DPFC_DISABLE_DUMMY0);
512 static void bdw_init_clock_gating(struct drm_i915_private *i915)
516 /* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */
517 intel_uncore_rmw(&i915->uncore, CHICKEN_PIPESL_1(PIPE_A), 0, HSW_FBCQ_DIS);
519 /* WaSwitchSolVfFArbitrationPriority:bdw */
520 intel_uncore_rmw(&i915->uncore, GAM_ECOCHK, 0, HSW_ECOCHK_ARB_PRIO_SOL);
522 /* WaPsrDPAMaskVBlankInSRD:bdw */
523 intel_uncore_rmw(&i915->uncore, CHICKEN_PAR1_1, 0, DPA_MASK_VBLANK_SRD);
525 for_each_pipe(i915, pipe) {
526 /* WaPsrDPRSUnmaskVBlankInSRD:bdw */
527 intel_uncore_rmw(&i915->uncore, CHICKEN_PIPESL_1(pipe),
528 0, BDW_DPRS_MASK_VBLANK_SRD);
531 /* WaVSRefCountFullforceMissDisable:bdw */
532 /* WaDSRefCountFullforceMissDisable:bdw */
533 intel_uncore_rmw(&i915->uncore, GEN7_FF_THREAD_MODE,
534 GEN8_FF_DS_REF_CNT_FFME | GEN7_FF_VS_REF_CNT_FFME, 0);
536 intel_uncore_write(&i915->uncore, RING_PSMI_CTL(RENDER_RING_BASE),
537 _MASKED_BIT_ENABLE(GEN8_RC_SEMA_IDLE_MSG_DISABLE));
539 /* WaDisableSDEUnitClockGating:bdw */
540 intel_uncore_rmw(&i915->uncore, GEN8_UCGCTL6, 0, GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
542 /* WaProgramL3SqcReg1Default:bdw */
543 gen8_set_l3sqc_credits(i915, 30, 2);
545 /* WaKVMNotificationOnConfigChange:bdw */
546 intel_uncore_rmw(&i915->uncore, CHICKEN_PAR2_1,
547 0, KVM_CONFIG_CHANGE_NOTIFICATION_SELECT);
549 lpt_init_clock_gating(i915);
551 /* WaDisableDopClockGating:bdw
553 * Also see the CHICKEN2 write in bdw_init_workarounds() to disable DOP
556 intel_uncore_rmw(&i915->uncore, GEN6_UCGCTL1, 0, GEN6_EU_TCUNIT_CLOCK_GATE_DISABLE);
559 static void hsw_init_clock_gating(struct drm_i915_private *i915)
561 /* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */
562 intel_uncore_rmw(&i915->uncore, CHICKEN_PIPESL_1(PIPE_A), 0, HSW_FBCQ_DIS);
564 /* This is required by WaCatErrorRejectionIssue:hsw */
565 intel_uncore_rmw(&i915->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
566 0, GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
568 /* WaSwitchSolVfFArbitrationPriority:hsw */
569 intel_uncore_rmw(&i915->uncore, GAM_ECOCHK, 0, HSW_ECOCHK_ARB_PRIO_SOL);
571 lpt_init_clock_gating(i915);
574 static void ivb_init_clock_gating(struct drm_i915_private *i915)
576 intel_uncore_write(&i915->uncore, ILK_DSPCLK_GATE_D, ILK_VRHUNIT_CLOCK_GATE_DISABLE);
578 /* WaFbcAsynchFlipDisableFbcQueue:ivb */
579 intel_uncore_rmw(&i915->uncore, ILK_DISPLAY_CHICKEN1, 0, ILK_FBCQ_DIS);
581 /* WaDisableBackToBackFlipFix:ivb */
582 intel_uncore_write(&i915->uncore, IVB_CHICKEN3,
583 CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
584 CHICKEN3_DGMG_DONE_FIX_DISABLE);
586 if (IS_IVB_GT1(i915))
587 intel_uncore_write(&i915->uncore, GEN7_ROW_CHICKEN2,
588 _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
590 /* must write both registers */
591 intel_uncore_write(&i915->uncore, GEN7_ROW_CHICKEN2,
592 _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
593 intel_uncore_write(&i915->uncore, GEN7_ROW_CHICKEN2_GT2,
594 _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
598 * According to the spec, bit 13 (RCZUNIT) must be set on IVB.
599 * This implements the WaDisableRCZUnitClockGating:ivb workaround.
601 intel_uncore_write(&i915->uncore, GEN6_UCGCTL2,
602 GEN6_RCZUNIT_CLOCK_GATE_DISABLE);
604 /* This is required by WaCatErrorRejectionIssue:ivb */
605 intel_uncore_rmw(&i915->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
606 0, GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
608 g4x_disable_trickle_feed(i915);
610 intel_uncore_rmw(&i915->uncore, GEN6_MBCUNIT_SNPCR, GEN6_MBC_SNPCR_MASK,
613 if (!HAS_PCH_NOP(i915))
614 cpt_init_clock_gating(i915);
616 gen6_check_mch_setup(i915);
619 static void vlv_init_clock_gating(struct drm_i915_private *i915)
621 /* WaDisableBackToBackFlipFix:vlv */
622 intel_uncore_write(&i915->uncore, IVB_CHICKEN3,
623 CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
624 CHICKEN3_DGMG_DONE_FIX_DISABLE);
626 /* WaDisableDopClockGating:vlv */
627 intel_uncore_write(&i915->uncore, GEN7_ROW_CHICKEN2,
628 _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
630 /* This is required by WaCatErrorRejectionIssue:vlv */
631 intel_uncore_rmw(&i915->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
632 0, GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
635 * According to the spec, bit 13 (RCZUNIT) must be set on IVB.
636 * This implements the WaDisableRCZUnitClockGating:vlv workaround.
638 intel_uncore_write(&i915->uncore, GEN6_UCGCTL2,
639 GEN6_RCZUNIT_CLOCK_GATE_DISABLE);
641 /* WaDisableL3Bank2xClockGate:vlv
642 * Disabling L3 clock gating- MMIO 940c[25] = 1
643 * Set bit 25, to disable L3_BANK_2x_CLK_GATING */
644 intel_uncore_rmw(&i915->uncore, GEN7_UCGCTL4, 0, GEN7_L3BANK2X_CLOCK_GATE_DISABLE);
647 * WaDisableVLVClockGating_VBIIssue:vlv
648 * Disable clock gating on th GCFG unit to prevent a delay
649 * in the reporting of vblank events.
651 intel_uncore_write(&i915->uncore, VLV_GUNIT_CLOCK_GATE, GCFG_DIS);
654 static void chv_init_clock_gating(struct drm_i915_private *i915)
656 /* WaVSRefCountFullforceMissDisable:chv */
657 /* WaDSRefCountFullforceMissDisable:chv */
658 intel_uncore_rmw(&i915->uncore, GEN7_FF_THREAD_MODE,
659 GEN8_FF_DS_REF_CNT_FFME | GEN7_FF_VS_REF_CNT_FFME, 0);
661 /* WaDisableSemaphoreAndSyncFlipWait:chv */
662 intel_uncore_write(&i915->uncore, RING_PSMI_CTL(RENDER_RING_BASE),
663 _MASKED_BIT_ENABLE(GEN8_RC_SEMA_IDLE_MSG_DISABLE));
665 /* WaDisableCSUnitClockGating:chv */
666 intel_uncore_rmw(&i915->uncore, GEN6_UCGCTL1, 0, GEN6_CSUNIT_CLOCK_GATE_DISABLE);
668 /* WaDisableSDEUnitClockGating:chv */
669 intel_uncore_rmw(&i915->uncore, GEN8_UCGCTL6, 0, GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
672 * WaProgramL3SqcReg1Default:chv
673 * See gfxspecs/Related Documents/Performance Guide/
674 * LSQC Setting Recommendations.
676 gen8_set_l3sqc_credits(i915, 38, 2);
679 static void g4x_init_clock_gating(struct drm_i915_private *i915)
683 intel_uncore_write(&i915->uncore, RENCLK_GATE_D1, 0);
684 intel_uncore_write(&i915->uncore, RENCLK_GATE_D2, VF_UNIT_CLOCK_GATE_DISABLE |
685 GS_UNIT_CLOCK_GATE_DISABLE |
686 CL_UNIT_CLOCK_GATE_DISABLE);
687 intel_uncore_write(&i915->uncore, RAMCLK_GATE_D, 0);
688 dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE |
689 OVRUNIT_CLOCK_GATE_DISABLE |
690 OVCUNIT_CLOCK_GATE_DISABLE;
692 dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE;
693 intel_uncore_write(&i915->uncore, DSPCLK_GATE_D(i915), dspclk_gate);
695 g4x_disable_trickle_feed(i915);
698 static void i965gm_init_clock_gating(struct drm_i915_private *i915)
700 struct intel_uncore *uncore = &i915->uncore;
702 intel_uncore_write(uncore, RENCLK_GATE_D1, I965_RCC_CLOCK_GATE_DISABLE);
703 intel_uncore_write(uncore, RENCLK_GATE_D2, 0);
704 intel_uncore_write(uncore, DSPCLK_GATE_D(i915), 0);
705 intel_uncore_write(uncore, RAMCLK_GATE_D, 0);
706 intel_uncore_write16(uncore, DEUC, 0);
707 intel_uncore_write(uncore,
709 _MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
712 static void i965g_init_clock_gating(struct drm_i915_private *i915)
714 intel_uncore_write(&i915->uncore, RENCLK_GATE_D1, I965_RCZ_CLOCK_GATE_DISABLE |
715 I965_RCC_CLOCK_GATE_DISABLE |
716 I965_RCPB_CLOCK_GATE_DISABLE |
717 I965_ISC_CLOCK_GATE_DISABLE |
718 I965_FBC_CLOCK_GATE_DISABLE);
719 intel_uncore_write(&i915->uncore, RENCLK_GATE_D2, 0);
720 intel_uncore_write(&i915->uncore, MI_ARB_STATE,
721 _MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
724 static void gen3_init_clock_gating(struct drm_i915_private *i915)
726 u32 dstate = intel_uncore_read(&i915->uncore, D_STATE);
728 dstate |= DSTATE_PLL_D3_OFF | DSTATE_GFX_CLOCK_GATING |
729 DSTATE_DOT_CLOCK_GATING;
730 intel_uncore_write(&i915->uncore, D_STATE, dstate);
732 if (IS_PINEVIEW(i915))
733 intel_uncore_write(&i915->uncore, ECOSKPD(RENDER_RING_BASE),
734 _MASKED_BIT_ENABLE(ECO_GATING_CX_ONLY));
736 /* IIR "flip pending" means done if this bit is set */
737 intel_uncore_write(&i915->uncore, ECOSKPD(RENDER_RING_BASE),
738 _MASKED_BIT_DISABLE(ECO_FLIP_DONE));
740 /* interrupts should cause a wake up from C3 */
741 intel_uncore_write(&i915->uncore, INSTPM, _MASKED_BIT_ENABLE(INSTPM_AGPBUSY_INT_EN));
743 /* On GEN3 we really need to make sure the ARB C3 LP bit is set */
744 intel_uncore_write(&i915->uncore, MI_ARB_STATE,
745 _MASKED_BIT_ENABLE(MI_ARB_C3_LP_WRITE_ENABLE));
747 intel_uncore_write(&i915->uncore, MI_ARB_STATE,
748 _MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
751 static void i85x_init_clock_gating(struct drm_i915_private *i915)
753 intel_uncore_write(&i915->uncore, RENCLK_GATE_D1, SV_CLOCK_GATE_DISABLE);
755 /* interrupts should cause a wake up from C3 */
756 intel_uncore_write(&i915->uncore, MI_STATE, _MASKED_BIT_ENABLE(MI_AGPBUSY_INT_EN) |
757 _MASKED_BIT_DISABLE(MI_AGPBUSY_830_MODE));
759 intel_uncore_write(&i915->uncore, MEM_MODE,
760 _MASKED_BIT_ENABLE(MEM_DISPLAY_TRICKLE_FEED_DISABLE));
763 * Have FBC ignore 3D activity since we use software
764 * render tracking, and otherwise a pure 3D workload
765 * (even if it just renders a single frame and then does
766 * abosultely nothing) would not allow FBC to recompress
767 * until a 2D blit occurs.
769 intel_uncore_write(&i915->uncore, SCPD0,
770 _MASKED_BIT_ENABLE(SCPD_FBC_IGNORE_3D));
773 static void i830_init_clock_gating(struct drm_i915_private *i915)
775 intel_uncore_write(&i915->uncore, MEM_MODE,
776 _MASKED_BIT_ENABLE(MEM_DISPLAY_A_TRICKLE_FEED_DISABLE) |
777 _MASKED_BIT_ENABLE(MEM_DISPLAY_B_TRICKLE_FEED_DISABLE));
780 void intel_clock_gating_init(struct drm_i915_private *i915)
782 i915->clock_gating_funcs->init_clock_gating(i915);
785 static void nop_init_clock_gating(struct drm_i915_private *i915)
787 drm_dbg_kms(&i915->drm,
788 "No clock gating settings or workarounds applied.\n");
791 #define CG_FUNCS(platform) \
792 static const struct drm_i915_clock_gating_funcs platform##_clock_gating_funcs = { \
793 .init_clock_gating = platform##_init_clock_gating, \
824 * intel_clock_gating_hooks_init - setup the clock gating hooks
825 * @i915: device private
827 * Setup the hooks that configure which clocks of a given platform can be
828 * gated and also apply various GT and display specific workarounds for these
829 * platforms. Note that some GT specific workarounds are applied separately
830 * when GPU contexts or batchbuffers start their execution.
832 void intel_clock_gating_hooks_init(struct drm_i915_private *i915)
834 if (IS_METEORLAKE(i915))
835 i915->clock_gating_funcs = &nop_clock_gating_funcs;
836 else if (IS_PONTEVECCHIO(i915))
837 i915->clock_gating_funcs = &pvc_clock_gating_funcs;
838 else if (IS_DG2(i915))
839 i915->clock_gating_funcs = &dg2_clock_gating_funcs;
840 else if (IS_XEHPSDV(i915))
841 i915->clock_gating_funcs = &xehpsdv_clock_gating_funcs;
842 else if (IS_ALDERLAKE_P(i915))
843 i915->clock_gating_funcs = &adlp_clock_gating_funcs;
844 else if (GRAPHICS_VER(i915) == 12)
845 i915->clock_gating_funcs = &gen12lp_clock_gating_funcs;
846 else if (GRAPHICS_VER(i915) == 11)
847 i915->clock_gating_funcs = &icl_clock_gating_funcs;
848 else if (IS_COFFEELAKE(i915) || IS_COMETLAKE(i915))
849 i915->clock_gating_funcs = &cfl_clock_gating_funcs;
850 else if (IS_SKYLAKE(i915))
851 i915->clock_gating_funcs = &skl_clock_gating_funcs;
852 else if (IS_KABYLAKE(i915))
853 i915->clock_gating_funcs = &kbl_clock_gating_funcs;
854 else if (IS_BROXTON(i915))
855 i915->clock_gating_funcs = &bxt_clock_gating_funcs;
856 else if (IS_GEMINILAKE(i915))
857 i915->clock_gating_funcs = &glk_clock_gating_funcs;
858 else if (IS_BROADWELL(i915))
859 i915->clock_gating_funcs = &bdw_clock_gating_funcs;
860 else if (IS_CHERRYVIEW(i915))
861 i915->clock_gating_funcs = &chv_clock_gating_funcs;
862 else if (IS_HASWELL(i915))
863 i915->clock_gating_funcs = &hsw_clock_gating_funcs;
864 else if (IS_IVYBRIDGE(i915))
865 i915->clock_gating_funcs = &ivb_clock_gating_funcs;
866 else if (IS_VALLEYVIEW(i915))
867 i915->clock_gating_funcs = &vlv_clock_gating_funcs;
868 else if (GRAPHICS_VER(i915) == 6)
869 i915->clock_gating_funcs = &gen6_clock_gating_funcs;
870 else if (GRAPHICS_VER(i915) == 5)
871 i915->clock_gating_funcs = &ilk_clock_gating_funcs;
872 else if (IS_G4X(i915))
873 i915->clock_gating_funcs = &g4x_clock_gating_funcs;
874 else if (IS_I965GM(i915))
875 i915->clock_gating_funcs = &i965gm_clock_gating_funcs;
876 else if (IS_I965G(i915))
877 i915->clock_gating_funcs = &i965g_clock_gating_funcs;
878 else if (GRAPHICS_VER(i915) == 3)
879 i915->clock_gating_funcs = &gen3_clock_gating_funcs;
880 else if (IS_I85X(i915) || IS_I865G(i915))
881 i915->clock_gating_funcs = &i85x_clock_gating_funcs;
882 else if (GRAPHICS_VER(i915) == 2)
883 i915->clock_gating_funcs = &i830_clock_gating_funcs;
885 MISSING_CASE(INTEL_DEVID(i915));
886 i915->clock_gating_funcs = &nop_clock_gating_funcs;