Commit e10ad9c6 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915/fbc: Reallocate cfb if we need more of it

The code assumes we can omit the cfb allocation once fbc
has been enabled once. That's nonsense. Let's try to
reallocate it if we need to.

The code is still a mess, but maybe this is enough to get
fbc going in some cases where it initially underallocates
the cfb and there's no full modeset to fix it up.

Cc: Daniel Drake <drake@endlessm.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Jian-Hong Pan <jian-hong@endlessm.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191127201222.16669-15-ville.syrjala@linux.intel.comTested-by: default avatarDaniel Drake <drake@endlessm.com>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
parent 34cddbc0
...@@ -673,6 +673,14 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc, ...@@ -673,6 +673,14 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc,
cache->fence_id = -1; cache->fence_id = -1;
} }
static bool intel_fbc_cfb_size_changed(struct drm_i915_private *dev_priv)
{
struct intel_fbc *fbc = &dev_priv->fbc;
return intel_fbc_calculate_cfb_size(dev_priv, &fbc->state_cache) >
fbc->compressed_fb.size * fbc->threshold;
}
static bool intel_fbc_can_activate(struct intel_crtc *crtc) static bool intel_fbc_can_activate(struct intel_crtc *crtc)
{ {
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
...@@ -758,8 +766,7 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc) ...@@ -758,8 +766,7 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc)
* we didn't get any invalidate/deactivate calls, but this would require * we didn't get any invalidate/deactivate calls, but this would require
* a lot of tracking just for a specific case. If we conclude it's an * a lot of tracking just for a specific case. If we conclude it's an
* important case, we can implement it later. */ * important case, we can implement it later. */
if (intel_fbc_calculate_cfb_size(dev_priv, &fbc->state_cache) > if (intel_fbc_cfb_size_changed(dev_priv)) {
fbc->compressed_fb.size * fbc->threshold) {
fbc->no_fbc_reason = "CFB requirements changed"; fbc->no_fbc_reason = "CFB requirements changed";
return false; return false;
} }
...@@ -1115,12 +1122,12 @@ void intel_fbc_enable(struct intel_crtc *crtc, ...@@ -1115,12 +1122,12 @@ void intel_fbc_enable(struct intel_crtc *crtc,
mutex_lock(&fbc->lock); mutex_lock(&fbc->lock);
if (fbc->crtc) { if (fbc->crtc) {
WARN_ON(fbc->crtc == crtc && !crtc_state->enable_fbc); if (fbc->crtc != crtc ||
goto out; !intel_fbc_cfb_size_changed(dev_priv))
} goto out;
if (!crtc_state->enable_fbc) __intel_fbc_disable(dev_priv);
goto out; }
WARN_ON(fbc->active); WARN_ON(fbc->active);
...@@ -1133,6 +1140,7 @@ void intel_fbc_enable(struct intel_crtc *crtc, ...@@ -1133,6 +1140,7 @@ void intel_fbc_enable(struct intel_crtc *crtc,
if (intel_fbc_alloc_cfb(dev_priv, if (intel_fbc_alloc_cfb(dev_priv,
intel_fbc_calculate_cfb_size(dev_priv, cache), intel_fbc_calculate_cfb_size(dev_priv, cache),
fb->format->cpp[0])) { fb->format->cpp[0])) {
cache->plane.visible = false;
fbc->no_fbc_reason = "not enough stolen memory"; fbc->no_fbc_reason = "not enough stolen memory";
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment