Skip to content

Commit a5941b4

Browse files
committed
drm/i915: Extract skl_check_wm_level() and skl_check_nv12_wm_level()
Make the code more typo proof by extracting small helpers that do the "do we have enough DDB for the WM level?" checks in a consistent manner. Cc: Stanislav Lisovskiy <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Stanislav Lisovskiy <[email protected]>
1 parent 18ffd6d commit a5941b4

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

drivers/gpu/drm/i915/intel_pm.c

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4782,6 +4782,36 @@ skl_plane_trans_wm(const struct skl_pipe_wm *pipe_wm,
47824782
return &wm->trans_wm;
47834783
}
47844784

4785+
/*
4786+
* We only disable the watermarks for each plane if
4787+
* they exceed the ddb allocation of said plane. This
4788+
* is done so that we don't end up touching cursor
4789+
* watermarks needlessly when some other plane reduces
4790+
* our max possible watermark level.
4791+
*
4792+
* Bspec has this to say about the PLANE_WM enable bit:
4793+
* "All the watermarks at this level for all enabled
4794+
* planes must be enabled before the level will be used."
4795+
* So this is actually safe to do.
4796+
*/
4797+
static void
4798+
skl_check_wm_level(struct skl_wm_level *wm, u64 total)
4799+
{
4800+
if (wm->min_ddb_alloc > total)
4801+
memset(wm, 0, sizeof(*wm));
4802+
}
4803+
4804+
static void
4805+
skl_check_nv12_wm_level(struct skl_wm_level *wm, struct skl_wm_level *uv_wm,
4806+
u64 total, u64 uv_total)
4807+
{
4808+
if (wm->min_ddb_alloc > total ||
4809+
uv_wm->min_ddb_alloc > uv_total) {
4810+
memset(wm, 0, sizeof(*wm));
4811+
memset(uv_wm, 0, sizeof(*uv_wm));
4812+
}
4813+
}
4814+
47854815
static int
47864816
skl_allocate_plane_ddb(struct intel_atomic_state *state,
47874817
struct intel_crtc *crtc)
@@ -4949,21 +4979,8 @@ skl_allocate_plane_ddb(struct intel_atomic_state *state,
49494979
struct skl_plane_wm *wm =
49504980
&crtc_state->wm.skl.optimal.planes[plane_id];
49514981

4952-
/*
4953-
* We only disable the watermarks for each plane if
4954-
* they exceed the ddb allocation of said plane. This
4955-
* is done so that we don't end up touching cursor
4956-
* watermarks needlessly when some other plane reduces
4957-
* our max possible watermark level.
4958-
*
4959-
* Bspec has this to say about the PLANE_WM enable bit:
4960-
* "All the watermarks at this level for all enabled
4961-
* planes must be enabled before the level will be used."
4962-
* So this is actually safe to do.
4963-
*/
4964-
if (wm->wm[level].min_ddb_alloc > total[plane_id] ||
4965-
wm->uv_wm[level].min_ddb_alloc > uv_total[plane_id])
4966-
memset(&wm->wm[level], 0, sizeof(wm->wm[level]));
4982+
skl_check_nv12_wm_level(&wm->wm[level], &wm->uv_wm[level],
4983+
total[plane_id], uv_total[plane_id]);
49674984

49684985
/*
49694986
* Wa_1408961008:icl, ehl
@@ -4986,14 +5003,9 @@ skl_allocate_plane_ddb(struct intel_atomic_state *state,
49865003
struct skl_plane_wm *wm =
49875004
&crtc_state->wm.skl.optimal.planes[plane_id];
49885005

4989-
if (wm->trans_wm.min_ddb_alloc > total[plane_id])
4990-
memset(&wm->trans_wm, 0, sizeof(wm->trans_wm));
4991-
4992-
if (wm->sagv.wm0.min_ddb_alloc > total[plane_id])
4993-
memset(&wm->sagv.wm0, 0, sizeof(wm->sagv.wm0));
4994-
4995-
if (wm->sagv.trans_wm.min_ddb_alloc > total[plane_id])
4996-
memset(&wm->sagv.trans_wm, 0, sizeof(wm->sagv.trans_wm));
5006+
skl_check_wm_level(&wm->trans_wm, total[plane_id]);
5007+
skl_check_wm_level(&wm->sagv.wm0, total[plane_id]);
5008+
skl_check_wm_level(&wm->sagv.trans_wm, total[plane_id]);
49975009
}
49985010

49995011
return 0;

0 commit comments

Comments
 (0)