Skip to content

Commit fa292a4

Browse files
committed
drm/i915: Clean up vlv_program_watermarks()
Add small helpers to make the intent of the staggered enable/disable sequence in vlv_program_watermarks() easier on the eyes. Signed-off-by: Ville Syrjälä <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Maarten Lankhorst <[email protected]>
1 parent 50f4cae commit fa292a4

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

drivers/gpu/drm/i915/intel_pm.c

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,55 +1327,63 @@ static void vlv_merge_wm(struct drm_i915_private *dev_priv,
13271327
}
13281328
}
13291329

1330+
static bool is_disabling(int old, int new, int threshold)
1331+
{
1332+
return old >= threshold && new < threshold;
1333+
}
1334+
1335+
static bool is_enabling(int old, int new, int threshold)
1336+
{
1337+
return old < threshold && new >= threshold;
1338+
}
1339+
13301340
static void vlv_update_wm(struct intel_crtc *crtc)
13311341
{
13321342
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
13331343
enum pipe pipe = crtc->pipe;
1334-
struct vlv_wm_values wm = {};
1344+
struct vlv_wm_values *old_wm = &dev_priv->wm.vlv;
1345+
struct vlv_wm_values new_wm = {};
13351346

13361347
vlv_compute_wm(crtc);
1337-
vlv_merge_wm(dev_priv, &wm);
1348+
vlv_merge_wm(dev_priv, &new_wm);
13381349

1339-
if (memcmp(&dev_priv->wm.vlv, &wm, sizeof(wm)) == 0) {
1350+
if (memcmp(old_wm, &new_wm, sizeof(new_wm)) == 0) {
13401351
/* FIXME should be part of crtc atomic commit */
13411352
vlv_pipe_set_fifo_size(crtc);
1353+
13421354
return;
13431355
}
13441356

1345-
if (wm.level < VLV_WM_LEVEL_DDR_DVFS &&
1346-
dev_priv->wm.vlv.level >= VLV_WM_LEVEL_DDR_DVFS)
1357+
if (is_disabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_DDR_DVFS))
13471358
chv_set_memory_dvfs(dev_priv, false);
13481359

1349-
if (wm.level < VLV_WM_LEVEL_PM5 &&
1350-
dev_priv->wm.vlv.level >= VLV_WM_LEVEL_PM5)
1360+
if (is_disabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_PM5))
13511361
chv_set_memory_pm5(dev_priv, false);
13521362

1353-
if (!wm.cxsr && dev_priv->wm.vlv.cxsr)
1363+
if (is_disabling(old_wm->cxsr, new_wm.cxsr, true))
13541364
_intel_set_memory_cxsr(dev_priv, false);
13551365

13561366
/* FIXME should be part of crtc atomic commit */
13571367
vlv_pipe_set_fifo_size(crtc);
13581368

1359-
vlv_write_wm_values(dev_priv, &wm);
1369+
vlv_write_wm_values(dev_priv, &new_wm);
13601370

13611371
DRM_DEBUG_KMS("Setting FIFO watermarks - %c: plane=%d, cursor=%d, "
13621372
"sprite0=%d, sprite1=%d, SR: plane=%d, cursor=%d level=%d cxsr=%d\n",
1363-
pipe_name(pipe), wm.pipe[pipe].plane[PLANE_PRIMARY], wm.pipe[pipe].plane[PLANE_CURSOR],
1364-
wm.pipe[pipe].plane[PLANE_SPRITE0], wm.pipe[pipe].plane[PLANE_SPRITE1],
1365-
wm.sr.plane, wm.sr.cursor, wm.level, wm.cxsr);
1373+
pipe_name(pipe), new_wm.pipe[pipe].plane[PLANE_PRIMARY], new_wm.pipe[pipe].plane[PLANE_CURSOR],
1374+
new_wm.pipe[pipe].plane[PLANE_SPRITE0], new_wm.pipe[pipe].plane[PLANE_SPRITE1],
1375+
new_wm.sr.plane, new_wm.sr.cursor, new_wm.level, new_wm.cxsr);
13661376

1367-
if (wm.cxsr && !dev_priv->wm.vlv.cxsr)
1377+
if (is_enabling(old_wm->cxsr, new_wm.cxsr, true))
13681378
_intel_set_memory_cxsr(dev_priv, true);
13691379

1370-
if (wm.level >= VLV_WM_LEVEL_PM5 &&
1371-
dev_priv->wm.vlv.level < VLV_WM_LEVEL_PM5)
1380+
if (is_enabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_PM5))
13721381
chv_set_memory_pm5(dev_priv, true);
13731382

1374-
if (wm.level >= VLV_WM_LEVEL_DDR_DVFS &&
1375-
dev_priv->wm.vlv.level < VLV_WM_LEVEL_DDR_DVFS)
1383+
if (is_enabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_DDR_DVFS))
13761384
chv_set_memory_dvfs(dev_priv, true);
13771385

1378-
dev_priv->wm.vlv = wm;
1386+
*old_wm = new_wm;
13791387
}
13801388

13811389
#define single_plane_enabled(mask) is_power_of_2(mask)

0 commit comments

Comments
 (0)