| From 46999a5faf8aaa5ea1dcaa81f7cb8b9799780a2f Mon Sep 17 00:00:00 2001 |
| From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <ville.syrjala@linux.intel.com> |
| Date: Wed, 7 Aug 2013 13:24:47 +0300 |
| Subject: drm/i915: Pull watermark level validity check out |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| Refactor the code a bit to split the watermark level validity check into |
| a separate function. |
| |
| Also add hack there that allows us to use it even for LP0 watermarks. |
| ATM we don't pre-compute/check the LP0 watermarks, so we just have to |
| clamp them to the maximum and hope things work out. |
| |
| v2: Add some debug prints when we exceed max WM0 |
| Kill pointless ret = false' assignment. |
| Include the check for the already disabled 'result' which |
| got shuffled around when the patchs got reorderd |
| |
| Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> |
| Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> |
| Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> |
| (cherry picked from commit a9786a119d2cd0f43d5554bddda71a5fd6ee39ff) |
| Signed-off-by: Darren Hart <dvhart@linux.intel.com> |
| --- |
| drivers/gpu/drm/i915/intel_pm.c | 51 +++++++++++++++++++++++++++++++++++------ |
| 1 file changed, 44 insertions(+), 7 deletions(-) |
| |
| diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c |
| index a5a995948fa9..1dd8f30e5427 100644 |
| --- a/drivers/gpu/drm/i915/intel_pm.c |
| +++ b/drivers/gpu/drm/i915/intel_pm.c |
| @@ -2278,6 +2278,49 @@ static uint32_t ilk_compute_fbc_wm(struct hsw_pipe_wm_parameters *params, |
| params->pri_bytes_per_pixel); |
| } |
| |
| +static bool ilk_check_wm(int level, |
| + const struct hsw_wm_maximums *max, |
| + struct hsw_lp_wm_result *result) |
| +{ |
| + bool ret; |
| + |
| + /* already determined to be invalid? */ |
| + if (!result->enable) |
| + return false; |
| + |
| + result->enable = result->pri_val <= max->pri && |
| + result->spr_val <= max->spr && |
| + result->cur_val <= max->cur; |
| + |
| + ret = result->enable; |
| + |
| + /* |
| + * HACK until we can pre-compute everything, |
| + * and thus fail gracefully if LP0 watermarks |
| + * are exceeded... |
| + */ |
| + if (level == 0 && !result->enable) { |
| + if (result->pri_val > max->pri) |
| + DRM_DEBUG_KMS("Primary WM%d too large %u (max %u)\n", |
| + level, result->pri_val, max->pri); |
| + if (result->spr_val > max->spr) |
| + DRM_DEBUG_KMS("Sprite WM%d too large %u (max %u)\n", |
| + level, result->spr_val, max->spr); |
| + if (result->cur_val > max->cur) |
| + DRM_DEBUG_KMS("Cursor WM%d too large %u (max %u)\n", |
| + level, result->cur_val, max->cur); |
| + |
| + result->pri_val = min_t(uint32_t, result->pri_val, max->pri); |
| + result->spr_val = min_t(uint32_t, result->spr_val, max->spr); |
| + result->cur_val = min_t(uint32_t, result->cur_val, max->cur); |
| + result->enable = true; |
| + } |
| + |
| + DRM_DEBUG_KMS("WM%d: %sabled\n", level, result->enable ? "en" : "dis"); |
| + |
| + return ret; |
| +} |
| + |
| static void ilk_compute_wm_level(struct drm_i915_private *dev_priv, |
| int level, |
| struct hsw_pipe_wm_parameters *p, |
| @@ -2318,13 +2361,7 @@ static bool hsw_compute_lp_wm(struct drm_i915_private *dev_priv, |
| result->fbc_val = max3(res[0].fbc_val, res[1].fbc_val, res[2].fbc_val); |
| result->enable = true; |
| |
| - if (!result->enable) |
| - return false; |
| - |
| - result->enable = result->pri_val <= max->pri && |
| - result->spr_val <= max->spr && |
| - result->cur_val <= max->cur; |
| - return result->enable; |
| + return ilk_check_wm(level, max, result); |
| } |
| |
| static uint32_t hsw_compute_wm_pipe(struct drm_i915_private *dev_priv, |
| -- |
| 1.8.5.rc3 |
| |