1 // SPDX-License-Identifier: MIT
3 * Copyright © 2019 Intel Corporation
6 #include <drm/drm_atomic_state_helper.h>
8 #include "intel_atomic.h"
10 #include "intel_cdclk.h"
11 #include "intel_display_types.h"
13 #include "intel_sideband.h"
15 /* Parameters for Qclk Geyserville (QGV) */
16 struct intel_qgv_point {
17 u16 dclk, t_rp, t_rdpre, t_rc, t_ras, t_rcd;
20 struct intel_psf_gv_point {
21 u8 clk; /* clock in multiples of 16.6666 MHz */
24 struct intel_qgv_info {
25 struct intel_qgv_point points[I915_NUM_QGV_POINTS];
26 struct intel_psf_gv_point psf_points[I915_NUM_PSF_GV_POINTS];
32 static int dg1_mchbar_read_qgv_point_info(struct drm_i915_private *dev_priv,
33 struct intel_qgv_point *sp,
36 u32 dclk_ratio, dclk_reference;
39 val = intel_uncore_read(&dev_priv->uncore, SA_PERF_STATUS_0_0_0_MCHBAR_PC);
40 dclk_ratio = REG_FIELD_GET(DG1_QCLK_RATIO_MASK, val);
41 if (val & DG1_QCLK_REFERENCE)
42 dclk_reference = 6; /* 6 * 16.666 MHz = 100 MHz */
44 dclk_reference = 8; /* 8 * 16.666 MHz = 133 MHz */
45 sp->dclk = dclk_ratio * dclk_reference;
47 val = intel_uncore_read(&dev_priv->uncore, SKL_MC_BIOS_DATA_0_0_0_MCHBAR_PCU);
48 if (val & DG1_GEAR_TYPE)
54 val = intel_uncore_read(&dev_priv->uncore, MCHBAR_CH0_CR_TC_PRE_0_0_0_MCHBAR);
55 sp->t_rp = REG_FIELD_GET(DG1_DRAM_T_RP_MASK, val);
56 sp->t_rdpre = REG_FIELD_GET(DG1_DRAM_T_RDPRE_MASK, val);
58 val = intel_uncore_read(&dev_priv->uncore, MCHBAR_CH0_CR_TC_PRE_0_0_0_MCHBAR_HIGH);
59 sp->t_rcd = REG_FIELD_GET(DG1_DRAM_T_RCD_MASK, val);
60 sp->t_ras = REG_FIELD_GET(DG1_DRAM_T_RAS_MASK, val);
62 sp->t_rc = sp->t_rp + sp->t_ras;
67 static int icl_pcode_read_qgv_point_info(struct drm_i915_private *dev_priv,
68 struct intel_qgv_point *sp,
71 u32 val = 0, val2 = 0;
74 ret = sandybridge_pcode_read(dev_priv,
75 ICL_PCODE_MEM_SUBSYSYSTEM_INFO |
76 ICL_PCODE_MEM_SS_READ_QGV_POINT_INFO(point),
81 sp->dclk = val & 0xffff;
82 sp->t_rp = (val & 0xff0000) >> 16;
83 sp->t_rcd = (val & 0xff000000) >> 24;
85 sp->t_rdpre = val2 & 0xff;
86 sp->t_ras = (val2 & 0xff00) >> 8;
88 sp->t_rc = sp->t_rp + sp->t_ras;
93 static int adls_pcode_read_psf_gv_point_info(struct drm_i915_private *dev_priv,
94 struct intel_psf_gv_point *points)
100 ret = sandybridge_pcode_read(dev_priv,
101 ICL_PCODE_MEM_SUBSYSYSTEM_INFO |
102 ADL_PCODE_MEM_SS_READ_PSF_GV_INFO,
107 for (i = 0; i < I915_NUM_PSF_GV_POINTS; i++) {
108 points[i].clk = val & 0xff;
115 int icl_pcode_restrict_qgv_points(struct drm_i915_private *dev_priv,
120 /* bspec says to keep retrying for at least 1 ms */
121 ret = skl_pcode_request(dev_priv, ICL_PCODE_SAGV_DE_MEM_SS_CONFIG,
123 ICL_PCODE_POINTS_RESTRICTED_MASK,
124 ICL_PCODE_POINTS_RESTRICTED,
128 drm_err(&dev_priv->drm, "Failed to disable qgv points (%d) points: 0x%x\n", ret, points_mask);
135 static int icl_get_qgv_points(struct drm_i915_private *dev_priv,
136 struct intel_qgv_info *qi)
138 const struct dram_info *dram_info = &dev_priv->dram_info;
141 qi->num_points = dram_info->num_qgv_points;
142 qi->num_psf_points = dram_info->num_psf_gv_points;
144 if (DISPLAY_VER(dev_priv) == 12)
145 switch (dram_info->type) {
146 case INTEL_DRAM_DDR4:
149 case INTEL_DRAM_DDR5:
156 else if (DISPLAY_VER(dev_priv) == 11)
157 qi->t_bl = dev_priv->dram_info.type == INTEL_DRAM_DDR4 ? 4 : 8;
159 if (drm_WARN_ON(&dev_priv->drm,
160 qi->num_points > ARRAY_SIZE(qi->points)))
161 qi->num_points = ARRAY_SIZE(qi->points);
163 for (i = 0; i < qi->num_points; i++) {
164 struct intel_qgv_point *sp = &qi->points[i];
166 if (IS_DG1(dev_priv))
167 ret = dg1_mchbar_read_qgv_point_info(dev_priv, sp, i);
169 ret = icl_pcode_read_qgv_point_info(dev_priv, sp, i);
174 drm_dbg_kms(&dev_priv->drm,
175 "QGV %d: DCLK=%d tRP=%d tRDPRE=%d tRAS=%d tRCD=%d tRC=%d\n",
176 i, sp->dclk, sp->t_rp, sp->t_rdpre, sp->t_ras,
177 sp->t_rcd, sp->t_rc);
180 if (qi->num_psf_points > 0) {
181 ret = adls_pcode_read_psf_gv_point_info(dev_priv, qi->psf_points);
183 drm_err(&dev_priv->drm, "Failed to read PSF point data; PSF points will not be considered in bandwidth calculations.\n");
184 qi->num_psf_points = 0;
187 for (i = 0; i < qi->num_psf_points; i++)
188 drm_dbg_kms(&dev_priv->drm,
189 "PSF GV %d: CLK=%d \n",
190 i, qi->psf_points[i].clk);
196 static int icl_calc_bw(int dclk, int num, int den)
198 /* multiples of 16.666MHz (100/6) */
199 return DIV_ROUND_CLOSEST(num * dclk * 100, den * 6);
202 static int adl_calc_psf_bw(int clk)
205 * clk is multiples of 16.666MHz (100/6)
206 * According to BSpec PSF GV bandwidth is
207 * calculated as BW = 64 * clk * 16.666Mhz
209 return DIV_ROUND_CLOSEST(64 * clk * 100, 6);
212 static int icl_sagv_max_dclk(const struct intel_qgv_info *qi)
217 for (i = 0; i < qi->num_points; i++)
218 dclk = max(dclk, qi->points[i].dclk);
223 struct intel_sa_info {
225 u8 deburst, deprogbwlimit;
228 static const struct intel_sa_info icl_sa_info = {
230 .deprogbwlimit = 25, /* GB/s */
234 static const struct intel_sa_info tgl_sa_info = {
236 .deprogbwlimit = 34, /* GB/s */
240 static const struct intel_sa_info rkl_sa_info = {
242 .deprogbwlimit = 20, /* GB/s */
246 static const struct intel_sa_info adls_sa_info = {
248 .deprogbwlimit = 38, /* GB/s */
252 static int icl_get_bw_info(struct drm_i915_private *dev_priv, const struct intel_sa_info *sa)
254 struct intel_qgv_info qi = {};
255 bool is_y_tile = true; /* assume y tile may be used */
256 int num_channels = max_t(u8, 1, dev_priv->dram_info.num_channels);
258 int ipqdepth, ipqdepthpch;
263 ret = icl_get_qgv_points(dev_priv, &qi);
265 drm_dbg_kms(&dev_priv->drm,
266 "Failed to get memory subsystem information, ignoring bandwidth limits");
270 deinterleave = DIV_ROUND_UP(num_channels, is_y_tile ? 4 : 2);
271 dclk_max = icl_sagv_max_dclk(&qi);
275 maxdebw = min(sa->deprogbwlimit * 1000,
276 icl_calc_bw(dclk_max, 16, 1) * 6 / 10); /* 60% */
277 ipqdepth = min(ipqdepthpch, sa->displayrtids / num_channels);
279 for (i = 0; i < ARRAY_SIZE(dev_priv->max_bw); i++) {
280 struct intel_bw_info *bi = &dev_priv->max_bw[i];
284 clpchgroup = (sa->deburst * deinterleave / num_channels) << i;
285 bi->num_planes = (ipqdepth - clpchgroup) / clpchgroup + 1;
287 bi->num_qgv_points = qi.num_points;
288 bi->num_psf_gv_points = qi.num_psf_points;
290 for (j = 0; j < qi.num_points; j++) {
291 const struct intel_qgv_point *sp = &qi.points[j];
297 * FIXME what is the logic behind the
298 * assumed burst length?
300 ct = max_t(int, sp->t_rc, sp->t_rp + sp->t_rcd +
301 (clpchgroup - 1) * qi.t_bl + sp->t_rdpre);
302 bw = icl_calc_bw(sp->dclk, clpchgroup * 32 * num_channels, ct);
304 bi->deratedbw[j] = min(maxdebw,
305 bw * 9 / 10); /* 90% */
307 drm_dbg_kms(&dev_priv->drm,
308 "BW%d / QGV %d: num_planes=%d deratedbw=%u\n",
309 i, j, bi->num_planes, bi->deratedbw[j]);
312 for (j = 0; j < qi.num_psf_points; j++) {
313 const struct intel_psf_gv_point *sp = &qi.psf_points[j];
315 bi->psf_bw[j] = adl_calc_psf_bw(sp->clk);
317 drm_dbg_kms(&dev_priv->drm,
318 "BW%d / PSF GV %d: num_planes=%d bw=%u\n",
319 i, j, bi->num_planes, bi->psf_bw[j]);
322 if (bi->num_planes == 1)
327 * In case if SAGV is disabled in BIOS, we always get 1
328 * SAGV point, but we can't send PCode commands to restrict it
329 * as it will fail and pointless anyway.
331 if (qi.num_points == 1)
332 dev_priv->sagv_status = I915_SAGV_NOT_CONTROLLED;
334 dev_priv->sagv_status = I915_SAGV_ENABLED;
339 static void dg2_get_bw_info(struct drm_i915_private *i915)
341 struct intel_bw_info *bi = &i915->max_bw[0];
344 * DG2 doesn't have SAGV or QGV points, just a constant max bandwidth
345 * that doesn't depend on the number of planes enabled. Create a
346 * single dummy QGV point to reflect that. DG2-G10 platforms have a
347 * constant 50 GB/s bandwidth, whereas DG2-G11 platforms have 38 GB/s.
350 bi->num_qgv_points = 1;
351 if (IS_DG2_G11(i915))
352 bi->deratedbw[0] = 38000;
354 bi->deratedbw[0] = 50000;
356 i915->sagv_status = I915_SAGV_NOT_CONTROLLED;
359 static unsigned int icl_max_bw(struct drm_i915_private *dev_priv,
360 int num_planes, int qgv_point)
365 * Let's return max bw for 0 planes
367 num_planes = max(1, num_planes);
369 for (i = 0; i < ARRAY_SIZE(dev_priv->max_bw); i++) {
370 const struct intel_bw_info *bi =
371 &dev_priv->max_bw[i];
374 * Pcode will not expose all QGV points when
375 * SAGV is forced to off/min/med/max.
377 if (qgv_point >= bi->num_qgv_points)
380 if (num_planes >= bi->num_planes)
381 return bi->deratedbw[qgv_point];
387 static unsigned int adl_psf_bw(struct drm_i915_private *dev_priv,
390 const struct intel_bw_info *bi =
391 &dev_priv->max_bw[0];
393 return bi->psf_bw[psf_gv_point];
396 void intel_bw_init_hw(struct drm_i915_private *dev_priv)
398 if (!HAS_DISPLAY(dev_priv))
401 if (IS_DG2(dev_priv))
402 dg2_get_bw_info(dev_priv);
403 else if (IS_ALDERLAKE_S(dev_priv) || IS_ALDERLAKE_P(dev_priv))
404 icl_get_bw_info(dev_priv, &adls_sa_info);
405 else if (IS_ROCKETLAKE(dev_priv))
406 icl_get_bw_info(dev_priv, &rkl_sa_info);
407 else if (DISPLAY_VER(dev_priv) == 12)
408 icl_get_bw_info(dev_priv, &tgl_sa_info);
409 else if (DISPLAY_VER(dev_priv) == 11)
410 icl_get_bw_info(dev_priv, &icl_sa_info);
413 static unsigned int intel_bw_crtc_num_active_planes(const struct intel_crtc_state *crtc_state)
416 * We assume cursors are small enough
417 * to not not cause bandwidth problems.
419 return hweight8(crtc_state->active_planes & ~BIT(PLANE_CURSOR));
422 static unsigned int intel_bw_crtc_data_rate(const struct intel_crtc_state *crtc_state)
424 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
425 unsigned int data_rate = 0;
426 enum plane_id plane_id;
428 for_each_plane_id_on_crtc(crtc, plane_id) {
430 * We assume cursors are small enough
431 * to not not cause bandwidth problems.
433 if (plane_id == PLANE_CURSOR)
436 data_rate += crtc_state->data_rate[plane_id];
442 void intel_bw_crtc_update(struct intel_bw_state *bw_state,
443 const struct intel_crtc_state *crtc_state)
445 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
446 struct drm_i915_private *i915 = to_i915(crtc->base.dev);
448 bw_state->data_rate[crtc->pipe] =
449 intel_bw_crtc_data_rate(crtc_state);
450 bw_state->num_active_planes[crtc->pipe] =
451 intel_bw_crtc_num_active_planes(crtc_state);
453 drm_dbg_kms(&i915->drm, "pipe %c data rate %u num active planes %u\n",
454 pipe_name(crtc->pipe),
455 bw_state->data_rate[crtc->pipe],
456 bw_state->num_active_planes[crtc->pipe]);
459 static unsigned int intel_bw_num_active_planes(struct drm_i915_private *dev_priv,
460 const struct intel_bw_state *bw_state)
462 unsigned int num_active_planes = 0;
465 for_each_pipe(dev_priv, pipe)
466 num_active_planes += bw_state->num_active_planes[pipe];
468 return num_active_planes;
471 static unsigned int intel_bw_data_rate(struct drm_i915_private *dev_priv,
472 const struct intel_bw_state *bw_state)
474 unsigned int data_rate = 0;
477 for_each_pipe(dev_priv, pipe)
478 data_rate += bw_state->data_rate[pipe];
480 if (DISPLAY_VER(dev_priv) >= 13 && intel_vtd_active())
481 data_rate = data_rate * 105 / 100;
486 struct intel_bw_state *
487 intel_atomic_get_old_bw_state(struct intel_atomic_state *state)
489 struct drm_i915_private *dev_priv = to_i915(state->base.dev);
490 struct intel_global_state *bw_state;
492 bw_state = intel_atomic_get_old_global_obj_state(state, &dev_priv->bw_obj);
494 return to_intel_bw_state(bw_state);
497 struct intel_bw_state *
498 intel_atomic_get_new_bw_state(struct intel_atomic_state *state)
500 struct drm_i915_private *dev_priv = to_i915(state->base.dev);
501 struct intel_global_state *bw_state;
503 bw_state = intel_atomic_get_new_global_obj_state(state, &dev_priv->bw_obj);
505 return to_intel_bw_state(bw_state);
508 struct intel_bw_state *
509 intel_atomic_get_bw_state(struct intel_atomic_state *state)
511 struct drm_i915_private *dev_priv = to_i915(state->base.dev);
512 struct intel_global_state *bw_state;
514 bw_state = intel_atomic_get_global_obj_state(state, &dev_priv->bw_obj);
515 if (IS_ERR(bw_state))
516 return ERR_CAST(bw_state);
518 return to_intel_bw_state(bw_state);
521 int skl_bw_calc_min_cdclk(struct intel_atomic_state *state)
523 struct drm_i915_private *dev_priv = to_i915(state->base.dev);
524 struct intel_bw_state *new_bw_state = NULL;
525 struct intel_bw_state *old_bw_state = NULL;
526 const struct intel_crtc_state *crtc_state;
527 struct intel_crtc *crtc;
532 for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
533 enum plane_id plane_id;
534 struct intel_dbuf_bw *crtc_bw;
536 new_bw_state = intel_atomic_get_bw_state(state);
537 if (IS_ERR(new_bw_state))
538 return PTR_ERR(new_bw_state);
540 old_bw_state = intel_atomic_get_old_bw_state(state);
542 crtc_bw = &new_bw_state->dbuf_bw[crtc->pipe];
544 memset(&crtc_bw->used_bw, 0, sizeof(crtc_bw->used_bw));
546 if (!crtc_state->hw.active)
549 for_each_plane_id_on_crtc(crtc, plane_id) {
550 const struct skl_ddb_entry *plane_alloc =
551 &crtc_state->wm.skl.plane_ddb_y[plane_id];
552 const struct skl_ddb_entry *uv_plane_alloc =
553 &crtc_state->wm.skl.plane_ddb_uv[plane_id];
554 unsigned int data_rate = crtc_state->data_rate[plane_id];
555 unsigned int dbuf_mask = 0;
556 enum dbuf_slice slice;
558 dbuf_mask |= skl_ddb_dbuf_slice_mask(dev_priv, plane_alloc);
559 dbuf_mask |= skl_ddb_dbuf_slice_mask(dev_priv, uv_plane_alloc);
562 * FIXME: To calculate that more properly we probably
563 * need to to split per plane data_rate into data_rate_y
564 * and data_rate_uv for multiplanar formats in order not
565 * to get accounted those twice if they happen to reside
566 * on different slices.
567 * However for pre-icl this would work anyway because
568 * we have only single slice and for icl+ uv plane has
569 * non-zero data rate.
570 * So in worst case those calculation are a bit
571 * pessimistic, which shouldn't pose any significant
574 for_each_dbuf_slice_in_mask(dev_priv, slice, dbuf_mask)
575 crtc_bw->used_bw[slice] += data_rate;
582 for_each_pipe(dev_priv, pipe) {
583 struct intel_dbuf_bw *crtc_bw;
584 enum dbuf_slice slice;
586 crtc_bw = &new_bw_state->dbuf_bw[pipe];
588 for_each_dbuf_slice(dev_priv, slice) {
590 * Current experimental observations show that contrary
591 * to BSpec we get underruns once we exceed 64 * CDCLK
592 * for slices in total.
593 * As a temporary measure in order not to keep CDCLK
594 * bumped up all the time we calculate CDCLK according
595 * to this formula for overall bw consumed by slices.
597 max_bw += crtc_bw->used_bw[slice];
601 new_bw_state->min_cdclk = max_bw / 64;
603 if (new_bw_state->min_cdclk != old_bw_state->min_cdclk) {
604 int ret = intel_atomic_lock_global_state(&new_bw_state->base);
613 int intel_bw_calc_min_cdclk(struct intel_atomic_state *state)
615 struct drm_i915_private *dev_priv = to_i915(state->base.dev);
616 struct intel_bw_state *new_bw_state = NULL;
617 struct intel_bw_state *old_bw_state = NULL;
618 const struct intel_crtc_state *crtc_state;
619 struct intel_crtc *crtc;
624 for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
625 new_bw_state = intel_atomic_get_bw_state(state);
626 if (IS_ERR(new_bw_state))
627 return PTR_ERR(new_bw_state);
629 old_bw_state = intel_atomic_get_old_bw_state(state);
635 for_each_pipe(dev_priv, pipe) {
636 struct intel_cdclk_state *cdclk_state;
638 cdclk_state = intel_atomic_get_new_cdclk_state(state);
642 min_cdclk = max(cdclk_state->min_cdclk[pipe], min_cdclk);
645 new_bw_state->min_cdclk = min_cdclk;
647 if (new_bw_state->min_cdclk != old_bw_state->min_cdclk) {
648 int ret = intel_atomic_lock_global_state(&new_bw_state->base);
657 int intel_bw_atomic_check(struct intel_atomic_state *state)
659 struct drm_i915_private *dev_priv = to_i915(state->base.dev);
660 struct intel_crtc_state *new_crtc_state, *old_crtc_state;
661 struct intel_bw_state *new_bw_state = NULL;
662 const struct intel_bw_state *old_bw_state = NULL;
663 unsigned int data_rate;
664 unsigned int num_active_planes;
665 struct intel_crtc *crtc;
667 u32 allowed_points = 0;
668 unsigned int max_bw_point = 0, max_bw = 0;
669 unsigned int num_qgv_points = dev_priv->max_bw[0].num_qgv_points;
670 unsigned int num_psf_gv_points = dev_priv->max_bw[0].num_psf_gv_points;
673 /* FIXME earlier gens need some checks too */
674 if (DISPLAY_VER(dev_priv) < 11)
678 * We can _not_ use the whole ADLS_QGV_PT_MASK here, as PCode rejects
679 * it with failure if we try masking any unadvertised points.
680 * So need to operate only with those returned from PCode.
682 if (num_qgv_points > 0)
683 mask |= REG_GENMASK(num_qgv_points - 1, 0);
685 if (num_psf_gv_points > 0)
686 mask |= REG_GENMASK(num_psf_gv_points - 1, 0) << ADLS_PSF_PT_SHIFT;
688 for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
690 unsigned int old_data_rate =
691 intel_bw_crtc_data_rate(old_crtc_state);
692 unsigned int new_data_rate =
693 intel_bw_crtc_data_rate(new_crtc_state);
694 unsigned int old_active_planes =
695 intel_bw_crtc_num_active_planes(old_crtc_state);
696 unsigned int new_active_planes =
697 intel_bw_crtc_num_active_planes(new_crtc_state);
700 * Avoid locking the bw state when
701 * nothing significant has changed.
703 if (old_data_rate == new_data_rate &&
704 old_active_planes == new_active_planes)
707 new_bw_state = intel_atomic_get_bw_state(state);
708 if (IS_ERR(new_bw_state))
709 return PTR_ERR(new_bw_state);
711 new_bw_state->data_rate[crtc->pipe] = new_data_rate;
712 new_bw_state->num_active_planes[crtc->pipe] = new_active_planes;
714 drm_dbg_kms(&dev_priv->drm,
715 "pipe %c data rate %u num active planes %u\n",
716 pipe_name(crtc->pipe),
717 new_bw_state->data_rate[crtc->pipe],
718 new_bw_state->num_active_planes[crtc->pipe]);
724 ret = intel_atomic_lock_global_state(&new_bw_state->base);
728 data_rate = intel_bw_data_rate(dev_priv, new_bw_state);
729 data_rate = DIV_ROUND_UP(data_rate, 1000);
731 num_active_planes = intel_bw_num_active_planes(dev_priv, new_bw_state);
733 for (i = 0; i < num_qgv_points; i++) {
734 unsigned int max_data_rate;
736 max_data_rate = icl_max_bw(dev_priv, num_active_planes, i);
738 * We need to know which qgv point gives us
739 * maximum bandwidth in order to disable SAGV
740 * if we find that we exceed SAGV block time
741 * with watermarks. By that moment we already
742 * have those, as it is calculated earlier in
743 * intel_atomic_check,
745 if (max_data_rate > max_bw) {
747 max_bw = max_data_rate;
749 if (max_data_rate >= data_rate)
750 allowed_points |= REG_FIELD_PREP(ADLS_QGV_PT_MASK, BIT(i));
752 drm_dbg_kms(&dev_priv->drm, "QGV point %d: max bw %d required %d\n",
753 i, max_data_rate, data_rate);
756 for (i = 0; i < num_psf_gv_points; i++) {
757 unsigned int max_data_rate = adl_psf_bw(dev_priv, i);
759 if (max_data_rate >= data_rate)
760 allowed_points |= REG_FIELD_PREP(ADLS_PSF_PT_MASK, BIT(i));
762 drm_dbg_kms(&dev_priv->drm, "PSF GV point %d: max bw %d"
764 i, max_data_rate, data_rate);
768 * BSpec states that we always should have at least one allowed point
769 * left, so if we couldn't - simply reject the configuration for obvious
772 if ((allowed_points & ADLS_QGV_PT_MASK) == 0) {
773 drm_dbg_kms(&dev_priv->drm, "No QGV points provide sufficient memory"
774 " bandwidth %d for display configuration(%d active planes).\n",
775 data_rate, num_active_planes);
779 if (num_psf_gv_points > 0) {
780 if ((allowed_points & ADLS_PSF_PT_MASK) == 0) {
781 drm_dbg_kms(&dev_priv->drm, "No PSF GV points provide sufficient memory"
782 " bandwidth %d for display configuration(%d active planes).\n",
783 data_rate, num_active_planes);
789 * Leave only single point with highest bandwidth, if
790 * we can't enable SAGV due to the increased memory latency it may
793 if (!intel_can_enable_sagv(dev_priv, new_bw_state)) {
794 allowed_points = BIT(max_bw_point);
795 drm_dbg_kms(&dev_priv->drm, "No SAGV, using single QGV point %d\n",
799 * We store the ones which need to be masked as that is what PCode
800 * actually accepts as a parameter.
802 new_bw_state->qgv_points_mask = ~allowed_points & mask;
804 old_bw_state = intel_atomic_get_old_bw_state(state);
806 * If the actual mask had changed we need to make sure that
807 * the commits are serialized(in case this is a nomodeset, nonblocking)
809 if (new_bw_state->qgv_points_mask != old_bw_state->qgv_points_mask) {
810 ret = intel_atomic_serialize_global_state(&new_bw_state->base);
818 static struct intel_global_state *
819 intel_bw_duplicate_state(struct intel_global_obj *obj)
821 struct intel_bw_state *state;
823 state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL);
830 static void intel_bw_destroy_state(struct intel_global_obj *obj,
831 struct intel_global_state *state)
836 static const struct intel_global_state_funcs intel_bw_funcs = {
837 .atomic_duplicate_state = intel_bw_duplicate_state,
838 .atomic_destroy_state = intel_bw_destroy_state,
841 int intel_bw_init(struct drm_i915_private *dev_priv)
843 struct intel_bw_state *state;
845 state = kzalloc(sizeof(*state), GFP_KERNEL);
849 intel_atomic_global_obj_init(dev_priv, &dev_priv->bw_obj,
850 &state->base, &intel_bw_funcs);